From: Eli Zaretskii <eliz@gnu.org>
To: Spencer Baugh <sbaugh@janestreet.com>,
Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 65137@debbugs.gnu.org
Subject: bug#65137: 29.1; completion-substring-try-completion doesn't return the longest common substring
Date: Tue, 08 Aug 2023 14:04:09 +0300 [thread overview]
Message-ID: <83a5v1okwm.fsf@gnu.org> (raw)
In-Reply-To: <ierr0oe4esg.fsf@janestreet.com> (message from Spencer Baugh on Mon, 07 Aug 2023 19:24:15 -0400)
> From: Spencer Baugh <sbaugh@janestreet.com>
> Date: Mon, 07 Aug 2023 19:24:15 -0400
>
>
> The substring completion style differs from the "basic" style by
> performing completion at the start of the input string. So for example,
> both of these are valid completions for "bar":
>
> (completion-substring-all-completions "bar" '("foobar" "foobarbaz") #'identity (length "bar"))
> -> ("foobarbaz" "foobar" . 0)
>
> However, the substring completion style's try-completion implementation
> does not reflect this. Since "foobar" is a prefix of all the valid
> completions, it should be returned by try-completion. But it is not,
> regardless of the location of point:
>
> (completion-substring-try-completion "bar" '("foobar" "foobarbaz") #'identity 0)
> -> ("bar" . 3)
>
> (completion-substring-try-completion "bar" '("foobar" "foobarbaz") #'identity (length "bar"))
> -> ("bar" . 3)
>
> This breaks completion when one completion candidate is a prefix of
> other completion candidates. The recourse is moving point to the start
> of the input, so that the "basic" completion style takes over, which
> will correctly insert the common prefix:
>
> (completion-basic-try-completion "bar" '("foobar" "foobarbaz") #'identity 0)
> -> ("foobar" . 6)
>
> However, even this does not work in the project-file and xref-location
> completion categories, for which the "basic" style is not included in
> completion-category-defaults. For such completion categories, there's
> simply no way to use completion to insert a common prefix. This is bad,
> because a filename or identifier might easily be a prefix of another
> filename or identifier.
>
> The solution is completion-substring-try-completion to be fixed to
> insert these common prefixes. I'll try and fix this, although the code
> is a bit intimidating.
Adding Stefan, in case he has some comments or ideas.
next prev parent reply other threads:[~2023-08-08 11:04 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-07 23:24 bug#65137: 29.1; completion-substring-try-completion doesn't return the longest common substring Spencer Baugh
2023-08-07 23:50 ` Spencer Baugh
2023-08-08 0:41 ` Spencer Baugh
2023-08-08 11:04 ` Eli Zaretskii [this message]
2023-08-08 12:40 ` sbaugh
2023-08-30 1:31 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-05 19:51 ` Spencer Baugh
2023-09-05 21:26 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-06 11:00 ` Eli Zaretskii
2023-08-25 0:40 ` Dmitry Gutov
2023-08-25 2:30 ` Drew Adams
2023-08-29 15:45 ` Spencer Baugh
2023-08-29 23:25 ` Dmitry Gutov
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=83a5v1okwm.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=65137@debbugs.gnu.org \
--cc=monnier@iro.umontreal.ca \
--cc=sbaugh@janestreet.com \
/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).