emacs: Add 'guix-list-get-display-entries'.

* emacs/guix-list.el (guix-list-get-display-entries): New procedure.
* emacs/guix-ui-generation.el (guix-generation-get-display): Use it.
This commit is contained in:
Alex Kost 2015-12-09 23:19:17 +03:00
parent e29d192484
commit ddf6948b22
2 changed files with 26 additions and 10 deletions

View File

@ -170,12 +170,6 @@ Return a vector made of values of FUN calls."
(cons (guix-list-param-title entry-type param) (cons (guix-list-param-title entry-type param)
rest-spec)))) rest-spec))))
(defun guix-list-insert-entries (entries entry-type)
"Print ENTRY-TYPE ENTRIES in the current buffer."
(setq tabulated-list-entries
(guix-list-tabulated-entries entries entry-type))
(tabulated-list-print))
(defun guix-list-tabulated-entries (entries entry-type) (defun guix-list-tabulated-entries (entries entry-type)
"Return a list of ENTRY-TYPE values for `tabulated-list-entries'." "Return a list of ENTRY-TYPE values for `tabulated-list-entries'."
(mapcar (lambda (entry) (mapcar (lambda (entry)
@ -194,6 +188,28 @@ Parameters are taken from ENTRY-TYPE ENTRY."
(funcall fun val entry) (funcall fun val entry)
(guix-get-string val)))))) (guix-get-string val))))))
;;; Displaying entries
(defun guix-list-get-display-entries (entry-type &rest args)
"Search for entries and show them in a 'list' buffer preferably."
(let ((entries (guix-buffer-get-entries 'list entry-type args)))
(if (or (null entries) ; = 0
(cdr entries) ; > 1
(guix-list-single-entry? entry-type)
(null (guix-buffer-value 'info entry-type 'show-entries)))
(guix-buffer-display-entries entries 'list entry-type args 'add)
(if (equal (guix-buffer-value 'info entry-type 'get-entries)
(guix-buffer-value 'list entry-type 'get-entries))
(guix-buffer-display-entries entries 'info entry-type args 'add)
(guix-buffer-get-display-entries 'info entry-type args 'add)))))
(defun guix-list-insert-entries (entries entry-type)
"Print ENTRY-TYPE ENTRIES in the current buffer."
(setq tabulated-list-entries
(guix-list-tabulated-entries entries entry-type))
(tabulated-list-print))
(defun guix-list-get-one-line (val &optional _) (defun guix-list-get-one-line (val &optional _)
"Return one-line string from a multi-line string VAL. "Return one-line string from a multi-line string VAL.
VAL may be nil." VAL may be nil."

View File

@ -47,10 +47,10 @@ If PROFILE is nil, use `guix-current-profile'.
See `guix-ui-get-entries' for the meaning of SEARCH-TYPE and See `guix-ui-get-entries' for the meaning of SEARCH-TYPE and
SEARCH-VALUES." SEARCH-VALUES."
(let ((args (cl-list* (or profile guix-current-profile) (apply #'guix-list-get-display-entries
search-type search-values))) 'generation
(guix-buffer-get-display-entries (or profile guix-current-profile)
'list 'generation args 'add))) search-type search-values))
(defun guix-delete-generations (profile generations (defun guix-delete-generations (profile generations
&optional operation-buffer) &optional operation-buffer)