diff options
author | Alex Kost <alezost@gmail.com> | 2016-02-07 11:08:57 +0300 |
---|---|---|
committer | Alex Kost <alezost@gmail.com> | 2016-02-10 01:31:19 +0300 |
commit | 2c04e2eec8bf250d1e928b7c8b1e60424b0b32fa (patch) | |
tree | 03e58fc32ef89d25196a3c705163a811460e1ab4 /emacs/guix-base.el | |
parent | f1957fc145dc531b977b702d2947d84d9122042c (diff) | |
download | patches-2c04e2eec8bf250d1e928b7c8b1e60424b0b32fa.tar patches-2c04e2eec8bf250d1e928b7c8b1e60424b0b32fa.tar.gz |
emacs: 'C-u M-x guix-edit' prompts for directory.
* emacs/guix-base.el (guix-read-directory): New procedure.
(guix-find-location, guix-edit): Add optional 'directory' argument.
* emacs/guix-ui-package.el (guix-package-list-edit)
(guix-output-list-edit): Likewise.
* doc/emacs.texi (Emacs Commands): Mention "C-u".
Diffstat (limited to 'emacs/guix-base.el')
-rw-r--r-- | emacs/guix-base.el | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/emacs/guix-base.el b/emacs/guix-base.el index 9f9f258451..1248ecbce5 100644 --- a/emacs/guix-base.el +++ b/emacs/guix-base.el @@ -55,6 +55,14 @@ If it is not set by a user, it is set after starting Guile REPL. This directory is used to define location of the packages.") +(defun guix-read-directory () + "Return `guix-directory' or prompt for it. +This function is intended for using in `interactive' forms." + (if current-prefix-arg + (read-directory-name "Directory with Guix modules: " + guix-directory) + guix-directory)) + (defun guix-set-directory () "Set `guix-directory' if needed." (or guix-directory @@ -63,17 +71,17 @@ This directory is used to define location of the packages.") (add-hook 'guix-after-start-repl-hook 'guix-set-directory) -(defun guix-find-location (location) +(defun guix-find-location (location &optional directory) "Go to LOCATION of a package. LOCATION is a string of the form: \"PATH:LINE:COLUMN\" If PATH is relative, it is considered to be relative to -`guix-directory'." +DIRECTORY (`guix-directory' by default)." (cl-multiple-value-bind (path line col) (split-string location ":") - (let ((file (expand-file-name path guix-directory)) + (let ((file (expand-file-name path (or directory guix-directory))) (line (string-to-number line)) (col (string-to-number col))) (find-file file) @@ -113,12 +121,17 @@ See `guix-packages-profile'." (guix-packages-profile profile generation system?))) ;;;###autoload -(defun guix-edit (id-or-name) - "Edit (go to location of) package with ID-OR-NAME." - (interactive (list (guix-read-package-name))) +(defun guix-edit (id-or-name &optional directory) + "Edit (go to location of) package with ID-OR-NAME. +See `guix-find-location' for the meaning of package location and +DIRECTORY. +Interactively, with prefix argument, prompt for DIRECTORY." + (interactive + (list (guix-read-package-name) + (guix-read-directory))) (let ((loc (guix-package-location id-or-name))) (if loc - (guix-find-location loc) + (guix-find-location loc directory) (message "Couldn't find package location.")))) |