From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alex Kost Subject: [PATCH 5/5] emacs: Add 'guix-pull' command. Date: Tue, 21 Oct 2014 22:12:35 +0400 Message-ID: <87mw8p47ho.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:34980) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XgdvK-000095-Kt for guix-devel@gnu.org; Tue, 21 Oct 2014 14:12:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XgdvB-0004ci-JF for guix-devel@gnu.org; Tue, 21 Oct 2014 14:12:46 -0400 Received: from mail-lb0-x22c.google.com ([2a00:1450:4010:c04::22c]:53801) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XgdvB-0004cS-5L for guix-devel@gnu.org; Tue, 21 Oct 2014 14:12:37 -0400 Received: by mail-lb0-f172.google.com with SMTP id b6so1504555lbj.3 for ; Tue, 21 Oct 2014 11:12:36 -0700 (PDT) Received: from leviafan (128-74-164-65.broadband.corbina.ru. [128.74.164.65]) by mx.google.com with ESMTPSA id bn6sm3441584lbc.5.2014.10.21.11.12.34 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Oct 2014 11:12:35 -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: base64 4oCcTS14IGd1aXgtcHVsbOKAnSBpdHNlbGYuDQoNCg== --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0005-emacs-Add-guix-pull-command.patch Content-Transfer-Encoding: quoted-printable >From c117fe99830323409c0563204d45ceb0f53e1e75 Mon Sep 17 00:00:00 2001 From: Alex Kost Date: Tue, 21 Oct 2014 11:48:28 +0400 Subject: [PATCH 5/5] emacs: Add 'guix-pull' command. * emacs/guix-base.el (guix-pull): New command. (guix-update-after-pull, guix-after-pull-hook): New variables. (guix-restart-repl-after-pull, guix-update-buffers-maybe-after-pull): New procedures. * emacs/guix-main.scm: Use (guix scripts pull) module. * doc/emacs.texi (Emacs Commands): Document 'guix-pull' command. --- doc/emacs.texi | 12 ++++++++++++ emacs/guix-base.el | 39 +++++++++++++++++++++++++++++++++++++++ emacs/guix-main.scm | 5 +---- 3 files changed, 52 insertions(+), 4 deletions(-) diff --git a/doc/emacs.texi b/doc/emacs.texi index 4c3833a..713fc49 100644 --- a/doc/emacs.texi +++ b/doc/emacs.texi @@ -133,6 +133,18 @@ date/time prompt,,, org, Org Mode Manual}). =20 @end table =20 +Also you can invoke @command{guix pull} command (@pxref{Invoking guix +pull}) from Emacs using: + +@table @kbd +@item M-x guix-pull +With @kbd{C-u}, make it verbose. +@end table + +After @command{guix pull} will be successfully performed, the Guix REPL +will be restared, so you can continue using Emacs interface with an +updated Guix. + @node Emacs General info @subsubsection General information =20 diff --git a/emacs/guix-base.el b/emacs/guix-base.el index c0a06c7..9583d49 100644 --- a/emacs/guix-base.el +++ b/emacs/guix-base.el @@ -994,6 +994,45 @@ Each element from GENERATIONS is a generation number." 'switch-to-generation profile generation) operation-buffer))) =20 + +;;; Pull + +(defcustom guix-update-after-pull t + "If non-nil, update Guix buffers after performing \\[guix-pull]." + :type 'boolean + :group 'guix) + +(defvar guix-after-pull-hook + '(guix-restart-repl-after-pull guix-update-buffers-maybe-after-pull) + "Hook run after successful performing `guix-pull' operation.") + +(defun guix-restart-repl-after-pull () + "Restart Guix REPL after `guix-pull' operation." + (guix-repl-exit) + (guix-start-process-maybe + "Restarting Guix REPL after pull operation ...")) + +(defun guix-update-buffers-maybe-after-pull () + "Update buffers depending on `guix-update-after-pull'." + (when guix-update-after-pull + (mapc #'guix-update-buffer + ;; No need to update "generation" buffers. + (guix-buffers '(guix-package-list-mode + guix-package-info-mode + guix-output-list-mode + guix-output-info-mode))) + (message "Guix buffers have been updated."))) + +;;;###autoload +(defun guix-pull (&optional verbose) + "Run Guix pull operation. +If VERBOSE is non-nil (with prefix argument), produce verbose output." + (interactive) + (let ((args (and verbose '("--verbose")))) + (guix-eval-in-repl + (apply #'guix-make-guile-expression 'guix-pull args) + nil 'pull))) + (provide 'guix-base) =20 ;;; guix-base.el ends here diff --git a/emacs/guix-main.scm b/emacs/guix-main.scm index b2f6335..1dd57bb 100644 --- a/emacs/guix-main.scm +++ b/emacs/guix-main.scm @@ -31,10 +31,6 @@ ;; installed manifest but not in a package directory), =E2=80=98id=E2=80= =99 parameter is ;; still "name-version" string. So =E2=80=98id=E2=80=99 package parameter= in the code ;; below is either an object-address number or a full-name string. -;; -;; Important: as object addresses live only during guile session, elisp -;; part should take care about updating information after "Guix REPL" is -;; restarted (TODO!) =20 ;; To speed-up the process of getting information, the following ;; auxiliary variables are used: @@ -60,6 +56,7 @@ (guix utils) (guix ui) (guix scripts package) + (guix scripts pull) (gnu packages)) =20 (define-syntax-rule (first-or-false lst) --=20 2.1.2 --=-=-=--