]> code.delx.au - gnu-emacs/commitdiff
* international/mule-cmds.el: Show chars in C-x 8 RET completions
authorStefan Monnier <monnier@iro.umontreal.ca>
Wed, 25 Mar 2015 17:45:34 +0000 (13:45 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Wed, 25 Mar 2015 17:45:34 +0000 (13:45 -0400)
* lisp/international/mule-cmds.el (mule--ucs-names-annotation): New func.
(read-char-by-name): Use it.

lisp/ChangeLog
lisp/international/mule-cmds.el

index 91decb31ff02e52e0918d60cf9302dc88a288b9c..e74733015c9856129f6da320cf70b6387a433f65 100644 (file)
@@ -1,5 +1,8 @@
 2015-03-25  Stefan Monnier  <monnier@iro.umontreal.ca>
 
+       * international/mule-cmds.el (mule--ucs-names-annotation): New func.
+       (read-char-by-name): Use it.
+
        * xt-mouse.el (xterm-mouse--read-number-from-terminal): Fix last commit.
 
 2015-03-25  Nicolas Petton <nicolas@petton.fr>
index dcf850d942585d78a52b1a989047a46761758a84..cca659f2cc1732c74908cdd3af96b71f7a3c861a 100644 (file)
@@ -2941,6 +2941,14 @@ on encoding."
        ;; char with that name.
        (setq ucs-names `(("BELL (BEL)" . 7) ,@names)))))
 
+(defun mule--ucs-names-annotation (name)
+  ;; FIXME: It would be much better to add this annotation before rather than
+  ;; after the char name, so the annotations are aligned.
+  ;; FIXME: The default behavior of displaying annotations in italics
+  ;; doesn't work well here.
+  (let ((char (assoc name ucs-names)))
+    (when char (format " (%c)" (cdr char)))))
+
 (defun read-char-by-name (prompt)
   "Read a character by its Unicode name or hex number string.
 Display PROMPT and read a string that represents a character by its
@@ -2964,7 +2972,9 @@ point or a number in hash notation, e.g. #o21430 for octal,
           prompt
           (lambda (string pred action)
             (if (eq action 'metadata)
-                '(metadata (category . unicode-name))
+                '(metadata
+                  (annotation-function . mule--ucs-names-annotation)
+                  (category . unicode-name))
               (complete-with-action action (ucs-names) string pred)))))
         (char
          (cond