[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
13/38: emacs: list: Add 'guix-list-mode-initialize'.
From: |
Alex Kost |
Subject: |
13/38: emacs: list: Add 'guix-list-mode-initialize'. |
Date: |
Sat, 02 Jan 2016 14:27:20 +0000 |
alezost pushed a commit to branch master
in repository guix.
commit 78fdbdc033a6e33076fd87bb612247e93e9ca935
Author: Alex Kost <address@hidden>
Date: Thu Nov 19 16:43:10 2015 +0300
emacs: list: Add 'guix-list-mode-initialize'.
* emacs/guix-list.el (guix-list-mode-initialize): New procedure.
(guix-list-define-entry-type): Use it.
---
emacs/guix-list.el | 22 +++++++++++++---------
1 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/emacs/guix-list.el b/emacs/guix-list.el
index aab3ef8..947a545 100644
--- a/emacs/guix-list.el
+++ b/emacs/guix-list.el
@@ -429,6 +429,8 @@ Same as `tabulated-list-sort', but also restore marks after
sorting."
(guix-list-restore-marks))
+;;; Major mode and interface definer
+
(defvar guix-list-mode-map
(let ((map (make-sparse-keymap)))
(set-keymap-parent
@@ -442,11 +444,18 @@ Same as `tabulated-list-sort', but also restore marks
after sorting."
(define-key map (kbd "DEL") 'guix-list-unmark-backward)
(define-key map [remap tabulated-list-sort] 'guix-list-sort)
map)
- "Parent keymap for list buffers.")
+ "Keymap for `guix-list-mode' buffers.")
(define-derived-mode guix-list-mode tabulated-list-mode "Guix-List"
- "Parent mode for displaying information in list buffers."
- (setq tabulated-list-padding 2))
+ "Parent mode for displaying data in 'list' form.")
+
+(defun guix-list-mode-initialize (entry-type)
+ "Set up the current 'list' buffer for displaying ENTRY-TYPE entries."
+ (setq tabulated-list-padding 2
+ tabulated-list-format (guix-list-tabulated-format entry-type)
+ tabulated-list-sort-key (guix-list-tabulated-sort-key entry-type))
+ (setq-local guix-list-marks (guix-list-marks entry-type))
+ (tabulated-list-init-header))
(defmacro guix-list-define-entry-type (entry-type &rest args)
"Define common stuff for displaying ENTRY-TYPE entries in list buffers.
@@ -515,12 +524,7 @@ See also `guix-list-describe'."
(defun ,init-fun ()
,(concat "Initial settings for `" mode-str "'.")
- (setq tabulated-list-sort-key (guix-list-tabulated-sort-key
- ',entry-type)
- tabulated-list-format (guix-list-tabulated-format
- ',entry-type))
- (setq-local guix-list-marks (guix-list-marks ',entry-type))
- (tabulated-list-init-header))
+ (guix-list-mode-initialize ',entry-type))
(guix-alist-put!
'((describe . ,describe-var)
- 02/38: emacs: Add 'guix-with-indent'., (continued)
- 02/38: emacs: Add 'guix-with-indent'., Alex Kost, 2016/01/02
- 05/38: emacs: list: Generate numerical sort predicates., Alex Kost, 2016/01/02
- 01/38: emacs: Use "cl-list*" instead of "apply #'list"., Alex Kost, 2016/01/02
- 04/38: emacs: Simplify defining parameter titles., Alex Kost, 2016/01/02
- 09/38: emacs: Add 'guix-alist-put'., Alex Kost, 2016/01/02
- 07/38: emacs: list: Configure format in one place., Alex Kost, 2016/01/02
- 12/38: emacs: list: Generalize 'sort-key' code., Alex Kost, 2016/01/02
- 15/38: emacs: list: Factorize "edit package" commands., Alex Kost, 2016/01/02
- 08/38: emacs: Add 'guix-keyword-args-let'., Alex Kost, 2016/01/02
- 10/38: emacs: list: Generalize 'marks' code., Alex Kost, 2016/01/02
- 13/38: emacs: list: Add 'guix-list-mode-initialize'.,
Alex Kost <=
- 03/38: emacs: Add API for 'guix-entry'., Alex Kost, 2016/01/02
- 06/38: emacs: Rename internal procedures., Alex Kost, 2016/01/02
- 11/38: emacs: list: Generalize 'describe' code., Alex Kost, 2016/01/02
- 14/38: emacs: list: Split 'guix-list-format' variable., Alex Kost, 2016/01/02
- 20/38: emacs: Add wrappers for 'history-size' and 'revert-confirm'., Alex Kost, 2016/01/02
- 23/38: emacs: Generalize buffer reverting., Alex Kost, 2016/01/02
- 19/38: emacs: Split 'guix-param-titles' variable., Alex Kost, 2016/01/02
- 25/38: emacs: info: Buttonize package name heading., Alex Kost, 2016/01/02
- 22/38: emacs: Generalize buffer redisplaying., Alex Kost, 2016/01/02
- 21/38: emacs: Split 'guix-root-map' keymap., Alex Kost, 2016/01/02