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: Heime
Subject: bug#65459: completing-read INITIAL-VALUE unaware of COLLECTION and REQUIRE-MATCH
Date: Thu, 24 Aug 2023 20:22:45 +0000

------- Original Message -------
On Friday, August 25th, 2023 at 7:35 AM, Stefan Monnier 
<monnier@iro.umontreal.ca> wrote:

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

Correct.
 
> 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"?

Yes, without prefilling the minibuffer.  Prefilling the minibuffer is quicker
for users, giving them the possibility to see the current stage if they forget 
default key shortcuts.  The more we discuss this the more it seems the 
prefilling
the minbuffer was something we never wanted users to have. 

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

Correct, but the actual collection might still be 

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

Rather than applying modifications to it, I can just specify the start index.
 
> > > 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 would think that if they use vertico, there is a reason that is convenient
to them to use cempletion, if they are not employing simple cycling (through
repeated use of <down>). 
 
> > > 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

Quite right, and help programmers from the need to go as low level as 
calling 'minibuffer-with-setup-hook' hacks.  The unfortunate thing is that
the inclusion of INITIAL makes people want to use it, as I did in certain 
circumstances.   Having to go through 'minibuffer-with-setup-hook' hacks
is not something one looks forward to do in the interactive clause of a 
function.







reply via email to

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