summaryrefslogtreecommitdiff
path: root/emacs/guix-buffer.el
diff options
context:
space:
mode:
authorAlex Kost <alezost@gmail.com>2015-12-18 11:19:12 +0300
committerAlex Kost <alezost@gmail.com>2016-01-02 17:25:35 +0300
commit8ed2c92eb12b894e03cc634d92d3c78636f44020 (patch)
treee31b57625ab343994443c2c3ec0c65dc29807537 /emacs/guix-buffer.el
parentdc690c445e4b483e6ce2a88f6c23dd19685057cc (diff)
emacs: Add hierarchy of customization groups.
* emacs/guix-buffer.el (guix-define-groups, guix-define-entry-type) (guix-define-buffer-type): New macros. (guix-buffer-define-interface): Add parent groups for the generated custom groups. * emacs/guix-info.el: Use 'guix-define-buffer-type' to generate custom groups. * emacs/guix-list.el: Likewise. * emacs/guix-ui.el: Use 'guix-define-groups' to generate custom groups. (guix-ui-define-entry-type): New macro. * emacs/guix-ui-package.el: Use it. * emacs/guix-ui-generation.el: Use it.
Diffstat (limited to 'emacs/guix-buffer.el')
-rw-r--r--emacs/guix-buffer.el64
1 files changed, 60 insertions, 4 deletions
diff --git a/emacs/guix-buffer.el b/emacs/guix-buffer.el
index 5687a250aa..af76e638b6 100644
--- a/emacs/guix-buffer.el
+++ b/emacs/guix-buffer.el
@@ -331,7 +331,58 @@ This function does not update the buffer data, use
(guix-buffer-redisplay)))
-;;; Interface definer
+;;; Interface definers
+
+(defmacro guix-define-groups (type &rest args)
+ "Define `guix-TYPE' and `guix-TYPE-faces' custom groups.
+Remaining arguments (ARGS) should have a form [KEYWORD VALUE] ...
+
+Optional keywords:
+
+ - `:parent-group' - name of a parent custom group.
+
+ - `:parent-faces-group' - name of a parent custom faces group.
+
+ - `:group-doc' - docstring of a `guix-TYPE' group.
+
+ - `:faces-group-doc' - docstring of a `guix-TYPE-faces' group."
+ (declare (indent 1))
+ (let* ((type-str (symbol-name type))
+ (prefix (concat "guix-" type-str))
+ (group (intern prefix))
+ (faces-group (intern (concat prefix "-faces"))))
+ (guix-keyword-args-let args
+ ((parent-group :parent-group 'guix)
+ (parent-faces-group :parent-faces-group 'guix-faces)
+ (group-doc :group-doc
+ (format "Settings for '%s' buffers."
+ type-str))
+ (faces-group-doc :faces-group-doc
+ (format "Faces for '%s' buffers."
+ type-str)))
+ `(progn
+ (defgroup ,group nil
+ ,group-doc
+ :group ',parent-group)
+
+ (defgroup ,faces-group nil
+ ,faces-group-doc
+ :group ',group
+ :group ',parent-faces-group)))))
+
+(defmacro guix-define-entry-type (entry-type &rest args)
+ "Define general code for ENTRY-TYPE.
+See `guix-define-groups'."
+ (declare (indent 1))
+ `(guix-define-groups ,entry-type
+ ,@args))
+
+(defmacro guix-define-buffer-type (buffer-type &rest args)
+ "Define general code for BUFFER-TYPE.
+See `guix-define-groups'."
+ (declare (indent 1))
+ `(guix-define-groups ,buffer-type
+ ,@args))
(defmacro guix-buffer-define-interface (buffer-type entry-type &rest args)
"Define BUFFER-TYPE interface for displaying ENTRY-TYPE entries.
@@ -408,14 +459,16 @@ Optional keywords:
(reduced? :reduced?))
`(progn
(defgroup ,group nil
- ,(format "Display '%s' entries in '%s' buffer."
+ ,(format "Displaying '%s' entries in '%s' buffer."
entry-type-str buffer-type-str)
- :prefix ,(concat prefix "-")
+ :group ',(intern (concat "guix-" entry-type-str))
:group ',(intern (concat "guix-" buffer-type-str)))
(defgroup ,faces-group nil
,(format "Faces for displaying '%s' entries in '%s' buffer."
entry-type-str buffer-type-str)
+ :group ',group
+ :group ',(intern (concat "guix-" entry-type-str "-faces"))
:group ',(intern (concat "guix-" buffer-type-str "-faces")))
(defcustom ,titles-var ,titles-val
@@ -555,7 +608,10 @@ Major mode for displaying '%s' entries in '%s' buffer.
(eval-when-compile
`((,(rx "(" (group (or "guix-buffer-with-item"
"guix-buffer-with-current-item"
- "guix-buffer-define-interface"))
+ "guix-buffer-define-interface"
+ "guix-define-groups"
+ "guix-define-entry-type"
+ "guix-define-buffer-type"))
symbol-end)
. 1))))