Subject: bug#65459: completing-read INITIAL-VALUE unaware of COLLECTION and REQUIRE-MATCH

From: Heime <[email-masked]>
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 <[email-masked]> 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.