From 2389b61af11fe507481b86b78e2ffd164afe3c4a Mon Sep 17 00:00:00 2001 From: Philippe Vaucher Date: Fri, 10 Aug 2018 21:59:24 +0200 Subject: [PATCH 1/2] Allow customization of sort indicators in tabulated-list * lisp/emacs-lisp/tabulated-list.el: add customization group, add defcustoms. --- lisp/emacs-lisp/tabulated-list.el | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/lisp/emacs-lisp/tabulated-list.el b/lisp/emacs-lisp/tabulated-list.el index 12d0151d67..7162334822 100644 --- a/lisp/emacs-lisp/tabulated-list.el +++ b/lisp/emacs-lisp/tabulated-list.el @@ -36,6 +36,29 @@ ;;; Code: +(defgroup tabulated-list nil + "Tabulated-list customization group.") + +(defcustom tabulated-list-sort-icon-asc " ▼" + "Icon to display when sort order is ascending." + :group 'tabulated-list + :type 'string) + +(defcustom tabulated-list-sort-icon-desc " ▲" + "Icon to display when sort order is descending." + :group 'tabulated-list + :type 'string) + +(defcustom tabulated-list-glyphless-sort-icon-asc "v" + "Glyphless icon to display when sort order is ascending." + :group 'tabulated-list + :type 'string) + +(defcustom tabulated-list-glyphless-sort-icon-desc "^" + "Glyphless icon to display when sort order is descending." + :group 'tabulated-list + :type 'string) + ;; The reason `tabulated-list-format' and other variables are ;; permanent-local is to make it convenient to switch to a different ;; major mode, switch back, and have the original Tabulated List data @@ -178,8 +201,8 @@ If ADVANCE is non-nil, move forward by one line afterwards." (let ((table (make-char-table 'glyphless-char-display nil))) (set-char-table-parent table glyphless-char-display) ;; Some text terminals can't display the Unicode arrows; be safe. - (aset table 9650 (cons nil "^")) - (aset table 9660 (cons nil "v")) + (aset table 9650 (cons nil tabulated-list-glyphless-sort-icon-desc)) + (aset table 9660 (cons nil tabulated-list-glyphless-sort-icon-asc)) table) "The `glyphless-char-display' table in Tabulated List buffers.") @@ -231,8 +254,8 @@ Populated by `tabulated-list-init-header'.") (concat label (cond ((> (+ 2 (length label)) width) "") - ((cdr tabulated-list-sort-key) " ▲") - (t " ▼"))) + ((cdr tabulated-list-sort-key) tabulated-list-sort-icon-desc) + (t tabulated-list-sort-icon-asc))) 'face 'bold 'tabulated-list-column-name label button-props)) -- 2.17.1