An uninteresting explanation of this patch is following.  I'm afraid it
is very unclear, so if you don't understand it, you have to believe that
this patch will not burn your computer.

Packages are defined by 'object-address'-es which are used as IDs for a
list of packages (when 'guix-package-list-type' var is 'package').  For
a list of outputs (when 'guix-package-list-type' var is 'output' which
is a default value) a string "<package-id>:<output>" is used as ID (may be
checked by ‘M-: (guix-list-current-id)’ in *Guix Package List* buffer).

But since it is not convenient to get a package ID from an output ID,
this patch adds an additional 'package-id' parameter for each output
(see ‘M-: (guix-list-current-entry)’ in *Guix Package List* buffer for
alist of parameters).

>From baad22cdd084b2981f6dddbb3a11a7375c5768af Mon Sep 17 00:00:00 2001
From: Alex Kost <alez...@gmail.com>
Date: Fri, 19 Jun 2015 21:47:31 +0300
Subject: [PATCH 1/2] emacs: Simplify defining package ID in a list buffer.

* emacs/guix-list.el: Always retrieve 'package-id' parameter for a list
  of outputs.
  (guix-list-current-package-id): New function.
---
 emacs/guix-list.el | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/emacs/guix-list.el b/emacs/guix-list.el
index 279de81..130b240 100644
--- a/emacs/guix-list.el
+++ b/emacs/guix-list.el
@@ -215,6 +215,14 @@ VAL may be nil."
   "Return alist of the current entry info."
   (guix-get-entry-by-id (guix-list-current-id) guix-entries))
 
+(defun guix-list-current-package-id ()
+  "Return ID of the current package."
+  (cl-ecase major-mode
+    (guix-package-list-mode
+     (guix-list-current-id))
+    (guix-output-list-mode
+     (guix-get-key-val (guix-list-current-entry) 'package-id))))
+
 (defun guix-list-for-each-line (fun &rest args)
   "Call FUN with ARGS for each entry line."
   (or (derived-mode-p 'guix-list-mode)
@@ -643,7 +651,8 @@ The specification is suitable for `guix-process-package-actions'."
 ;;; Displaying outputs
 
 (guix-define-buffer-type list output
-  :buffer-name "*Guix Package List*")
+  :buffer-name "*Guix Package List*"
+  :required (package-id))
 
 (guix-list-define-entry-type output
   :sort-key name
-- 
2.4.3

Reply via email to