[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [External] : Re: Stepping Back: A Wealth Of Completion systems Re: [
From: |
Drew Adams |
Subject: |
RE: [External] : Re: Stepping Back: A Wealth Of Completion systems Re: [ELPA] New package: vertico |
Date: |
Mon, 12 Apr 2021 18:36:12 +0000 |
> > 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.
> >
> > The best I can think of is using hash-maps to generate anonymous methods
> > but even that seems to be looking at the issue backwards.
>
> This is my main complaint with `completing-read' -- you can pass it data
> structures like alists or hash tables, but you still only get the string
> keys back out of it. In the past I've imagined being able to pass a
> lambda to `completing-read' (as if it didn't have enough arguments) that
> would be used to extract the desired value. If we're going to build an
> ad-hoc structure specifically for completion, we could just build it
> inside the call to `completing-read', and it could do the caching and
> value extraction.
I already mentioned that you can put the _full_ candidate
-- whatever Lisp object it might be -- on the _display_
candidate, which is just a string.
Then, providing you have a `completing-read' that doesn't
strip off text properties, you have everything you need,
just in the returned string.
How to put the full candidate, which might be a list or
whatever, on just a string?
Suppose the full candidate is an alist entry:
("cand" . WHATEVER). The display candidate is "cand".
Users match against it, and that's what `completing-read'
returns. But you want to get the WHATEVER when "cand"
is chosen.
Just replace "cand" by a copy of that string with a text
property that has value WHATEVER:
(defun my-put-whole-cand-prop (cand)
"Put cdr of CAND on its car, as text property `my-whole-cand'.
Returns a new propertized string corresponding to (car CAND)."
(let ((text-cand (copy-sequence (car cand))))
(put-text-property 0 (length text-cand)
'my-whole-candidate (cdr cand)
text-cand)
(setcar cand text-cand)
text-cand))
Use (get-text-property STRING 'my-whole-cand') to get
back WHATEVER.
If you wanted the full candidate, ("cand" . WHATEVER),
instead of just WHATEVER, then you'd use that as the
property value.
___
I do the same thing with bookmarks, so you can have more
than one bookmark with the same name. In that case, I
put the full bookmark, a list whose car is the bookmark
name, on that name as a property:
(put-text-property 0 (length bname) 'full-record bmk bname)
So the full bookmark has a car that's a string that
contains the full bookmark as a property. And yes, that
full bookmark that's the property value has a car that's
the string that contains...
- Re: Stepping Back: A Wealth Of Completion systems Re: [ELPA] New package: vertico, (continued)
- Re: Stepping Back: A Wealth Of Completion systems Re: [ELPA] New package: vertico, Eli Zaretskii, 2021/04/11
- Re: Stepping Back: A Wealth Of Completion systems Re: [ELPA] New package: vertico, Philip Kaludercic, 2021/04/11
- Re: Stepping Back: A Wealth Of Completion systems Re: [ELPA] New package: vertico, Eli Zaretskii, 2021/04/11
- Re: Stepping Back: A Wealth Of Completion systems Re: [ELPA] New package: vertico, Jean Louis, 2021/04/11
- Re: Stepping Back: A Wealth Of Completion systems Re: [ELPA] New package: vertico, Philip Kaludercic, 2021/04/11
- Re: Stepping Back: A Wealth Of Completion systems Re: [ELPA] New package: vertico, Jean Louis, 2021/04/12
- Re: Stepping Back: A Wealth Of Completion systems Re: [ELPA] New package: vertico, Philip Kaludercic, 2021/04/12
- Re: Stepping Back: A Wealth Of Completion systems Re: [ELPA] New package: vertico, Jean Louis, 2021/04/12
- Re: Stepping Back: A Wealth Of Completion systems Re: [ELPA] New package: vertico, Philip Kaludercic, 2021/04/12
- Re: Stepping Back: A Wealth Of Completion systems Re: [ELPA] New package: vertico, Eric Abrahamsen, 2021/04/12
- RE: [External] : Re: Stepping Back: A Wealth Of Completion systems Re: [ELPA] New package: vertico,
Drew Adams <=
- Re: [External] : Re: Stepping Back: A Wealth Of Completion systems Re: [ELPA] New package: vertico, Eric Abrahamsen, 2021/04/12
- RE: [External] : Re: Stepping Back: A Wealth Of Completion systems Re: [ELPA] New package: vertico, Drew Adams, 2021/04/12
- Re: [External] : Re: Stepping Back: A Wealth Of Completion systems Re: [ELPA] New package: vertico, Eric Abrahamsen, 2021/04/12
- RE: [External] : Re: Stepping Back: A Wealth Of Completion systems Re: [ELPA] New package: vertico, Drew Adams, 2021/04/12
- Re: Stepping Back: A Wealth Of Completion systems Re: [ELPA] New package: vertico, Stefan Monnier, 2021/04/12
- Re: Stepping Back: A Wealth Of Completion systems Re: [ELPA] New package: vertico, Dmitry Gutov, 2021/04/13
- Re: Stepping Back: A Wealth Of Completion systems Re: [ELPA] New package: vertico, Philip Kaludercic, 2021/04/21
- Re: Stepping Back: A Wealth Of Completion systems Re: [ELPA] New package: vertico, Eli Zaretskii, 2021/04/21
- Re: Stepping Back: A Wealth Of Completion systems Re: [ELPA] New package: vertico, Philip Kaludercic, 2021/04/21
- Re: Stepping Back: A Wealth Of Completion systems Re: [ELPA] New package: vertico, Eli Zaretskii, 2021/04/21