unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Continue cycling from a particular element in collection
@ 2023-08-22  7:39 Heime
  2023-08-22 16:04 ` [External] : " Drew Adams
  2023-08-22 21:20 ` Drew Adams
  0 siblings, 2 replies; 10+ messages in thread
From: Heime @ 2023-08-22  7:39 UTC (permalink / raw)
  To: Heime via Users list for the GNU Emacs text editor


I am using 'completing-read' with INITIAL-INPUT to prefill the minibuffer with
the first entry "alpha".  Hew can I then start at index k from collection as the 
next entry.

Thus, initially I have the minibuffer prefilled with "alpha", and after that I get the 
cycling continue from "gamma".

Thus the cycling would be "alpha" "gamma" "theta" "alpha" "beta" and so on.

  (interactive
    (let ( (csel '("alpha" "beta" "gamma" "theta"))
      (list
        (completing-read "Imprint: " csel nil t "alpha")) ))





^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: [External] : Continue cycling from a particular element in collection
  2023-08-22  7:39 Continue cycling from a particular element in collection Heime
@ 2023-08-22 16:04 ` Drew Adams
  2023-08-22 20:41   ` Heime
  2023-08-22 21:20 ` Drew Adams
  1 sibling, 1 reply; 10+ messages in thread
From: Drew Adams @ 2023-08-22 16:04 UTC (permalink / raw)
  To: Heime, Heime via Users list for the GNU Emacs text editor

> I am using 'completing-read' with INITIAL-INPUT to prefill the minibuffer
> with the first entry "alpha".  Hew can I then start at index k from collection
> as the next entry.

There is NO "next entry".  INITIAL-INPUT is simply a string that gets inserted in the minibuffer.  It need not correspond to any candidate provided by argument COLLECTION, meaning that it need not correspond to any completion.

`completing-read' can be LAX, meaning that, if REQUIRE-MATCH is nil or absent then it accepts any text you input - it need not be a completion candidate.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: [External] : Continue cycling from a particular element in collection
  2023-08-22 16:04 ` [External] : " Drew Adams
@ 2023-08-22 20:41   ` Heime
  2023-08-22 21:04     ` Drew Adams
  0 siblings, 1 reply; 10+ messages in thread
From: Heime @ 2023-08-22 20:41 UTC (permalink / raw)
  To: Drew Adams; +Cc: Heime via Users list for the GNU Emacs text editor






Sent with Proton Mail secure email.

------- Original Message -------
On Wednesday, August 23rd, 2023 at 4:04 AM, Drew Adams <drew.adams@oracle.com> wrote:


> > I am using 'completing-read' with INITIAL-INPUT to prefill the minibuffer
> > with the first entry "alpha". Hew can I then start at index k from collection
> > as the next entry.
> 
> 
> There is NO "next entry". INITIAL-INPUT is simply a string that gets inserted in the minibuffer. It need not correspond to any candidate provided by argument COLLECTION, meaning that it need not correspond to any completion.
> 
> `completing-read' can be LAX, meaning that, if REQUIRE-MATCH is nil or absent then it accepts any text you input - it need not be a completion candidate.

Ok, but can I ask completing-read to start from a different point in collection, rather than from the beginning ?



^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: [External] : Continue cycling from a particular element in collection
  2023-08-22 20:41   ` Heime
@ 2023-08-22 21:04     ` Drew Adams
  2023-08-22 21:11       ` Heime
  0 siblings, 1 reply; 10+ messages in thread
From: Drew Adams @ 2023-08-22 21:04 UTC (permalink / raw)
  To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor

> > > I am using 'completing-read' with INITIAL-INPUT to prefill the
> minibuffer
> > > with the first entry "alpha". Hew can I then start at index k from
> collection
> > > as the next entry.
> >
> >
> > There is NO "next entry". INITIAL-INPUT is simply a string that gets
> inserted in the minibuffer. It need not correspond to any candidate
> provided by argument COLLECTION, meaning that it need not correspond to
> any completion.
> >
> > `completing-read' can be LAX, meaning that, if REQUIRE-MATCH is nil or
> absent then it accepts any text you input - it need not be a completion
> candidate.
> 
> Ok, but can I ask completing-read to start from 
> a different point in collection, rather than
> from the beginning ?

Dunno.  I'm no expert on vanilla Emacs cycling,
and I'm not sure what kind of cycling ("next entry")
you have in mind.

If you're using argument DEFAULTS to provide a list
of "entries" then you can of course sort it (or
truncate it) however you like, to affect the "future
history".

If you're using a HISTORY variable and cycling the
(past/real) history then I suppose you could sort
(or truncate) its value.

But entries in neither DEFAULTS nor HISTORY need be
elements of COLLECTION.

If you meant the "future history" elements that are
provided by the misfeature of automatically adding
everything in COLLECTION to that pseudo-history,
then no, AFAIK there's no way to filter, sort, or
truncate the elements from COLLECTION that get added.

But maybe there will be now, since I think they're
considering adding some option that may help here -
dunno.

Maybe someone else will have a useful suggestion.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: [External] : Continue cycling from a particular element in collection
  2023-08-22 21:04     ` Drew Adams
@ 2023-08-22 21:11       ` Heime
  2023-08-22 21:21         ` Heime
  2023-08-22 21:23         ` Drew Adams
  0 siblings, 2 replies; 10+ messages in thread
From: Heime @ 2023-08-22 21:11 UTC (permalink / raw)
  To: Drew Adams; +Cc: Heime via Users list for the GNU Emacs text editor


------- Original Message -------
On Wednesday, August 23rd, 2023 at 9:04 AM, Drew Adams <drew.adams@oracle.com> wrote:


> > > > I am using 'completing-read' with INITIAL-INPUT to prefill the
> > > > minibuffer
> > > > with the first entry "alpha". Hew can I then start at index k from
> > > > collection
> > > > as the next entry.
> > > 
> > > There is NO "next entry". INITIAL-INPUT is simply a string that gets
> > > inserted in the minibuffer. It need not correspond to any candidate
> > > provided by argument COLLECTION, meaning that it need not correspond to
> > > any completion.
> > > 
> > > `completing-read' can be LAX, meaning that, if REQUIRE-MATCH is nil or
> > > absent then it accepts any text you input - it need not be a completion
> > > candidate.
> > 
> > Ok, but can I ask completing-read to start from
> > a different point in collection, rather than
> > from the beginning ?
> 
> 
> Dunno. I'm no expert on vanilla Emacs cycling,
> and I'm not sure what kind of cycling ("next entry")
> you have in mind.

By 'Next Entry' I mean what shows up after INITIAL-INPUT
is shown after pressing <down>.  
 
> If you're using argument DEFAULTS to provide a list
> of "entries" then you can of course sort it (or
> truncate it) however you like, to affect the "future
> history".
> 
> If you're using a HISTORY variable and cycling the
> (past/real) history then I suppose you could sort
> (or truncate) its value.
> 
> But entries in neither DEFAULTS nor HISTORY need be
> elements of COLLECTION.
> 
> If you meant the "future history" elements that are
> provided by the misfeature of automatically adding
> everything in COLLECTION to that pseudo-history,
> then no, AFAIK there's no way to filter, sort, or
> truncate the elements from COLLECTION that get added.
> 
> But maybe there will be now, since I think they're
> considering adding some option that may help here -
> dunno.
> 
> Maybe someone else will have a useful suggestion.



^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: [External] : Continue cycling from a particular element in collection
  2023-08-22  7:39 Continue cycling from a particular element in collection Heime
  2023-08-22 16:04 ` [External] : " Drew Adams
@ 2023-08-22 21:20 ` Drew Adams
  1 sibling, 0 replies; 10+ messages in thread
From: Drew Adams @ 2023-08-22 21:20 UTC (permalink / raw)
  To: Heime, Heime via Users list for the GNU Emacs text editor

>   (interactive
>     (let ( (csel '("alpha" "beta" "gamma" "theta"))

                ;; ) <==== missing

>       (list
>         (completing-read "Imprint: " csel nil t "alpha")) ))

Close your `let' binding before trying to
return a value for `interactive'.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: [External] : Continue cycling from a particular element in collection
  2023-08-22 21:11       ` Heime
@ 2023-08-22 21:21         ` Heime
  2023-08-22 21:27           ` Drew Adams
  2023-08-22 21:23         ` Drew Adams
  1 sibling, 1 reply; 10+ messages in thread
From: Heime @ 2023-08-22 21:21 UTC (permalink / raw)
  To: Heime; +Cc: Drew Adams, Heime via Users list for the GNU Emacs text editor


------- Original Message -------
On Wednesday, August 23rd, 2023 at 9:11 AM, Heime <heimeborgia@protonmail.com> wrote:


> ------- Original Message -------
> On Wednesday, August 23rd, 2023 at 9:04 AM, Drew Adams drew.adams@oracle.com wrote:
> 
> 
> 
> > > > > I am using 'completing-read' with INITIAL-INPUT to prefill the
> > > > > minibuffer
> > > > > with the first entry "alpha". Hew can I then start at index k from
> > > > > collection
> > > > > as the next entry.
> > > > 
> > > > There is NO "next entry". INITIAL-INPUT is simply a string that gets
> > > > inserted in the minibuffer. It need not correspond to any candidate
> > > > provided by argument COLLECTION, meaning that it need not correspond to
> > > > any completion.
> > > > 
> > > > `completing-read' can be LAX, meaning that, if REQUIRE-MATCH is nil or
> > > > absent then it accepts any text you input - it need not be a completion
> > > > candidate.
> > > 
> > > Ok, but can I ask completing-read to start from
> > > a different point in collection, rather than
> > > from the beginning ?
> > 
> > Dunno. I'm no expert on vanilla Emacs cycling,
> > and I'm not sure what kind of cycling ("next entry")
> > you have in mind.
> 
> 
> By 'Next Entry' I mean what shows up after INITIAL-INPUT
> is shown after pressing <down>.
> 
> > If you're using argument DEFAULTS to provide a list
> > of "entries" then you can of course sort it (or
> > truncate it) however you like, to affect the "future
> > history".
> > 
> > If you're using a HISTORY variable and cycling the
> > (past/real) history then I suppose you could sort
> > (or truncate) its value.
> > 
> > But entries in neither DEFAULTS nor HISTORY need be
> > elements of COLLECTION.
> > 
> > If you meant the "future history" elements that are
> > provided by the misfeature of automatically adding
> > everything in COLLECTION to that pseudo-history,
> > then no, AFAIK there's no way to filter, sort, or
> > truncate the elements from COLLECTION that get added.
> > 
> > But maybe there will be now, since I think they're
> > considering adding some option that may help here -
> > dunno.
> > 
> > Maybe someone else will have a useful suggestion.

It is a deficiency on the part of completing-read that makes
INITIAL-INPUT unaware of COLLECTION and of REQUIRE-MATCH.



^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: [External] : Continue cycling from a particular element in collection
  2023-08-22 21:11       ` Heime
  2023-08-22 21:21         ` Heime
@ 2023-08-22 21:23         ` Drew Adams
  1 sibling, 0 replies; 10+ messages in thread
From: Drew Adams @ 2023-08-22 21:23 UTC (permalink / raw)
  To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor

> > I'm not sure what kind of cycling ("next entry")
> > you have in mind.
> 
> By 'Next Entry' I mean what shows up after INITIAL-INPUT
> is shown after pressing <down>.

In the case of the code you showed (corrected
by adding missing right paren), that's the
COLLECTION arg that gets added automatically
to "future history"

Yes, you can sort COLLECTION any way you want,
and that will presumably control the order of
those elements of future history that are added
from COLLECTION.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: [External] : Continue cycling from a particular element in collection
  2023-08-22 21:21         ` Heime
@ 2023-08-22 21:27           ` Drew Adams
  2023-08-22 21:45             ` Heime
  0 siblings, 1 reply; 10+ messages in thread
From: Drew Adams @ 2023-08-22 21:27 UTC (permalink / raw)
  To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor

> It is a deficiency on the part of completing-read that makes
> INITIAL-INPUT unaware of COLLECTION and of REQUIRE-MATCH.

M-x report-emacs-bug

But specify clearly what you have in mind,
that is, what you _think_ you want.
___

INITIAL-INPUT is text to put in the minibuffer
at the outset.  It need not have any connection
with anything.  It need not ever be entered or
even edited.  It can be just a message "Happy
Birthday!", if you like.

INITIAL-INPUT has nothing, a priori, to do with
completion, hence with COLLECTION or with
REQUIRE-MATCH.

Read the doc.  Experiment.  Try to understand
how each arg can be used in different ways.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: [External] : Continue cycling from a particular element in collection
  2023-08-22 21:27           ` Drew Adams
@ 2023-08-22 21:45             ` Heime
  0 siblings, 0 replies; 10+ messages in thread
From: Heime @ 2023-08-22 21:45 UTC (permalink / raw)
  To: Drew Adams; +Cc: Heime via Users list for the GNU Emacs text editor






Sent with Proton Mail secure email.

------- Original Message -------
On Wednesday, August 23rd, 2023 at 9:27 AM, Drew Adams <drew.adams@oracle.com> wrote:


> > It is a deficiency on the part of completing-read that makes
> > INITIAL-INPUT unaware of COLLECTION and of REQUIRE-MATCH.
> 
> 
> M-x report-emacs-bug
> 
> But specify clearly what you have in mind,
> that is, what you think you want.
> ___
> 
> INITIAL-INPUT is text to put in the minibuffer
> at the outset. It need not have any connection
> with anything. It need not ever be entered or
> even edited. It can be just a message "Happy
> Birthday!", if you like.
> 
> INITIAL-INPUT has nothing, a priori, to do with
> completion, hence with COLLECTION or with
> REQUIRE-MATCH.

That's its design, but the design is too primitive
and only works in isolation to everything else.

Suppose you want INITIAL-VALUE to be aware of COLLECTION and
of REQUIRE-MATCH.  You can't.  Suppose you want INITIAL-VALUE
to match entry in collection.  Then suppose INITIAL-VALUE is
identical to first element in collection, and you want to skip 
the first entry in collection that would currently show the same
string as INITIAL-VALUE.  You can't.  A half baked implementation
that now some want it to do even more things.  

First one has to make a good job and do it well before complicating
things further.
 
 
> Read the doc. Experiment. Try to understand
> how each arg can be used in different ways.



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-08-22 21:45 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-22  7:39 Continue cycling from a particular element in collection Heime
2023-08-22 16:04 ` [External] : " Drew Adams
2023-08-22 20:41   ` Heime
2023-08-22 21:04     ` Drew Adams
2023-08-22 21:11       ` Heime
2023-08-22 21:21         ` Heime
2023-08-22 21:27           ` Drew Adams
2023-08-22 21:45             ` Heime
2023-08-22 21:23         ` Drew Adams
2023-08-22 21:20 ` Drew Adams

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).