GNU bug report logs - #56380
29.0.50; completing-read: INITIAL-INPUT arg

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Severity: wishlist; Reported by: Michael Heerdegen <michael_heerdegen@HIDDEN>; dated Mon, 4 Jul 2022 12:20:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 56380 <at> debbugs.gnu.org:


Received: (at 56380) by debbugs.gnu.org; 5 Jul 2022 11:33:32 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jul 05 07:33:32 2022
Received: from localhost ([127.0.0.1]:49456 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1o8go7-0003pC-OE
	for submit <at> debbugs.gnu.org; Tue, 05 Jul 2022 07:33:31 -0400
Received: from quimby.gnus.org ([95.216.78.240]:42932)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <larsi@HIDDEN>) id 1o8go5-0003oy-Fp
 for 56380 <at> debbugs.gnu.org; Tue, 05 Jul 2022 07:33:29 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org;
 s=20200322; h=Content-Type:MIME-Version:Message-ID:Date:References:
 In-Reply-To:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:
 Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender:
 Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:
 List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=MZcPvccKnfA1XVC2v2K0wYVEy1x6iP6fVLYWKlS99nA=; b=KXZAzXepPhfhH4Vhy4AaZGFUhr
 JN3avVI8qurlB3yAdTkmhznKqz7gwkZgOzSKR0wnfPdF84uH1bIo9l4J7lI2bV0ixqtWG2fzPFGBD
 bV3aMTZzRg/ucoAET+nm4InkiClOaijP+sexUIwCsQNTVClN4B6MWfFYE/WeV6nnForc=;
Received: from [84.212.220.105] (helo=joga)
 by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.92) (envelope-from <larsi@HIDDEN>)
 id 1o8gnq-00015x-3R; Tue, 05 Jul 2022 13:33:16 +0200
From: Lars Ingebrigtsen <larsi@HIDDEN>
To: Michael Heerdegen <michael_heerdegen@HIDDEN>
Subject: Re: bug#56380: 29.0.50; completing-read: INITIAL-INPUT arg
In-Reply-To: <878rp9840g.fsf@HIDDEN> (Michael Heerdegen's message of "Mon, 04
 Jul 2022 14:18:55 +0200")
References: <878rp9840g.fsf@HIDDEN>
X-Now-Playing: Eurythmics's _In The Garden_: "Belinda"
Date: Tue, 05 Jul 2022 13:33:12 +0200
Message-ID: <87v8sb4ww7.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 @@CONTACT_ADDRESS@@ for details.
 Content preview:  Michael Heerdegen <michael_heerdegen@HIDDEN> writes: > 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 th [...] 
 Content analysis details:   (-2.9 points, 5.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -1.0 ALL_TRUSTED            Passed through trusted hosts only via SMTP
 -1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%
 [score: 0.0000]
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 56380
Cc: Arash Esbati <arash@HIDDEN>, Stefan Monnier <monnier@HIDDEN>,
 Drew Adams <drew.adams@HIDDEN>, 56380 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Michael Heerdegen <michael_heerdegen@HIDDEN> writes:

> 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.

[...]

> +  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.

It's an improvement on the original text, but this makes it sound like
inserting a common prefix is something callers are expected to do.  (But
instead it's a super rare special case that virtually nobody would
actually do in practice.)  So I'd rather just remove that sentence about
what you can use INITIAL-INPUT for.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#56380; Package emacs. Full text available.
Severity set to 'wishlist' from 'normal' Request was from Stefan Kangas <stefan@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 4 Jul 2022 12:19:17 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jul 04 08:19:17 2022
Received: from localhost ([127.0.0.1]:46380 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1o8L2q-0001ka-Kc
	for submit <at> debbugs.gnu.org; Mon, 04 Jul 2022 08:19:16 -0400
Received: from lists.gnu.org ([209.51.188.17]:49044)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <michael_heerdegen@HIDDEN>) id 1o8L2o-0001kQ-32
 for submit <at> debbugs.gnu.org; Mon, 04 Jul 2022 08:19:15 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:50282)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <michael_heerdegen@HIDDEN>)
 id 1o8L2m-0006p0-Vg
 for bug-gnu-emacs@HIDDEN; Mon, 04 Jul 2022 08:19:13 -0400
Received: from mout.web.de ([212.227.17.11]:59041)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <michael_heerdegen@HIDDEN>)
 id 1o8L2h-0008Ic-L7; Mon, 04 Jul 2022 08:19:12 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de;
 s=dbaedf251592; t=1656937137;
 bh=LFjjamDwI5fflqmiNzneHunfq4S2uIY6DdfjE8Jb/7I=;
 h=X-UI-Sender-Class:From:To:Cc:Subject:Date;
 b=dDgtSr6QGTgRCD/r2nB7vegkUk1ZRs6268wUbHK5rq8w+A+7h6iU7kKcX5lOjTDL7
 A8qY/0UkSfYUpJPh51j0P4I4SLz3nCXvmHuzrX7sg1ROtnw6J8oTvyp6Eplfoe1mva
 ijk2mXv4O1meO/UWobGhXPZmK9TaIwzKcB5iyshI=
X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9
Received: from drachen.dragon ([88.66.201.45]) by smtp.web.de (mrweb106
 [213.165.67.124]) with ESMTPSA (Nemesis) id 1Mv3Yg-1nHKqW3vKS-00rKku; Mon, 04
 Jul 2022 14:18:57 +0200
From: Michael Heerdegen <michael_heerdegen@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 29.0.50; completing-read: INITIAL-INPUT arg
Date: Mon, 04 Jul 2022 14:18:55 +0200
Message-ID: <878rp9840g.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-Provags-ID: V03:K1:bjtN2CusgdyEvGPtGfDcwvp/lrnNXQ2ie3G61Eg2KO5EePp4grP
 n7bM0/Dx+reihDb3uIeeeOP13jgD7/1m1hqv8JInGcoAbIqMXAQ/VXQE8E6Oa8N1ELIoVfs
 dcVu1eh0mjxAW9c+9N6iiZ4gETwUkMUqXwBydrVNAHqzLSzovgzNoWWXkJl7oG7Yv8BrkjP
 xeGuWtaPv8a6t+cW3iFLw==
X-Spam-Flag: NO
X-UI-Out-Filterresults: notjunk:1;V03:K0:VJ4iZ4DIQOQ=:1m98gEE/wp+Xfr6Y3Ah5G8
 Lzc7mY4j8h4Djui72GyG0NhlnmEmNrIh67oQU50OV0WsVoIYjgCWzVvx6GCR9vVrlC618I+7u
 jBTh7QAuuUs9/xBDeQw4/dTqNC4hy5FY/R+r3zuBJDi+U6TzGBAp87P3X9/MiFE/U8/kWrjwg
 oHfXVrTms4CUPDQx6WXcfesu26GRHmHDUyWIaPXty2zPGbu8r3ZXa5QYr9AjW47tunsWgGEL2
 5LkLwteb/l/YitksUKdMPWuwjd+6r7c+xQi0NtPsBJBSnlUl9UDzAPHqXPqx2WXDQAl8ndLDZ
 I5FeVoH2ZcJ/Qzx+NQyNiIygAaMi9DbYJCwf3b7B+XFgAOzT5tk+fl4yg6EyvWKgXlWJRhlmy
 4wZf2NGVLTYg2HxtOoRdLhZQVmdf2cABAiwGvLZFvyMTo6ry9ucID0Ut+9YxEQXteuvRBGk90
 RxXoXDKCIj5PhgqvTXXz1nkYfEGY9VepUuuAVQS4MILcR3wUV4XdsKFSUFKrspLsHhw69sM34
 plkNusfCZXXObq2Sxn8TZAQUybLuyk0A1khBSUPiin++1nVCZW20JGtKxhA7CDYSf0SpqlO+V
 /egkGqgG2gkgn9PusEgLXfaX9YMh2CbAi8ElxVI1wUGhaQMtLV4X759WTK/kAropeP8ErbA7s
 nD6Ee6QIVRta5nobbC3o3Ou6yvEOGfvQ0m471E3/Z/ye39gZQ4IVaVrOjEQNlDFhxNW+waFJI
 qsFsD9RcC8Sf1kl/w6NTzOPsGIrAPS6dSbp0MgrL+V6g7JcaGlTdi0QIqKHUHRnZiioTRJ+hV
 a8+TxHaxxcgDwzGZeBRMaNu/89OOhN1YtCRILksC7pSDSgVv+zt6nFiB1acBpKbivyZs/c0kt
 vIFp9lUdin8vP/IPV1N/zQuNuZxXmj+Clg+Cp/3pAUu1JbiburZ/lT7E3y90cicXzW5Wjmaj7
 vi0NqvHPTo2IMRjEpqubkqidthFa3iHkdu/nOIoAEjAJdJuAnZN8YjIv75+FofROWFHlTTvm7
 TgFdF3weTGQ/fjctz34wNMHxtequuHu9zbbkKfAAkvwmVuDKV48CNTSRKY+Iia88iEG5i3iZv
 L8qTMeg1N6mbIyU8vbcVNFIy1BB7yloIXXFe/jfagY+0z5+aSFyk7mVNg==
Received-SPF: pass client-ip=212.227.17.11;
 envelope-from=michael_heerdegen@HIDDEN; helo=mout.web.de
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,
 RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 0.2 (/)
X-Debbugs-Envelope-To: submit
Cc: Arash Esbati <arash@HIDDEN>, Stefan Monnier <monnier@HIDDEN>,
 Drew Adams <drew.adams@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.4 (--)

--=-=-=
Content-Type: text/plain


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:


--=-=-=
Content-Type: text/x-diff
Content-Disposition: inline;
 filename=0001-completing-read-Clarify-why-to-avoid-INITIAL-INPUT.patch
Content-Transfer-Encoding: quoted-printable

=46rom e2a4e843c262416b7b866203a7e636265beb4673 Mon Sep 17 00:00:00 2001
From: Michael Heerdegen <michael_heerdegen@HIDDEN>
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@HIDDEN>
=2D--
 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
=2D-- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -2026,10 +2026,11 @@ DEFUN ("completing-read", Fcompleting_read, Scompl=
eting_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, Scomplet=
ing_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'.
=2D-
2.30.2


--=-=-=
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable


This patch is the result of a discussion in emacs dev:

  https://yhetil.org/emacs-devel/87v8smt9lp.fsf@HIDDEN/

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)


--=-=-=--




Acknowledgement sent to Michael Heerdegen <michael_heerdegen@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#56380; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Tue, 5 Jul 2022 11:45:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.