From: Alex Kost <alezost@gmail.com>
To: guix-devel@gnu.org
Subject: [PATCH 1/5] emacs: Handle updating by ID after REPL restart.
Date: Tue, 21 Oct 2014 22:12:02 +0400 [thread overview]
Message-ID: <87siih47il.fsf@gmail.com> (raw)
[-- 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
next reply other threads:[~2014-10-21 18:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-21 18:12 Alex Kost [this message]
2014-10-26 18:35 ` [PATCH 1/5] emacs: Handle updating by ID after REPL restart Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87siih47il.fsf@gmail.com \
--to=alezost@gmail.com \
--cc=guix-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.