* [PATCH 2/2] emacs: Add "edit" command to a list of packages.
@ 2015-06-19 19:48 Alex Kost
2015-06-22 7:30 ` Ludovic Courtès
0 siblings, 1 reply; 2+ messages in thread
From: Alex Kost @ 2015-06-19 19:48 UTC (permalink / raw)
To: guix-devel
[-- Attachment #1: Type: text/plain, Size: 157 bytes --]
"guix edit" command made me think that it would be good to be able to
press a key in a *Guix Package List* buffer to "edit" the current
package definition.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0002-emacs-Add-edit-command-to-a-list-of-packages.patch --]
[-- Type: text/x-patch, Size: 4588 bytes --]
From 387e91bfc31f31eb983d8a6589c442d7138ab6aa Mon Sep 17 00:00:00 2001
From: Alex Kost <alezost@gmail.com>
Date: Fri, 19 Jun 2015 21:57:04 +0300
Subject: [PATCH 2/2] 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.
---
doc/emacs.texi | 4 ++++
doc/guix.texi | 6 +++---
emacs/guix-base.el | 8 ++++++++
emacs/guix-list.el | 7 +++++++
emacs/guix-main.scm | 6 ++++++
5 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/doc/emacs.texi b/doc/emacs.texi
index 17682c3..0e89a11 100644
--- a/doc/emacs.texi
+++ b/doc/emacs.texi
@@ -268,6 +268,10 @@ Mark the current package for deletion.
Mark the current package for upgrading.
@item ^
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
Execute actions on the marked packages.
@end table
diff --git a/doc/guix.texi b/doc/guix.texi
index a669464..953caaf 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -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.
If you are using Emacs, note that the Emacs user interface provides
-similar functionality in the ``package info'' buffers created by
-@kbd{M-x guix-search-by-name} and similar commands (@pxref{Emacs
-Commands}).
+similar functionality in the ``package info'' and ``package list''
+buffers created by @kbd{M-x guix-search-by-name} and similar commands
+(@pxref{Emacs Commands}).
@node Invoking guix download
diff --git a/emacs/guix-base.el b/emacs/guix-base.el
index 851ee89..587288e 100644
--- a/emacs/guix-base.el
+++ b/emacs/guix-base.el
@@ -172,6 +172,14 @@ If PATH is relative, it is considered to be relative to
(move-to-column col)
(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."))))
+
\f
;;; Buffers and auto updating.
diff --git a/emacs/guix-list.el b/emacs/guix-list.el
index 130b240..26dfeac 100644
--- a/emacs/guix-list.el
+++ b/emacs/guix-list.el
@@ -467,6 +467,11 @@ With prefix (if ARG is non-nil), describe entries marked with any mark."
(list (guix-list-current-id)))))
(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)))
+
\f
;;; Displaying packages
@@ -505,6 +510,7 @@ likely)."
:group 'guix-package-list)
(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 "i") 'guix-package-list-mark-install)
(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))
(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 "i") 'guix-output-list-mark-install)
(define-key map (kbd "d") 'guix-output-list-mark-delete)
diff --git a/emacs/guix-main.scm b/emacs/guix-main.scm
index c6e4a82..e0dc683 100644
--- a/emacs/guix-main.scm
+++ b/emacs/guix-main.scm
@@ -887,6 +887,12 @@ GENERATIONS is a list of generation numbers."
(with-store store
(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)
"Return a store path of the package source DERIVATION."
(match (derivation-outputs derivation)
--
2.4.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 2/2] emacs: Add "edit" command to a list of packages.
2015-06-19 19:48 [PATCH 2/2] emacs: Add "edit" command to a list of packages Alex Kost
@ 2015-06-22 7:30 ` Ludovic Courtès
0 siblings, 0 replies; 2+ messages in thread
From: Ludovic Courtès @ 2015-06-22 7:30 UTC (permalink / raw)
To: Alex Kost; +Cc: guix-devel
Alex Kost <alezost@gmail.com> skribis:
> From 387e91bfc31f31eb983d8a6589c442d7138ab6aa Mon Sep 17 00:00:00 2001
> From: Alex Kost <alezost@gmail.com>
> Date: Fri, 19 Jun 2015 21:57:04 +0300
> Subject: [PATCH 2/2] 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.
Nice, please push!
Ludo’.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-06-22 7:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-19 19:48 [PATCH 2/2] emacs: Add "edit" command to a list of packages Alex Kost
2015-06-22 7:30 ` Ludovic Courtès
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).