[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: describe-char should display the character's Unicode name
From: |
Juri Linkov |
Subject: |
Re: describe-char should display the character's Unicode name |
Date: |
Sat, 19 Jul 2008 03:35:45 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (x86_64-pc-linux-gnu) |
> MB> An input method is not a good solution because while input methods are
> MB> good for heavy use, they're quite annoying to juggle for occasional
> inputs.
>
> Agreed, there should be a function that gives all the Unicode characters
> as input candidates and the user can select the one he wants quickly (I
> don't see one currently). An input method wouldn't provide completion
> candidates, so the user has to remember all the names he needs.
>
> Would a few thousand candidates be a problem for completion? I've only
> seen it with hundreds and it's not slow, but for this maybe maybe we can
> break it down by block name and then character name.
There is no problem with completion in a new function below created
to read a character by its Unicode name or hex number string. There
is only a small delay when it creates the completion list, and a
longer delay when it displays the *Completions* buffer with all
Unicode names:
Index: lisp/international/mule-cmds.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/international/mule-cmds.el,v
retrieving revision 1.333
diff -c -r1.333 mule-cmds.el
*** lisp/international/mule-cmds.el 15 Jul 2008 18:15:03 -0000 1.333
--- lisp/international/mule-cmds.el 19 Jul 2008 00:35:23 -0000
***************
*** 2846,2855 ****
(defvar nonascii-insert-offset 0 "This variable is obsolete.")
(defvar nonascii-translation-table nil "This variable is obsolete.")
(defun ucs-insert (arg)
"Insert a character of the given Unicode code point.
Interactively, prompts for a hex string giving the code."
! (interactive "sUnicode (hex): ")
(or (integerp arg)
(setq arg (string-to-number arg 16)))
(if (or (< arg 0) (> arg #x10FFFF))
--- 2849,2873 ----
(defvar nonascii-insert-offset 0 "This variable is obsolete.")
(defvar nonascii-translation-table nil "This variable is obsolete.")
+ (defun read-char-by-name (prompt)
+ "Read a character by its Unicode name or hex number string.
+ Display PROMPT and read a string that represent a character
+ by its Unicode property `name' or `old-name'. It also accepts
+ a hexadecimal number of Unicode code point. Returns a character
+ as a number."
+ (let (name names)
+ (dotimes (c #x10FFFF)
+ (if (setq name (get-char-code-property c 'name))
+ (setq names (cons (cons name c) names)))
+ (if (setq name (get-char-code-property c 'old-name))
+ (setq names (cons (cons name c) names))))
+ (or (cdr (assoc (setq name (completing-read prompt names)) names))
+ (string-to-number name 16))))
+
(defun ucs-insert (arg)
"Insert a character of the given Unicode code point.
Interactively, prompts for a hex string giving the code."
! (interactive (list (read-char-by-name "Unicode (hex or name): ")))
(or (integerp arg)
(setq arg (string-to-number arg 16)))
(if (or (< arg 0) (> arg #x10FFFF))
--
Juri Linkov
http://www.jurta.org/emacs/
- Re: describe-char should display the character's Unicode name, (continued)
- Re: describe-char should display the character's Unicode name, Juri Linkov, 2008/07/22
- Re: describe-char should display the character's Unicode name, Ted Zlatanov, 2008/07/23
- Re: describe-char should display the character's Unicode name, Juri Linkov, 2008/07/23
- Re: describe-char should display the character's Unicode name, Lennart Borgman (gmail), 2008/07/23
- Re: describe-char should display the character's Unicode name, Ted Zlatanov, 2008/07/24
- Re: describe-char should display the character's Unicode name, Lennart Borgman, 2008/07/24
- Re: describe-char should display the character's Unicode name, Ted Zlatanov, 2008/07/24
- Re: describe-char should display the character's Unicode name, Lennart Borgman (gmail), 2008/07/24
- Re: describe-char should display the character's Unicode name, Juri Linkov, 2008/07/24
- Re: describe-char should display the character's Unicode name, Kenichi Handa, 2008/07/24
- Re: describe-char should display the character's Unicode name,
Juri Linkov <=
- Re: describe-char should display the character's Unicode name, Kenichi Handa, 2008/07/18
- Re: inputting characters by hexadigit, Juri Linkov, 2008/07/19
- Re: inputting characters by hexadigit, Kenichi Handa, 2008/07/19
- Re: inputting characters by hexadigit, Juri Linkov, 2008/07/20
- Re: inputting characters by hexadigit, Ted Zlatanov, 2008/07/23
- Re: inputting characters by hexadigit, Stefan Monnier, 2008/07/23
- Re: inputting characters by hexadigit, Ted Zlatanov, 2008/07/23
- Re: inputting characters by hexadigit, Stefan Monnier, 2008/07/23
- Re: inputting characters by hexadigit, Ted Zlatanov, 2008/07/24
- Re: inputting characters by hexadigit, Lennart Borgman, 2008/07/24