summary refs log tree commit diff
path: root/emacs/guix.el
diff options
context:
space:
mode:
authorAlex Kost <alezost@gmail.com>2015-12-02 15:24:07 +0300
committerAlex Kost <alezost@gmail.com>2016-01-02 17:25:35 +0300
commit6c40b7b703424f757ff2e1fbb7503a525f9acfd8 (patch)
treef2eaad8eedcc9f2e2a413ec9eb899cb3832d640a /emacs/guix.el
parent8103c22fea9eef5e6ed1b97fedb565e0296bb6e3 (diff)
downloadguix-6c40b7b703424f757ff2e1fbb7503a525f9acfd8.tar.gz
emacs: Generalize buffer interface.
Extract the code for defining buffer interface from "guix-base.el",
generalize it and move to "guix-buffer.el".

* emacs.am (ELFILES): Add "emacs/guix-buffer.el".
* emacs/guix-base.el (guix-profile, guix-entries, guix-buffer-type)
  (guix-entry-type, guix-search-type, guix-search-vals, guix-set-vars)
  (guix-get-symbol, guix-show-entries, guix-get-show-entries)
  (guix-set-buffer, guix-history-call, guix-make-history-item)
  (guix-get-params-for-receiving): Remove.
  (guix-switch-to-buffer): Rename to 'guix-buffer-display' and move to
  "guix-buffer.el".
  (guix-get-entries): Rename to 'guix-ui-get-entries' and move to
  "guix-ui.el".
  (guix-buffer-data, guix-buffer-value, guix-buffer-param-title)
  (guix-buffer-name, guix-buffer-history-size)
  (guix-buffer-revert-confirm?, guix-buffer-map, guix-buffer-revert)
  (guix-buffer-after-redisplay-hook, guix-buffer-redisplay)
  (guix-buffer-redisplay-goto-button): Move to...
* emacs/guix-buffer.el: ... here.  New file.
  (guix-buffer-item): New variable.
  (guix-buffer-with-item, guix-buffer-with-current-item)
  (guix-buffer-define-current-item-accessor)
  (guix-buffer-define-current-item-accessors)
  (guix-buffer-define-current-args-accessor)
  (guix-buffer-define-current-args-accessors): New macros.
  (guix-buffer-get-entries, guix-buffer-mode-enable)
  (guix-buffer-mode-initialize, guix-buffer-insert-entries)
  (guix-buffer-show-entries-default, guix-buffer-show-entries)
  (guix-buffer-message, guix-buffer-history-item, guix-buffer-set)
  (guix-buffer-display-entries-current)
  (guix-buffer-get-display-entries-current)
  (guix-buffer-display-entries, guix-buffer-get-display-entries): New
  procedures.
* emacs/guix-info.el: Adjust for the procedures renaming.
  (guix-info-define-interface): Add ':show-entries-function' keyword.
* emacs/guix-list.el: Likewise.
* emacs/guix-ui.el (guix-ui-define-interface): Generate
  'guix-ENTRY-TYPE-BUFFER-TYPE-get-entries' procedure based on
  'guix-ui-get-entries'.
* emacs/guix.el (guix-get-show-packages, guix-get-show-generations):
  Adjust for the procedures renaming.
Diffstat (limited to 'emacs/guix.el')
-rw-r--r--emacs/guix.el45
1 files changed, 21 insertions, 24 deletions
diff --git a/emacs/guix.el b/emacs/guix.el
index ac6efbb475..12dd4a2553 100644
--- a/emacs/guix.el
+++ b/emacs/guix.el
@@ -56,42 +56,39 @@ If nil, show a single package in the info buffer."
 (defvar guix-search-history nil
   "A history of minibuffer prompts.")
 
-(defun guix-get-show-packages (profile search-type &rest search-vals)
+(defun guix-get-show-packages (profile search-type &rest search-values)
   "Search for packages and show results.
 
 If PROFILE is nil, use `guix-current-profile'.
 
-See `guix-get-entries' for the meaning of SEARCH-TYPE and
-SEARCH-VALS.
+See `guix-ui-get-entries' for the meaning of SEARCH-TYPE and
+SEARCH-VALUES.
 
 Results are displayed in the list buffer, unless a single package
 is found and `guix-list-single-package' is nil."
-  (or profile (setq profile guix-current-profile))
-  (let ((packages (guix-get-entries profile guix-package-list-type
-                                    search-type search-vals
-                                    (guix-get-params-for-receiving
-                                     'list guix-package-list-type))))
+  (let* ((args    (cl-list* (or profile guix-current-profile)
+                            search-type search-values))
+         (entries (guix-buffer-get-entries
+                   'list guix-package-list-type args)))
     (if (or guix-list-single-package
-            (cdr packages))
-        (guix-set-buffer profile packages 'list guix-package-list-type
-                         search-type search-vals)
-      (let ((packages (guix-get-entries profile guix-package-info-type
-                                        search-type search-vals
-                                        (guix-get-params-for-receiving
-                                         'info guix-package-info-type))))
-        (guix-set-buffer profile packages 'info guix-package-info-type
-                         search-type search-vals)))))
-
-(defun guix-get-show-generations (profile search-type &rest search-vals)
+            (null entries)
+            (cdr entries))
+        (guix-buffer-display-entries
+         entries 'list guix-package-list-type args 'add)
+      (guix-buffer-get-display-entries
+       'info guix-package-info-type args 'add))))
+
+(defun guix-get-show-generations (profile search-type &rest search-values)
   "Search for generations and show results.
 
 If PROFILE is nil, use `guix-current-profile'.
 
-See `guix-get-entries' for the meaning of SEARCH-TYPE and
-SEARCH-VALS."
-  (apply #'guix-get-show-entries
-         (or profile guix-current-profile)
-         'list 'generation search-type search-vals))
+See `guix-ui-get-entries' for the meaning of SEARCH-TYPE and
+SEARCH-VALUES."
+  (let ((args (cl-list* (or profile guix-current-profile)
+                        search-type search-values)))
+    (guix-buffer-get-display-entries
+     'list 'generation args 'add)))
 
 ;;;###autoload
 (defun guix-search-by-name (name &optional profile)