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
This commit is contained in:
parent
3eb0509259
commit
34b4b7eb7e
4 changed files with 23 additions and 12 deletions
|
@ -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)
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
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:
|
||||
|
|
Loading…
Add table
Reference in a new issue