summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlex Kost <alezost@gmail.com>2015-11-22 14:28:01 +0300
committerAlex Kost <alezost@gmail.com>2016-01-02 17:25:35 +0300
commitfc7a28897c454d1404e1af793b553ccb2c25ac24 (patch)
tree5b0b017d16b443fbf457016bfa1055debceb0f75
parent87fe9ecae5bc3ae0681a47e0ec6e6929d910664b (diff)
downloadguix-fc7a28897c454d1404e1af793b553ccb2c25ac24.tar.gz
emacs: Improve messages for packages found by ID.
* emacs/guix-messages.el (guix-message-packages-by-id): New procedure.
  (guix-messages): Use it.
-rw-r--r--emacs/guix-messages.el26
1 files changed, 20 insertions, 6 deletions
diff --git a/emacs/guix-messages.el b/emacs/guix-messages.el
index 2bf99de6fa..eb2a76e216 100644
--- a/emacs/guix-messages.el
+++ b/emacs/guix-messages.el
@@ -31,9 +31,8 @@
 (defvar guix-messages
   `((package
      (id
-      (0 "Packages not found.")
-      (1 "")
-      (many "%d packages." count))
+      ,(lambda (_ entries ids)
+         (guix-message-packages-by-id entries 'package ids)))
      (name
       ,(lambda (_ entries names)
          (guix-message-packages-by-name entries 'package names)))
@@ -67,9 +66,8 @@
 
     (output
      (id
-      (0 "Package outputs not found.")
-      (1 "")
-      (many "%d package outputs." count))
+      ,(lambda (_ entries ids)
+         (guix-message-packages-by-id entries 'output ids)))
      (name
       ,(lambda (_ entries names)
          (guix-message-packages-by-name entries 'output names)))
@@ -147,6 +145,22 @@
                (guix-message-string-entry-type
                 entry-type 'plural)))))
 
+(defun guix-message-packages-by-id (entries entry-type ids)
+  "Display a message for packages or outputs searched by IDS."
+  (let* ((count (length entries))
+         (str-beg (guix-message-string-entries count entry-type))
+         (str-end (if (> count 1)
+                      (concat "with the following IDs: "
+                              (mapconcat #'guix-get-string ids ", "))
+                    (concat "with ID " (guix-get-string (car ids))))))
+    (if (zerop count)
+        (message "%s %s.
+Most likely, Guix REPL was restarted, so IDs are not actual
+anymore, because they live only during the REPL process.
+Try \"M-x guix-search-by-name\"."
+                 str-beg str-end)
+      (message "%s %s." str-beg str-end))))
+
 (defun guix-message-packages-by-name (entries entry-type names)
   "Display a message for packages or outputs searched by NAMES."
   (let* ((count (length entries))