* [PATCH 1/5] emacs: Handle updating by ID after REPL restart.
@ 2014-10-21 18:12 Alex Kost
2014-10-26 18:35 ` Ludovic Courtès
0 siblings, 1 reply; 2+ messages in thread
From: Alex Kost @ 2014-10-21 18:12 UTC (permalink / raw)
To: guix-devel
[-- Attachment #1: Type: text/plain, Size: 583 bytes --]
Hello, this patchset is for adding “M-x guix-pull” command, plus some
related (and not very related) changes.
The attached patch fixes the following problem:
You describe a package by pressing RET in a list of packages and you get
*Guix Package Info* buffer with this package. Then if you restart Guix
REPL and revert the "info" buffer, you get "Packages not found" because
the package is identified by an ‘object-address’ which is not actual
anymore.
So as a workaround instead of using a search by ID, a search by name
will be used after a REPL restart.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-emacs-Handle-updating-by-ID-after-REPL-restart.patch --]
[-- Type: text/x-diff, Size: 3510 bytes --]
From a6eff11fc7810a26aefd382bb09cef439e10e03e Mon Sep 17 00:00:00 2001
From: Alex Kost <alezost@gmail.com>
Date: Mon, 20 Oct 2014 16:07:38 +0400
Subject: [PATCH 1/5] 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.
---
emacs/guix-base.el | 40 ++++++++++++++++++++++++++++++++++------
1 file changed, 34 insertions(+), 6 deletions(-)
diff --git a/emacs/guix-base.el b/emacs/guix-base.el
index ed8b554..5b98579 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.
--
2.1.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 1/5] emacs: Handle updating by ID after REPL restart.
2014-10-21 18:12 [PATCH 1/5] emacs: Handle updating by ID after REPL restart Alex Kost
@ 2014-10-26 18:35 ` Ludovic Courtès
0 siblings, 0 replies; 2+ messages in thread
From: Ludovic Courtès @ 2014-10-26 18:35 UTC (permalink / raw)
To: Alex Kost; +Cc: guix-devel
Alex Kost <alezost@gmail.com> skribis:
> The attached patch fixes the following problem:
>
> You describe a package by pressing RET in a list of packages and you get
> *Guix Package Info* buffer with this package. Then if you restart Guix
> REPL and revert the "info" buffer, you get "Packages not found" because
> the package is identified by an ‘object-address’ which is not actual
> anymore.
OK, I had not experienced it.
> So as a workaround instead of using a search by ID, a search by name
> will be used after a REPL restart.
Sounds reasonable.
> From a6eff11fc7810a26aefd382bb09cef439e10e03e Mon Sep 17 00:00:00 2001
> From: Alex Kost <alezost@gmail.com>
> Date: Mon, 20 Oct 2014 16:07:38 +0400
> Subject: [PATCH 1/5] 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.
OK!
Ludo’.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-10-26 20:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-21 18:12 [PATCH 1/5] emacs: Handle updating by ID after REPL restart Alex Kost
2014-10-26 18:35 ` Ludovic Courtès
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.