From f8476e17a70ecc7d46c746480130477b7c35306b Mon Sep 17 00:00:00 2001 From: Alex Kost Date: Tue, 5 Apr 2016 23:39:03 +0300 Subject: emacs: Add 'guix-package-from-file' command. * emacs/guix-main.scm (register-package, packages-from-file): New procedures. (%patterns-makers): Add 'from-file' search type. * emacs/guix-messages.el (guix-messages): Add messages for it. * emacs/guix-ui-package.el (guix-package-from-file): New command. (guix-package-info-insert-location): Adjust for 'from-file' type. * doc/emacs.texi (Emacs Commands): Document it. --- emacs/guix-ui-package.el | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) (limited to 'emacs/guix-ui-package.el') diff --git a/emacs/guix-ui-package.el b/emacs/guix-ui-package.el index 38f0c08fc7..edc36486fc 100644 --- a/emacs/guix-ui-package.el +++ b/emacs/guix-ui-package.el @@ -393,15 +393,17 @@ formatted with this string, an action button is inserted.") (guix-format-insert nil) (let ((location-file (car (split-string location ":")))) (guix-info-insert-value-indent location 'guix-package-location) - (guix-info-insert-indent) - (guix-info-insert-action-button - "Packages" - (lambda (btn) - (guix-package-get-display (guix-ui-current-profile) - 'location - (button-get btn 'location))) - (format "Display packages from location '%s'" location-file) - 'location location-file)))) + ;; Do not show "Packages" button if a package 'from file' is displayed. + (unless (eq (guix-ui-current-search-type) 'from-file) + (guix-info-insert-indent) + (guix-info-insert-action-button + "Packages" + (lambda (btn) + (guix-package-get-display (guix-ui-current-profile) + 'location + (button-get btn 'location))) + (format "Display packages from location '%s'" location-file) + 'location location-file))))) (defun guix-package-info-insert-systems (systems entry) "Insert supported package SYSTEMS at point." @@ -1000,6 +1002,19 @@ Interactively with prefix, prompt for PROFILE." (guix-ui-read-profile))) (guix-package-get-display profile 'location location)) +;;;###autoload +(defun guix-package-from-file (file &optional profile) + "Display Guix package that the code from FILE evaluates to. +If PROFILE is nil, use `guix-current-profile'. +Interactively with prefix, prompt for PROFILE." + (interactive + (list (read-file-name "File with package: ") + (guix-ui-read-profile))) + (guix-buffer-get-display-entries + 'info 'package + (list (or profile guix-current-profile) 'from-file file) + 'add)) + ;;;###autoload (defun guix-search-by-regexp (regexp &optional params profile) "Search for Guix packages by REGEXP. -- cgit v1.2.3