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


Message #26 received at 65459 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Heime <heimeborgia <at> protonmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 65459 <at> debbugs.gnu.org
Subject: Re: bug#65459: completing-read INITIAL-VALUE unaware of COLLECTION
 and REQUIRE-MATCH
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





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.