mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2025-01-12 06:06:53 -05:00
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.
This commit is contained in:
parent
dc690c445e
commit
8ed2c92eb1
6 changed files with 83 additions and 33 deletions
|
@ -331,7 +331,58 @@ This function does not update the buffer data, use
|
||||||
(guix-buffer-redisplay)))
|
(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)
|
(defmacro guix-buffer-define-interface (buffer-type entry-type &rest args)
|
||||||
"Define BUFFER-TYPE interface for displaying ENTRY-TYPE entries.
|
"Define BUFFER-TYPE interface for displaying ENTRY-TYPE entries.
|
||||||
|
@ -408,14 +459,16 @@ Optional keywords:
|
||||||
(reduced? :reduced?))
|
(reduced? :reduced?))
|
||||||
`(progn
|
`(progn
|
||||||
(defgroup ,group nil
|
(defgroup ,group nil
|
||||||
,(format "Display '%s' entries in '%s' buffer."
|
,(format "Displaying '%s' entries in '%s' buffer."
|
||||||
entry-type-str buffer-type-str)
|
entry-type-str buffer-type-str)
|
||||||
:prefix ,(concat prefix "-")
|
:group ',(intern (concat "guix-" entry-type-str))
|
||||||
:group ',(intern (concat "guix-" buffer-type-str)))
|
:group ',(intern (concat "guix-" buffer-type-str)))
|
||||||
|
|
||||||
(defgroup ,faces-group nil
|
(defgroup ,faces-group nil
|
||||||
,(format "Faces for displaying '%s' entries in '%s' buffer."
|
,(format "Faces for displaying '%s' entries in '%s' buffer."
|
||||||
entry-type-str buffer-type-str)
|
entry-type-str buffer-type-str)
|
||||||
|
:group ',group
|
||||||
|
:group ',(intern (concat "guix-" entry-type-str "-faces"))
|
||||||
:group ',(intern (concat "guix-" buffer-type-str "-faces")))
|
:group ',(intern (concat "guix-" buffer-type-str "-faces")))
|
||||||
|
|
||||||
(defcustom ,titles-var ,titles-val
|
(defcustom ,titles-var ,titles-val
|
||||||
|
@ -555,7 +608,10 @@ Major mode for displaying '%s' entries in '%s' buffer.
|
||||||
(eval-when-compile
|
(eval-when-compile
|
||||||
`((,(rx "(" (group (or "guix-buffer-with-item"
|
`((,(rx "(" (group (or "guix-buffer-with-item"
|
||||||
"guix-buffer-with-current-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)
|
symbol-end)
|
||||||
. 1))))
|
. 1))))
|
||||||
|
|
||||||
|
|
|
@ -29,15 +29,7 @@
|
||||||
(require 'guix-entry)
|
(require 'guix-entry)
|
||||||
(require 'guix-utils)
|
(require 'guix-utils)
|
||||||
|
|
||||||
(defgroup guix-info nil
|
(guix-define-buffer-type info)
|
||||||
"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)
|
|
||||||
|
|
||||||
(defface guix-info-heading
|
(defface guix-info-heading
|
||||||
'((((type tty pc) (class color)) :weight bold)
|
'((((type tty pc) (class color)) :weight bold)
|
||||||
|
|
|
@ -31,15 +31,7 @@
|
||||||
(require 'guix-entry)
|
(require 'guix-entry)
|
||||||
(require 'guix-utils)
|
(require 'guix-utils)
|
||||||
|
|
||||||
(defgroup guix-list nil
|
(guix-define-buffer-type list)
|
||||||
"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)
|
|
||||||
|
|
||||||
(defface guix-list-file-path
|
(defface guix-list-file-path
|
||||||
'((t :inherit guix-info-file-path))
|
'((t :inherit guix-info-file-path))
|
||||||
|
|
|
@ -36,9 +36,7 @@
|
||||||
(require 'guix-entry)
|
(require 'guix-entry)
|
||||||
(require 'guix-utils)
|
(require 'guix-utils)
|
||||||
|
|
||||||
(defgroup guix-generation nil
|
(guix-ui-define-entry-type generation)
|
||||||
"Interface for displaying generations."
|
|
||||||
:group 'guix-ui)
|
|
||||||
|
|
||||||
(defun guix-generation-get-display (profile search-type &rest search-values)
|
(defun guix-generation-get-display (profile search-type &rest search-values)
|
||||||
"Search for generations and show results.
|
"Search for generations and show results.
|
||||||
|
|
|
@ -35,9 +35,8 @@
|
||||||
(require 'guix-entry)
|
(require 'guix-entry)
|
||||||
(require 'guix-utils)
|
(require 'guix-utils)
|
||||||
|
|
||||||
(defgroup guix-package nil
|
(guix-ui-define-entry-type package)
|
||||||
"Interface for displaying packages and outputs."
|
(guix-ui-define-entry-type output)
|
||||||
:group 'guix-ui)
|
|
||||||
|
|
||||||
(defcustom guix-package-list-type 'output
|
(defcustom guix-package-list-type 'output
|
||||||
"Define how to display packages in 'list' buffer.
|
"Define how to display packages in 'list' buffer.
|
||||||
|
|
|
@ -31,11 +31,11 @@
|
||||||
(require 'guix-utils)
|
(require 'guix-utils)
|
||||||
(require 'guix-messages)
|
(require 'guix-messages)
|
||||||
|
|
||||||
(defgroup guix-ui nil
|
(guix-define-groups ui
|
||||||
"Settings for Guix package management.
|
:group-doc "\
|
||||||
|
Settings for 'ui' (Guix package management) buffers.
|
||||||
This group includes settings for displaying packages, outputs and
|
This group includes settings for displaying packages, outputs and
|
||||||
generations in 'list' and 'info' buffers."
|
generations in 'list' and 'info' buffers.")
|
||||||
:group 'guix)
|
|
||||||
|
|
||||||
(defvar guix-ui-map
|
(defvar guix-ui-map
|
||||||
(let ((map (make-sparse-keymap)))
|
(let ((map (make-sparse-keymap)))
|
||||||
|
@ -175,6 +175,18 @@ See `guix-ui-update-after-operation' for details."
|
||||||
|
|
||||||
;;; Interface definers
|
;;; 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)
|
(defmacro guix-ui-define-interface (buffer-type entry-type &rest args)
|
||||||
"Define BUFFER-TYPE interface for displaying ENTRY-TYPE entries.
|
"Define BUFFER-TYPE interface for displaying ENTRY-TYPE entries.
|
||||||
Remaining arguments (ARGS) should have a form [KEYWORD VALUE] ...
|
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
|
(defvar guix-ui-font-lock-keywords
|
||||||
(eval-when-compile
|
(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-info-define-interface"
|
||||||
"guix-ui-list-define-interface"))
|
"guix-ui-list-define-interface"))
|
||||||
symbol-end)
|
symbol-end)
|
||||||
|
|
Loading…
Reference in a new issue