mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-24 21:38:07 -05:00
emacs: Split 'guix-param-titles' variable.
Generate 'guix-ENTRY-TYPE-BUFFER-TYPE-titles' variables for each ENTRY-TYPE and BUFFER-TYPE instead. * emacs/guix-base.el (guix-param-titles): Remove. (guix-buffer-data): New variable. (guix-buffer-value, guix-buffer-param-title): New procedures. (guix-buffer-define-interface): Add ':titles' keyword. * emacs/guix-info.el (guix-info-param-title): Adjust accordingly. * emacs/guix-list.el (guix-list-param-title): Likewise. (guix-list-column-titles): Remove. * doc/emacs.texi (Emacs Appearance): Adjust accordingly.
This commit is contained in:
parent
9193fb7c1d
commit
574f6727b0
4 changed files with 48 additions and 37 deletions
|
@ -480,11 +480,12 @@ the following variables (@dfn{ENTRY-TYPE} means @code{package},
|
||||||
|
|
||||||
@table @code
|
@table @code
|
||||||
@item guix-ENTRY-TYPE-list-format
|
@item guix-ENTRY-TYPE-list-format
|
||||||
@itemx guix-list-column-titles
|
@itemx guix-ENTRY-TYPE-list-titles
|
||||||
Specify the columns, their names, what and how is displayed in ``list''
|
Specify the columns, their names, what and how is displayed in ``list''
|
||||||
buffers.
|
buffers.
|
||||||
|
|
||||||
@item guix-ENTRY-TYPE-info-format
|
@item guix-ENTRY-TYPE-info-format
|
||||||
|
@itemx guix-ENTRY-TYPE-info-titles
|
||||||
@itemx guix-info-ignore-empty-values
|
@itemx guix-info-ignore-empty-values
|
||||||
@itemx guix-info-param-title-format
|
@itemx guix-info-param-title-format
|
||||||
@itemx guix-info-multiline-prefix
|
@itemx guix-info-multiline-prefix
|
||||||
|
|
|
@ -39,28 +39,6 @@
|
||||||
|
|
||||||
;;; Parameters of the entries
|
;;; Parameters of the entries
|
||||||
|
|
||||||
(defvar guix-param-titles
|
|
||||||
'((package
|
|
||||||
(home-url . "Home page"))
|
|
||||||
(installed
|
|
||||||
(path . "Installed path"))
|
|
||||||
(output
|
|
||||||
(home-url . "Home page")
|
|
||||||
(path . "Installed path"))
|
|
||||||
(generation
|
|
||||||
(prev-number . "Previous number")))
|
|
||||||
"List for defining titles of entry parameters.
|
|
||||||
Titles are used for displaying information about entries.
|
|
||||||
Each element of the list has a form:
|
|
||||||
|
|
||||||
(ENTRY-TYPE . ((PARAM . TITLE) ...))")
|
|
||||||
|
|
||||||
(defun guix-get-param-title (entry-type param)
|
|
||||||
"Return title of an ENTRY-TYPE entry parameter PARAM."
|
|
||||||
(or (guix-assq-value guix-param-titles
|
|
||||||
entry-type param)
|
|
||||||
(guix-symbol-title param)))
|
|
||||||
|
|
||||||
(defun guix-package-name-specification (name version &optional output)
|
(defun guix-package-name-specification (name version &optional output)
|
||||||
"Return Guix package specification by its NAME, VERSION and OUTPUT."
|
"Return Guix package specification by its NAME, VERSION and OUTPUT."
|
||||||
(concat name "-" version
|
(concat name "-" version
|
||||||
|
@ -278,6 +256,25 @@ See `guix-update-after-operation' for details."
|
||||||
|
|
||||||
;;; Common definitions for buffer types
|
;;; Common definitions for buffer types
|
||||||
|
|
||||||
|
(defvar guix-buffer-data nil
|
||||||
|
"Alist with 'buffer' data.
|
||||||
|
This alist is filled by `guix-buffer-define-interface' macro.")
|
||||||
|
|
||||||
|
(defun guix-buffer-value (buffer-type entry-type symbol)
|
||||||
|
"Return SYMBOL's value for BUFFER-TYPE/ENTRY-TYPE from `guix-buffer-data'."
|
||||||
|
(symbol-value
|
||||||
|
(guix-assq-value guix-buffer-data buffer-type entry-type symbol)))
|
||||||
|
|
||||||
|
(defun guix-buffer-param-title (buffer-type entry-type param)
|
||||||
|
"Return PARAM title for BUFFER-TYPE/ENTRY-TYPE."
|
||||||
|
(or (guix-assq-value (guix-buffer-value buffer-type entry-type 'titles)
|
||||||
|
param)
|
||||||
|
;; Fallback to a title defined in 'info' interface.
|
||||||
|
(unless (eq buffer-type 'info)
|
||||||
|
(guix-assq-value (guix-buffer-value 'info entry-type 'titles)
|
||||||
|
param))
|
||||||
|
(guix-symbol-title param)))
|
||||||
|
|
||||||
(defvar guix-root-map
|
(defvar guix-root-map
|
||||||
(let ((map (make-sparse-keymap)))
|
(let ((map (make-sparse-keymap)))
|
||||||
(define-key map (kbd "l") 'guix-history-back)
|
(define-key map (kbd "l") 'guix-history-back)
|
||||||
|
@ -354,13 +351,17 @@ Optional keywords:
|
||||||
- `:buffer-name' - default value of the generated
|
- `:buffer-name' - default value of the generated
|
||||||
`guix-TYPE-buffer-name' variable.
|
`guix-TYPE-buffer-name' variable.
|
||||||
|
|
||||||
|
- `:titles' - default value of the generated
|
||||||
|
`guix-TYPE-titles' variable.
|
||||||
|
|
||||||
- `:history-size' - default value of the generated
|
- `:history-size' - default value of the generated
|
||||||
`guix-TYPE-history-size' variable.
|
`guix-TYPE-history-size' variable.
|
||||||
|
|
||||||
- `:revert-confirm?' - default value of the generated
|
- `:revert-confirm?' - default value of the generated
|
||||||
`guix-TYPE-revert-confirm' variable.
|
`guix-TYPE-revert-confirm' variable.
|
||||||
|
|
||||||
- `:reduced?' - if non-nil, generate only group and faces group."
|
- `:reduced?' - if non-nil, generate only group, faces group
|
||||||
|
and titles variable."
|
||||||
(declare (indent 2))
|
(declare (indent 2))
|
||||||
(let* ((entry-type-str (symbol-name entry-type))
|
(let* ((entry-type-str (symbol-name entry-type))
|
||||||
(buffer-type-str (symbol-name buffer-type))
|
(buffer-type-str (symbol-name buffer-type))
|
||||||
|
@ -377,12 +378,14 @@ Optional keywords:
|
||||||
(mode (intern (concat prefix "-mode")))
|
(mode (intern (concat prefix "-mode")))
|
||||||
(mode-init-fun (intern (concat prefix "-mode-initialize")))
|
(mode-init-fun (intern (concat prefix "-mode-initialize")))
|
||||||
(buffer-name-var (intern (concat prefix "-buffer-name")))
|
(buffer-name-var (intern (concat prefix "-buffer-name")))
|
||||||
|
(titles-var (intern (concat prefix "-titles")))
|
||||||
(history-size-var (intern (concat prefix "-history-size")))
|
(history-size-var (intern (concat prefix "-history-size")))
|
||||||
(revert-confirm-var (intern (concat prefix "-revert-confirm"))))
|
(revert-confirm-var (intern (concat prefix "-revert-confirm"))))
|
||||||
(guix-keyword-args-let args
|
(guix-keyword-args-let args
|
||||||
((buffer-name-val :buffer-name
|
((buffer-name-val :buffer-name
|
||||||
(format "*Guix %s %s*"
|
(format "*Guix %s %s*"
|
||||||
Entry-type-str Buffer-type-str))
|
Entry-type-str Buffer-type-str))
|
||||||
|
(titles-val :titles)
|
||||||
(history-size-val :history-size 20)
|
(history-size-val :history-size 20)
|
||||||
(revert-confirm-val :revert-confirm? t)
|
(revert-confirm-val :revert-confirm? t)
|
||||||
(reduced? :reduced?))
|
(reduced? :reduced?))
|
||||||
|
@ -398,6 +401,12 @@ Optional keywords:
|
||||||
entry-type-str buffer-type-str)
|
entry-type-str buffer-type-str)
|
||||||
:group ',(intern (concat "guix-" buffer-type-str "-faces")))
|
:group ',(intern (concat "guix-" buffer-type-str "-faces")))
|
||||||
|
|
||||||
|
(defcustom ,titles-var ,titles-val
|
||||||
|
,(format "Alist of titles of '%s' parameters."
|
||||||
|
entry-type-str)
|
||||||
|
:type '(alist :key-type symbol :value-type string)
|
||||||
|
:group ',group)
|
||||||
|
|
||||||
,(unless reduced?
|
,(unless reduced?
|
||||||
`(progn
|
`(progn
|
||||||
(defcustom ,buffer-name-var ,buffer-name-val
|
(defcustom ,buffer-name-var ,buffer-name-val
|
||||||
|
@ -429,7 +438,11 @@ If non-nil, ask to confirm for reverting `%S' buffer."
|
||||||
"\\{" mode-map-str "}")
|
"\\{" mode-map-str "}")
|
||||||
(setq-local revert-buffer-function 'guix-revert-buffer)
|
(setq-local revert-buffer-function 'guix-revert-buffer)
|
||||||
(setq-local guix-history-size ,history-size-var)
|
(setq-local guix-history-size ,history-size-var)
|
||||||
(and (fboundp ',mode-init-fun) (,mode-init-fun)))))))))
|
(and (fboundp ',mode-init-fun) (,mode-init-fun)))))
|
||||||
|
|
||||||
|
(guix-alist-put!
|
||||||
|
',titles-var 'guix-buffer-data
|
||||||
|
',buffer-type ',entry-type 'titles)))))
|
||||||
|
|
||||||
|
|
||||||
;;; Getting and displaying info about packages and generations
|
;;; Getting and displaying info about packages and generations
|
||||||
|
|
|
@ -127,7 +127,7 @@ This alist is filled by `guix-info-define-interface' macro.")
|
||||||
|
|
||||||
(defun guix-info-param-title (entry-type param)
|
(defun guix-info-param-title (entry-type param)
|
||||||
"Return a title of an ENTRY-TYPE parameter PARAM."
|
"Return a title of an ENTRY-TYPE parameter PARAM."
|
||||||
(guix-get-param-title entry-type param))
|
(guix-buffer-param-title 'info entry-type param))
|
||||||
|
|
||||||
(defun guix-info-format (entry-type)
|
(defun guix-info-format (entry-type)
|
||||||
"Return 'info' format for ENTRY-TYPE."
|
"Return 'info' format for ENTRY-TYPE."
|
||||||
|
@ -486,11 +486,13 @@ After calling each METHOD, a new line is inserted."
|
||||||
(native-inputs format (format guix-package-native-input))
|
(native-inputs format (format guix-package-native-input))
|
||||||
(propagated-inputs format
|
(propagated-inputs format
|
||||||
(format guix-package-propagated-input)))
|
(format guix-package-propagated-input)))
|
||||||
|
:titles '((home-url . "Home page"))
|
||||||
:required '(id name version installed non-unique))
|
:required '(id name version installed non-unique))
|
||||||
|
|
||||||
(guix-info-define-interface installed-output
|
(guix-info-define-interface installed-output
|
||||||
:format '((path simple (indent guix-file))
|
:format '((path simple (indent guix-file))
|
||||||
(dependencies simple (indent guix-file)))
|
(dependencies simple (indent guix-file)))
|
||||||
|
:titles '((path . "Store directory"))
|
||||||
:reduced? t)
|
:reduced? t)
|
||||||
|
|
||||||
(defface guix-package-info-heading
|
(defface guix-package-info-heading
|
||||||
|
@ -794,6 +796,7 @@ This function is used to hide a \"Download\" button if needed."
|
||||||
(propagated-inputs format
|
(propagated-inputs format
|
||||||
(format guix-package-propagated-input))
|
(format guix-package-propagated-input))
|
||||||
(description simple (indent guix-package-info-description)))
|
(description simple (indent guix-package-info-description)))
|
||||||
|
:titles guix-package-info-titles
|
||||||
:required '(id package-id installed non-unique))
|
:required '(id package-id installed non-unique))
|
||||||
|
|
||||||
(defun guix-output-info-insert-version (version entry)
|
(defun guix-output-info-insert-version (version entry)
|
||||||
|
@ -827,7 +830,9 @@ This function is used to hide a \"Download\" button if needed."
|
||||||
(prev-number format (format))
|
(prev-number format (format))
|
||||||
(current format guix-generation-info-insert-current)
|
(current format guix-generation-info-insert-current)
|
||||||
(path simple (indent guix-file))
|
(path simple (indent guix-file))
|
||||||
(time format (time))))
|
(time format (time)))
|
||||||
|
:titles '((path . "File name")
|
||||||
|
(prev-number . "Previous number")))
|
||||||
|
|
||||||
(defface guix-generation-info-number
|
(defface guix-generation-info-number
|
||||||
'((t :inherit font-lock-keyword-face))
|
'((t :inherit font-lock-keyword-face))
|
||||||
|
|
|
@ -52,13 +52,6 @@
|
||||||
"Face used for time stamps."
|
"Face used for time stamps."
|
||||||
:group 'guix-list-faces)
|
:group 'guix-list-faces)
|
||||||
|
|
||||||
(defvar guix-list-column-titles
|
|
||||||
'((generation
|
|
||||||
(number . "N.")))
|
|
||||||
"Column titles for list buffers.
|
|
||||||
Has the same structure as `guix-param-titles', but titles from
|
|
||||||
this list have a priority.")
|
|
||||||
|
|
||||||
(defun guix-list-describe (&optional mark-names)
|
(defun guix-list-describe (&optional mark-names)
|
||||||
"Describe entries marked with a general mark.
|
"Describe entries marked with a general mark.
|
||||||
'Describe' means display entries in 'info' buffer.
|
'Describe' means display entries in 'info' buffer.
|
||||||
|
@ -87,9 +80,7 @@ This alist is filled by `guix-list-define-interface' macro.")
|
||||||
|
|
||||||
(defun guix-list-param-title (entry-type param)
|
(defun guix-list-param-title (entry-type param)
|
||||||
"Return column title of an ENTRY-TYPE parameter PARAM."
|
"Return column title of an ENTRY-TYPE parameter PARAM."
|
||||||
(or (guix-assq-value guix-list-column-titles
|
(guix-buffer-param-title 'list entry-type param))
|
||||||
entry-type param)
|
|
||||||
(guix-get-param-title entry-type param)))
|
|
||||||
|
|
||||||
(defun guix-list-format (entry-type)
|
(defun guix-list-format (entry-type)
|
||||||
"Return column format for ENTRY-TYPE."
|
"Return column format for ENTRY-TYPE."
|
||||||
|
@ -816,6 +807,7 @@ See `guix-package-info-type'."
|
||||||
(current guix-generation-list-get-current 10 t)
|
(current guix-generation-list-get-current 10 t)
|
||||||
(time guix-list-get-time 20 t)
|
(time guix-list-get-time 20 t)
|
||||||
(path guix-list-get-file-path 30 t))
|
(path guix-list-get-file-path 30 t))
|
||||||
|
:titles '((number . "N."))
|
||||||
:sort-key '(number . t)
|
:sort-key '(number . t)
|
||||||
:marks '((delete . ?D)))
|
:marks '((delete . ?D)))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue