emacs: Improve key bindings for marking the packages.
Use "U" to upgrade the current package, "^" to upgrade all. * emacs/guix-list.el: (guix-list-unmark): With prefix, mark all. (guix-package-list-mark-outputs): New procedure. (guix-package-list-mark-install, guix-package-list-mark-delete) (guix-package-list-mark-upgrade): Use it. (guix-package-list-mark-upgrades): New command. * doc/emacs.texi (emacs List buffer): Update the manual accordingly.
This commit is contained in:
parent
db60b1d9ff
commit
91cc37a1e3
|
@ -163,11 +163,9 @@ Mark the current entry.
|
||||||
@item M
|
@item M
|
||||||
Mark all entries.
|
Mark all entries.
|
||||||
@item u
|
@item u
|
||||||
Unmark the current entry.
|
Unmark the current entry (with prefix, unmark all entries).
|
||||||
@item @key{DEL}
|
@item @key{DEL}
|
||||||
Unmark backward.
|
Unmark backward.
|
||||||
@item U
|
|
||||||
Unmark all entries.
|
|
||||||
@item S
|
@item S
|
||||||
Sort entries by a specified column.
|
Sort entries by a specified column.
|
||||||
@end table
|
@end table
|
||||||
|
@ -179,12 +177,16 @@ A ``package-list'' buffer additionally provides the following bindings:
|
||||||
Describe marked packages (display available information in a
|
Describe marked packages (display available information in a
|
||||||
``package-info'' buffer).
|
``package-info'' buffer).
|
||||||
@item i
|
@item i
|
||||||
Mark a package for installation (with prefix, prompt for output(s) to
|
Mark "out" of the current package for installation (with prefix, prompt
|
||||||
install).
|
for output(s) to install).
|
||||||
@item d
|
@item d
|
||||||
Mark a package for deletion.
|
Mark all installed outputs of the current package for deletion (with
|
||||||
|
prefix, prompt for output(s) to delete).
|
||||||
|
@item U
|
||||||
|
Mark all installed outputs of the current package for upgrading (with
|
||||||
|
prefix, prompt for output(s) to upgrade).
|
||||||
@item ^
|
@item ^
|
||||||
Mark a package for upgrading.
|
Mark all obsolete packages for upgrading.
|
||||||
@item x
|
@item x
|
||||||
Execute actions on marked packages.
|
Execute actions on marked packages.
|
||||||
@end table
|
@end table
|
||||||
|
|
|
@ -303,10 +303,13 @@ Interactively, put a general mark on all lines."
|
||||||
(interactive '(general))
|
(interactive '(general))
|
||||||
(guix-list-for-each-line #'guix-list-mark mark-name))
|
(guix-list-for-each-line #'guix-list-mark mark-name))
|
||||||
|
|
||||||
(defun guix-list-unmark ()
|
(defun guix-list-unmark (&optional arg)
|
||||||
"Unmark the current line and move to the next line."
|
"Unmark the current line and move to the next line.
|
||||||
(interactive)
|
With ARG, unmark all lines."
|
||||||
(guix-list-mark 'empty t))
|
(interactive "P")
|
||||||
|
(if arg
|
||||||
|
(guix-list-unmark-all)
|
||||||
|
(guix-list-mark 'empty t)))
|
||||||
|
|
||||||
(defun guix-list-unmark-backward ()
|
(defun guix-list-unmark-backward ()
|
||||||
"Move up one line and unmark it."
|
"Move up one line and unmark it."
|
||||||
|
@ -344,7 +347,6 @@ Same as `tabulated-list-sort', but also restore marks after sorting."
|
||||||
(define-key map (kbd "*") 'guix-list-mark)
|
(define-key map (kbd "*") 'guix-list-mark)
|
||||||
(define-key map (kbd "M") 'guix-list-mark-all)
|
(define-key map (kbd "M") 'guix-list-mark-all)
|
||||||
(define-key map (kbd "u") 'guix-list-unmark)
|
(define-key map (kbd "u") 'guix-list-unmark)
|
||||||
(define-key map (kbd "U") 'guix-list-unmark-all)
|
|
||||||
(define-key map (kbd "DEL") 'guix-list-unmark-backward)
|
(define-key map (kbd "DEL") 'guix-list-unmark-backward)
|
||||||
(define-key map [remap tabulated-list-sort] 'guix-list-sort)
|
(define-key map [remap tabulated-list-sort] 'guix-list-sort)
|
||||||
map)
|
map)
|
||||||
|
@ -478,8 +480,9 @@ likely)."
|
||||||
(define-key map (kbd "RET") 'guix-package-list-describe)
|
(define-key map (kbd "RET") 'guix-package-list-describe)
|
||||||
(define-key map (kbd "x") 'guix-package-list-execute)
|
(define-key map (kbd "x") 'guix-package-list-execute)
|
||||||
(define-key map (kbd "i") 'guix-package-list-mark-install)
|
(define-key map (kbd "i") 'guix-package-list-mark-install)
|
||||||
(define-key map (kbd "^") 'guix-package-list-mark-upgrade)
|
(define-key map (kbd "d") 'guix-package-list-mark-delete)
|
||||||
(define-key map (kbd "d") 'guix-package-list-mark-delete))
|
(define-key map (kbd "U") 'guix-package-list-mark-upgrade)
|
||||||
|
(define-key map (kbd "^") 'guix-package-list-mark-upgrades))
|
||||||
|
|
||||||
(defun guix-package-list-get-name (name entry)
|
(defun guix-package-list-get-name (name entry)
|
||||||
"Return NAME of the package ENTRY.
|
"Return NAME of the package ENTRY.
|
||||||
|
@ -505,24 +508,33 @@ Colorize it with `guix-package-list-installed' or
|
||||||
(eq guix-search-type 'generation))
|
(eq guix-search-type 'generation))
|
||||||
(error "Action marks are disabled for lists of 'generation packages'")))
|
(error "Action marks are disabled for lists of 'generation packages'")))
|
||||||
|
|
||||||
|
(defun guix-package-list-mark-outputs (mark default
|
||||||
|
&optional prompt available)
|
||||||
|
"Mark the current package with MARK and move to the next line.
|
||||||
|
If PROMPT is non-nil, use it to ask a user for outputs from
|
||||||
|
AVAILABLE list, otherwise mark all DEFAULT outputs."
|
||||||
|
(let ((outputs (if prompt
|
||||||
|
(guix-completing-read-multiple
|
||||||
|
prompt available nil t)
|
||||||
|
default)))
|
||||||
|
(apply #'guix-list-mark mark t outputs)))
|
||||||
|
|
||||||
(defun guix-package-list-mark-install (&optional arg)
|
(defun guix-package-list-mark-install (&optional arg)
|
||||||
"Mark the current package for installation and move to the next line.
|
"Mark the current package for installation and move to the next line.
|
||||||
With ARG, prompt for the outputs to install (several outputs may
|
With ARG, prompt for the outputs to install (several outputs may
|
||||||
be separated with \",\")."
|
be separated with \",\")."
|
||||||
(interactive "P")
|
(interactive "P")
|
||||||
(guix-package-list-marking-check)
|
(guix-package-list-marking-check)
|
||||||
(let* ((entry (guix-list-current-entry))
|
(let* ((entry (guix-list-current-entry))
|
||||||
(available (guix-get-key-val entry 'outputs))
|
(all (guix-get-key-val entry 'outputs))
|
||||||
(installed (guix-get-installed-outputs entry))
|
(installed (guix-get-installed-outputs entry))
|
||||||
(to-install (if arg
|
(available (cl-set-difference all installed :test #'string=)))
|
||||||
(guix-completing-read-multiple
|
(or available
|
||||||
"Output(s) to install: " available nil t)
|
(user-error "This package is already installed"))
|
||||||
'("out")))
|
(guix-package-list-mark-outputs
|
||||||
(to-install (cl-set-difference to-install installed
|
'install '("out")
|
||||||
:test #'string=)))
|
(and arg "Output(s) to install: ")
|
||||||
(if to-install
|
available)))
|
||||||
(apply #'guix-list-mark 'install t to-install)
|
|
||||||
(user-error "This package is already installed"))))
|
|
||||||
|
|
||||||
(defun guix-package-list-mark-delete (&optional arg)
|
(defun guix-package-list-mark-delete (&optional arg)
|
||||||
"Mark the current package for deletion and move to the next line.
|
"Mark the current package for deletion and move to the next line.
|
||||||
|
@ -534,23 +546,47 @@ be separated with \",\")."
|
||||||
(installed (guix-get-installed-outputs entry)))
|
(installed (guix-get-installed-outputs entry)))
|
||||||
(or installed
|
(or installed
|
||||||
(user-error "This package is not installed"))
|
(user-error "This package is not installed"))
|
||||||
(let ((to-delete (when arg
|
(guix-package-list-mark-outputs
|
||||||
(guix-completing-read-multiple
|
'delete installed
|
||||||
"Output(s) to delete: " installed nil t))))
|
(and arg "Output(s) to delete: ")
|
||||||
(if to-delete
|
installed)))
|
||||||
(apply #'guix-list-mark 'delete t to-delete)
|
|
||||||
(guix-package-list-mark-delete-simple)))))
|
|
||||||
|
|
||||||
(defun guix-package-list-mark-upgrade ()
|
(defun guix-package-list-mark-upgrade (&optional arg)
|
||||||
"Mark the current package for upgrading and move to the next line."
|
"Mark the current package for upgrading and move to the next line.
|
||||||
(interactive)
|
With ARG, prompt for the outputs to upgrade (several outputs may
|
||||||
|
be separated with \",\")."
|
||||||
|
(interactive "P")
|
||||||
(guix-package-list-marking-check)
|
(guix-package-list-marking-check)
|
||||||
(let ((entry (guix-list-current-entry)))
|
(let* ((entry (guix-list-current-entry))
|
||||||
(or (guix-get-installed-outputs entry)
|
(installed (guix-get-installed-outputs entry)))
|
||||||
|
(or installed
|
||||||
(user-error "This package is not installed"))
|
(user-error "This package is not installed"))
|
||||||
(when (or (guix-get-key-val entry 'obsolete)
|
(when (or (guix-get-key-val entry 'obsolete)
|
||||||
(y-or-n-p "This package is not obsolete. Try to upgrade it anyway? "))
|
(y-or-n-p "This package is not obsolete. Try to upgrade it anyway? "))
|
||||||
(guix-package-list-mark-upgrade-simple))))
|
(guix-package-list-mark-outputs
|
||||||
|
'upgrade installed
|
||||||
|
(and arg "Output(s) to upgrade: ")
|
||||||
|
installed))))
|
||||||
|
|
||||||
|
(defun guix-package-list-mark-upgrades ()
|
||||||
|
"Mark all obsolete packages for upgrading."
|
||||||
|
(interactive)
|
||||||
|
(guix-package-list-marking-check)
|
||||||
|
(let ((obsolete (cl-remove-if-not
|
||||||
|
(lambda (entry)
|
||||||
|
(guix-get-key-val entry 'obsolete))
|
||||||
|
guix-entries)))
|
||||||
|
(guix-list-for-each-line
|
||||||
|
(lambda ()
|
||||||
|
(let* ((id (guix-list-current-id))
|
||||||
|
(entry (cl-find-if
|
||||||
|
(lambda (entry)
|
||||||
|
(equal id (guix-get-key-val entry 'id)))
|
||||||
|
obsolete)))
|
||||||
|
(when entry
|
||||||
|
(apply #'guix-list-mark
|
||||||
|
'upgrade nil
|
||||||
|
(guix-get-installed-outputs entry))))))))
|
||||||
|
|
||||||
(defun guix-package-list-execute ()
|
(defun guix-package-list-execute ()
|
||||||
"Perform actions on the marked packages."
|
"Perform actions on the marked packages."
|
||||||
|
|
Loading…
Reference in New Issue