emacs: Add 'guix-pull' command.
authorAlex Kost <alezost@gmail.com>
Tue, 21 Oct 2014 07:48:28 +0000 (11:48 +0400)
committerAlex Kost <alezost@gmail.com>
Mon, 27 Oct 2014 18:52:56 +0000 (21:52 +0300)
* 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
emacs/guix-base.el
emacs/guix-main.scm

index 4c3833a..17440e4 100644 (file)
@@ -133,6 +133,17 @@ date/time prompt,,, org, Org Mode Manual}).
 
 @end table
 
+You can also invoke the @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
+
+Once @command{guix pull} has succeeded, the Guix REPL is restared.  This
+allows you to keep using the Emacs interface with the updated Guix.
+
 @node Emacs General info
 @subsubsection General information
 
index c0a06c7..9583d49 100644 (file)
@@ -994,6 +994,45 @@ Each element from GENERATIONS is a generation number."
       'switch-to-generation profile generation)
      operation-buffer)))
 
+\f
+;;; 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)
 
 ;;; guix-base.el ends here
index b2f6335..1dd57bb 100644 (file)
 ;; installed manifest but not in a package directory), ‘id’ parameter is
 ;; still "name-version" string.  So ‘id’ 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!)
 
 ;; 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))
 
 (define-syntax-rule (first-or-false lst)