emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Suggestion] New function `sorted-key-descriptions'


From: Wedler, Christoph
Subject: [Suggestion] New function `sorted-key-descriptions'
Date: Fri, 2 May 2003 21:54:09 +0200

I would like to see the following function defined in Emacs[1]:

(defun sorted-key-descriptions (keys &optional separator)
  "Sort and separate the key descriptions for KEYS.
The sorting is done by length (shortest bindings first), and the bindings
are separated with SEPARATOR (\", \" by default)."
  (mapconcat 'key-description
             (sort keys #'(lambda (x y)
                            (< (length x) (length y))))
             (or separator ", ")))

You might argue that these 4 lines are not really worth to make a
function out of it, Emacs should use that code at the 3..5 places where
it is needed, but here are some reasons to make a function out of it:

 1. Such a function helps ensuring a consistent user interface:
    currently, the key distriptions are ordered for icomplete.el, but
    not in `where-is' and `apropos-print'.

 2. The sorting could be made smarter/customizable in the future: e.g.,
    one could imagine that non-console users would prefer to see <right>
    instead C-f as the first binding of `forward-char'.

- Christoph

[1] This function is already defined in XEmacs.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]