From a2adb11e15a60ad30741c6cd8c47f03b5b1a902e Mon Sep 17 00:00:00 2001 From: Robert Pluim Date: Fri, 7 Jun 2024 12:21:11 +0200 Subject: [PATCH 3/3] Show character names when describing translations To: emacs-devel@gnu.org This implements Bug#71411. * lisp/help.el (help-key-description): Use 'char-to-name' to show the Unicode name of translated keys. (help--describe-command): And here. * etc/NEWS: Announce the change. --- etc/NEWS | 14 ++++++++++++++ lisp/help.el | 9 +++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index c63e231f44f..66bc4d741ff 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -182,6 +182,20 @@ This user option controls outline visibility in the output buffer of *** 'C-h m' ('describe-mode') uses outlining by default. Set 'describe-mode-outline' to nil to get back the old behavior. +*** 'C-h k' ('describe-key') shows Unicode name. +For translated keys only, this will now show the Unicode name of the +translation, e.g. 'C-h k C-x 8 E' will now show + + € 'EURO SIGN' (translated from C-x 8 E) + +*** 'C-h b' ('describe-bindings') shows Unicode names. +For translated keys only, Unicode names will now be shown, i.e. + + A-! ¡ INVERTED EXCLAMATION MARK + A-$ ¤ CURRENCY SIGN + +and so on. + ** Outline mode *** New commands to show/hide outlines by regexp. diff --git a/lisp/help.el b/lisp/help.el index 2feb178ff6c..878dd404256 100644 --- a/lisp/help.el +++ b/lisp/help.el @@ -883,7 +883,9 @@ help-key-description (let ((otherstring (help--key-description-fontified untranslated))) (if (equal string otherstring) string - (format "%s (translated from %s)" string otherstring)))))) + (if-let ((char-name (char-to-name (aref string 0)))) + (format "%s '%s' (translated from %s)" string char-name otherstring) + (format "%s (translated from %s)" string otherstring))))))) (defun help--binding-undefined-p (defn) (or (null defn) (integerp defn) (equal defn #'undefined))) @@ -1664,7 +1666,10 @@ help--shadow-lookup (defun help--describe-command (definition &optional translation) (cond ((or (stringp definition) (vectorp definition)) (if translation - (insert (key-description definition nil) "\n") + (insert (concat (key-description definition nil) + (when-let ((char-name (char-to-name (aref definition 0)))) + (format "\t%s" char-name)) + "\n")) ;; These should be rare nowadays, replaced by `kmacro's. (insert "Keyboard Macro\n"))) ((keymapp definition) -- 2.39.2