[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: emacs-28 a866674b2a: Fix inaccuracies in "lax search" documentation
From: |
Robert Pluim |
Subject: |
Re: emacs-28 a866674b2a: Fix inaccuracies in "lax search" documentation |
Date: |
Wed, 31 Aug 2022 19:26:48 +0200 |
>>>>> On Wed, 31 Aug 2022 20:22:30 +0300, Eli Zaretskii <eliz@gnu.org> said:
>> From: Juri Linkov <juri@linkov.net>
>> Cc: Eli Zaretskii <eliz@gnu.org>, emacs-devel@gnu.org
>> Date: Wed, 31 Aug 2022 20:13:45 +0300
>>
>> I see it the other way around - that pleads for fixing
>> `read-char-from-minibuffer':
Eli> You do?
Eli> If read-char-from-minibuffer is supposed to return a single character,
Eli> it cannot return nil (or anything else that indicates empty input).
Eli> If you make such a change, expect it to break many use cases
Eli> elsewhere.
Eli> To me, the above says that read-char-from-minibuffer is not the right
Eli> tool for this job.
Hereʼs the kind of thing I had in mind:
diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el
index 12896cc4b0..4137642528 100644
--- a/lisp/international/mule-cmds.el
+++ b/lisp/international/mule-cmds.el
@@ -3195,7 +3195,7 @@ read-char-by-name-sort
:group 'mule
:version "28.1")
-(defun read-char-by-name (prompt)
+(defun read-char-by-name (prompt &optional allow-single)
"Read a character by its Unicode name or hex number string.
Display PROMPT and read a string that represents a character by its
Unicode property `name' or `old-name'.
@@ -3216,7 +3216,10 @@ read-char-by-name
number like \"2A10\", or a number in hash notation (e.g.,
\"#x2a10\" for hex, \"10r10768\" for decimal, or \"#o25020\" for
octal). Treat otherwise-ambiguous strings like \"BED\" (U+1F6CF)
-as names, not numbers."
+as names, not numbers.
+
+Optional arg ALLOW-SINGLE non-nil means to additionally allow
+single characters to be treated as standing for themselves."
(let* ((enable-recursive-minibuffers t)
(completion-ignore-case t)
(completion-tab-width 4)
@@ -3239,6 +3242,9 @@ read-char-by-name
(char
(cond
((char-from-name input t))
+ ((and allow-single
+ (string-match-p "\\`.\\'" input)
+ (ignore-errors (string-to-char input))))
((string-match-p "\\`[[:xdigit:]]+\\'" input)
(ignore-errors (string-to-number input 16)))
((string-match-p "\\`#\\([bBoOxX]\\|[0-9]+[rR]\\)[0-9a-zA-Z]+\\'"
Robert
--
- Re: emacs-28 a866674b2a: Fix inaccuracies in "lax search" documentation, Juri Linkov, 2022/08/30
- Re: emacs-28 a866674b2a: Fix inaccuracies in "lax search" documentation, Robert Pluim, 2022/08/31
- Re: emacs-28 a866674b2a: Fix inaccuracies in "lax search" documentation, Juri Linkov, 2022/08/31
- Re: emacs-28 a866674b2a: Fix inaccuracies in "lax search" documentation, Robert Pluim, 2022/08/31
- Re: emacs-28 a866674b2a: Fix inaccuracies in "lax search" documentation, Eli Zaretskii, 2022/08/31
- Re: emacs-28 a866674b2a: Fix inaccuracies in "lax search" documentation, Robert Pluim, 2022/08/31
- Re: emacs-28 a866674b2a: Fix inaccuracies in "lax search" documentation, Juri Linkov, 2022/08/31
- Re: emacs-28 a866674b2a: Fix inaccuracies in "lax search" documentation, Eli Zaretskii, 2022/08/31
- Re: emacs-28 a866674b2a: Fix inaccuracies in "lax search" documentation,
Robert Pluim <=
- RE: [External] : Re: emacs-28 a866674b2a: Fix inaccuracies in "lax search" documentation, Drew Adams, 2022/08/31
- Re: emacs-28 a866674b2a: Fix inaccuracies in "lax search" documentation, Juri Linkov, 2022/08/31
- Re: emacs-28 a866674b2a: Fix inaccuracies in "lax search" documentation, Stefan Monnier, 2022/08/31