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 /lisp | |
| 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.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/emacs-lisp/tabulated-list.el | 65 |
1 files changed, 56 insertions, 9 deletions
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) |