diff options
author | Alex Kost <alezost@gmail.com> | 2015-11-21 11:35:43 +0300 |
---|---|---|
committer | Alex Kost <alezost@gmail.com> | 2016-01-02 17:25:35 +0300 |
commit | 574f6727b061e2b58b23cb9b75a75d03822f5d08 (patch) | |
tree | 6ebfe66edc69f4bf557dd3149776a6f1d3b144dd | |
parent | 9193fb7c1dedcf2233287baa819a9c9ded8242a8 (diff) | |
download | guix-574f6727b061e2b58b23cb9b75a75d03822f5d08.tar.gz guix-574f6727b061e2b58b23cb9b75a75d03822f5d08.zip |
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.
-rw-r--r-- | doc/emacs.texi | 3 | ||||
-rw-r--r-- | emacs/guix-base.el | 61 | ||||
-rw-r--r-- | emacs/guix-info.el | 9 | ||||
-rw-r--r-- | emacs/guix-list.el | 12 |
4 files changed, 48 insertions, 37 deletions
diff --git a/doc/emacs.texi b/doc/emacs.texi index fb6da31cdb..5828bb74d5 100644 --- a/doc/emacs.texi +++ b/doc/emacs.texi @@ -480,11 +480,12 @@ the following variables (@dfn{ENTRY-TYPE} means @code{package}, @table @code @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'' buffers. @item guix-ENTRY-TYPE-info-format +@itemx guix-ENTRY-TYPE-info-titles @itemx guix-info-ignore-empty-values @itemx guix-info-param-title-format @itemx guix-info-multiline-prefix diff --git a/emacs/guix-base.el b/emacs/guix-base.el index 6fa03064b8..f75624c6c9 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,11 @@ 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-data + ',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 bf43b40e9e..3cad6624f3 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." @@ -486,11 +486,13 @@ After calling each METHOD, a new line is inserted." (native-inputs 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 @@ -794,6 +796,7 @@ This function is used to hide a \"Download\" button if needed." (propagated-inputs format (format guix-package-propagated-input)) (description simple (indent guix-package-info-description))) + :titles guix-package-info-titles :required '(id package-id installed non-unique)) (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)) (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 8943e8f589..9aed7dcb82 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))) |