From 7c4a0e3b46dff5ccd2233c24ac0143d3f30747ff Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Wed, 25 Mar 2015 13:45:34 -0400 Subject: [PATCH] * international/mule-cmds.el: Show chars in C-x 8 RET completions * lisp/international/mule-cmds.el (mule--ucs-names-annotation): New func. (read-char-by-name): Use it. --- lisp/ChangeLog | 3 +++ lisp/international/mule-cmds.el | 12 +++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 91decb31ff0..e74733015c9 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,8 @@ 2015-03-25 Stefan Monnier + * 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 diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el index dcf850d9425..cca659f2cc1 100644 --- a/lisp/international/mule-cmds.el +++ b/lisp/international/mule-cmds.el @@ -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 -- 2.11.4.GIT