diff options
| author | Philippe Vaucher | 2019-03-02 20:03:41 +0100 |
|---|---|---|
| committer | Eli Zaretskii | 2019-03-15 11:08:01 +0200 |
| commit | 18fb250d6748bd31672a9d2bdd5dff99ac7f7743 (patch) | |
| tree | 34178feabb3e6c19fdf3d5358f6a3d6ba6969b5f | |
| parent | c72c2b04c2ed1688c9903cd87e7925b74a307541 (diff) | |
| download | emacs-18fb250d6748bd31672a9d2bdd5dff99ac7f7743.tar.gz emacs-18fb250d6748bd31672a9d2bdd5dff99ac7f7743.zip | |
Customize tabulated-list sort indicators
This allows the user to customize the sorting indicators displayed
near the current column.
* lisp/emacs-lisp/tabulated-list.el (tabulated-list): New group.
(tabulated-list-gui-sort-indicator-asc)
(tabulated-list-gui-sort-indicator-desc)
(tabulated-list-tty-sort-indicator-asc)
(tabulated-list-tty-sort-indicator-desc): New defcustomd.
(tabulated-list-glyphless-char-display): Remove.
(tabulated-list-make-glyphless-char-display-table): New function.
* doc/lispref/modes.texi (Tabulated List Mode): Add documentation
for new options.
* etc/NEWS: Mention the new options.
| -rw-r--r-- | doc/lispref/modes.texi | 23 | ||||
| -rw-r--r-- | etc/NEWS | 13 | ||||
| -rw-r--r-- | lisp/emacs-lisp/tabulated-list.el | 65 |
3 files changed, 91 insertions, 10 deletions
diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi index 3f6bee9821d..1afbc5a5cee 100644 --- a/doc/lispref/modes.texi +++ b/doc/lispref/modes.texi | |||
| @@ -1015,6 +1015,29 @@ list-processes}). The listing command should create or switch to a | |||
| 1015 | buffer, turn on the derived mode, specify the tabulated data, and | 1015 | buffer, turn on the derived mode, specify the tabulated data, and |
| 1016 | finally call @code{tabulated-list-print} to populate the buffer. | 1016 | finally call @code{tabulated-list-print} to populate the buffer. |
| 1017 | 1017 | ||
| 1018 | @defopt tabulated-list-gui-sort-indicator-asc | ||
| 1019 | This variable specifies the character to be used on GUI frames as an | ||
| 1020 | indication that the column is sorted in the ascending order. | ||
| 1021 | |||
| 1022 | Whenever you change the sort direction in Tabulated List buffers, this | ||
| 1023 | indicator toggles between ascending (``asc'') and descending (``desc''). | ||
| 1024 | @end defopt | ||
| 1025 | |||
| 1026 | @defopt tabulated-list-gui-sort-indicator-desc | ||
| 1027 | Like @code{tabulated-list-gui-sort-indicator-asc}, but used when the | ||
| 1028 | column is sorted in the descending order. | ||
| 1029 | @end defopt | ||
| 1030 | |||
| 1031 | @defopt tabulated-list-tty-sort-indicator-asc | ||
| 1032 | Like @code{tabulated-list-gui-sort-indicator-asc}, but used for | ||
| 1033 | text-mode frames. | ||
| 1034 | @end defopt | ||
| 1035 | |||
| 1036 | @defopt tabulated-list-tty-sort-indicator-desc | ||
| 1037 | Like @code{tabulated-list-tty-sort-indicator-asc}, but used when the | ||
| 1038 | column is sorted in the descending order. | ||
| 1039 | @end defopt | ||
| 1040 | |||
| 1018 | @defvar tabulated-list-format | 1041 | @defvar tabulated-list-format |
| 1019 | This buffer-local variable specifies the format of the Tabulated List | 1042 | This buffer-local variable specifies the format of the Tabulated List |
| 1020 | data. Its value should be a vector. Each element of the vector | 1043 | data. Its value should be a vector. Each element of the vector |
| @@ -923,7 +923,7 @@ been instrumented by Edebug. | |||
| 923 | the XTerm window title. This feature is experimental and is disabled | 923 | the XTerm window title. This feature is experimental and is disabled |
| 924 | by default. | 924 | by default. |
| 925 | 925 | ||
| 926 | ** grep | 926 | ** Grep |
| 927 | 927 | ||
| 928 | +++ | 928 | +++ |
| 929 | *** rgrep, lgrep and zrgrep now hide part of the command line | 929 | *** rgrep, lgrep and zrgrep now hide part of the command line |
| @@ -1194,6 +1194,17 @@ the 128...255 range, as expected. | |||
| 1194 | This allows to create and parent immediately a minibuffer-only child | 1194 | This allows to create and parent immediately a minibuffer-only child |
| 1195 | frame when making a frame. | 1195 | frame when making a frame. |
| 1196 | 1196 | ||
| 1197 | ** Tabulated List mode | ||
| 1198 | |||
| 1199 | +++ | ||
| 1200 | ** New user options for tabulated list sort indicators. | ||
| 1201 | You can now customize which sorting indicator character to display | ||
| 1202 | near the current column in Tabulated Lists (see variables | ||
| 1203 | 'tabulated-list-gui-sort-indicator-asc', | ||
| 1204 | 'tabulated-list-gui-sort-indicator-desc', | ||
| 1205 | 'tabulated-list-tty-sort-indicator-asc', and | ||
| 1206 | 'tabulated-list-tty-sort-indicator-desc'). | ||
| 1207 | |||
| 1197 | 1208 | ||
| 1198 | * New Modes and Packages in Emacs 27.1 | 1209 | * New Modes and Packages in Emacs 27.1 |
| 1199 | 1210 | ||
diff --git a/lisp/emacs-lisp/tabulated-list.el b/lisp/emacs-lisp/tabulated-list.el index 12d0151d67f..b23ce21027b 100644 --- a/lisp/emacs-lisp/tabulated-list.el +++ b/lisp/emacs-lisp/tabulated-list.el | |||
| @@ -36,6 +36,43 @@ | |||
| 36 | 36 | ||
| 37 | ;;; Code: | 37 | ;;; Code: |
| 38 | 38 | ||
| 39 | (defgroup tabulated-list nil | ||
| 40 | "Tabulated-list customization group." | ||
| 41 | :group 'convenience | ||
| 42 | :group 'display) | ||
| 43 | |||
| 44 | (defcustom tabulated-list-gui-sort-indicator-asc ?▼ | ||
| 45 | "Indicator for columns sorted in ascending order, for GUI frames. | ||
| 46 | See `tabulated-list-tty-sort-indicator-asc' for the indicator used on | ||
| 47 | text-mode frames." | ||
| 48 | :group 'tabulated-list | ||
| 49 | :type 'character | ||
| 50 | :version "27.1") | ||
| 51 | |||
| 52 | (defcustom tabulated-list-gui-sort-indicator-desc ?▲ | ||
| 53 | "Indicator for columns sorted in descending order, for GUI frames. | ||
| 54 | See `tabulated-list-tty-sort-indicator-desc' for the indicator used on | ||
| 55 | text-mode frames." | ||
| 56 | :group 'tabulated-list | ||
| 57 | :type 'character | ||
| 58 | :version "27.1") | ||
| 59 | |||
| 60 | (defcustom tabulated-list-tty-sort-indicator-asc ?v | ||
| 61 | "Indicator for columns sorted in ascending order, for text-mode frames. | ||
| 62 | See `tabulated-list-gui-sort-indicator-asc' for the indicator used on GUI | ||
| 63 | frames." | ||
| 64 | :group 'tabulated-list | ||
| 65 | :type 'character | ||
| 66 | :version "27.1") | ||
| 67 | |||
| 68 | (defcustom tabulated-list-tty-sort-indicator-desc ?^ | ||
| 69 | "Indicator for columns sorted in ascending order, for text-mode frames. | ||
| 70 | See `tabulated-list-gui-sort-indicator-asc' for the indicator used on GUI | ||
| 71 | frames." | ||
| 72 | :group 'tabulated-list | ||
| 73 | :type 'character | ||
| 74 | :version "27.1") | ||
| 75 | |||
| 39 | ;; The reason `tabulated-list-format' and other variables are | 76 | ;; The reason `tabulated-list-format' and other variables are |
| 40 | ;; permanent-local is to make it convenient to switch to a different | 77 | ;; permanent-local is to make it convenient to switch to a different |
| 41 | ;; major mode, switch back, and have the original Tabulated List data | 78 | ;; major mode, switch back, and have the original Tabulated List data |
| @@ -174,14 +211,20 @@ If ADVANCE is non-nil, move forward by one line afterwards." | |||
| 174 | map) | 211 | map) |
| 175 | "Local keymap for `tabulated-list-mode' sort buttons.") | 212 | "Local keymap for `tabulated-list-mode' sort buttons.") |
| 176 | 213 | ||
| 177 | (defvar tabulated-list-glyphless-char-display | 214 | (defun tabulated-list-make-glyphless-char-display-table () |
| 215 | "Make the `glyphless-char-display' table used for text-mode frames. | ||
| 216 | This table is used for displaying the sorting indicators, see | ||
| 217 | variables `tabulated-list-tty-sort-indicator-asc' and | ||
| 218 | `tabulated-list-tty-sort-indicator-desc' for more information." | ||
| 178 | (let ((table (make-char-table 'glyphless-char-display nil))) | 219 | (let ((table (make-char-table 'glyphless-char-display nil))) |
| 179 | (set-char-table-parent table glyphless-char-display) | 220 | (set-char-table-parent table glyphless-char-display) |
| 180 | ;; Some text terminals can't display the Unicode arrows; be safe. | 221 | (aset table |
| 181 | (aset table 9650 (cons nil "^")) | 222 | tabulated-list-gui-sort-indicator-desc |
| 182 | (aset table 9660 (cons nil "v")) | 223 | (cons nil (char-to-string tabulated-list-tty-sort-indicator-desc))) |
| 183 | table) | 224 | (aset table |
| 184 | "The `glyphless-char-display' table in Tabulated List buffers.") | 225 | tabulated-list-gui-sort-indicator-asc |
| 226 | (cons nil (char-to-string tabulated-list-tty-sort-indicator-asc))) | ||
| 227 | table)) | ||
| 185 | 228 | ||
| 186 | (defvar tabulated-list--header-string nil | 229 | (defvar tabulated-list--header-string nil |
| 187 | "Holds the header if `tabulated-list-use-header-line' is nil. | 230 | "Holds the header if `tabulated-list-use-header-line' is nil. |
| @@ -231,8 +274,11 @@ Populated by `tabulated-list-init-header'.") | |||
| 231 | (concat label | 274 | (concat label |
| 232 | (cond | 275 | (cond |
| 233 | ((> (+ 2 (length label)) width) "") | 276 | ((> (+ 2 (length label)) width) "") |
| 234 | ((cdr tabulated-list-sort-key) " ▲") | 277 | ((cdr tabulated-list-sort-key) |
| 235 | (t " ▼"))) | 278 | (format " %c" |
| 279 | tabulated-list-gui-sort-indicator-desc)) | ||
| 280 | (t (format " %c" | ||
| 281 | tabulated-list-gui-sort-indicator-asc)))) | ||
| 236 | 'face 'bold | 282 | 'face 'bold |
| 237 | 'tabulated-list-column-name label | 283 | 'tabulated-list-column-name label |
| 238 | button-props)) | 284 | button-props)) |
| @@ -655,7 +701,8 @@ as the ewoc pretty-printer." | |||
| 655 | (setq-local truncate-lines t) | 701 | (setq-local truncate-lines t) |
| 656 | (setq-local buffer-undo-list t) | 702 | (setq-local buffer-undo-list t) |
| 657 | (setq-local revert-buffer-function #'tabulated-list-revert) | 703 | (setq-local revert-buffer-function #'tabulated-list-revert) |
| 658 | (setq-local glyphless-char-display tabulated-list-glyphless-char-display) | 704 | (setq-local glyphless-char-display |
| 705 | (tabulated-list-make-glyphless-char-display-table)) | ||
| 659 | ;; Avoid messing up the entries' display just because the first | 706 | ;; Avoid messing up the entries' display just because the first |
| 660 | ;; column of the first entry happens to begin with a R2L letter. | 707 | ;; column of the first entry happens to begin with a R2L letter. |
| 661 | (setq bidi-paragraph-direction 'left-to-right) | 708 | (setq bidi-paragraph-direction 'left-to-right) |