Commit 34b4b7eb authored by Chong Yidong's avatar Chong Yidong
Browse files

Make read-char-by-name signal an error for invalid input.

* international/mule-cmds.el (read-char-by-name): Signal an error
if the user does not supply a valid character.

* editfns.c (Finsert_char): Since read-char-by-name now signals an
error for invalid chars, don't check for a nil return value.

Fixes: debbugs:13177
parent 3eb05092
......@@ -5,6 +5,9 @@
 
2012-12-21 Chong Yidong <cyd@gnu.org>
 
* international/mule-cmds.el (read-char-by-name): Signal an error
if the user does not supply a valid character (Bug#13177).
* simple.el (transpose-subr-1): Preserve marker positions by
changing the insertion sequence (Bug#13122).
 
......
......@@ -2953,14 +2953,18 @@ point or a number in hash notation, e.g. #o21430 for octal,
(let ((completion-ignore-case t))
(if (eq action 'metadata)
'(metadata (category . unicode-name))
(complete-with-action action (ucs-names) string pred)))))))
(cond
((string-match-p "\\`[0-9a-fA-F]+\\'" input)
(string-to-number input 16))
((string-match-p "\\`#" input)
(read input))
(t
(cdr (assoc-string input (ucs-names) t))))))
(complete-with-action action (ucs-names) string pred))))))
(char
(cond
((string-match-p "\\`[0-9a-fA-F]+\\'" input)
(string-to-number input 16))
((string-match-p "\\`#" input)
(read input))
(t
(cdr (assoc-string input (ucs-names) t))))))
(unless (characterp char)
(error "Invalid character"))
char))
(define-obsolete-function-alias 'ucs-insert 'insert-char "24.3")
(define-key ctl-x-map "8\r" 'insert-char)
......
2012-12-21 Chong Yidong <cyd@gnu.org>
* editfns.c (Finsert_char): Since read-char-by-name now signals an
error for invalid chars, don't check for a nil return value.
2012-12-20 Dmitry Antipov <dmantipov@yandex.ru>
 
Avoid calls to CHAR_TO_BYTE if byte position is known.
......
......@@ -2361,10 +2361,9 @@ usage: (insert-before-markers-and-inherit &rest ARGS) */)
}
DEFUN ("insert-char", Finsert_char, Sinsert_char, 1, 3,
"(list (or (read-char-by-name \"Insert character (Unicode name or hex): \")\
(error \"You did not specify a valid character\"))\
(prefix-numeric-value current-prefix-arg)\
t))",
"(list (read-char-by-name \"Insert character (Unicode name or hex): \")\
(prefix-numeric-value current-prefix-arg)\
t))",
doc: /* Insert COUNT copies of CHARACTER.
Interactively, prompt for CHARACTER. You can specify CHARACTER in one
of these ways:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment