guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 2/4] emacs: Add 'guix-devel-download-package-source'.


From: Alex Kost
Subject: [PATCH 2/4] emacs: Add 'guix-devel-download-package-source'.
Date: Fri, 2 Oct 2015 16:04:04 +0300

* emacs/guix-devel.el (guix-devel-setup-repl): Use (guix packages) module.
  (guix-devel-download-package-source): New command.
  (guix-devel-keys-map): Add key binding for it.
* doc/emacs.texi (Emacs Development): Document it.
---
 doc/emacs.texi      |  6 ++++++
 emacs/guix-devel.el | 14 ++++++++++++++
 2 files changed, 20 insertions(+)

diff --git a/doc/emacs.texi b/doc/emacs.texi
index b6f2701..00f86f3 100644
--- a/doc/emacs.texi
+++ b/doc/emacs.texi
@@ -667,6 +667,12 @@ this command---for example, with @kbd{C-M-x} (@pxref{To 
eval or not to
 eval,,, geiser, Geiser User Manual})
 (@code{guix-devel-build-package-definition}).
 
address@hidden C-c . s
+Download a source of the package defined by the current variable
+definition and print its SHA256 hash.  This command has the same meaning
+as running @code{guix download} on the package source (@pxref{Invoking
+guix download}) (@code{guix-devel-download-package-source}).
+
 @end table
 
 Unluckily, there is a limitation related to long-running REPL commands.
diff --git a/emacs/guix-devel.el b/emacs/guix-devel.el
index ee7629f..a8167a0 100644
--- a/emacs/guix-devel.el
+++ b/emacs/guix-devel.el
@@ -69,6 +69,7 @@ Interactively, use the module defined by the current scheme 
file."
 (defun guix-devel-setup-repl (&optional repl)
   "Setup REPL for using `guix-devel-...' commands."
   (guix-devel-use-modules "(guix monad-repl)"
+                          "(guix packages)"
                           "(guix scripts)"
                           "(guix store)")
   ;; Without this workaround, the build output disappears.  See
@@ -113,6 +114,18 @@ run BODY."
                                       guix-use-substitutes)
                 "#:dry-run?" (guix-guile-boolean guix-dry-run)))))))
 
+(defun guix-devel-download-package-source ()
+  "Download the source of the current package.
+Use this function to compute SHA256 hash of the package source."
+  (interactive)
+  (guix-devel-with-definition def
+    (guix-devel-use-modules "(guix scripts download)")
+    (when (or (not guix-operation-confirm)
+              (y-or-n-p (format "Download '%s' package source?" def)))
+      (guix-geiser-eval-in-repl
+       (format "(guix-download (origin-uri (package-source %s)))"
+               def)))))
+
 
 ;;; Font-lock
 
@@ -151,6 +164,7 @@ to find 'modify-phases' keywords."
 (defvar guix-devel-keys-map
   (let ((map (make-sparse-keymap)))
     (define-key map (kbd "b") 'guix-devel-build-package-definition)
+    (define-key map (kbd "s") 'guix-devel-download-package-source)
     (define-key map (kbd "k") 'guix-devel-copy-module-as-kill)
     (define-key map (kbd "u") 'guix-devel-use-module)
     map)
-- 
2.5.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]