[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: |
Sat, 19 Jul 2008 03:27:55 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (x86_64-pc-linux-gnu) |
> David De La Harpe Golden <address@hidden> writes:
>>> I once proposed C-q 8 and C-9 to change read-quoted-char-radix to 10
>>> and 16 temporarily so that one can type C-q 9 c 0 RET to input
>>> U+00C0. I still think it's very convenient.
>>
>> Well, convenient, but maybe supporting emacs lisp hex
>> literal syntax might be more memorable? e.g. C-q #x2618
>
> Yes, that sounds like a good syntax to me -- I think it's important that
> it be easy to remember, because many people will use it only
> occasionally.
In pre-23 days I once submitted a patch that used `C-q x00B6' syntax.
But I agree that hash notation is better because it is easy to remember
and consistent with standard Lisp syntax.
The patch below now provides the following variants:
C-q #x2323
C-q #o21443
C-q #b0010001100100011
C-q #d8995
However, I'm not sure about #d8995. It is non-standard syntax where read
fails with (invalid-read-syntax "#"). The standard syntax for decimal is
without hash notation. This suggests using `C-q 8995'. But this means
changing read-quoted-char-radix default to 10!
Anyway, this patch also provides `C-q U2323' syntax that is mnemonic
for everyone accustomed to U+ syntax.
And another convenience is `C-q # RET' where after typing RET it reads a
code point or Unicode name in the minibuffer.
Index: lisp/subr.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/subr.el,v
retrieving revision 1.601
diff -c -r1.601 subr.el
*** lisp/subr.el 27 Jun 2008 02:13:36 -0000 1.601
--- lisp/subr.el 19 Jul 2008 00:27:36 -0000
***************
*** 1721,1727 ****
The optional argument PROMPT specifies a string to use to prompt the user.
The variable `read-quoted-char-radix' controls which radix to use
for numeric input."
! (let ((message-log-max nil) done (first t) (code 0) char translated)
(while (not done)
(let ((inhibit-quit first)
;; Don't let C-h get the help message--only help function keys.
--- 1721,1728 ----
The optional argument PROMPT specifies a string to use to prompt the user.
The variable `read-quoted-char-radix' controls which radix to use
for numeric input."
! (let ((message-log-max nil) done (first t) (code 0) char translated
! (radix read-quoted-char-radix) hash)
(while (not done)
(let ((inhibit-quit first)
;; Don't let C-h get the help message--only help function keys.
***************
*** 1753,1765 ****
;; Turn a meta-character into a character with the 0200 bit set.
(setq code (logior (logand translated (lognot ?\M-\^@)) 128)
done t))
! ((and (<= ?0 translated) (< translated (+ ?0 (min 10
read-quoted-char-radix))))
! (setq code (+ (* code read-quoted-char-radix) (- translated ?0)))
(and prompt (setq prompt (message "%s %c" prompt translated))))
((and (<= ?a (downcase translated))
! (< (downcase translated) (+ ?a -10 (min 36
read-quoted-char-radix))))
! (setq code (+ (* code read-quoted-char-radix)
! (+ 10 (- (downcase translated) ?a))))
(and prompt (setq prompt (message "%s %c" prompt translated))))
((and (not first) (eq translated ?\C-m))
(setq done t))
--- 1754,1789 ----
;; Turn a meta-character into a character with the 0200 bit set.
(setq code (logior (logand translated (lognot ?\M-\^@)) 128)
done t))
! ((and first (= ?u (downcase translated)))
! (setq radix 16)
! (and prompt (setq prompt (message "%s U+" prompt))))
! ((and first (= ?# translated))
! (setq hash t)
! (and prompt (setq prompt (message "%s #" prompt))))
! (hash
! (cond
! ((= ?d (downcase translated))
! (setq radix 10)
! (and prompt (setq prompt (message "%s D" prompt))))
! ((= ?b (downcase translated))
! (setq radix 2)
! (and prompt (setq prompt (message "%s B" prompt))))
! ((= ?o (downcase translated))
! (setq radix 8)
! (and prompt (setq prompt (message "%s O" prompt))))
! ((= ?x (downcase translated))
! (setq radix 16)
! (and prompt (setq prompt (message "%s X" prompt))))
! ((= ?\015 (downcase translated))
! (setq done t code (read-char-by-name "Unicode (hex or name): "))
! (and prompt (setq prompt (message "%s X" prompt)))))
! (setq hash nil))
! ((and (<= ?0 translated) (< translated (+ ?0 (min 10 radix))))
! (setq code (+ (* code radix) (- translated ?0)))
(and prompt (setq prompt (message "%s %c" prompt translated))))
((and (<= ?a (downcase translated))
! (< (downcase translated) (+ ?a -10 (min 36 radix))))
! (setq code (+ (* code radix) (+ 10 (- (downcase translated) ?a))))
(and prompt (setq prompt (message "%s %c" prompt translated))))
((and (not first) (eq translated ?\C-m))
(setq done t))
--
Juri Linkov
http://www.jurta.org/emacs/
- Re: inputting characters by hexadigit, (continued)
- Re: inputting characters by hexadigit, Stefan Monnier, 2008/07/20
- Re: inputting characters by hexadigit, David De La Harpe Golden, 2008/07/21
- Re: inputting characters by hexadigit, Juri Linkov, 2008/07/22
- Re: inputting characters by hexadigit, Lennart Borgman (gmail), 2008/07/22
- Re: inputting characters by hexadigit, David De La Harpe Golden, 2008/07/22
- 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, Stephen J. Turnbull, 2008/07/19
- Re: inputting characters by hexadigit, Miles Bader, 2008/07/18
- Re: inputting characters by hexadigit, Juri Linkov, 2008/07/18
- Re: inputting characters by hexadigit,
Juri Linkov <=
- Re: inputting characters by hexadigit, Juri Linkov, 2008/07/20
- Re: inputting characters by hexadigit, Stefan Monnier, 2008/07/20
- Re: inputting characters by hexadigit, David De La Harpe Golden, 2008/07/21
- Re: inputting characters by hexadigit, Stefan Monnier, 2008/07/21
- Re: inputting characters by hexadigit, Juri Linkov, 2008/07/21
- Re: inputting characters by hexadigit, Johan Bockgård, 2008/07/21
- Re: inputting characters by hexadigit, David Kastrup, 2008/07/21
- Re: inputting characters by hexadigit, Johan Bockgård, 2008/07/21
- Re: inputting characters by hexadigit, David Kastrup, 2008/07/21
- Re: inputting characters by hexadigit, Lennart Borgman (gmail), 2008/07/21