From: Daniel Mendler <mail@daniel-mendler.de>
To: emacs-devel@gnu.org
Subject: Re: Improvement proposals for `completing-read'
Date: Thu, 8 Apr 2021 11:01:42 +0200 [thread overview]
Message-ID: <264397e8-5a03-9eff-436c-639d76514775@daniel-mendler.de> (raw)
In-Reply-To: <jwv7dld960i.fsf-monnier+emacs@gnu.org>
On 4/7/21 11:26 PM, Stefan Monnier wrote:
> What I meant is that I can't think of many situations where
> we specifically want no history (which is where t is used) as opposed to
> the many situations where we simply don't care about history (in which
> case nil works just as well).
>
> IIRC the t case for read-from-minibuffer was added for the needs of
> `read-passwd` where we really don't want the history, for security reasons.
> I don't know of any other use case yet.
There is one use case I found a bit useful - if you are browsing a
history itself with `completing-read` then you may want to disable
writing to the given or another history at the same time, such that the
completion you are doing is not side-effecting.
I would also like if `completing-read` is consistent with
`read-from-minibuffer` in this case, since this lead to actual
confusion, where the false assumption has been made that
`completing-read` also accepts `t`.
>>>> Proposal 3: Sort file names by history
> Currently we're not even close to that. So I think the first step is to
> fix the code to pay attention to boundaries. My comment was just
> pointing out that this can be done right now a simple bug fix without
> any extra information.
Okay, I also have the code for that approach. It is a simple bug fix as
you say. I dropped it from Vertico for my file name sorting for
performance reasons and since I wanted to do better in the special
important case of files. But no problem to prepare patches for both and
fix the boundaries case first.
> `flex` without sorting is *much* less usable, in my experience.
> The direction of `flex` is actually to replace filtering with sorting.
> E.g. I have a local completion style which I call "forgiving" because it
> tries to accommodate typos in the input, so basically every member of
> the completion table always matches, only its sorting position is
> affected by the input text. So if you removing sorting, there's
> nothing left.
>
> I agree with you that the current way style-based sorting works is
> problematic, but I think the principle of style-based sorting is sound
> because we don't want this to be specific to a UI nor to a backend.
Okay, I see. I am actually not using the flex style since I find it too
slow and generating too many matches. But in the Emacs completion
implementation it will only be triggered if the earlier styles do not
match so maybe that is okay.
I am not using flex since I am using something else - the orderless
style. "regexp1 regexp2 regexp3" matches the regexps in any order.
Furthermore I am using "style dispatchers", "regexp flex~ !not
literal=", where the "flex~" token is used to generate a flex regexp,
etc. Maybe we will see the orderless package in ELPA at some point.
>>>> Proposal 5: Forbid the null completions for `REQUIRE-MATCH=t'
>>>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> Okay, I think it is reasonable to gather some data regarding the extent of
>> the problem. But then I would strongly prefer to just fix the issue. That
>> being said, it was not obvious to me that you can actually force require
>> match by writing a proper completion table which properly handles the
>> `test-completion` action.
>
> No, you can't force require match this way. What you can do this way is
> to re-loosen the match so as to accept the empty-string again like in
> the old (i.e. current) code.
Thanks for clarifying.
>> Yes, that is right. If you care about the actual candidate you get from
>> a set of duplicates, you must use a completion UI which can handle
>> duplicates. If you use an UI which cannot handle this (which rather
>> completes) you cannot get the distinction.
>>
>> I think there is a real need for this if you look at the Swiper command and
>> you want to navigate across equal lines. Then there is the
>> ivy-occur/embark-export/embark-collect command which allows to export the
>> lines to an occur buffer where you can again navigate over the duplicate
>> items. Given how everything is implemented internally (list of candidates,
>> filtering via completion-all-completions etc), it feels like an unnecessary
>> restriction to remove duplicates. It would be more natural to just
>> allow them.
>
> As long as we can offer some way (that's not too cumbersome) to select
> between the different cases using things like self-insert-command + RET,
> I'm fine with it. IOW I think it require reifying the "subtle
> differences" as some kind of optional extra text.
Okay, maybe I can come up with something. This will require
experimentation. The duplicates could be deduplicated at the UI level by
appending some index for example "candidate (1)", "candidate (2)", ...
>>> I suspect "pass the small subset of candidates once again through
>>> `completion-all-completions'" can be tricky to do (e.g. for things like
>>> file-name completion with `partial-completion`).
>> In `vertico--highlight` I am checking the length of the result. If it is not
>> equal to the original length, the UI simply displays the original
>> candidates. This is an ugly hack. Maybe it would be better to have
>> a `completion-style-operation` variable which can be either `'both`,
>> `'filter` or `'highlight`?
>
> I'm not really interested in hacking a slightly better solution, so
> I think your current hack is good enough: the way I see it, the
> replacement of `completion-all-completions` should return
> non-highlighted candidates along with some extra opaque data, and then
> a separate new function can take one of those candidates, together with
> that opaque data (plus some additional optional args) to add highlight
> one candidate at a time.
>
> This way, the highlighting in *Completions* could be applied
> incrementally via jit-lock, and the "additional optional args" should
> make it possible for the UI to have control over the color scheme
> being used.
One thing to consider - maybe returning the highlights as some extra
data is not actually faster than simply propertizing the strings? I
guess you only save the allocations of the strings? The idea of the
proposed hack is really to avoid the entire work of computing the
highlights, since it is mostly unnecessary and slow if you filter many
candidates and display only a small subset. I would therefore go with
the simple solution first since this provable solves the issue. But
using jit-lock in buffers has appeal.
Daniel Mendler
next prev parent reply other threads:[~2021-04-08 9:01 UTC|newest]
Thread overview: 89+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-07 11:16 Improvement proposals for `completing-read' Daniel Mendler
2021-04-07 17:11 ` Stefan Monnier
2021-04-07 17:20 ` Stefan Monnier
2021-04-07 19:46 ` Daniel Mendler
2021-04-07 21:26 ` Stefan Monnier
2021-04-08 9:01 ` Daniel Mendler [this message]
2021-04-08 14:44 ` Stefan Monnier
2021-04-08 15:26 ` Stefan Kangas
2021-04-08 15:47 ` Daniel Mendler
2021-04-08 17:31 ` Stefan Monnier
2021-04-08 15:37 ` Daniel Mendler
2021-04-08 17:22 ` [External] : " Drew Adams
2021-04-08 18:22 ` Dmitry Gutov
2021-04-08 18:48 ` Drew Adams
2021-04-08 19:03 ` Dmitry Gutov
2021-04-08 19:32 ` Drew Adams
2021-04-08 17:30 ` Stefan Monnier
2021-04-08 17:57 ` Daniel Mendler
2021-04-08 18:13 ` Stefan Monnier
2021-04-08 19:15 ` Daniel Mendler
2021-04-08 19:20 ` Dmitry Gutov
2021-04-08 19:46 ` [External] : " Drew Adams
2021-04-08 20:12 ` Dmitry Gutov
2021-04-08 21:12 ` Drew Adams
2021-04-08 22:37 ` Stefan Kangas
2021-04-09 0:03 ` Dmitry Gutov
2021-04-09 2:09 ` Using more and/or better icons in Emacs Stefan Kangas
2021-04-09 3:09 ` Lars Ingebrigtsen
2021-04-09 3:35 ` chad
2021-04-09 12:06 ` Stefan Kangas
2021-04-09 7:41 ` Yuri Khan
2021-04-09 9:59 ` tomas
2021-04-09 11:15 ` Dmitry Gutov
2021-04-09 11:19 ` Dmitry Gutov
2021-04-09 12:22 ` Stefan Kangas
2021-04-09 12:29 ` Dmitry Gutov
2021-04-09 17:46 ` Stefan Kangas
2021-04-09 18:45 ` Eli Zaretskii
2021-04-09 19:30 ` Alan Third
2021-04-09 19:40 ` Alan Third
2021-04-09 22:38 ` Dmitry Gutov
2021-04-10 0:56 ` Stefan Kangas
2021-04-10 1:43 ` Stefan Kangas
2021-04-10 9:12 ` Alan Third
2021-04-10 10:56 ` Stefan Kangas
2021-04-10 13:48 ` Alan Third
2021-04-12 19:39 ` Alan Third
2021-04-13 1:25 ` Stefan Kangas
2021-04-13 7:35 ` Alan Third
2021-04-13 10:39 ` Stefan Kangas
2021-04-13 19:50 ` Alan Third
2021-04-13 22:44 ` Stefan Kangas
2021-04-14 6:46 ` Eli Zaretskii
2021-04-15 15:37 ` Alan Third
2021-04-15 15:50 ` Eli Zaretskii
2021-04-15 17:10 ` Alan Third
2021-04-11 21:57 ` Dmitry Gutov
2021-04-09 23:16 ` Alan Third
2021-04-10 0:55 ` Stefan Kangas
2021-04-10 7:23 ` Eli Zaretskii
2021-04-10 9:17 ` Alan Third
2021-04-10 9:25 ` Eli Zaretskii
2021-04-08 17:22 ` [External] : Re: Improvement proposals for `completing-read' Drew Adams
2021-04-08 18:33 ` Drew Adams
2021-04-07 23:11 ` Drew Adams
2021-04-08 7:56 ` Eli Zaretskii
2021-04-07 18:39 ` Jean Louis
2021-04-07 19:49 ` Daniel Mendler
2021-04-07 22:16 ` Dmitry Gutov
2021-04-08 8:37 ` Daniel Mendler
2021-04-08 20:44 ` Dmitry Gutov
2021-04-08 21:30 ` Daniel Mendler
2021-04-10 2:21 ` Dmitry Gutov
2021-04-10 9:18 ` Daniel Mendler
2021-04-11 0:51 ` Dmitry Gutov
2021-04-11 13:08 ` Daniel Mendler
2021-04-12 0:32 ` Dmitry Gutov
2021-04-12 0:40 ` Daniel Mendler
2021-04-12 10:47 ` Dmitry Gutov
2021-04-12 11:04 ` Daniel Mendler
2021-04-14 0:00 ` Dmitry Gutov
2021-04-14 10:44 ` Daniel Mendler
2021-04-07 23:49 ` [External] : " Drew Adams
2021-04-08 9:29 ` Daniel Mendler
2021-04-08 17:19 ` Drew Adams
2021-04-09 11:19 ` Jean Louis
2021-04-09 11:47 ` Daniel Mendler
2021-04-09 17:22 ` Drew Adams
2021-04-09 17:41 ` Daniel Mendler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=264397e8-5a03-9eff-436c-639d76514775@daniel-mendler.de \
--to=mail@daniel-mendler.de \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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).