From: Juri Linkov <juri@jurta.org>
To: Juanma Barranquero <lekktu@gmail.com>
Cc: 10857@debbugs.gnu.org
Subject: bug#10857: ucs-insert deals inconsistently with errors
Date: Wed, 22 Feb 2012 02:09:20 +0200 [thread overview]
Message-ID: <87ehtnwwy7.fsf@mail.jurta.org> (raw)
In-Reply-To: <CAAeL0SREwH7rDyt3MEKLh6iBUA7MGQvRN=JvX_hz_J_ot6bQfw@mail.gmail.com> (Juanma Barranquero's message of "Tue, 21 Feb 2012 02:25:47 +0100")
tags 10857 patch
thanks
> Yes. I don't think `read-char-by-name' should return "zzz", I think
> `ucs-insert' should not say the "nil" part. Perhaps just "Not a
> Unicode character".
>
>> In `read-char-by-name', the condition for this purpose is:
>>
>> (string-match-p "^[0-9a-fA-F]+$" input)
>
> They are equivalent, aren't they? But my point was that the docstring
> does not say what to expect in CHARACTER.
This should be fixed by this patch:
=== modified file 'lisp/international/mule-cmds.el'
--- lisp/international/mule-cmds.el 2012-02-10 19:35:28 +0000
+++ lisp/international/mule-cmds.el 2012-02-22 00:07:34 +0000
@@ -2949,7 +2949,7 @@ (defun read-char-by-name (prompt)
'(metadata (category . unicode-name))
(complete-with-action action (ucs-names) string pred))))))
(cond
- ((string-match-p "^[0-9a-fA-F]+$" input)
+ ((string-match-p "\\`[0-9a-fA-F]+\\'" input)
(string-to-number input 16))
((string-match-p "^#" input)
(read input))
@@ -2967,6 +2967,10 @@ (defun ucs-insert (character &optional c
the characters whose names include that substring, not necessarily
at the beginning of the name.
+This function also accepts a hexadecimal number of Unicode code
+point or a number in hash notation, e.g. #o21430 for octal,
+#x2318 for hex, or #10r8984 for decimal.
+
The optional third arg INHERIT (non-nil when called interactively),
says to inherit text properties from adjoining text, if those
properties are sticky."
@@ -2975,9 +2979,12 @@ (defun ucs-insert (character &optional c
(prefix-numeric-value current-prefix-arg)
t))
(unless count (setq count 1))
- (if (stringp character)
+ (if (and (stringp character)
+ (string-match-p "\\`[0-9a-fA-F]+\\'" character))
(setq character (string-to-number character 16)))
(cond
+ ((null character)
+ (error "Not a Unicode character"))
((not (integerp character))
(error "Not a Unicode character code: %S" character))
((or (< character 0) (> character #x10FFFF))
next prev parent reply other threads:[~2012-02-22 0:09 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-20 15:53 bug#10857: ucs-insert deals inconsistently with errors Juanma Barranquero
2012-02-21 0:37 ` Juri Linkov
2012-02-21 1:25 ` Juanma Barranquero
2012-02-21 9:16 ` Andreas Schwab
2012-02-21 10:39 ` Juanma Barranquero
2012-02-22 0:09 ` Juri Linkov [this message]
2012-02-22 9:03 ` Andreas Schwab
2012-02-22 23:35 ` Juri Linkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ehtnwwy7.fsf@mail.jurta.org \
--to=juri@jurta.org \
--cc=10857@debbugs.gnu.org \
--cc=lekktu@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).