From: Michael Heerdegen <michael_heerdegen@web.de>
To: 56380@debbugs.gnu.org
Cc: Arash Esbati <arash@gnu.org>,
Stefan Monnier <monnier@iro.umontreal.ca>,
Drew Adams <drew.adams@oracle.com>
Subject: bug#56380: 29.0.50; completing-read: INITIAL-INPUT arg
Date: Mon, 04 Jul 2022 14:18:55 +0200 [thread overview]
Message-ID: <878rp9840g.fsf@web.de> (raw)
[-- Attachment #1: Type: text/plain, Size: 354 bytes --]
Hello,
The docstring of `completing-read' says the argument INITIAL-INPUT is
deprecated - yet there are over 30 nontrivial uses in Emacs' own Elisp
sources. So, although we currently don't want that this argument is
used just to insert a default input, it's sometimes not possible to
avoid using it.
Here is an attempt to improve the documentation:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-completing-read-Clarify-why-to-avoid-INITIAL-INPUT.patch --]
[-- Type: text/x-diff, Size: 2218 bytes --]
From e2a4e843c262416b7b866203a7e636265beb4673 Mon Sep 17 00:00:00 2001
From: Michael Heerdegen <michael_heerdegen@web.de>
Date: Mon, 27 Jun 2022 15:42:58 +0200
Subject: [PATCH] completing-read: Clarify why to avoid INITIAL-INPUT
* src/minibuf.c (completing-read): Don't say INITIAL-INPUT is
deprecated because it's necessary to use it in some cases.
Mention M-n and M-p as well as `minibuffer-with-setup-hook'.
Co-authored-by: Drew Adams <drew.adams@oracle.com>
---
src/minibuf.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/minibuf.c b/src/minibuf.c
index c2e270a450..2ad74e4d38 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -2026,10 +2026,11 @@ DEFUN ("completing-read", Fcompleting_read, Scompleting_read, 2, 8, 0,
initial input is STRING, but point is placed at _zero-indexed_
position POSITION in STRING. (*Note* that this is different from
`read-from-minibuffer' and related functions, which use one-indexing
- for POSITION.) This feature is deprecated--it is best to pass nil
- for INITIAL-INPUT and supply the default value DEF instead. The
- user can yank the default value into the minibuffer easily using
- \\<minibuffer-local-map>\\[next-history-element].
+ for POSITION.) Don't use this argument to insert a default value --
+ use DEF for that. You can use INITIAL-INPUT, for example, to insert
+ a prefix common to all completion candidates. See
+ `minibuffer-with-setup-hook' for a general method to prepare the
+ minibuffer.
HIST, if non-nil, specifies a history list and optionally the initial
position in the list. It can be a symbol, which is the history list
@@ -2044,6 +2045,9 @@ DEFUN ("completing-read", Fcompleting_read, Scompleting_read, 2, 8, 0,
of a history list. If HIST is t, history is not recorded.
DEF, if non-nil, is the default value or the list of default values.
+ These can be yanked into the minibuffer using \
+\\<minibuffer-local-map>\\[next-history-element] and \
+\\[previous-history-element].
If INHERIT-INPUT-METHOD is non-nil, the minibuffer inherits the
current input method and the setting of `enable-multibyte-characters'.
--
2.30.2
[-- Attachment #3: Type: text/plain, Size: 2096 bytes --]
This patch is the result of a discussion in emacs dev:
https://yhetil.org/emacs-devel/87v8smt9lp.fsf@web.de/
Further things mentioned in that discussion:
1. Likewise we want to improve the docstrings of `read-string' and
`read-from-minibuffer'. And as well (Arash Esbati):
Emacs Lisp reference the text/descriptions in
@node Text from Minibuffer
@section Reading Text Strings with the Minibuffer
@node Initial Input
@section Initial Input
@node Minibuffer Completion
@subsection Completion and the Minibuffer
2. Add a minor mode that automatically inserts a DEF into the
minibuffer, and add a defcustom to allow users to enable that mode in
their configuration. Some people simply prefer that behavior. This
would allow people to avoid using INITIAL-INPUT to get what they want.
3. Stefan Monnier:
[...] the `initial-input` arg should be changed into `setup-function`
(so we don't have to use the hideous `minibuffer-with-setup-function`
hack) and using a string there should be deprecated (the rare places
where inserting an initial string makes sense can use a setup-function
instead).
Also the prompt handling should be changed so that it automatically
inserts the default into the prompt. Doing that in a reliable and
backward compatible way is not completely straightforward, tho, so maybe
a simpler solution is to introduce a whole new function instead.
Then a user-customization could also be used to choose between the
current default (where the default is added to the prompt) or the other
option of always inserting the default as initial value (pre-selected
so it can be deleted with a quick DEL).
TIA,
Michael.
In GNU Emacs 29.0.50 (build 13, x86_64-pc-linux-gnu, GTK+ Version 3.24.24, cairo version 1.16.0)
of 2022-07-03 built on drachen
Repository revision: 0de355d8ee729ed6fec3ea379258d4a1f1d49021
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12011000
System Description: Debian GNU/Linux 11 (bullseye)
next reply other threads:[~2022-07-04 12:18 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-04 12:18 Michael Heerdegen [this message]
2022-07-05 11:33 ` bug#56380: 29.0.50; completing-read: INITIAL-INPUT arg Lars Ingebrigtsen
2022-07-05 12:49 ` Arash Esbati
2022-07-05 14:50 ` Drew Adams
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=878rp9840g.fsf@web.de \
--to=michael_heerdegen@web.de \
--cc=56380@debbugs.gnu.org \
--cc=arash@gnu.org \
--cc=drew.adams@oracle.com \
--cc=monnier@iro.umontreal.ca \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.