emacs: Add support for deleting generations.
* doc/emacs.texi (emacs List buffer): Mention new key bindings. * emacs/guix-base.el (guix-delete-generations): New procedure. * emacs/guix-info.el (guix-generation-info-insert-number): Use it. * emacs/guix-list.el (guix-generation-list-mark-delete, guix-generation-list-execute): New procedures. * emacs/guix-main.scm (delete-generations*): New procedure.
This commit is contained in:
parent
d3d337d2d8
commit
cb6a5c71d8
5 changed files with 49 additions and 5 deletions
|
@ -105,8 +105,8 @@ many last generations.
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
By default commands for displaying packages display each output on a
|
By default commands for displaying packages display each output on a
|
||||||
separate line. If you prefer to see a list of packages (i.e.@: a list
|
separate line. If you prefer to see a list of packages---i.e., a list
|
||||||
with a package per line), use the following setting:
|
with a package per line, use the following setting:
|
||||||
|
|
||||||
@example
|
@example
|
||||||
(setq guix-package-list-type 'package)
|
(setq guix-package-list-type 'package)
|
||||||
|
@ -205,6 +205,11 @@ List packages installed in the current generation.
|
||||||
@item i
|
@item i
|
||||||
Describe marked generations (display available information in a
|
Describe marked generations (display available information in a
|
||||||
``generation-info'' buffer).
|
``generation-info'' buffer).
|
||||||
|
@item d
|
||||||
|
Mark the current generation for deletion (with prefix, mark all
|
||||||
|
generations).
|
||||||
|
@item x
|
||||||
|
Execute actions on the marked generations---i.e., delete generations.
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
@node emacs Info buffer
|
@node emacs Info buffer
|
||||||
|
|
|
@ -801,6 +801,20 @@ Return non-nil, if the operation should be continued; nil otherwise."
|
||||||
guix-operation-option-separator)))
|
guix-operation-option-separator)))
|
||||||
(force-mode-line-update))
|
(force-mode-line-update))
|
||||||
|
|
||||||
|
(defun guix-delete-generations (&rest generations)
|
||||||
|
"Delete GENERATIONS.
|
||||||
|
Each element from GENERATIONS is a generation number."
|
||||||
|
(when (or (not guix-operation-confirm)
|
||||||
|
(y-or-n-p
|
||||||
|
(let ((count (length generations)))
|
||||||
|
(if (> count 1)
|
||||||
|
(format "Delete %d generations? " count)
|
||||||
|
(format "Delete generation number %d? "
|
||||||
|
(car generations))))))
|
||||||
|
(guix-eval-in-repl
|
||||||
|
(guix-make-guile-expression
|
||||||
|
'delete-generations* guix-current-profile generations))))
|
||||||
|
|
||||||
(provide 'guix-base)
|
(provide 'guix-base)
|
||||||
|
|
||||||
;;; guix-base.el ends here
|
;;; guix-base.el ends here
|
||||||
|
|
|
@ -627,8 +627,10 @@ ENTRY is an alist with package info."
|
||||||
(guix-info-insert-indent)
|
(guix-info-insert-indent)
|
||||||
(guix-info-insert-action-button
|
(guix-info-insert-action-button
|
||||||
"Delete"
|
"Delete"
|
||||||
(lambda (btn) (error "Sorry, not implemented yet"))
|
(lambda (btn)
|
||||||
"Delete this generation"))
|
(guix-delete-generations (button-get btn 'number)))
|
||||||
|
"Delete this generation"
|
||||||
|
'number number))
|
||||||
|
|
||||||
(provide 'guix-info)
|
(provide 'guix-info)
|
||||||
|
|
||||||
|
|
|
@ -728,8 +728,9 @@ Also see `guix-package-info-type'."
|
||||||
|
|
||||||
(let ((map guix-generation-list-mode-map))
|
(let ((map guix-generation-list-mode-map))
|
||||||
(define-key map (kbd "RET") 'guix-generation-list-show-packages)
|
(define-key map (kbd "RET") 'guix-generation-list-show-packages)
|
||||||
|
(define-key map (kbd "x") 'guix-generation-list-execute)
|
||||||
(define-key map (kbd "i") 'guix-list-describe)
|
(define-key map (kbd "i") 'guix-list-describe)
|
||||||
(define-key map (kbd "d") 'guix-generation-list-mark-delete-simple))
|
(define-key map (kbd "d") 'guix-generation-list-mark-delete))
|
||||||
|
|
||||||
(defun guix-generation-list-show-packages ()
|
(defun guix-generation-list-show-packages ()
|
||||||
"List installed packages for the generation at point."
|
"List installed packages for the generation at point."
|
||||||
|
@ -737,6 +738,22 @@ Also see `guix-package-info-type'."
|
||||||
(guix-get-show-entries 'list guix-package-list-type 'generation
|
(guix-get-show-entries 'list guix-package-list-type 'generation
|
||||||
(guix-list-current-id)))
|
(guix-list-current-id)))
|
||||||
|
|
||||||
|
(defun guix-generation-list-mark-delete (&optional arg)
|
||||||
|
"Mark the current generation for deletion and move to the next line.
|
||||||
|
With ARG, mark all generations for deletion."
|
||||||
|
(interactive "P")
|
||||||
|
(if arg
|
||||||
|
(guix-list-mark-all 'delete)
|
||||||
|
(guix-list-mark 'delete t)))
|
||||||
|
|
||||||
|
(defun guix-generation-list-execute ()
|
||||||
|
"Delete marked generations."
|
||||||
|
(interactive)
|
||||||
|
(let ((marked (guix-list-get-marked-id-list 'delete)))
|
||||||
|
(or marked
|
||||||
|
(user-error "No generations marked for deletion"))
|
||||||
|
(apply #'guix-delete-generations marked)))
|
||||||
|
|
||||||
(provide 'guix-list)
|
(provide 'guix-list)
|
||||||
|
|
||||||
;;; guix-list.el ends here
|
;;; guix-list.el ends here
|
||||||
|
|
|
@ -815,3 +815,9 @@ (define* (process-package-actions
|
||||||
"~a packages in profile~%"
|
"~a packages in profile~%"
|
||||||
count)
|
count)
|
||||||
count)))))))))
|
count)))))))))
|
||||||
|
|
||||||
|
(define (delete-generations* profile generations)
|
||||||
|
"Delete GENERATIONS from PROFILE.
|
||||||
|
GENERATIONS is a list of generation numbers."
|
||||||
|
(with-store store
|
||||||
|
(delete-generations store profile generations)))
|
||||||
|
|
Loading…
Reference in a new issue