2014-11-02 05:50:27 -05:00
|
|
|
;;; guix-messages.el --- Minibuffer messages
|
|
|
|
|
2015-08-16 00:11:57 -04:00
|
|
|
;; Copyright © 2014, 2015 Alex Kost <alezost@gmail.com>
|
2014-11-02 05:50:27 -05:00
|
|
|
|
|
|
|
;; This file is part of GNU Guix.
|
|
|
|
|
|
|
|
;; GNU Guix is free software; you can redistribute it and/or modify
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
;; (at your option) any later version.
|
|
|
|
|
|
|
|
;; GNU Guix is distributed in the hope that it will be useful,
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
|
|
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
;; This file provides `guix-result-message' function used to show a
|
|
|
|
;; minibuffer message after displaying packages/generations in a
|
|
|
|
;; list/info buffer.
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
|
|
(require 'cl-lib)
|
|
|
|
(require 'guix-utils)
|
|
|
|
|
|
|
|
(defvar guix-messages
|
|
|
|
`((package
|
|
|
|
(id
|
2015-11-22 06:28:01 -05:00
|
|
|
,(lambda (_ entries ids)
|
|
|
|
(guix-message-packages-by-id entries 'package ids)))
|
2014-11-02 05:50:27 -05:00
|
|
|
(name
|
|
|
|
,(lambda (_ entries names)
|
|
|
|
(guix-message-packages-by-name entries 'package names)))
|
|
|
|
(regexp
|
|
|
|
(0 "No packages matching '%s'." val)
|
|
|
|
(1 "A single package matching '%s'." val)
|
|
|
|
(many "%d packages matching '%s'." count val))
|
|
|
|
(all-available
|
|
|
|
(0 "No packages are available for some reason.")
|
|
|
|
(1 "A single available package (that's strange).")
|
|
|
|
(many "%d available packages." count))
|
|
|
|
(newest-available
|
|
|
|
(0 "No packages are available for some reason.")
|
|
|
|
(1 "A single newest available package (that's strange).")
|
|
|
|
(many "%d newest available packages." count))
|
|
|
|
(installed
|
|
|
|
(0 "No packages installed in profile '%s'." profile)
|
|
|
|
(1 "A single package installed in profile '%s'." profile)
|
|
|
|
(many "%d packages installed in profile '%s'." count profile))
|
|
|
|
(obsolete
|
|
|
|
(0 "No obsolete packages in profile '%s'." profile)
|
|
|
|
(1 "A single obsolete package in profile '%s'." profile)
|
2016-01-07 14:40:53 -05:00
|
|
|
(many "%d obsolete packages in profile '%s'." count profile)))
|
2014-11-02 05:50:27 -05:00
|
|
|
|
|
|
|
(output
|
|
|
|
(id
|
2015-11-22 06:28:01 -05:00
|
|
|
,(lambda (_ entries ids)
|
|
|
|
(guix-message-packages-by-id entries 'output ids)))
|
2014-11-02 05:50:27 -05:00
|
|
|
(name
|
|
|
|
,(lambda (_ entries names)
|
|
|
|
(guix-message-packages-by-name entries 'output names)))
|
|
|
|
(regexp
|
|
|
|
(0 "No package outputs matching '%s'." val)
|
|
|
|
(1 "A single package output matching '%s'." val)
|
|
|
|
(many "%d package outputs matching '%s'." count val))
|
|
|
|
(all-available
|
|
|
|
(0 "No package outputs are available for some reason.")
|
|
|
|
(1 "A single available package output (that's strange).")
|
|
|
|
(many "%d available package outputs." count))
|
|
|
|
(newest-available
|
|
|
|
(0 "No package outputs are available for some reason.")
|
|
|
|
(1 "A single newest available package output (that's strange).")
|
|
|
|
(many "%d newest available package outputs." count))
|
|
|
|
(installed
|
|
|
|
(0 "No package outputs installed in profile '%s'." profile)
|
|
|
|
(1 "A single package output installed in profile '%s'." profile)
|
|
|
|
(many "%d package outputs installed in profile '%s'." count profile))
|
|
|
|
(obsolete
|
|
|
|
(0 "No obsolete package outputs in profile '%s'." profile)
|
|
|
|
(1 "A single obsolete package output in profile '%s'." profile)
|
|
|
|
(many "%d obsolete package outputs in profile '%s'." count profile))
|
2016-01-04 14:59:04 -05:00
|
|
|
(profile-diff
|
emacs: Add interface for comparing generations.
Suggested by Ludovic Courtès.
* doc/emacs.texi (Emacs List buffer): Document new key bindings.
* emacs/guix-base.el (guix-generation-packages-buffer-name-function,
guix-generation-packages-update-buffer, guix-output-name-width): New
variables.
(guix-generation-file, guix-manifest-file, guix-generation-packages,
guix-generation-packages-buffer-name-default,
guix-generation-packages-buffer-name-long,
guix-generation-packages-buffer-name, guix-generation-packages-buffer,
guix-generation-insert-package, guix-generation-insert-packages,
guix-profile-generation-manifest-file,
guix-profile-generation-packages-buffer): New procedures.
* emacs/guix-list.el: Add key bindings for comparing generations.
(guix-generation-list-generations-to-compare,
guix-generation-list-show-added-packages,
guix-generation-list-show-removed-packages, guix-generation-list-compare,
guix-generation-list-ediff-manifests, guix-generation-list-diff-manifests,
guix-generation-list-ediff-packages, guix-generation-list-diff-packages,
guix-generation-list-ediff, guix-generation-list-diff): New procedures.
* emacs/guix-messages.el (guix-messages): Add 'generation-diff' search type.
(guix-message-outputs-by-diff): New procedure.
* emacs/guix-utils.el (guix-diff-switches): New variable.
(guix-diff): New procedure.
* emacs/guix-main.scm (package/output-sexps): Handle 'generation-diff' search
type.
(manifest-entry->package-specification,
manifest-entries->package-specifications, generation-package-specifications,
generation-package-specifications+paths, generation-difference): New
procedures.
2014-11-02 05:58:21 -05:00
|
|
|
guix-message-outputs-by-diff))
|
2014-11-02 05:50:27 -05:00
|
|
|
|
|
|
|
(generation
|
|
|
|
(id
|
|
|
|
(0 "Generations not found.")
|
|
|
|
(1 "")
|
|
|
|
(many "%d generations." count))
|
|
|
|
(last
|
|
|
|
(0 "No generations in profile '%s'." profile)
|
|
|
|
(1 "The last generation of profile '%s'." profile)
|
|
|
|
(many "%d last generations of profile '%s'." count profile))
|
|
|
|
(all
|
|
|
|
(0 "No generations in profile '%s'." profile)
|
|
|
|
(1 "A single generation available in profile '%s'." profile)
|
|
|
|
(many "%d generations available in profile '%s'." count profile))
|
|
|
|
(time
|
|
|
|
guix-message-generations-by-time))))
|
|
|
|
|
|
|
|
(defun guix-message-string-name (name)
|
|
|
|
"Return a quoted name string."
|
|
|
|
(concat "'" name "'"))
|
|
|
|
|
|
|
|
(defun guix-message-string-entry-type (entry-type &optional plural)
|
|
|
|
"Return a string denoting an ENTRY-TYPE."
|
|
|
|
(cl-ecase entry-type
|
|
|
|
(package
|
|
|
|
(if plural "packages" "package"))
|
|
|
|
(output
|
|
|
|
(if plural "package outputs" "package output"))
|
|
|
|
(generation
|
|
|
|
(if plural "generations" "generation"))))
|
|
|
|
|
|
|
|
(defun guix-message-string-entries (count entry-type)
|
|
|
|
"Return a string denoting the COUNT of ENTRY-TYPE entries."
|
|
|
|
(cl-case count
|
|
|
|
(0 (concat "No "
|
|
|
|
(guix-message-string-entry-type
|
|
|
|
entry-type 'plural)))
|
|
|
|
(1 (concat "A single "
|
|
|
|
(guix-message-string-entry-type
|
|
|
|
entry-type)))
|
|
|
|
(t (format "%d %s"
|
|
|
|
count
|
|
|
|
(guix-message-string-entry-type
|
|
|
|
entry-type 'plural)))))
|
|
|
|
|
2015-11-22 06:28:01 -05:00
|
|
|
(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))))
|
|
|
|
|
2014-11-02 05:50:27 -05:00
|
|
|
(defun guix-message-packages-by-name (entries entry-type names)
|
|
|
|
"Display a message for packages or outputs searched by NAMES."
|
|
|
|
(let* ((count (length entries))
|
|
|
|
(str-beg (guix-message-string-entries count entry-type))
|
|
|
|
(str-end (if (cdr names)
|
|
|
|
(concat "matching the following names: "
|
|
|
|
(mapconcat #'guix-message-string-name
|
|
|
|
names ", "))
|
|
|
|
(concat "with name "
|
|
|
|
(guix-message-string-name (car names))))))
|
|
|
|
(message "%s %s." str-beg str-end)))
|
|
|
|
|
|
|
|
(defun guix-message-generations-by-time (profile entries times)
|
|
|
|
"Display a message for generations searched by TIMES."
|
|
|
|
(let* ((count (length entries))
|
|
|
|
(str-beg (guix-message-string-entries count 'generation))
|
|
|
|
(time-beg (guix-get-time-string (car times)))
|
|
|
|
(time-end (guix-get-time-string (cadr times))))
|
|
|
|
(message (concat "%s of profile '%s'\n"
|
|
|
|
"matching time period '%s' - '%s'.")
|
|
|
|
str-beg profile time-beg time-end)))
|
|
|
|
|
2016-01-04 14:59:04 -05:00
|
|
|
(defun guix-message-outputs-by-diff (_ entries profiles)
|
|
|
|
"Display a message for outputs searched by PROFILES difference."
|
emacs: Add interface for comparing generations.
Suggested by Ludovic Courtès.
* doc/emacs.texi (Emacs List buffer): Document new key bindings.
* emacs/guix-base.el (guix-generation-packages-buffer-name-function,
guix-generation-packages-update-buffer, guix-output-name-width): New
variables.
(guix-generation-file, guix-manifest-file, guix-generation-packages,
guix-generation-packages-buffer-name-default,
guix-generation-packages-buffer-name-long,
guix-generation-packages-buffer-name, guix-generation-packages-buffer,
guix-generation-insert-package, guix-generation-insert-packages,
guix-profile-generation-manifest-file,
guix-profile-generation-packages-buffer): New procedures.
* emacs/guix-list.el: Add key bindings for comparing generations.
(guix-generation-list-generations-to-compare,
guix-generation-list-show-added-packages,
guix-generation-list-show-removed-packages, guix-generation-list-compare,
guix-generation-list-ediff-manifests, guix-generation-list-diff-manifests,
guix-generation-list-ediff-packages, guix-generation-list-diff-packages,
guix-generation-list-ediff, guix-generation-list-diff): New procedures.
* emacs/guix-messages.el (guix-messages): Add 'generation-diff' search type.
(guix-message-outputs-by-diff): New procedure.
* emacs/guix-utils.el (guix-diff-switches): New variable.
(guix-diff): New procedure.
* emacs/guix-main.scm (package/output-sexps): Handle 'generation-diff' search
type.
(manifest-entry->package-specification,
manifest-entries->package-specifications, generation-package-specifications,
generation-package-specifications+paths, generation-difference): New
procedures.
2014-11-02 05:58:21 -05:00
|
|
|
(let* ((count (length entries))
|
|
|
|
(str-beg (guix-message-string-entries count 'output))
|
2016-01-04 14:59:04 -05:00
|
|
|
(profile1 (car profiles))
|
|
|
|
(profile2 (cadr profiles)))
|
emacs: Add interface for comparing generations.
Suggested by Ludovic Courtès.
* doc/emacs.texi (Emacs List buffer): Document new key bindings.
* emacs/guix-base.el (guix-generation-packages-buffer-name-function,
guix-generation-packages-update-buffer, guix-output-name-width): New
variables.
(guix-generation-file, guix-manifest-file, guix-generation-packages,
guix-generation-packages-buffer-name-default,
guix-generation-packages-buffer-name-long,
guix-generation-packages-buffer-name, guix-generation-packages-buffer,
guix-generation-insert-package, guix-generation-insert-packages,
guix-profile-generation-manifest-file,
guix-profile-generation-packages-buffer): New procedures.
* emacs/guix-list.el: Add key bindings for comparing generations.
(guix-generation-list-generations-to-compare,
guix-generation-list-show-added-packages,
guix-generation-list-show-removed-packages, guix-generation-list-compare,
guix-generation-list-ediff-manifests, guix-generation-list-diff-manifests,
guix-generation-list-ediff-packages, guix-generation-list-diff-packages,
guix-generation-list-ediff, guix-generation-list-diff): New procedures.
* emacs/guix-messages.el (guix-messages): Add 'generation-diff' search type.
(guix-message-outputs-by-diff): New procedure.
* emacs/guix-utils.el (guix-diff-switches): New variable.
(guix-diff): New procedure.
* emacs/guix-main.scm (package/output-sexps): Handle 'generation-diff' search
type.
(manifest-entry->package-specification,
manifest-entries->package-specifications, generation-package-specifications,
generation-package-specifications+paths, generation-difference): New
procedures.
2014-11-02 05:58:21 -05:00
|
|
|
(cl-multiple-value-bind (new old str-action)
|
2016-01-04 14:59:04 -05:00
|
|
|
(if (string-lessp profile2 profile1)
|
|
|
|
(list profile1 profile2 "added to")
|
|
|
|
(list profile2 profile1 "removed from"))
|
|
|
|
(message "%s %s profile '%s' comparing with profile '%s'."
|
|
|
|
str-beg str-action new old))))
|
emacs: Add interface for comparing generations.
Suggested by Ludovic Courtès.
* doc/emacs.texi (Emacs List buffer): Document new key bindings.
* emacs/guix-base.el (guix-generation-packages-buffer-name-function,
guix-generation-packages-update-buffer, guix-output-name-width): New
variables.
(guix-generation-file, guix-manifest-file, guix-generation-packages,
guix-generation-packages-buffer-name-default,
guix-generation-packages-buffer-name-long,
guix-generation-packages-buffer-name, guix-generation-packages-buffer,
guix-generation-insert-package, guix-generation-insert-packages,
guix-profile-generation-manifest-file,
guix-profile-generation-packages-buffer): New procedures.
* emacs/guix-list.el: Add key bindings for comparing generations.
(guix-generation-list-generations-to-compare,
guix-generation-list-show-added-packages,
guix-generation-list-show-removed-packages, guix-generation-list-compare,
guix-generation-list-ediff-manifests, guix-generation-list-diff-manifests,
guix-generation-list-ediff-packages, guix-generation-list-diff-packages,
guix-generation-list-ediff, guix-generation-list-diff): New procedures.
* emacs/guix-messages.el (guix-messages): Add 'generation-diff' search type.
(guix-message-outputs-by-diff): New procedure.
* emacs/guix-utils.el (guix-diff-switches): New variable.
(guix-diff): New procedure.
* emacs/guix-main.scm (package/output-sexps): Handle 'generation-diff' search
type.
(manifest-entry->package-specification,
manifest-entries->package-specifications, generation-package-specifications,
generation-package-specifications+paths, generation-difference): New
procedures.
2014-11-02 05:58:21 -05:00
|
|
|
|
2014-11-02 05:50:27 -05:00
|
|
|
(defun guix-result-message (profile entries entry-type
|
|
|
|
search-type search-vals)
|
|
|
|
"Display an appropriate message after displaying ENTRIES."
|
2015-08-16 00:11:57 -04:00
|
|
|
(let* ((type-spec (guix-assq-value guix-messages
|
|
|
|
entry-type search-type))
|
2014-11-02 05:50:27 -05:00
|
|
|
(fun-or-count-spec (car type-spec)))
|
|
|
|
(if (functionp fun-or-count-spec)
|
|
|
|
(funcall fun-or-count-spec profile entries search-vals)
|
|
|
|
(let* ((count (length entries))
|
|
|
|
(count-key (if (> count 1) 'many count))
|
2015-08-16 00:11:57 -04:00
|
|
|
(msg-spec (guix-assq-value type-spec count-key))
|
2014-11-02 05:50:27 -05:00
|
|
|
(msg (car msg-spec))
|
|
|
|
(args (cdr msg-spec)))
|
|
|
|
(mapc (lambda (subst)
|
|
|
|
(setq args (cl-substitute (cdr subst) (car subst) args)))
|
|
|
|
`((count . ,count)
|
|
|
|
(val . ,(car search-vals))
|
|
|
|
(profile . ,profile)))
|
|
|
|
(apply #'message msg args)))))
|
|
|
|
|
|
|
|
(provide 'guix-messages)
|
|
|
|
|
|
|
|
;;; guix-messages.el ends here
|