me
/
guix
Archived
1
0
Fork 0

emacs: Add 'current' generation parameter.

* emacs/guix-main.scm (generation-param-alist): Add 'current' parameter.
* emacs/guix-base.el (guix-param-titles): Add title for 'current' parameter.
* emacs/guix-info.el: Display 'current' parameter.
  (guix-generation-info-current, guix-generation-info-not-current): New faces.
  (guix-generation-info-insert-current): New procedure.
* emacs/guix-list.el: Display 'current' column.
  (guix-generation-list-get-current): New procedure.
master
Alex Kost 2014-10-10 23:50:15 +04:00
parent 0546393164
commit c2379b3c1f
4 changed files with 36 additions and 10 deletions

View File

@ -107,6 +107,7 @@ Interactively, prompt for PATH. With prefix, use
(id . "ID") (id . "ID")
(number . "Number") (number . "Number")
(prev-number . "Previous number") (prev-number . "Previous number")
(current . "Current")
(path . "Path") (path . "Path")
(time . "Time"))) (time . "Time")))
"List for defining titles of entry parameters. "List for defining titles of entry parameters.

View File

@ -136,6 +136,7 @@ number of characters, it will be split into several lines.")
(location guix-package-info-insert-location)) (location guix-package-info-insert-location))
(generation (generation
(number guix-generation-info-insert-number) (number guix-generation-info-insert-number)
(current guix-generation-info-insert-current)
(path guix-info-insert-file-path) (path guix-info-insert-file-path)
(time guix-info-insert-time))) (time guix-info-insert-time)))
"Methods for inserting parameter values. "Methods for inserting parameter values.
@ -161,7 +162,7 @@ argument.")
(output name version output synopsis path dependencies location home-url (output name version output synopsis path dependencies location home-url
license inputs native-inputs propagated-inputs description) license inputs native-inputs propagated-inputs description)
(installed path dependencies) (installed path dependencies)
(generation number prev-number time path)) (generation number prev-number current time path))
"List of displayed entry parameters. "List of displayed entry parameters.
Each element of the list should have a form: Each element of the list should have a form:
@ -613,6 +614,16 @@ ENTRY is an alist with package info."
"Face used for a number of a generation." "Face used for a number of a generation."
:group 'guix-generation-info) :group 'guix-generation-info)
(defface guix-generation-info-current
'((t :inherit guix-package-info-installed-outputs))
"Face used if a generation is the current one."
:group 'guix-generation-info)
(defface guix-generation-info-not-current
'((t nil))
"Face used if a generation is not the current one."
:group 'guix-generation-info)
(defun guix-generation-info-insert-number (number &optional _) (defun guix-generation-info-insert-number (number &optional _)
"Insert generation NUMBER and action buttons." "Insert generation NUMBER and action buttons."
(guix-info-insert-val-default number 'guix-generation-info-number) (guix-info-insert-val-default number 'guix-generation-info-number)
@ -632,6 +643,12 @@ ENTRY is an alist with package info."
"Delete this generation" "Delete this generation"
'number number)) 'number number))
(defun guix-generation-info-insert-current (val entry)
"Insert boolean value VAL showing whether this generation is current."
(if val
(guix-info-insert-val-default "Yes" 'guix-generation-info-current)
(guix-info-insert-val-default "No" 'guix-generation-info-not-current)))
(provide 'guix-info) (provide 'guix-info)
;;; guix-info.el ends here ;;; guix-info.el ends here

View File

@ -65,6 +65,7 @@ entries, he will be prompted for confirmation."
(number 5 (number 5
,(lambda (a b) (guix-list-sort-numerically 0 a b)) ,(lambda (a b) (guix-list-sort-numerically 0 a b))
:right-align t) :right-align t)
(current 10 t)
(time 20 t) (time 20 t)
(path 30 t))) (path 30 t)))
"Columns displayed in list buffers. "Columns displayed in list buffers.
@ -93,8 +94,9 @@ this list have a priority.")
(synopsis . guix-list-get-one-line) (synopsis . guix-list-get-one-line)
(description . guix-list-get-one-line)) (description . guix-list-get-one-line))
(generation (generation
(time . guix-list-get-time) (current . guix-generation-list-get-current)
(path . guix-list-get-file-path))) (time . guix-list-get-time)
(path . guix-list-get-file-path)))
"Methods for inserting parameter values in columns. "Methods for inserting parameter values in columns.
Each element of the list has a form: Each element of the list has a form:
@ -735,6 +737,11 @@ Also see `guix-package-info-type'."
(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)) (define-key map (kbd "d") 'guix-generation-list-mark-delete))
(defun guix-generation-list-get-current (val &optional _)
"Return string from VAL showing whether this generation is current.
VAL is a boolean value."
(if val "(current)" ""))
(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)

View File

@ -638,13 +638,14 @@ See 'entry-sexps' for details."
(define (generation-param-alist profile) (define (generation-param-alist profile)
"Return an alist of generation parameters and procedures for PROFILE." "Return an alist of generation parameters and procedures for PROFILE."
(list (let ((current (generation-number profile)))
(cons 'id identity) `((id . ,identity)
(cons 'number identity) (number . ,identity)
(cons 'prev-number (cut previous-generation-number profile <>)) (prev-number . ,(cut previous-generation-number profile <>))
(cons 'path (cut generation-file-name profile <>)) (current . ,(cut = current <>))
(cons 'time (lambda (gen) (path . ,(cut generation-file-name profile <>))
(time-second (generation-time profile gen)))))) (time . ,(lambda (gen)
(time-second (generation-time profile gen)))))))
(define (matching-generations profile predicate) (define (matching-generations profile predicate)
"Return a list of PROFILE generations matching PREDICATE." "Return a list of PROFILE generations matching PREDICATE."