From: Robert Pluim <rpluim@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Juri Linkov <juri@linkov.net>, emacs-devel@gnu.org
Subject: Re: emacs-28 a866674b2a: Fix inaccuracies in "lax search" documentation
Date: Wed, 31 Aug 2022 19:26:48 +0200 [thread overview]
Message-ID: <8735dcjpd3.fsf@gmail.com> (raw)
In-Reply-To: <83h71ss4yx.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 31 Aug 2022 20:22:30 +0300")
>>>>> 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
--
next prev parent reply other threads:[~2022-08-31 17:26 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <165875050243.3275.8867100069985547389@vcs2.savannah.gnu.org>
[not found] ` <20220725120142.D1283C0F203@vcs2.savannah.gnu.org>
2022-07-25 13:01 ` emacs-28 a866674b2a: Fix inaccuracies in "lax search" documentation Robert Pluim
2022-07-25 13:43 ` Eli Zaretskii
2022-07-25 14:48 ` Robert Pluim
2022-07-25 16:02 ` Eli Zaretskii
2022-07-26 12:52 ` Robert Pluim
2022-07-26 13:16 ` Eli Zaretskii
2022-07-26 14:23 ` Robert Pluim
2022-07-26 16:06 ` Eli Zaretskii
2022-07-26 16:54 ` Robert Pluim
2022-07-26 17:15 ` Eli Zaretskii
2022-07-27 7:54 ` Robert Pluim
2022-07-27 11:32 ` Eli Zaretskii
2022-07-25 17:52 ` Juri Linkov
2022-07-25 18:15 ` Eli Zaretskii
2022-07-25 18:42 ` Juri Linkov
2022-07-25 19:49 ` Juri Linkov
2022-07-26 7:59 ` Robert Pluim
2022-07-26 12:16 ` Eli Zaretskii
2022-07-27 7:46 ` Juri Linkov
2022-07-27 8:13 ` Robert Pluim
2022-07-27 11:32 ` Eli Zaretskii
2022-07-27 18:54 ` Juri Linkov
2022-07-27 19:23 ` Eli Zaretskii
2022-07-27 19:55 ` Juri Linkov
2022-07-28 5:40 ` Eli Zaretskii
2022-07-28 6:07 ` Eli Zaretskii
2022-07-28 7:13 ` Juri Linkov
2022-07-28 7:56 ` Eli Zaretskii
2022-07-28 7:10 ` Juri Linkov
2022-07-28 7:55 ` Eli Zaretskii
2022-07-28 19:40 ` Juri Linkov
2022-08-30 7:29 ` Juri Linkov
2022-08-31 8:49 ` Robert Pluim
2022-08-31 16:09 ` Juri Linkov
2022-08-31 16:36 ` Robert Pluim
2022-08-31 16:40 ` Eli Zaretskii
2022-08-31 16:56 ` Robert Pluim
2022-08-31 17:13 ` Juri Linkov
2022-08-31 17:22 ` Eli Zaretskii
2022-08-31 17:26 ` Robert Pluim [this message]
2022-08-31 17:29 ` [External] : " Drew Adams
2022-08-31 18:04 ` Juri Linkov
2022-08-31 20:14 ` Stefan Monnier
2022-09-01 7:22 ` Juri Linkov
2022-09-01 8:14 ` Robert Pluim
2022-09-01 11:34 ` Eli Zaretskii
2022-09-01 12:23 ` Robert Pluim
2022-09-01 13:00 ` Stefan Monnier
2022-09-01 13:07 ` Robert Pluim
2022-09-01 15:28 ` Robert Pluim
2022-09-01 15:30 ` Eli Zaretskii
2022-09-01 15:58 ` Robert Pluim
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=8735dcjpd3.fsf@gmail.com \
--to=rpluim@gmail.com \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=juri@linkov.net \
/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).