>From 292c5f137f6cc3cf72e71e2dd5fa40f38fc7d7bb Mon Sep 17 00:00:00 2001 From: Alex Kost Date: Sun, 7 Feb 2016 11:08:57 +0300 Subject: [PATCH] emacs: 'C-u M-x guix-edit' prompts for directory. * emacs/guix-base.el (guix-find-location, guix-edit): Add optional 'directory' argument. --- emacs/guix-base.el | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/emacs/guix-base.el b/emacs/guix-base.el index 9f9f258..8282f2d 100644 --- a/emacs/guix-base.el +++ b/emacs/guix-base.el @@ -63,17 +63,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 +113,19 @@ 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) + (when current-prefix-arg + (read-directory-name "Directory with Guix modules: " + guix-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.")))) -- 2.6.3