[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
19/35: emacs: Split 'guix-param-titles' variable.
From: |
Alex Kost |
Subject: |
19/35: emacs: Split 'guix-param-titles' variable. |
Date: |
Fri, 11 Dec 2015 11:42:36 +0000 |
alezost pushed a commit to branch wip-refactor-emacs-ui
in repository guix.
commit b9eb342aba50a53cd94dda778109f7706cd82a48
Author: Alex Kost <address@hidden>
Date: Sat Nov 21 11:35:43 2015 +0300
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.
---
emacs/guix-base.el | 60 +++++++++++++++++++++++++++++++--------------------
emacs/guix-info.el | 9 ++++++-
emacs/guix-list.el | 12 +--------
3 files changed, 45 insertions(+), 36 deletions(-)
diff --git a/emacs/guix-base.el b/emacs/guix-base.el
index 6fa0306..b3e181b 100644
--- a/emacs/guix-base.el
+++ b/emacs/guix-base.el
@@ -39,28 +39,6 @@
;;; 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)
"Return Guix package specification by its NAME, VERSION and OUTPUT."
(concat name "-" version
@@ -278,6 +256,25 @@ See `guix-update-after-operation' for details."
;;; 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
(let ((map (make-sparse-keymap)))
(define-key map (kbd "l") 'guix-history-back)
@@ -354,13 +351,17 @@ Optional keywords:
- `:buffer-name' - default value of the generated
`guix-TYPE-buffer-name' variable.
+ - `:titles' - default value of the generated
+ `guix-TYPE-titles' variable.
+
- `:history-size' - default value of the generated
`guix-TYPE-history-size' variable.
- `:revert-confirm?' - default value of the generated
`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))
(let* ((entry-type-str (symbol-name entry-type))
(buffer-type-str (symbol-name buffer-type))
@@ -377,12 +378,14 @@ Optional keywords:
(mode (intern (concat prefix "-mode")))
(mode-init-fun (intern (concat prefix "-mode-initialize")))
(buffer-name-var (intern (concat prefix "-buffer-name")))
+ (titles-var (intern (concat prefix "-titles")))
(history-size-var (intern (concat prefix "-history-size")))
(revert-confirm-var (intern (concat prefix "-revert-confirm"))))
(guix-keyword-args-let args
((buffer-name-val :buffer-name
(format "*Guix %s %s*"
Entry-type-str Buffer-type-str))
+ (titles-val :titles)
(history-size-val :history-size 20)
(revert-confirm-val :revert-confirm? t)
(reduced? :reduced?))
@@ -398,6 +401,12 @@ Optional keywords:
entry-type-str buffer-type-str)
: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?
`(progn
(defcustom ,buffer-name-var ,buffer-name-val
@@ -429,7 +438,10 @@ If non-nil, ask to confirm for reverting `%S' buffer."
"\\{" mode-map-str "}")
(setq-local revert-buffer-function 'guix-revert-buffer)
(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
+ ',buffer-type ',entry-type 'titles)))))
;;; Getting and displaying info about packages and generations
diff --git a/emacs/guix-info.el b/emacs/guix-info.el
index a4ef2c6..3111643 100644
--- a/emacs/guix-info.el
+++ b/emacs/guix-info.el
@@ -127,7 +127,7 @@ This alist is filled by `guix-info-define-interface'
macro.")
(defun guix-info-param-title (entry-type 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)
"Return 'info' format for ENTRY-TYPE."
@@ -482,11 +482,13 @@ After calling each METHOD, a new line is inserted."
format (format guix-package-native-input))
(propagated-inputs
format (format guix-package-propagated-input)))
+ :titles '((home-url . "Home page"))
:required '(id name version installed non-unique))
(guix-info-define-interface installed-output
:format '((path simple (indent guix-file))
(dependencies simple (indent guix-file)))
+ :titles '((path . "Store directory"))
:reduced? t)
(defface guix-package-info-heading
@@ -791,6 +793,7 @@ This function is used to hide a \"Download\" button if
needed."
(propagated-inputs
format (format guix-package-propagated-input))
(description format (format guix-package-info-description)))
+ :titles '((home-url . "Home page"))
:required '(id package-id installed non-unique))
(defun guix-output-info-insert-version (version entry)
@@ -824,7 +827,9 @@ This function is used to hide a \"Download\" button if
needed."
(prev-number format (format))
(current format guix-generation-info-insert-current)
(path simple (indent guix-file))
- (time format (time))))
+ (time format (time)))
+ :titles '((path . "File name")
+ (prev-number . "Previous number")))
(defface guix-generation-info-number
'((t :inherit font-lock-keyword-face))
diff --git a/emacs/guix-list.el b/emacs/guix-list.el
index 8943e8f..9aed7dc 100644
--- a/emacs/guix-list.el
+++ b/emacs/guix-list.el
@@ -52,13 +52,6 @@
"Face used for time stamps."
: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)
"Describe entries marked with a general mark.
'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)
"Return column title of an ENTRY-TYPE parameter PARAM."
- (or (guix-assq-value guix-list-column-titles
- entry-type param)
- (guix-get-param-title entry-type param)))
+ (guix-buffer-param-title 'list entry-type param))
(defun guix-list-format (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)
(time guix-list-get-time 20 t)
(path guix-list-get-file-path 30 t))
+ :titles '((number . "N."))
:sort-key '(number . t)
:marks '((delete . ?D)))
- 07/35: emacs: list: Configure format in one place., (continued)
- 07/35: emacs: list: Configure format in one place., Alex Kost, 2015/12/11
- 13/35: emacs: list: Add 'guix-list-mode-initialize'., Alex Kost, 2015/12/11
- 08/35: emacs: Add 'guix-keyword-args-let'., Alex Kost, 2015/12/11
- 12/35: emacs: list: Generalize 'sort-key' code., Alex Kost, 2015/12/11
- 15/35: emacs: list: Factorize "edit package" commands., Alex Kost, 2015/12/11
- 10/35: emacs: list: Generalize 'marks' code., Alex Kost, 2015/12/11
- 11/35: emacs: list: Generalize 'describe' code., Alex Kost, 2015/12/11
- 14/35: emacs: list: Split 'guix-list-format' variable., Alex Kost, 2015/12/11
- 20/35: emacs: Add wrappers for 'history-size' and 'revert-confirm'., Alex Kost, 2015/12/11
- 03/35: emacs: Add API for 'guix-entry'., Alex Kost, 2015/12/11
- 19/35: emacs: Split 'guix-param-titles' variable.,
Alex Kost <=
- 24/35: emacs: Improve messages for packages found by ID., Alex Kost, 2015/12/11
- 21/35: emacs: Split 'guix-root-map' keymap., Alex Kost, 2015/12/11
- 23/35: emacs: Generalize buffer reverting., Alex Kost, 2015/12/11
- 25/35: emacs: info: Buttonize package name heading., Alex Kost, 2015/12/11
- 22/35: emacs: Generalize buffer redisplaying., Alex Kost, 2015/12/11
- 27/35: emacs: info: Get rid of syntactic fontification., Alex Kost, 2015/12/11
- 18/35: emacs: info: Split 'guix-info-format' variable., Alex Kost, 2015/12/11
- 17/35: emacs: Factorize macros for defining interfaces., Alex Kost, 2015/12/11
- 29/35: emacs: Reorganize 'readers' code., Alex Kost, 2015/12/11
- 31/35: emacs: Add 'list-single' variables., Alex Kost, 2015/12/11