Show character names when describing translations
authorRobert Pluim <rpluim@gmail.com>
Fri, 7 Jun 2024 10:21:11 +0000 (12:21 +0200)
committerRobert Pluim <rpluim@gmail.com>
Tue, 11 Jun 2024 09:06:37 +0000 (11:06 +0200)
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
lisp/help.el

index c18872189e4882d6a06159be204674886588bffc..ccef8a0f1ed5d78e5429c688b9fbe72e8022f1a0 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -189,6 +189,26 @@ 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 keybindings which produce single characters via translation or input
+methods, 'C-h k' now shows the Unicode name of the produced character in
+addition to the character itself, e.g.
+
+'C-h k C-x 8 E' =>
+
+    € 'EURO SIGN' (translated from C-x 8 E)
+
+*** 'C-h b' ('describe-bindings') shows Unicode names.
+For keybindings which produce single characters via translation (such as
+those using the 'C-x 8' or 'A-' prefix, or 'dead-acute', 'dead-grave',
+etc), the Unicode names will now be shown in addition to the character
+itself, i.e.
+
+    A-!                        ¡      INVERTED EXCLAMATION MARK
+    A-$                        ¤      CURRENCY SIGN
+
+and so on.
+
 ** Emacs now comes with Org v9.7.
 See the file "etc/ORG-NEWS" for user-visible changes in Org.
 
index 2feb178ff6c1df5fbc176b808d26ee9414e955ab..878dd40425616e36ccb3fbabd323ebfa91a705f1 100644 (file)
@@ -883,7 +883,9 @@ If INSERT (the prefix arg) is non-nil, insert the message in the buffer."
       (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 @@ Return nil if the key sequence is too long."
 (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)