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: Sun, 20 Jul 2008 23:28:59 +0300 Organization: JURTA Message-ID: <87r69oqojm.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> <873am6rb8k.fsf@jurta.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1216586651 16182 80.91.229.12 (20 Jul 2008 20:44:11 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 20 Jul 2008 20:44:11 +0000 (UTC) Cc: David De La Harpe Golden , tzz@lifelogs.com, emacs-devel@gnu.org, Kenichi Handa To: Miles Bader Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jul 20 22:44:59 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 1KKfm1-0003RZ-8D for ged-emacs-devel@m.gmane.org; Sun, 20 Jul 2008 22:44:53 +0200 Original-Received: from localhost ([127.0.0.1]:37970 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KKfl8-0002Fc-BK for ged-emacs-devel@m.gmane.org; Sun, 20 Jul 2008 16:43:58 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KKfl3-0002FK-P4 for emacs-devel@gnu.org; Sun, 20 Jul 2008 16:43:53 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KKfl3-0002Ex-8x for emacs-devel@gnu.org; Sun, 20 Jul 2008 16:43:53 -0400 Original-Received: from [199.232.76.173] (port=45171 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KKfl3-0002Et-5s for emacs-devel@gnu.org; Sun, 20 Jul 2008 16:43:53 -0400 Original-Received: from relay01.kiev.sovam.com ([62.64.120.200]:2586) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KKfky-0000Ou-IR; Sun, 20 Jul 2008 16:43:48 -0400 Original-Received: from [83.170.232.243] (helo=smtp.svitonline.com) by relay01.kiev.sovam.com with esmtp (Exim 4.67) (envelope-from ) id 1KKfji-000Kt2-FW; Sun, 20 Jul 2008 23:43:45 +0300 In-Reply-To: <873am6rb8k.fsf@jurta.org> (Juri Linkov's message of "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) X-Scanner-Signature: eb35aeac2b84d7677a861f668fbe3b20 X-DrWeb-checked: yes X-SpamTest-Envelope-From: juri@jurta.org X-SpamTest-Group-ID: 00000000 X-SpamTest-Header: Trusted X-SpamTest-Info: Profiles 4378 [July 20 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 4.8-5.1 (or MacOS X 10.2-10.3) 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:101031 Archived-At: > 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. It seems better to support all Emacs Lisp notations including both leading characters `#' and `?': #b101100 => 44 #o54 => 44 #x2c => 44 #24r1k => 44 ?\012 => 10 ?\t => 9 ?\C-j => 10 ?\101 => 65 ?A => 65 ?\v => 11 ?\f => 12 ?\r => 13 ?\e => 27 ?\s => 32 ?\\ => 92 ?\d => 127 ?\uNNNN The patch below simply uses `read' to read a character from the entered string. It also prepends `?' when the string begins with `\' thus allowing to input Unicode code points using `C-q \uNNNN'. Index: lisp/subr.el =================================================================== RCS file: /sources/emacs/emacs/lisp/subr.el,v retrieving revision 1.601 diff -u -r1.601 subr.el --- lisp/subr.el 27 Jun 2008 02:13:36 -0000 1.601 +++ lisp/subr.el 20 Jul 2008 20:28:29 -0000 @@ -1721,7 +1721,7 @@ 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) + (let ((message-log-max nil) done (first t) (code 0) char translated string) (while (not done) (let ((inhibit-quit first) ;; Don't let C-h get the help message--only help function keys. @@ -1753,6 +1753,19 @@ ;; Turn a meta-character into a character with the 0200 bit set. (setq code (logior (logand translated (lognot ?\M-\^@)) 128) done t)) + ((and first (memq translated '(?# ?? ?\\))) + (setq string (char-to-string translated)) + (and prompt (setq prompt (message "%s %c" prompt translated)))) + (string + (if (eq translated ?\C-m) + (setq done t code + (if (eq (length string) 1) + (read-char-by-name "Unicode (hex or name): ") + (setq code (read (if (eq (aref string 0) ?\\) + (concat "?" string) + string))))) + (setq string (concat string (char-to-string translated))) + (and prompt (setq prompt (message "%s %c" prompt translated))))) ((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)))) -- Juri Linkov http://www.jurta.org/emacs/