Function: hpath:file-position-to-line-and-column

hpath:file-position-to-line-and-column is a byte-compiled function defined in hpath.el.

Signature

(hpath:file-position-to-line-and-column PATH POSITION)

Documentation

Return "path:L<line-num>:C<col-num>" given PATH and character POSITION.

If col-num is 0, the :C<col-num> is excluded. The path in the result is abbreviated relative to the caller's buffer directory.

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hpath.el
(defun hpath:file-position-to-line-and-column (path position)
  "Return \"path:L<line-num>:C<col-num>\" given PATH and character POSITION.
If col-num is 0, the :C<col-num> is excluded.  The path in the
result is abbreviated relative to the caller's buffer directory."
  (let ((shortened-path (hpath:shorten path)))
    (with-current-buffer (find-file-noselect path)
      (save-excursion
	(goto-char position)
	(if (zerop (current-column))
	    (format "%s:L%d" shortened-path (line-number-at-pos (point) t))
	  (format "%s:L%d:C%d"
		  shortened-path
		  (line-number-at-pos (point) t)
		  (current-column)))))))