GNU bug report logs - #65459
completing-read INITIAL-VALUE unaware of COLLECTION and REQUIRE-MATCH

Previous Next

Package: emacs;

Reported by: Heime <heimeborgia <at> protonmail.com>

Date: Tue, 22 Aug 2023 22:05:02 UTC

Severity: normal

Full log


View this message in rfc822 format

From: Heime <heimeborgia <at> protonmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 65459 <at> debbugs.gnu.org
Subject: bug#65459: completing-read INITIAL-VALUE unaware of COLLECTION and REQUIRE-MATCH
Date: Wed, 23 Aug 2023 18:12:22 +0000




Sent with Proton Mail secure email.

------- Original Message -------
On Thursday, August 24th, 2023 at 4:58 AM, Stefan Monnier <monnier <at> iro.umontreal.ca> wrote:


> > > Could you give a bit more context about why/where you'd want to do that
> > > so I can better imagine how to attack the problem?
> > > 
> > > Hopefully it would explain why you want "alpha epsilon ..." first but
> > > "alpha beta .." later.
> > 
> > In such instance one considers collection as a cyclic list for the case of
> > simple cycling. But with possibility of starting from a particular index.
> 
> 
> So the initial "alpha" is simply not considered, OK, that makes sense,
> so given that the ordering of COLLECTION happens to be preserved, you
> can get the above behavior if you reorder COLLECTION before the call, as
> in:
> 
> (let ((cseq '("epsilon" "zeta" "eta" "alpha" "beta" "gamma" "delta")))
> (completing-read "Grapheme: " cseq nil t "alpha"))
 
> > > Also for such uses of `completing-read` we usually recommend against a
> > > non-nil value for INITIAL-INPUT, so that context should try to explain
> > > why you use "alpha" as INITIAL-INPUT. - Stefan
> > > Because using INITIAL is the only way available to pre-insert a value in
> > > the minibuffer.
> 
> That's a bit tautological.
> What I meant is why do you need to preinsert a value?

In particular cases, the pre-insertion indicates to the user
the kind of input structure of collection that can help him
apply a completion strategy for traversing the possibilities.

 
> The normal/recommended call looks like:
> 
> (let ((cseq '("alpha" "beta" "gamma" "delta" "epsilon" "zeta" "eta")))
> (completing-read (format-prompt "Grapheme" "alpha")
> cseq nil t nil nil "alpha"))
> 
> [ Yes, it's a bit cumbersome: hysterical raisins :-( ] - Stefan

Correct.  The solution involves an unwieldy parameter configurations, and possibly 
using convoluted workarounds to achieve the desired behavior.  This scenario implies
that using the function as intended requires a level of effort, understanding, and 
manipulation that goes beyond direct usage.






This bug report was last modified 1 year and 289 days ago.

Previous Next


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