[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: inputting characters by hexadigit
From: |
Juri Linkov |
Subject: |
Re: inputting characters by hexadigit |
Date: |
Wed, 30 Jul 2008 18:29:19 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (x86_64-pc-linux-gnu) |
>>> I think we should improve `ucs-insert' to accept input in standard
>>> Emacs Lisp notations: #o... for octal and #x... for hex.
>>
>> Agreed.
>
> Sure, though it should be noted that this is an incompatible editing
> change: with standing Lisp notation, 123 would be decimal, not octal.
Hexadecimal numbers is the primary notation for Unicode code points
so it would be better to keep the current default. In addition we can
support the hash notation that allows entering decimal numbers (though,
in less convenient way) as e.g. #10r182. I propose the following patch
that keeps `ucs-insert' backward-compatible in regard of treating
numbers as hex by default, adds reading numbers with hash notations,
and improves error-handling of `ucs-insert'.
Index: lisp/international/mule-cmds.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/international/mule-cmds.el,v
retrieving revision 1.335
diff -c -r1.335 mule-cmds.el
*** lisp/international/mule-cmds.el 29 Jul 2008 14:45:50 -0000 1.335
--- lisp/international/mule-cmds.el 30 Jul 2008 15:29:11 -0000
***************
*** 2864,2883 ****
as a number."
(let* ((completion-ignore-case t)
(input (completing-read prompt ucs-completions)))
! (or (and (string-match "^[0-9a-fA-F]+$" input)
! (string-to-number input 16))
! (cdr (assoc input (ucs-names))))))
(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 (name or hex): ")))
! (or (integerp arg)
(setq arg (string-to-number arg 16)))
! (if (or (< arg 0) (> arg #x10FFFF))
! (error "Not a Unicode character code: 0x%X" arg))
(insert-and-inherit arg))
;; arch-tag: b382c432-4b36-460e-bf4c-05efd0bb18dc
;;; mule-cmds.el ends here
--- 2864,2891 ----
as a number."
(let* ((completion-ignore-case t)
(input (completing-read prompt ucs-completions)))
! (cond
! ((string-match "^[0-9a-fA-F]+$" input)
! (string-to-number input 16))
! ((string-match "^#" input)
! (read input))
! (t
! (cdr (assoc input (ucs-names)))))))
(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 (name or hex): ")))
! (if (stringp arg)
(setq arg (string-to-number arg 16)))
! (cond
! ((not (integerp arg))
! (error "Not a Unicode character code: %S" arg))
! ((< arg 0) (> arg #x10FFFF)
! (error "Not a Unicode character code: 0x%X" arg)))
(insert-and-inherit arg))
+ (define-key ctl-x-map "8\r" 'ucs-insert)
;; arch-tag: b382c432-4b36-460e-bf4c-05efd0bb18dc
;;; mule-cmds.el ends here
--
Juri Linkov
http://www.jurta.org/emacs/
- RE: inputting characters by hexadigit, (continued)
- RE: inputting characters by hexadigit, Drew Adams, 2008/07/23
- Re: inputting characters by hexadigit, Juri Linkov, 2008/07/23
- Re: inputting characters by hexadigit, Stefan Monnier, 2008/07/23
- Re: inputting characters by hexadigit, Juri Linkov, 2008/07/23
- Re: inputting characters by hexadigit, Stefan Monnier, 2008/07/23
- Re: inputting characters by hexadigit, Juri Linkov, 2008/07/29
- Re: inputting characters by hexadigit, Chong Yidong, 2008/07/29
- Re: inputting characters by hexadigit, Juri Linkov, 2008/07/29
- Re: inputting characters by hexadigit, Stefan Monnier, 2008/07/29
- Re: inputting characters by hexadigit, Chong Yidong, 2008/07/29
- Re: inputting characters by hexadigit,
Juri Linkov <=
- Re: inputting characters by hexadigit, Ted Zlatanov, 2008/07/31
- Re: describe-char should display the character's Unicode name, Kenichi Handa, 2008/07/17
- Re: describe-char should display the character's Unicode name, Miles Bader, 2008/07/17
- Re: describe-char should display the character's Unicode name, Ted Zlatanov, 2008/07/18
- RE: describe-char should display the character's Unicode name, Drew Adams, 2008/07/18
- Re: describe-char should display the character's Unicode name, Stefan Monnier, 2008/07/18
- Re: describe-char should display the character's Unicode name, Ted Zlatanov, 2008/07/18
- Re: describe-char should display the character's Unicode name, Juri Linkov, 2008/07/18
- Re: describe-char should display the character's Unicode name, Ted Zlatanov, 2008/07/21
- Re: describe-char should display the character's Unicode name, Lennart Borgman (gmail), 2008/07/21