[Top][All Lists]

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

Re: Stepping Back: A Wealth Of Completion systems Re: [ELPA] New package

From: Jean Louis
Subject: Re: Stepping Back: A Wealth Of Completion systems Re: [ELPA] New package: vertico
Date: Mon, 12 Apr 2021 13:56:27 +0300
User-agent: Mutt/2.0.6 (2021-03-06)

* Philip Kaludercic <philipk@posteo.net> [2021-04-12 13:15]:
> Jean Louis <bugs@gnu.support> writes:
> > * Philip Kaludercic <philipk@posteo.net> [2021-04-11 18:53]:
> >> Jean Louis <bugs@gnu.support> writes:
> >> 
> >> > One way I use for complex data structures is to have some kind of ID
> >> > and visual description, then by using the ID I fetch the data
> >> > structure later.
> >> 
> >> I'm not sure I completely understood your example. What do hash tables
> >> offer over lists of objects that can have a programmed
> >> representation?
> >
> > Completing read supports hash tables, once representation candidate
> > has been selected one can then use the key to get value of some quite
> > different or very complex data structure.
> >
> > (setq h (make-hash-table :test 'equal))
> > (puthash "United States" [("ABC" 30 t)] h)
> > (puthash "Australia" 2 h)
> > (puthash "United Kingdom" 3 h)
> >
> > (message "%s" (gethash (completing-read "Choice: " h) h)) ⇒ "[(ABC 30 t)]"
> But don't you think that it is weird that completing-read returns the
> representation and not the object itself. That is exactly what I want to
> avoid by having the representation computed using a method.

That could be implemented as some new options.

But users like me may not always want to use hash, I may want to use
the key, though the key has some optional data, I may wish to use key
only. At some other times I may want to use value in the hash or part
of that value.

How I understand, you want to use values or some variable data to
compute representation, fine and I hope it will not break standard

Side note, representation by hash key does not really support
duplicates, so when constructing a key, I am adding the unique ID to
the key to avoid duplicates. Maybe usages of duplicates is not
clear. Completion candidates could be in some order like

"Expenses" - could carry value 1
"Expenses" - could carry value 2

and by looking into the order user could recognize that second one is
the one that is wanted. But as there is no option to have duplicates
in a hash, I am modifying keys to carry unique ID.


Take action in Free Software Foundation campaigns:

Sign an open letter in support of Richard M. Stallman

reply via email to

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