emacs: Add "Build" button to Package Info.

* emacs/guix-main.scm: Use (guix scripts) module for 'build-package'
procedure.
* emacs/guix-base.el (guix-build-package): New procedure.
* emacs/guix-ui-package.el (guix-package-info-insert-build-button): New
procedure.
(guix-package-info-button-functions): New variable.
(guix-package-info-insert-misc): Insert buttons using it.
This commit is contained in:
Alex Kost 2016-05-15 11:10:04 +03:00
parent 65e5fe54ba
commit e98316e69f
No known key found for this signature in database
GPG Key ID: 82460C082A0EE98F
3 changed files with 42 additions and 1 deletions

View File

@ -231,6 +231,20 @@ Ask a user with PROMPT for continuing an operation."
:dry-run? (or guix-dry-run 'f)) :dry-run? (or guix-dry-run 'f))
nil 'source-download))) nil 'source-download)))
(defun guix-build-package (package-id &optional prompt)
"Build package with PACKAGE-ID.
Ask a user with PROMPT for continuing the build operation."
(when (or (not guix-operation-confirm)
(guix-operation-prompt (or prompt "Build package?")))
(guix-eval-in-repl
(format (concat ",run-in-store "
"(build-package (package-by-id %d)"
" #:use-substitutes? %s"
" #:dry-run? %s)")
package-id
(guix-guile-boolean guix-use-substitutes)
(guix-guile-boolean guix-dry-run)))))
;;;###autoload ;;;###autoload
(defun guix-apply-manifest (profile file &optional operation-buffer) (defun guix-apply-manifest (profile file &optional operation-buffer)
"Apply manifest from FILE to PROFILE. "Apply manifest from FILE to PROFILE.

View File

@ -51,6 +51,7 @@
(guix licenses) (guix licenses)
(guix utils) (guix utils)
(guix ui) (guix ui)
(guix scripts)
(guix scripts package) (guix scripts package)
(gnu packages) (gnu packages)
(gnu system)) (gnu system))

View File

@ -332,6 +332,13 @@ prompt depending on `guix-operation-confirm' variable)."
:type 'boolean :type 'boolean
:group 'guix-package-info) :group 'guix-package-info)
(defcustom guix-package-info-button-functions
'(guix-package-info-insert-build-button)
"List of functions used to insert package buttons in Info buffer.
Each function is called with 2 arguments: package ID and full name."
:type '(repeat function)
:group 'guix-package-info)
(defvar guix-package-info-download-buffer nil (defvar guix-package-info-download-buffer nil
"Buffer from which a current download operation was performed.") "Buffer from which a current download operation was performed.")
@ -558,6 +565,7 @@ PACKAGE-ID is an ID of the package which store path to show."
(let* ((entry-id (guix-entry-id entry)) (let* ((entry-id (guix-entry-id entry))
(package-id (or (guix-entry-value entry 'package-id) (package-id (or (guix-entry-value entry 'package-id)
entry-id)) entry-id))
(full-name (guix-package-entry->name-specification entry))
(store-path (guix-entry-value entry 'store-path))) (store-path (guix-entry-value entry 'store-path)))
(guix-info-insert-title-simple "Package") (guix-info-insert-title-simple "Package")
(if store-path (if store-path
@ -570,7 +578,25 @@ PACKAGE-ID is an ID of the package which store path to show."
(button-get btn 'package-id))) (button-get btn 'package-id)))
"Show the store directory of the current package" "Show the store directory of the current package"
'entry-id entry-id 'entry-id entry-id
'package-id package-id))))) 'package-id package-id))
(when guix-package-info-button-functions
(insert "\n")
(guix-mapinsert (lambda (fun)
(funcall fun package-id full-name))
guix-package-info-button-functions
(guix-info-get-indent)
:indent guix-info-indent
:column (guix-info-fill-column))))))
(defun guix-package-info-insert-build-button (id full-name)
"Insert button to build a package defined by ID."
(guix-info-insert-action-button
"Build"
(lambda (btn)
(guix-build-package (button-get btn 'id)
(format "Build '%s' package?" full-name)))
(format "Build the current package")
'id id))
(defun guix-package-info-show-source (entry-id package-id) (defun guix-package-info-show-source (entry-id package-id)
"Show file name of a package source in the current info buffer. "Show file name of a package source in the current info buffer.