From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: inputting characters by hexadigit Date: Sat, 19 Jul 2008 03:27:55 +0300 Organization: JURTA Message-ID: <873am6rb8k.fsf@jurta.org> References: <868ww3vydn.fsf@lifelogs.com> <87myki6fqp.fsf@jurta.org> <87mykhz6tf.fsf@jurta.org> <87tzeokrku.fsf@jurta.org> <87tzeogih6.fsf@catnip.gol.com> <488020A4.4060601@harpegolden.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1216428335 20846 80.91.229.12 (19 Jul 2008 00:45:35 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 19 Jul 2008 00:45:35 +0000 (UTC) Cc: tzz@lifelogs.com, Kenichi Handa , emacs-devel@gnu.org, David De La Harpe Golden To: Miles Bader Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Jul 19 02:46:22 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KK0ab-0006oh-TQ for ged-emacs-devel@m.gmane.org; Sat, 19 Jul 2008 02:46:22 +0200 Original-Received: from localhost ([127.0.0.1]:38004 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KK0Zj-00088z-0l for ged-emacs-devel@m.gmane.org; Fri, 18 Jul 2008 20:45:27 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KK0Z8-0007vV-Rs for emacs-devel@gnu.org; Fri, 18 Jul 2008 20:44:50 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KK0Z8-0007v4-3g for emacs-devel@gnu.org; Fri, 18 Jul 2008 20:44:50 -0400 Original-Received: from [199.232.76.173] (port=36513 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KK0Z7-0007ux-QP for emacs-devel@gnu.org; Fri, 18 Jul 2008 20:44:49 -0400 Original-Received: from relay03.kiev.sovam.com ([62.64.120.201]:56362) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KK0Z0-0004UU-Sf; Fri, 18 Jul 2008 20:44:43 -0400 Original-Received: from [83.170.232.243] (helo=smtp.svitonline.com) by relay03.kiev.sovam.com with esmtp (Exim 4.67) (envelope-from ) id 1KK0Yr-000HZs-Li; Sat, 19 Jul 2008 03:44:36 +0300 In-Reply-To: (Miles Bader's message of "Fri, 18 Jul 2008 21:39:01 +0900") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (x86_64-pc-linux-gnu) X-Scanner-Signature: a89dff86c47152c77ba722073511b1ec X-DrWeb-checked: yes X-SpamTest-Envelope-From: juri@jurta.org X-SpamTest-Group-ID: 00000000 X-SpamTest-Header: Trusted X-SpamTest-Info: Profiles 4362 [July 19 2008] X-SpamTest-Info: {received from trusted relay: common white list} X-SpamTest-Info: {HEADERS: header Content-Type found without required header Content-Transfer-Encoding} X-SpamTest-Method: white ip list X-SpamTest-Rate: 10 X-SpamTest-Status: Trusted X-SpamTest-Status-Extended: trusted X-SpamTest-Version: SMTP-Filter Version 3.0.0 [0278], KAS30/Release X-detected-kernel: by monty-python.gnu.org: FreeBSD 6.x (1) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:100962 Archived-At: > David De La Harpe Golden 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/