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

From: Stefan Monnier <[email-masked]>
Date: Wed, 23 Aug 2023 12:58:40 -0400

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

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