mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2025-01-25 20:19:18 -05:00
emacs: Add support for switching generations.
* emacs/guix-base.el (guix-switch-to-generation): New procedure. * emacs/guix-info.el (guix-generation-info-insert-current): Insert button for switching to generation. * emacs/guix-list.el (guix-generation-list-switch): New procedure. * doc/emacs.texi (emacs List buffer, emacs Info buffer): Document switching generations.
This commit is contained in:
parent
c2379b3c1f
commit
af874238d4
4 changed files with 31 additions and 1 deletions
|
@ -205,6 +205,8 @@ 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 s
|
||||||
|
Switch profile to the current generation.
|
||||||
@item d
|
@item d
|
||||||
Mark the current generation for deletion (with prefix, mark all
|
Mark the current generation for deletion (with prefix, mark all
|
||||||
generations).
|
generations).
|
||||||
|
@ -236,6 +238,7 @@ emacs, The Emacs Editor}) which can be used to:
|
||||||
|
|
||||||
@itemize @minus
|
@itemize @minus
|
||||||
@item remove a generation;
|
@item remove a generation;
|
||||||
|
@item switch to a generation;
|
||||||
@item list packages installed in a generation;
|
@item list packages installed in a generation;
|
||||||
@item jump to a generation directory.
|
@item jump to a generation directory.
|
||||||
@end itemize
|
@end itemize
|
||||||
|
|
|
@ -816,6 +816,15 @@ Each element from GENERATIONS is a generation number."
|
||||||
(guix-make-guile-expression
|
(guix-make-guile-expression
|
||||||
'delete-generations* guix-current-profile generations))))
|
'delete-generations* guix-current-profile generations))))
|
||||||
|
|
||||||
|
(defun guix-switch-to-generation (generation)
|
||||||
|
"Switch `guix-current-profile' to GENERATION number."
|
||||||
|
(when (or (not guix-operation-confirm)
|
||||||
|
(y-or-n-p (format "Switch current profile to generation %d? "
|
||||||
|
generation)))
|
||||||
|
(guix-eval-in-repl
|
||||||
|
(guix-make-guile-expression
|
||||||
|
'switch-to-generation guix-current-profile generation))))
|
||||||
|
|
||||||
(provide 'guix-base)
|
(provide 'guix-base)
|
||||||
|
|
||||||
;;; guix-base.el ends here
|
;;; guix-base.el ends here
|
||||||
|
|
|
@ -647,7 +647,14 @@ ENTRY is an alist with package info."
|
||||||
"Insert boolean value VAL showing whether this generation is current."
|
"Insert boolean value VAL showing whether this generation is current."
|
||||||
(if val
|
(if val
|
||||||
(guix-info-insert-val-default "Yes" 'guix-generation-info-current)
|
(guix-info-insert-val-default "Yes" 'guix-generation-info-current)
|
||||||
(guix-info-insert-val-default "No" 'guix-generation-info-not-current)))
|
(guix-info-insert-val-default "No" 'guix-generation-info-not-current)
|
||||||
|
(guix-info-insert-indent)
|
||||||
|
(guix-info-insert-action-button
|
||||||
|
"Switch"
|
||||||
|
(lambda (btn)
|
||||||
|
(guix-switch-to-generation (button-get btn 'number)))
|
||||||
|
"Switch to this generation (make it the current one)"
|
||||||
|
'number (guix-get-key-val entry 'number))))
|
||||||
|
|
||||||
(provide 'guix-info)
|
(provide 'guix-info)
|
||||||
|
|
||||||
|
|
|
@ -735,6 +735,7 @@ Also see `guix-package-info-type'."
|
||||||
(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 "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 "s") 'guix-generation-list-switch)
|
||||||
(define-key map (kbd "d") 'guix-generation-list-mark-delete))
|
(define-key map (kbd "d") 'guix-generation-list-mark-delete))
|
||||||
|
|
||||||
(defun guix-generation-list-get-current (val &optional _)
|
(defun guix-generation-list-get-current (val &optional _)
|
||||||
|
@ -742,6 +743,16 @@ Also see `guix-package-info-type'."
|
||||||
VAL is a boolean value."
|
VAL is a boolean value."
|
||||||
(if val "(current)" ""))
|
(if val "(current)" ""))
|
||||||
|
|
||||||
|
(defun guix-generation-list-switch ()
|
||||||
|
"Switch current profile to the generation at point."
|
||||||
|
(interactive)
|
||||||
|
(let* ((entry (guix-list-current-entry))
|
||||||
|
(current (guix-get-key-val entry 'current))
|
||||||
|
(number (guix-get-key-val entry 'number)))
|
||||||
|
(if current
|
||||||
|
(user-error "This generation is already the current one")
|
||||||
|
(guix-switch-to-generation number))))
|
||||||
|
|
||||||
(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."
|
||||||
(interactive)
|
(interactive)
|
||||||
|
|
Loading…
Reference in a new issue