diff options
author | Alex Kost <alezost@gmail.com> | 2014-10-20 16:07:38 +0400 |
---|---|---|
committer | Alex Kost <alezost@gmail.com> | 2014-10-27 21:52:55 +0300 |
commit | d2b299a91f3be283df1264afe62770ab2783ace9 (patch) | |
tree | f7dd7dec790d478d265c144c2986360621442965 | |
parent | 8a96bd4bb0f0b67f535ab84d22d1275436fa0b8e (diff) | |
download | guix-d2b299a91f3be283df1264afe62770ab2783ace9.tar.gz |
emacs: Handle updating by ID after REPL restart.
* emacs/guix-base.el (guix-entry-to-specification, guix-entries-to-specifications): New procedures. (guix-revert-buffer): Search by name if searching by ID gives no results.
-rw-r--r-- | emacs/guix-base.el | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/emacs/guix-base.el b/emacs/guix-base.el index ed8b554866..5b98579c5d 100644 --- a/emacs/guix-base.el +++ b/emacs/guix-base.el @@ -142,6 +142,17 @@ Each element of the list has a form: (guix-get-key-val entry 'version) output)) +(defun guix-entry-to-specification (entry) + "Return name specification by the package or output ENTRY." + (guix-get-name-spec (guix-get-key-val entry 'name) + (guix-get-key-val entry 'version) + (guix-get-key-val entry 'output))) + +(defun guix-entries-to-specifications (entries) + "Return name specifications by the package or output ENTRIES." + (cl-remove-duplicates (mapcar #'guix-entry-to-specification entries) + :test #'string=)) + (defun guix-get-installed-outputs (entry) "Return list of installed outputs for the package ENTRY." (mapcar (lambda (installed-entry) @@ -591,13 +602,30 @@ See `revert-buffer' for the meaning of NOCONFIRM." (guix-get-symbol "revert-no-confirm" guix-buffer-type guix-entry-type)) (y-or-n-p "Update current information? ")) - (let ((entries (guix-get-entries - guix-profile guix-entry-type - guix-search-type guix-search-vals - (guix-get-params-for-receiving guix-buffer-type - guix-entry-type)))) + (let* ((search-type guix-search-type) + (search-vals guix-search-vals) + (params (guix-get-params-for-receiving guix-buffer-type + guix-entry-type)) + (entries (guix-get-entries + guix-profile guix-entry-type + guix-search-type guix-search-vals params)) + ;; If a REPL was restarted, package/output IDs are not actual + ;; anymore, because 'object-address'-es died with the REPL, so if a + ;; search by ID didn't give results, search again by name. + (entries (if (and (null entries) + (eq guix-search-type 'id) + (or (eq guix-entry-type 'package) + (eq guix-entry-type 'output))) + (progn + (setq search-type 'name + search-vals (guix-entries-to-specifications + guix-entries)) + (guix-get-entries + guix-profile guix-entry-type + search-type search-vals params)) + entries))) (guix-set-buffer guix-profile entries guix-buffer-type guix-entry-type - guix-search-type guix-search-vals t t)))) + search-type search-vals t t)))) (defun guix-redisplay-buffer () "Redisplay current information. |