emacs: Add "edit" command to a list of packages.

* emacs/guix-base.el (guix-edit-package): New function.
* emacs/guix-list.el (guix-list-edit-package): New command.  Bind it to
  "e" key.
* emacs/guix-main.scm (package-location-string): New procedure.
* doc/emacs.texi (Emacs List buffer): Document "e" key binding.
* doc/guix.texi (Invoking guix edit): Mention "package list" buffer.
This commit is contained in:
Alex Kost 2015-06-19 21:57:04 +03:00
parent 6a8c9545cb
commit 6248e32635
5 changed files with 28 additions and 3 deletions

View file

@ -268,6 +268,10 @@ Mark the current package for deletion.
Mark the current package for upgrading. Mark the current package for upgrading.
@item ^ @item ^
Mark all obsolete packages for upgrading. Mark all obsolete packages for upgrading.
@item e
Edit the definition of the curent package (go to its location). This is
similar to @command{guix edit} command (@pxref{Invoking guix edit}), but
for opening a package recipe in the current Emacs instance.
@item x @item x
Execute actions on the marked packages. Execute actions on the marked packages.
@end table @end table

View file

@ -3577,9 +3577,9 @@ launches the program specified in the @code{EDITOR} environment variable
to edit the recipe of GCC@tie{}4.8.4 and that of Vim. to edit the recipe of GCC@tie{}4.8.4 and that of Vim.
If you are using Emacs, note that the Emacs user interface provides If you are using Emacs, note that the Emacs user interface provides
similar functionality in the ``package info'' buffers created by similar functionality in the ``package info'' and ``package list''
@kbd{M-x guix-search-by-name} and similar commands (@pxref{Emacs buffers created by @kbd{M-x guix-search-by-name} and similar commands
Commands}). (@pxref{Emacs Commands}).
@node Invoking guix download @node Invoking guix download

View file

@ -172,6 +172,14 @@ If PATH is relative, it is considered to be relative to
(move-to-column col) (move-to-column col)
(recenter 1)))) (recenter 1))))
(defun guix-edit-package (id)
"Edit (go to location of) package with ID."
(let ((loc (guix-eval-read (guix-make-guile-expression
'package-location-string id))))
(if loc
(guix-find-location loc)
(message "Couldn't find package location."))))
;;; Buffers and auto updating. ;;; Buffers and auto updating.

View file

@ -467,6 +467,11 @@ With prefix (if ARG is non-nil), describe entries marked with any mark."
(list (guix-list-current-id))))) (list (guix-list-current-id)))))
(guix-list-describe-maybe guix-entry-type ids))) (guix-list-describe-maybe guix-entry-type ids)))
(defun guix-list-edit-package ()
"Go to the location of the current package."
(interactive)
(guix-edit-package (guix-list-current-package-id)))
;;; Displaying packages ;;; Displaying packages
@ -505,6 +510,7 @@ likely)."
:group 'guix-package-list) :group 'guix-package-list)
(let ((map guix-package-list-mode-map)) (let ((map guix-package-list-mode-map))
(define-key map (kbd "e") 'guix-list-edit-package)
(define-key map (kbd "x") 'guix-package-list-execute) (define-key map (kbd "x") 'guix-package-list-execute)
(define-key map (kbd "i") 'guix-package-list-mark-install) (define-key map (kbd "i") 'guix-package-list-mark-install)
(define-key map (kbd "d") 'guix-package-list-mark-delete) (define-key map (kbd "d") 'guix-package-list-mark-delete)
@ -662,6 +668,7 @@ The specification is suitable for `guix-process-package-actions'."
(let ((map guix-output-list-mode-map)) (let ((map guix-output-list-mode-map))
(define-key map (kbd "RET") 'guix-output-list-describe) (define-key map (kbd "RET") 'guix-output-list-describe)
(define-key map (kbd "e") 'guix-list-edit-package)
(define-key map (kbd "x") 'guix-output-list-execute) (define-key map (kbd "x") 'guix-output-list-execute)
(define-key map (kbd "i") 'guix-output-list-mark-install) (define-key map (kbd "i") 'guix-output-list-mark-install)
(define-key map (kbd "d") 'guix-output-list-mark-delete) (define-key map (kbd "d") 'guix-output-list-mark-delete)

View file

@ -887,6 +887,12 @@ (define (delete-generations* profile generations)
(with-store store (with-store store
(delete-generations store profile generations))) (delete-generations store profile generations)))
(define (package-location-string package-id)
"Return a location string of a package PACKAGE-ID."
(and-let* ((package (package-by-id package-id))
(location (package-location package)))
(location->string location)))
(define (package-source-derivation->store-path derivation) (define (package-source-derivation->store-path derivation)
"Return a store path of the package source DERIVATION." "Return a store path of the package source DERIVATION."
(match (derivation-outputs derivation) (match (derivation-outputs derivation)