bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#65459: completing-read INITIAL-VALUE unaware of COLLECTION and REQUI


From: Stefan Monnier
Subject: bug#65459: completing-read INITIAL-VALUE unaware of COLLECTION and REQUIRE-MATCH
Date: Thu, 24 Aug 2023 15:35:46 -0400
User-agent: Gnus/5.13 (Gnus v5.13)

>> My question is not about INITIAL-INPUT but about the behavior that the
>> user sees: why do you want the users of your code to see a minibuffer
>> that is prefilled rather than one whose content is initially empty?
>
> I was planning something like for 'read-file-name' where one can expect 
> that the initial input will very likely be the part the user will end up
> typing,

You mean if the users will probably select "Chronological Dating",
you want to prefill the buffer so they don't need to type it and just
hit RET?

Using the DEFault arg gives you the same benefit without prefilling the
minibuffer, so I must be missing something.  What would be the advantage
for the users by prefilling the minibuffer with "Chronological Dating"?

>> So, IIUC, you have a `completing-read` call asking them which template
>> to insert, and you want to order the set of completions based on
>> knowledge of the stage at which they are?
> No ordering actually happens, a particular element in collection is used
> to prefill the minibuffer entry and consecutive elements in simple 
> cycling continue through the next stages.

Yes, the ordering I'm talking about is the order in the operational
flow refined such that if the likely next stage is "Composition and
Provenance", then you'll want to use:

    "Composition and Provenance" "Isotope Analysis" "Physical Analysis" 
"Chronological Dating"

That's what you want, right?

>> I suspect you'll want to use a COLLECTION that explicitly asks to not be
>> (re)sorted and which you "manually" re-order before the call, so that
>> the sort order you choose is obeyed not just by this specific cycling
>> you're using but also for users who rely on different UIs.
> Actually, tho order is only obeyed for the specific cycling I am using, but
> users have the possibility to use a different UI such as the usual 
> manipulation
> possibilities provided by completing read.

You mean, if they use, say, `icomplete-mode` or `vertico-mode`, you'd
prefer that those UIs use an alphabetical ordering rather than the one
based on operational flow?

>> I don't see any part there that explains why the minibuffer needs to be
>> prefilled, but that is usually handled separately from the
>> completions anyway. - Stefan
> Then my conclusion is that the introduction of INITIAL for 'completing-read'
> was a mistake.  That completing-read should only be about completion.  And 
> that
> prefilling the minibuffer should involve a separate function call.

FWIW, I tend to agree and if(?) we introduce a new API I'd replace this
INITIAL-INPUT argument with a function which could then do what we
usually do via the `minibuffer-with-setup-hook` hack.


        Stefan






reply via email to

[Prev in Thread] Current Thread [Next in Thread]