From 0b0fbf0c16a280270c1ce4d716e958d07efbccbd Mon Sep 17 00:00:00 2001 From: Alex Kost Date: Sun, 9 Nov 2014 11:03:39 +0300 Subject: emacs: Add "Source" field to 'guix-info' buffers. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Suggested by Ludovic Courtès. * emacs/guix-info.el (guix-info-insert-methods, guix-info-displayed-params): Add 'source' parameter. (guix-package-info-source): New face. (guix-package-source): New button type. (guix-package-info-auto-find-source, guix-package-info-auto-download-source, guix-package-info-download-buffer): New variables. (guix-package-info-show-source, guix-package-info-insert-source-url, guix-package-info-insert-source, guix-package-info-download-source, guix-package-info-redisplay-after-download): New procedures. * emacs/guix-base.el (guix-param-titles): Add 'source' parameter. (guix-operation-prompt): Add 'prompt' argument. (guix-after-source-download-hook): New variable. (guix-package-source-path, guix-package-source-build-derivation): New procedures. * emacs/guix-main.scm (%package-param-alist): Add 'source' parameter. (package-source-names, package-source-derivation->store-path, package-source-path, package-source-build-derivation): New procedures. --- emacs/guix-base.el | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'emacs/guix-base.el') diff --git a/emacs/guix-base.el b/emacs/guix-base.el index a6e56dced1..23575ac2bf 100644 --- a/emacs/guix-base.el +++ b/emacs/guix-base.el @@ -82,6 +82,7 @@ Interactively, prompt for PATH. With prefix, use (id . "ID") (name . "Name") (version . "Version") + (source . "Source") (license . "License") (synopsis . "Synopsis") (description . "Description") @@ -100,6 +101,7 @@ Interactively, prompt for PATH. With prefix, use (id . "ID") (name . "Name") (version . "Version") + (source . "Source") (license . "License") (synopsis . "Synopsis") (description . "Description") @@ -954,13 +956,14 @@ ENTRIES is a list of package entries to get info about packages." strings) (insert "\n"))) -(defun guix-operation-prompt () +(defun guix-operation-prompt (&optional prompt) "Prompt a user for continuing the current operation. -Return non-nil, if the operation should be continued; nil otherwise." +Return non-nil, if the operation should be continued; nil otherwise. +Ask a user with PROMPT for continuing an operation." (let* ((option-keys (mapcar #'guix-operation-option-key guix-operation-options)) (keys (append '(?y ?n) option-keys)) - (prompt (concat (propertize "Continue operation?" + (prompt (concat (propertize (or prompt "Continue operation?") 'face 'minibuffer-prompt) " (" (mapconcat @@ -1035,6 +1038,30 @@ Each element from GENERATIONS is a generation number." 'switch-to-generation profile generation) operation-buffer))) +(defun guix-package-source-path (package-id) + "Return a store file path to a source of a package PACKAGE-ID." + (message "Calculating the source derivation ...") + (guix-eval-read + (guix-make-guile-expression + 'package-source-path package-id))) + +(defvar guix-after-source-download-hook nil + "Hook run after successful performing a 'source-download' operation.") + +(defun guix-package-source-build-derivation (package-id &optional prompt) + "Build source derivation of a package PACKAGE-ID. +Ask a user with PROMPT for continuing an operation." + (when (or (not guix-operation-confirm) + (guix-operation-prompt (or prompt + "Build the source derivation?"))) + (guix-eval-in-repl + (guix-make-guile-expression + 'package-source-build-derivation + package-id + :use-substitutes? (or guix-use-substitutes 'f) + :dry-run? (or guix-dry-run 'f)) + nil 'source-download))) + ;;; Pull -- cgit v1.2.3