summaryrefslogtreecommitdiff
path: root/emacs/guix-info.el
diff options
context:
space:
mode:
authorAlex Kost <alezost@gmail.com>2015-11-20 12:38:31 +0300
committerAlex Kost <alezost@gmail.com>2016-01-02 17:25:35 +0300
commit7735c503b5b8dfe7d8963207f4f2cf0b7dfd3894 (patch)
treeabff13562165160b51938a84a7f93ab32c39f329 /emacs/guix-info.el
parent2c7ed388cf403120c17b5e222ac5dda093f5ad94 (diff)
downloadpatches-7735c503b5b8dfe7d8963207f4f2cf0b7dfd3894.tar
patches-7735c503b5b8dfe7d8963207f4f2cf0b7dfd3894.tar.gz
emacs: Factorize macros for defining interfaces.
Make a root 'guix-buffer-define-interface' macro. It should generate a common code for any type of interface. Inherit 'guix-info-define-interface' and 'guix-list-define-interface' from it. They should provide a general 'info'/'list' interface for any data. Finally, make 'guix-ui-define-interface' for the common code for interfaces to Guix packages and generations, and inherit 'guix-ui-info-define-interface' and 'guix-ui-list-define-interface' from it. * emacs/guix-base.el (guix-define-buffer-type): Rename to... (guix-buffer-define-interface): ... this. Rename internal variables ('buf-' -> 'buffer-'). Move ':required' keyword to 'guix-ui-define-interface'. * emacs/guix-info.el (guix-info-define-interface): New macro. (guix-info-font-lock-keywords): New variable. * emacs/guix-list.el (guix-list-define-entry-type): Rename to... (guix-list-define-interface): ... this. (guix-list-font-lock-keywords): New variable. (guix-list-describe-ids): Move and rename to... * emacs/guix-ui.el: New file. (guix-ui-list-describe): ... this. (guix-ui-define-interface, guix-ui-info-define-interface) (guix-ui-list-define-interface): New macros. (guix-ui-font-lock-keywords): New variable. * emacs.am (ELFILES): Add "emacs/guix-ui.el"
Diffstat (limited to 'emacs/guix-info.el')
-rw-r--r--emacs/guix-info.el30
1 files changed, 26 insertions, 4 deletions
diff --git a/emacs/guix-info.el b/emacs/guix-info.el
index 9c46810f60..d31e0377ff 100644
--- a/emacs/guix-info.el
+++ b/emacs/guix-info.el
@@ -28,6 +28,7 @@
(require 'guix-base)
(require 'guix-entry)
(require 'guix-utils)
+(require 'guix-ui)
(defgroup guix-info nil
"General settings for info buffers."
@@ -455,6 +456,8 @@ See `insert-text-button' for the meaning of PROPERTIES."
properties))
+;;; Major mode and interface definer
+
(defvar guix-info-mode-map
(let ((map (make-sparse-keymap)))
(set-keymap-parent
@@ -466,11 +469,21 @@ See `insert-text-button' for the meaning of PROPERTIES."
(define-derived-mode guix-info-mode special-mode "Guix-Info"
"Parent mode for displaying information in info buffers.")
+(defmacro guix-info-define-interface (entry-type &rest args)
+ "Define 'info' interface for displaying ENTRY-TYPE entries.
+Remaining arguments (ARGS) should have a form [KEYWORD VALUE] ...
+
+The rest keyword arguments are passed to
+`guix-buffer-define-interface' macro."
+ (declare (indent 1))
+ `(guix-buffer-define-interface info ,entry-type
+ ,@args))
+
;;; Displaying packages
-(guix-define-buffer-type info package
- :required (id name version installed non-unique))
+(guix-ui-info-define-interface package
+ :required '(id name version installed non-unique))
(defface guix-package-info-heading
'((t :inherit guix-info-heading))
@@ -758,7 +771,7 @@ This function is used to hide a \"Download\" button if needed."
(guix-ui-info-define-interface output
:buffer-name "*Guix Package Info*"
- :required (id package-id installed non-unique))
+ :required '(id package-id installed non-unique))
(defun guix-output-info-insert-version (version entry)
"Insert output VERSION and obsolete text if needed at point."
@@ -786,7 +799,7 @@ This function is used to hide a \"Download\" button if needed."
;;; Displaying generations
-(guix-define-buffer-type info generation)
+(guix-ui-info-define-interface generation)
(defface guix-generation-info-number
'((t :inherit font-lock-keyword-face))
@@ -837,6 +850,15 @@ This function is used to hide a \"Download\" button if needed."
"Switch to this generation (make it the current one)"
'number (guix-entry-value entry 'number))))
+
+(defvar guix-info-font-lock-keywords
+ (eval-when-compile
+ `((,(rx "(" (group "guix-info-define-interface")
+ symbol-end)
+ . 1))))
+
+(font-lock-add-keywords 'emacs-lisp-mode guix-info-font-lock-keywords)
+
(provide 'guix-info)
;;; guix-info.el ends here