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: Wed, 30 Jul 2008 18:29:19 +0300 Organization: JURTA Message-ID: <87k5f39y28.fsf@jurta.org> References: <868ww3vydn.fsf@lifelogs.com> <488020A4.4060601@harpegolden.net> <873am6rb8k.fsf@jurta.org> <87r69oqojm.fsf@jurta.org> <006a01c8ec04$27f3c2d0$0200a8c0@us.oracle.com> <86ej5keovj.fsf@lifelogs.com> <48872C97.6020505@gmail.com> <873am0fzfw.fsf@jurta.org> <874p6g1fpx.fsf@jurta.org> <877ib4lmla.fsf@jurta.org> <87sktsoarg.fsf@stupidchicken.com> <878wvkfuk1.fsf@jurta.org> <874p68za5h.fsf@stupidchicken.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1217432889 12347 80.91.229.12 (30 Jul 2008 15:48:09 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 30 Jul 2008 15:48:09 +0000 (UTC) Cc: Ted Zlatanov , Stefan Monnier , emacs-devel@gnu.org To: Chong Yidong Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jul 30 17:48:58 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 1KODuz-00066W-K4 for ged-emacs-devel@m.gmane.org; Wed, 30 Jul 2008 17:48:49 +0200 Original-Received: from localhost ([127.0.0.1]:35684 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KODu5-0002sr-Ej for ged-emacs-devel@m.gmane.org; Wed, 30 Jul 2008 11:47:53 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KODtQ-00020z-1r for emacs-devel@gnu.org; Wed, 30 Jul 2008 11:47:12 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KODtP-0001zZ-2o for emacs-devel@gnu.org; Wed, 30 Jul 2008 11:47:11 -0400 Original-Received: from [199.232.76.173] (port=37241 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KODtO-0001zD-Pt for emacs-devel@gnu.org; Wed, 30 Jul 2008 11:47:10 -0400 Original-Received: from smtp-out.neti.ee ([194.126.126.37]:60740) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KODtO-0004vl-9H for emacs-devel@gnu.org; Wed, 30 Jul 2008 11:47:10 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by MXR-5.estpak.ee (Postfix) with ESMTP id 7D0991DE624; Wed, 30 Jul 2008 18:47:08 +0300 (EEST) X-Virus-Scanned: Debian amavisd-new at estpak.ee Original-Received: from smtp-out.neti.ee ([127.0.0.1]) by localhost (MXR-5.estpak.ee [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ibLmiEYIDjbU; Wed, 30 Jul 2008 18:47:05 +0300 (EEST) Original-Received: from Relayhost1.neti.ee (Relayhost1 [88.196.174.141]) by MXR-5.estpak.ee (Postfix) with ESMTP id 9F73A1DE9C4; Wed, 30 Jul 2008 18:47:05 +0300 (EEST) Original-Received: from mail.estpak.ee (66.132.191.90.dyn.estpak.ee [90.191.132.66]) by Relayhost1.neti.ee (Postfix) with ESMTP id 1C32E2A44E4; Wed, 30 Jul 2008 18:47:02 +0300 (EEST) In-Reply-To: <874p68za5h.fsf@stupidchicken.com> (Chong Yidong's message of "Tue, 29 Jul 2008 16:51:38 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (x86_64-pc-linux-gnu) X-detected-kernel: by monty-python.gnu.org: Linux 2.4-2.6 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:101761 Archived-At: >>> 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/