unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Philippe Vaucher <philippe.vaucher@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Eli Zaretskii <eliz@gnu.org>, Emacs developers <emacs-devel@gnu.org>
Subject: Re: tabulated-list sort icon is reversed
Date: Mon, 11 Mar 2019 11:54:08 +0100	[thread overview]
Message-ID: <CAGK7Mr47jmpVnSrZqNWu8jtZcCsApPuA2+aCRtmDqN5D3hUi2w@mail.gmail.com> (raw)
In-Reply-To: <CAGK7Mr5WJ9DYzNzY1OPgWwZ=x-xLC2Q2W+Ed-bZZKiYY528M5w@mail.gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 256 bytes --]

Okay this should be OK.

What maybe remains to be improved is the manual text... I tried to add a
bit of description but it's already quite self-explicit for most of us so I
have a bit of trouble figuring how much we need to explain.

Regards,
Philippe

>

[-- Attachment #1.2: Type: text/html, Size: 517 bytes --]

[-- Attachment #2: 0001-Customize-tabulated-list-sort-indicators.patch --]
[-- Type: text/x-patch, Size: 7109 bytes --]

From ca03942bce64e1b00d5af5e8d63f1bb7e3fc8db9 Mon Sep 17 00:00:00 2001
From: Philippe Vaucher <philippe.vaucher@gmail.com>
Date: Sat, 2 Mar 2019 20:03:41 +0100
Subject: [PATCH] Customize tabulated-list sort indicators

This allows the user to customize the sorting indicators displayed
near the current column.

* etc/NEWS: Mention changes
* doc/lispref/modes.texi: Add documentation for
  'tabulated-list-gui-sort-indicator-asc',
  'tabulated-list-gui-sort-indicator-desc',
  'tabulated-list-tty-sort-indicator-asc' and
  'tabulated-list-tty-sort-indicator-desc'.
* 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 defcustom.
(tabulated-list-glyphless-char-display): Remove.
(tabulated-list-make-glyphless-char-display-table): New function.
---
 doc/lispref/modes.texi            | 23 ++++++++++++
 etc/NEWS                          |  9 +++++
 lisp/emacs-lisp/tabulated-list.el | 59 ++++++++++++++++++++++++++-----
 3 files changed, 82 insertions(+), 9 deletions(-)

diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi
index 22592a57b0..0d4f0b12fe 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
 buffer, turn on the derived mode, specify the tabulated data, and
 finally call @code{tabulated-list-print} to populate the buffer.
 
+@defopt tabulated-list-gui-sort-indicator-asc
+This is the ascending character indicator displayed next to the currently sorted
+column, for GUI frames.
+
+Whenever you change the sort direction in Tabulated List buffers, you
+toggle this indicator between ascending (asc) and descending
+(desc).
+@end defopt
+
+@defopt tabulated-list-gui-sort-indicator-desc
+Like @code{tabulated-list-gui-sort-indicator-asc}, but used when the
+sort order is descending.
+@end defopt
+
+@defopt tabulated-list-tty-sort-indicator-asc
+Like @code{tabulated-list-gui-sort-indicator-asc}, but used for text-mode frames.
+@end defopt
+
+@defopt tabulated-list-tty-sort-indicator-desc
+Like @code{tabulated-list-tty-sort-indicator-asc}, but used when the
+sort order is descending.
+@end defopt
+
 @defvar tabulated-list-format
 This buffer-local variable specifies the format of the Tabulated List
 data.  Its value should be a vector.  Each element of the vector
diff --git a/etc/NEWS b/etc/NEWS
index 3e347b5318..6119acdf15 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -279,6 +279,15 @@ matches strings where the pattern appears as a subsequence.  Put
 simply, makes "foo" complete to both "barfoo" and "frodo".  Add 'flex'
 to 'completion-styles' or 'completion-category-overrides' to use it.
 
++++
+** New user options for tabulated list sort indicators.
+The user can customize which sorting indicator character to display
+near the current column in Tabulated Lists (see variables
+'tabulated-list-gui-sort-indicator-asc',
+'tabulated-list-gui-sort-indicator-desc',
+'tabulated-list-tty-sort-indicator-asc' and
+'tabulated-list-tty-sort-indicator-desc')
+
 \f
 * Editing Changes in Emacs 27.1
 
diff --git a/lisp/emacs-lisp/tabulated-list.el b/lisp/emacs-lisp/tabulated-list.el
index 12d0151d67..5a54f2d68a 100644
--- a/lisp/emacs-lisp/tabulated-list.el
+++ b/lisp/emacs-lisp/tabulated-list.el
@@ -36,6 +36,41 @@
 
 ;;; Code:
 
+(defgroup tabulated-list nil
+  "Tabulated-list customization group.")
+
+(defcustom tabulated-list-gui-sort-indicator-asc ?▼
+  "Indicator for column sorted in ascending order, for GUI frames.
+See `tabulated-list-tty-sort-indicator-asc' for the indicator used on
+text-mode frames."
+  :group 'tabulated-list
+  :type 'character
+  :version "27.1")
+
+(defcustom tabulated-list-gui-sort-indicator-desc ?▲
+  "Indicator for column sorted in descending order, for GUI frames.
+See `tabulated-list-tty-sort-indicator-desc' for the indicator used on
+text-mode frames."
+  :group 'tabulated-list
+  :type 'character
+  :version "27.1")
+
+(defcustom tabulated-list-tty-sort-indicator-asc ?v
+  "Indicator for column sorted in ascending order, for text-mode frames.
+See `tabulated-list-gui-sort-indicator-asc' for the indicator used on GUI
+frames."
+  :group 'tabulated-list
+  :type 'character
+  :version "27.1")
+
+(defcustom tabulated-list-tty-sort-indicator-desc ?^
+  "Indicator for column sorted in ascending order, for text-mode frames.
+See `tabulated-list-gui-sort-indicator-asc' for the indicator used on GUI
+frames."
+  :group 'tabulated-list
+  :type 'character
+  :version "27.1")
+
 ;; 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
@@ -174,14 +209,20 @@ If ADVANCE is non-nil, move forward by one line afterwards."
     map)
   "Local keymap for `tabulated-list-mode' sort buttons.")
 
-(defvar tabulated-list-glyphless-char-display
+(defun tabulated-list-make-glyphless-char-display-table ()
+  "Make the `glyphless-char-display' table used for text-mode frames.
+This table is used for displaying the sorting indicators, see
+variables `tabulated-list-tty-sort-indicator-asc' and
+`tabulated-list-tty-sort-indicator-desc' for more information."
   (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"))
-    table)
-  "The `glyphless-char-display' table in Tabulated List buffers.")
+    (aset table
+          tabulated-list-gui-sort-indicator-desc
+          (cons nil (char-to-string tabulated-list-tty-sort-indicator-desc)))
+    (aset table
+          tabulated-list-gui-sort-indicator-asc
+          (cons nil (char-to-string tabulated-list-tty-sort-indicator-asc)))
+    table))
 
 (defvar tabulated-list--header-string nil
   "Holds the header if `tabulated-list-use-header-line' is nil.
@@ -231,8 +272,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) (format " %c" tabulated-list-gui-sort-indicator-desc))
+			   (t (format " %c" tabulated-list-gui-sort-indicator-asc))))
 		  'face 'bold
 		  'tabulated-list-column-name label
 		  button-props))
@@ -655,7 +696,7 @@ as the ewoc pretty-printer."
   (setq-local truncate-lines t)
   (setq-local buffer-undo-list t)
   (setq-local revert-buffer-function #'tabulated-list-revert)
-  (setq-local glyphless-char-display tabulated-list-glyphless-char-display)
+  (setq-local glyphless-char-display (tabulated-list-make-glyphless-char-display-table))
   ;; Avoid messing up the entries' display just because the first
   ;; column of the first entry happens to begin with a R2L letter.
   (setq bidi-paragraph-direction 'left-to-right)
-- 
2.17.1


  reply	other threads:[~2019-03-11 10:54 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-28 18:14 tabulated-list sort icon is reversed Philippe Vaucher
2018-07-28 19:03 ` Eli Zaretskii
2018-07-28 22:00   ` Philippe Vaucher
2018-07-29 17:34     ` Eli Zaretskii
2018-07-30  7:14       ` Robert Pluim
2018-07-30 10:47       ` Joost Kremers
2018-07-30 14:48         ` Drew Adams
2018-07-30 15:17           ` Robert Pluim
2018-07-30 15:24             ` Eli Zaretskii
2018-07-30 17:33       ` Stefan Monnier
2018-07-30 17:57         ` Clément Pit-Claudel
2018-07-31 18:28           ` Philippe Vaucher
2018-07-31 18:34         ` Philippe Vaucher
2018-07-31 18:35           ` Philippe Vaucher
2018-07-31 19:24           ` Stefan Monnier
2018-07-31 19:37             ` Drew Adams
2018-07-31 20:19               ` Stefan Monnier
2018-07-31 21:46                 ` Drew Adams
2018-08-01 20:48                   ` Joost Kremers
2018-08-02  2:09                     ` Richard Stallman
2018-08-02  5:02                       ` Stefan Monnier
2018-08-02  8:56                         ` Philippe Vaucher
2018-08-02 13:09                         ` Clément Pit-Claudel
2018-08-03 11:13                         ` Joost Kremers
2018-08-03 11:23                           ` Robert Pluim
2018-08-05  4:01                       ` Van L
2018-08-10  9:56                         ` Philippe Vaucher
2018-08-10 12:18                           ` Eli Zaretskii
2018-08-10 12:37                             ` Philippe Vaucher
2018-08-10 12:49                               ` Eli Zaretskii
2018-08-10 14:07                                 ` Philippe Vaucher
2018-08-10 13:20                           ` Clément Pit-Claudel
2018-08-10 14:11                             ` Philippe Vaucher
2018-08-10 14:52                               ` Yuri Khan
2018-08-10 20:10                                 ` Philippe Vaucher
2019-02-12 19:13                               ` Clément Pit-Claudel
2019-02-12 19:43                                 ` Eli Zaretskii
2019-02-12 20:54                                   ` Clément Pit-Claudel
2019-02-15 13:38                                   ` Philippe Vaucher
2019-02-15 14:05                                     ` Clément Pit-Claudel
2019-02-15 14:15                                     ` Eli Zaretskii
2019-02-15 14:42                                       ` Philippe Vaucher
2019-02-27 20:08                                         ` Philippe Vaucher
2019-02-27 20:21                                           ` Clément Pit-Claudel
2019-02-27 21:23                                           ` Stefan Monnier
2019-02-28  7:55                                             ` Philippe Vaucher
2019-03-01  9:48                                               ` Philippe Vaucher
2019-03-01 13:56                                                 ` Stefan Monnier
2019-03-01 16:34                                                   ` Philippe Vaucher
2019-03-01 17:34                                                     ` Stefan Monnier
2019-03-01 18:14                                                       ` Philippe Vaucher
2019-03-02 11:53                                               ` Eli Zaretskii
2019-03-02 17:48                                                 ` Philippe Vaucher
2019-03-02 17:51                                                   ` Philippe Vaucher
2019-03-02 18:15                                                     ` Eli Zaretskii
2019-03-02 19:06                                                       ` Philippe Vaucher
2019-03-08  9:43                                                         ` Eli Zaretskii
2019-03-08 13:38                                                           ` Stefan Monnier
2019-03-08 14:35                                                             ` Eli Zaretskii
2019-03-09 10:18                                                           ` Philippe Vaucher
2019-03-09 10:20                                                             ` Philippe Vaucher
2019-03-09 15:06                                                             ` Eli Zaretskii
2019-03-09 17:08                                                               ` Philippe Vaucher
2019-03-09 17:19                                                                 ` Eli Zaretskii
2019-03-09 19:57                                                                 ` Stefan Monnier
2019-03-11  9:08                                                                   ` Philippe Vaucher
2019-03-11 10:54                                                                     ` Philippe Vaucher [this message]
2019-03-15  9:11                                                                       ` Eli Zaretskii
2019-03-17 11:55                                                                         ` Philippe Vaucher
2019-03-02 18:15                                                   ` Eli Zaretskii
2018-08-02  8:56                     ` Philippe Vaucher

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAGK7Mr47jmpVnSrZqNWu8jtZcCsApPuA2+aCRtmDqN5D3hUi2w@mail.gmail.com \
    --to=philippe.vaucher@gmail.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).