aboutsummaryrefslogtreecommitdiff
path: root/emacs/guix.el
diff options
context:
space:
mode:
authorAlex Kost <alezost@gmail.com>2014-10-17 22:21:32 +0400
committerAlex Kost <alezost@gmail.com>2014-10-18 10:24:13 +0400
commit23459fa59b3e96baa07da1ae4c78af70c255ac20 (patch)
tree9251bba1b7781a68ff2e6c69253781923cbd08ae /emacs/guix.el
parent7c3c0374de446af387c8478f77083fd0e357253c (diff)
downloadpatches-23459fa59b3e96baa07da1ae4c78af70c255ac20.tar
patches-23459fa59b3e96baa07da1ae4c78af70c255ac20.tar.gz
emacs: Improve interface for working with multiple profiles.
Suggested by David Thompson, Ludovic Courtès and Mathieu Lirzin. * emacs/guix-base.el (guix-profile-prompt): New procedure. (guix-set-current-profile): Use it. (guix-buffer-name-simple, guix-buffer-name-default, guix-buffer-name): New procedures. (guix-buffer-name-function, guix-profile): New variables. (guix-set-vars, guix-get-entries, guix-get-show-entries, guix-set-buffer, guix-history-call, guix-process-package-actions, guix-continue-package-operation-p, guix-delete-generations, guix-switch-to-generation): Add 'profile' argument. * emacs/guix.el (guix-get-show-packages, guix-get-show-generations, guix-search-by-name, guix-search-by-regexp, guix-installed-packages, guix-obsolete-packages, guix-all-available-packages, guix-newest-available-packages, guix-generations, guix-generations-by-time): Likewise. (guix-last-generations): New command. * emacs/guix-info.el: Adjust for using 'profile' argument where needed. * emacs/guix-list.el: Likewise. * doc/emacs.texi (Emacs Commands): Document 'guix-last-generations' and using "C-u" for commands. (Emacs Buffer Names): Document 'guix-buffer-name-function'.
Diffstat (limited to 'emacs/guix.el')
-rw-r--r--emacs/guix.el141
1 files changed, 94 insertions, 47 deletions
diff --git a/emacs/guix.el b/emacs/guix.el
index b91a88dc14..afe7285696 100644
--- a/emacs/guix.el
+++ b/emacs/guix.el
@@ -50,99 +50,146 @@ If nil, show a single package in the info buffer."
(defvar guix-search-history nil
"A history of minibuffer prompts.")
-(defun guix-get-show-packages (search-type &rest search-vals)
+(defun guix-get-show-packages (profile search-type &rest search-vals)
"Search for packages and show results.
+If PROFILE is nil, use `guix-current-profile'.
+
See `guix-get-entries' for the meaning of SEARCH-TYPE and
SEARCH-VALS.
Results are displayed in the list buffer, unless a single package
is found and `guix-list-single-package' is nil."
- (let ((packages (guix-get-entries guix-package-list-type
+ (or profile (setq profile guix-current-profile))
+ (let ((packages (guix-get-entries profile guix-package-list-type
search-type search-vals
(guix-get-params-for-receiving
'list guix-package-list-type))))
(if (or guix-list-single-package
(cdr packages))
- (guix-set-buffer packages 'list guix-package-list-type
+ (guix-set-buffer profile packages 'list guix-package-list-type
search-type search-vals)
- (let ((packages (guix-get-entries guix-package-info-type
+ (let ((packages (guix-get-entries profile guix-package-info-type
search-type search-vals
(guix-get-params-for-receiving
'info guix-package-info-type))))
- (guix-set-buffer packages 'info guix-package-info-type
+ (guix-set-buffer profile packages 'info guix-package-info-type
search-type search-vals)))))
-(defun guix-get-show-generations (search-type &rest search-vals)
- "Search for generations and show results."
+(defun guix-get-show-generations (profile search-type &rest search-vals)
+ "Search for generations and show results.
+
+If PROFILE is nil, use `guix-current-profile'.
+
+See `guix-get-entries' for the meaning of SEARCH-TYPE and
+SEARCH-VALS."
(apply #'guix-get-show-entries
+ (or profile guix-current-profile)
'list 'generation search-type search-vals))
;;;###autoload
-(defun guix-search-by-name (name)
+(defun guix-search-by-name (name &optional profile)
"Search for Guix packages by NAME.
NAME is a string with name specification. It may optionally contain
-a version number. Examples: \"guile\", \"guile-2.0.11\"."
+a version number. Examples: \"guile\", \"guile-2.0.11\".
+
+If PROFILE is nil, use `guix-current-profile'.
+Interactively with prefix, prompt for PROFILE."
(interactive
- (list (read-string "Package name: " nil 'guix-search-history)))
- (guix-get-show-packages 'name name))
+ (list (read-string "Package name: " nil 'guix-search-history)
+ (and current-prefix-arg
+ (guix-profile-prompt))))
+ (guix-get-show-packages profile 'name name))
;;;###autoload
-(defun guix-search-by-regexp (regexp &rest params)
+(defun guix-search-by-regexp (regexp &optional params profile)
"Search for Guix packages by REGEXP.
PARAMS are package parameters that should be searched.
-If PARAMS are not specified, use `guix-search-params'."
+If PARAMS are not specified, use `guix-search-params'.
+
+If PROFILE is nil, use `guix-current-profile'.
+Interactively with prefix, prompt for PROFILE."
+ (interactive
+ (list (read-regexp "Regexp: " nil 'guix-search-history)
+ nil
+ (and current-prefix-arg
+ (guix-profile-prompt))))
+ (guix-get-show-packages profile 'regexp regexp
+ (or params guix-search-params)))
+
+;;;###autoload
+(defun guix-installed-packages (&optional profile)
+ "Display information about installed Guix packages.
+If PROFILE is nil, use `guix-current-profile'.
+Interactively with prefix, prompt for PROFILE."
(interactive
- (list (read-string "Regexp: " nil 'guix-search-history)))
- (or params (setq params guix-search-params))
- (guix-get-show-packages 'regexp regexp params))
+ (list (and current-prefix-arg
+ (guix-profile-prompt))))
+ (guix-get-show-packages profile 'installed))
;;;###autoload
-(defun guix-installed-packages ()
- "Display information about installed Guix packages."
- (interactive)
- (guix-get-show-packages 'installed))
+(defun guix-obsolete-packages (&optional profile)
+ "Display information about obsolete Guix packages.
+If PROFILE is nil, use `guix-current-profile'.
+Interactively with prefix, prompt for PROFILE."
+ (interactive
+ (list (and current-prefix-arg
+ (guix-profile-prompt))))
+ (guix-get-show-packages profile 'obsolete))
;;;###autoload
-(defun guix-obsolete-packages ()
- "Display information about obsolete Guix packages."
- (interactive)
- (guix-get-show-packages 'obsolete))
+(defun guix-all-available-packages (&optional profile)
+ "Display information about all available Guix packages.
+If PROFILE is nil, use `guix-current-profile'.
+Interactively with prefix, prompt for PROFILE."
+ (interactive
+ (list (and current-prefix-arg
+ (guix-profile-prompt))))
+ (guix-get-show-packages profile 'all-available))
;;;###autoload
-(defun guix-all-available-packages ()
- "Display information about all available Guix packages."
- (interactive)
- (guix-get-show-packages 'all-available))
+(defun guix-newest-available-packages (&optional profile)
+ "Display information about the newest available Guix packages.
+If PROFILE is nil, use `guix-current-profile'.
+Interactively with prefix, prompt for PROFILE."
+ (interactive
+ (list (and current-prefix-arg
+ (guix-profile-prompt))))
+ (guix-get-show-packages profile 'newest-available))
;;;###autoload
-(defun guix-newest-available-packages ()
- "Display information about the newest available Guix packages."
- (interactive)
- (guix-get-show-packages 'newest-available))
+(defun guix-generations (&optional profile)
+ "Display information about all generations.
+If PROFILE is nil, use `guix-current-profile'.
+Interactively with prefix, prompt for PROFILE."
+ (interactive
+ (list (and current-prefix-arg
+ (guix-profile-prompt))))
+ (guix-get-show-generations profile 'all))
;;;###autoload
-(defun guix-generations (&optional number)
+(defun guix-last-generations (number &optional profile)
"Display information about last NUMBER generations.
-If NUMBER is nil, display all generations.
-
-Generations can be displayed in a list or info buffers depending
-on `guix-show-generations-function'.
-
-Interactively, NUMBER is defined by a numeric prefix."
- (interactive "P")
- (if (numberp number)
- (guix-get-show-generations 'last number)
- (guix-get-show-generations 'all)))
+If PROFILE is nil, use `guix-current-profile'.
+Interactively with prefix, prompt for PROFILE."
+ (interactive
+ (list (read-number "The number of last generations: ")
+ (and current-prefix-arg
+ (guix-profile-prompt))))
+ (guix-get-show-generations profile 'last number))
;;;###autoload
-(defun guix-generations-by-time (from to)
+(defun guix-generations-by-time (from to &optional profile)
"Display information about generations created between FROM and TO.
-FROM and TO should be time values."
+FROM and TO should be time values.
+If PROFILE is nil, use `guix-current-profile'.
+Interactively with prefix, prompt for PROFILE."
(interactive
(list (guix-read-date "Find generations (from): ")
- (guix-read-date "Find generations (to): ")))
- (guix-get-show-generations 'time
+ (guix-read-date "Find generations (to): ")
+ (and current-prefix-arg
+ (guix-profile-prompt))))
+ (guix-get-show-generations profile 'time
(float-time from)
(float-time to)))