From fc7a28897c454d1404e1af793b553ccb2c25ac24 Mon Sep 17 00:00:00 2001 From: Alex Kost Date: Sun, 22 Nov 2015 14:28:01 +0300 Subject: emacs: Improve messages for packages found by ID. * emacs/guix-messages.el (guix-message-packages-by-id): New procedure. (guix-messages): Use it. --- emacs/guix-messages.el | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'emacs') 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)) -- cgit 1.4.1