aboutsummaryrefslogtreecommitdiff
path: root/emacs
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
parentdc690c445e4b483e6ce2a88f6c23dd19685057cc (diff)
downloadguix-8ed2c92eb12b894e03cc634d92d3c78636f44020.tar.gz
guix-8ed2c92eb12b894e03cc634d92d3c78636f44020.zip
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')
-rw-r--r--emacs/guix-buffer.el64
-rw-r--r--emacs/guix-info.el10
-rw-r--r--emacs/guix-list.el10
-rw-r--r--emacs/guix-ui-generation.el4
-rw-r--r--emacs/guix-ui-package.el5
-rw-r--r--emacs/guix-ui.el23
6 files changed, 83 insertions, 33 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))))
diff --git a/emacs/guix-info.el b/emacs/guix-info.el
index 5219ac5507..644533eb29 100644
--- a/emacs/guix-info.el
+++ b/emacs/guix-info.el
@@ -29,15 +29,7 @@
(require 'guix-entry)
(require 'guix-utils)
-(defgroup guix-info nil
- "General settings for info buffers."
- :prefix "guix-info-"
- :group 'guix)
-
-(defgroup guix-info-faces nil
- "Faces for info buffers."
- :group 'guix-info
- :group 'guix-faces)
+(guix-define-buffer-type info)
(defface guix-info-heading
'((((type tty pc) (class color)) :weight bold)
diff --git a/emacs/guix-list.el b/emacs/guix-list.el
index 66e0bc8033..7e57f42cb2 100644
--- a/emacs/guix-list.el
+++ b/emacs/guix-list.el
@@ -31,15 +31,7 @@
(require 'guix-entry)
(require 'guix-utils)
-(defgroup guix-list nil
- "General settings for list buffers."
- :prefix "guix-list-"
- :group 'guix)
-
-(defgroup guix-list-faces nil
- "Faces for list buffers."
- :group 'guix-list
- :group 'guix-faces)
+(guix-define-buffer-type list)
(defface guix-list-file-path
'((t :inherit guix-info-file-path))
diff --git a/emacs/guix-ui-generation.el b/emacs/guix-ui-generation.el
index ec6d2187cd..040e5855f8 100644
--- a/emacs/guix-ui-generation.el
+++ b/emacs/guix-ui-generation.el
@@ -36,9 +36,7 @@
(require 'guix-entry)
(require 'guix-utils)
-(defgroup guix-generation nil
- "Interface for displaying generations."
- :group 'guix-ui)
+(guix-ui-define-entry-type generation)
(defun guix-generation-get-display (profile search-type &rest search-values)
"Search for generations and show results.
diff --git a/emacs/guix-ui-package.el b/emacs/guix-ui-package.el
index 66cf0fe6f0..b457539c0d 100644
--- a/emacs/guix-ui-package.el
+++ b/emacs/guix-ui-package.el
@@ -35,9 +35,8 @@
(require 'guix-entry)
(require 'guix-utils)
-(defgroup guix-package nil
- "Interface for displaying packages and outputs."
- :group 'guix-ui)
+(guix-ui-define-entry-type package)
+(guix-ui-define-entry-type output)
(defcustom guix-package-list-type 'output
"Define how to display packages in 'list' buffer.
diff --git a/emacs/guix-ui.el b/emacs/guix-ui.el
index 55c3f1b55c..7b63e63378 100644
--- a/emacs/guix-ui.el
+++ b/emacs/guix-ui.el
@@ -31,11 +31,11 @@
(require 'guix-utils)
(require 'guix-messages)
-(defgroup guix-ui nil
- "Settings for Guix package management.
+(guix-define-groups ui
+ :group-doc "\
+Settings for 'ui' (Guix package management) buffers.
This group includes settings for displaying packages, outputs and
-generations in 'list' and 'info' buffers."
- :group 'guix)
+generations in 'list' and 'info' buffers.")
(defvar guix-ui-map
(let ((map (make-sparse-keymap)))
@@ -175,6 +175,18 @@ See `guix-ui-update-after-operation' for details."
;;; Interface definers
+(defmacro guix-ui-define-entry-type (entry-type &rest args)
+ "Define general code for ENTRY-TYPE.
+Remaining arguments (ARGS) should have a form [KEYWORD VALUE] ...
+
+The rest keyword arguments are passed to
+`guix-define-entry-type' macro."
+ (declare (indent 1))
+ `(guix-define-entry-type ,entry-type
+ :parent-group guix-ui
+ :parent-faces-group guix-ui-faces
+ ,@args))
+
(defmacro guix-ui-define-interface (buffer-type entry-type &rest args)
"Define BUFFER-TYPE interface for displaying ENTRY-TYPE entries.
Remaining arguments (ARGS) should have a form [KEYWORD VALUE] ...
@@ -300,7 +312,8 @@ The rest keyword arguments are passed to
(defvar guix-ui-font-lock-keywords
(eval-when-compile
- `((,(rx "(" (group (or "guix-ui-define-interface"
+ `((,(rx "(" (group (or "guix-ui-define-entry-type"
+ "guix-ui-define-interface"
"guix-ui-info-define-interface"
"guix-ui-list-define-interface"))
symbol-end)