From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alex Kost Subject: [PATCH 1/5] emacs: Handle updating by ID after REPL restart. Date: Tue, 21 Oct 2014 22:12:02 +0400 Message-ID: <87siih47il.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:34790) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xgduo-0008OZ-SJ for guix-devel@gnu.org; Tue, 21 Oct 2014 14:12:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xgduf-00047A-Qi for guix-devel@gnu.org; Tue, 21 Oct 2014 14:12:14 -0400 Received: from mail-la0-x232.google.com ([2a00:1450:4010:c03::232]:60101) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xgduf-00042e-DU for guix-devel@gnu.org; Tue, 21 Oct 2014 14:12:05 -0400 Received: by mail-la0-f50.google.com with SMTP id s18so1574603lam.37 for ; Tue, 21 Oct 2014 11:12:03 -0700 (PDT) Received: from leviafan (128-74-164-65.broadband.corbina.ru. [128.74.164.65]) by mx.google.com with ESMTPSA id t2sm4834557lae.31.2014.10.21.11.12.01 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Oct 2014 11:12:02 -0700 (PDT) List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: guix-devel@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello, this patchset is for adding =E2=80=9CM-x guix-pull=E2=80=9D 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 =E2=80=98object-address=E2=80=99 which is n= ot actual anymore. So as a workaround instead of using a search by ID, a search by name will be used after a REPL restart. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-emacs-Handle-updating-by-ID-after-REPL-restart.patch >From a6eff11fc7810a26aefd382bb09cef439e10e03e Mon Sep 17 00:00:00 2001 From: Alex Kost 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 --=-=-=--