emacs-devel
[Top][All Lists]
Advanced

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

Re: Improvement proposals for `completing-read'


From: Daniel Mendler
Subject: Re: Improvement proposals for `completing-read'
Date: Thu, 8 Apr 2021 19:57:50 +0200

On 4/8/21 7:30 PM, Stefan Monnier wrote:
Yes, that would be the best possibility. There are many ways to provide that
data: Via a text property, via an extra metadata function, etc. In the case
of Swiper the extra data could simply be the line number. However a general
solution should also automatically generate indices, since it is probably
better to not require the completion table to provide the information in any
case. I would like some graceful degradation.
E.g. for a completion table of something like Swiper, every entry would
contain the line's text plus a suffix containing the line number.
And then the metadata would tell the UI how it can hide the suffix if it
doesn't need textual uniqueness.

This is similar to what I am doing in my `consult-line` command, which is a Swiper equivalent. There I encode the line number in Unicode characters of some private plane and hide them with 'invisible or 'display. At least it is unlikely that we don't get unintentional matches on those prefixes. But is still a very ugly hack.

If I could mark that part of the string as 'unmatchable I would be happy to! Maybe that's the cleaner solution? The nice advantage is that it would be backward compatible. I could just start to mark my prefixes as 'unmatchable and the basic completion style would suddenly start to work. On older Emacs versions everything would continue to work as is; the user is required to use a completion style which matches substrings, e.g., substring, orderless, flex, etc.

One thing to consider - maybe returning the highlights as some extra data is
not actually faster than simply propertizing the strings?
The extra opaque data is cheap/free to compute.  It would not contain
"the highlights", but just the side information that might be needed to
compute the highlights: e.g. you can't do the highlighting correctly for
`partial-completion` without having access to the "pattern" against
which it was matched.
I don't think this is true.
[...]

I don't see anything in your description that disagrees with what
I said, so it looks like we're in "violent agreement" ;-)

Ok, I didn't get it. But I violently agree :)

Daniel



reply via email to

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