emacs: Make 'guix-find-location' interactive.
* emacs/guix-location.el (guix-find-location): Make interactive. Adjust to handle "reduced" locations (without line and column numbers).
This commit is contained in:
parent
8934c3b60f
commit
e81a89d176
|
@ -34,24 +34,31 @@ For the meaning of location, see `guix-find-location'."
|
||||||
(guix-eval-read (guix-make-guile-expression
|
(guix-eval-read (guix-make-guile-expression
|
||||||
'package-location-string id-or-name)))
|
'package-location-string id-or-name)))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
(defun guix-find-location (location &optional directory)
|
(defun guix-find-location (location &optional directory)
|
||||||
"Go to LOCATION of a package.
|
"Go to LOCATION of a package.
|
||||||
LOCATION is a string of the form:
|
LOCATION is a string of the form:
|
||||||
|
|
||||||
\"PATH:LINE:COLUMN\"
|
\"FILE:LINE:COLUMN\"
|
||||||
|
|
||||||
If PATH is relative, it is considered to be relative to
|
If FILE is relative, it is considered to be relative to
|
||||||
DIRECTORY (`guix-directory' by default)."
|
DIRECTORY (`guix-directory' by default).
|
||||||
(cl-multiple-value-bind (path line col)
|
|
||||||
|
Interactively, prompt for LOCATION. With prefix argument, prompt
|
||||||
|
for DIRECTORY as well."
|
||||||
|
(interactive
|
||||||
|
(list (guix-read-package-location)
|
||||||
|
(guix-read-directory)))
|
||||||
|
(cl-multiple-value-bind (file line column)
|
||||||
(split-string location ":")
|
(split-string location ":")
|
||||||
(let ((file (expand-file-name path (or directory guix-directory)))
|
(find-file (expand-file-name file (or directory guix-directory)))
|
||||||
(line (string-to-number line))
|
(when (and line column)
|
||||||
(col (string-to-number col)))
|
(let ((line (string-to-number line))
|
||||||
(find-file file)
|
(column (string-to-number column)))
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(forward-line (- line 1))
|
(forward-line (- line 1))
|
||||||
(move-to-column col)
|
(move-to-column column)
|
||||||
(recenter 1))))
|
(recenter 1)))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun guix-edit (id-or-name &optional directory)
|
(defun guix-edit (id-or-name &optional directory)
|
||||||
|
|
Loading…
Reference in New Issue