diff options
author | Alex Kost <alezost@gmail.com> | 2015-12-09 23:19:17 +0300 |
---|---|---|
committer | Alex Kost <alezost@gmail.com> | 2016-01-02 17:25:35 +0300 |
commit | ddf6948b2204fbb453df9bc2ade48454d3d6ee12 (patch) | |
tree | 4acae5b81042e9c45b050da255c9f2b095cc59dc /emacs/guix-list.el | |
parent | e29d19248483d2ac527894ca20fa69f88fabdfd3 (diff) | |
download | patches-ddf6948b2204fbb453df9bc2ade48454d3d6ee12.tar patches-ddf6948b2204fbb453df9bc2ade48454d3d6ee12.tar.gz |
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.
Diffstat (limited to 'emacs/guix-list.el')
-rw-r--r-- | emacs/guix-list.el | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/emacs/guix-list.el b/emacs/guix-list.el index 8b37a88615..66e0bc8033 100644 --- a/emacs/guix-list.el +++ b/emacs/guix-list.el @@ -170,12 +170,6 @@ Return a vector made of values of FUN calls." (cons (guix-list-param-title entry-type param) 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) "Return a list of ENTRY-TYPE values for `tabulated-list-entries'." (mapcar (lambda (entry) @@ -194,6 +188,28 @@ Parameters are taken from ENTRY-TYPE ENTRY." (funcall fun val entry) (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 _) "Return one-line string from a multi-line string VAL. VAL may be nil." |