unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Teach completion to insert a common prefix
@ 2023-08-07 20:38 Spencer Baugh
  2023-08-08  6:19 ` Yuri Khan
  0 siblings, 1 reply; 4+ messages in thread
From: Spencer Baugh @ 2023-08-07 20:38 UTC (permalink / raw)
  To: help-gnu-emacs


Example in emacs -Q:

C-h v -matching-lines- TAB

All possible completions for -matching-lines- start with
list-matching-lines-.  So there would be no harm in inserting "list" at
the start of the completion input.  But Emacs does not do this.

Is it possible to teach Emacs completion to insert a common prefix if
there is one, like in this situation?

Two reasons:

- It would look nicer

- It would make completion work better if the desired completion
alternative is itself a prefix of some other alternative.  For example,
if both list-matching-lines-buffer and list-matching-lines-buffer-face
are available completion alternatives, then it is hard to use completion
to input list-matching-lines-buffer, since it only completes to
-matching-lines-buffer which is not an actual alternative.

This is *not* a matter of completion-styles, variable completion already
uses the substring completion style, otherwise -matching-lines- wouldn't
even validly complete to list-matching-lines-something.

This is purely a matter of teaching completion to eagerly insert the
common prefix when there is one.

Is this possible?




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Teach completion to insert a common prefix
  2023-08-07 20:38 Teach completion to insert a common prefix Spencer Baugh
@ 2023-08-08  6:19 ` Yuri Khan
  2023-08-09  4:09   ` Pierre Rouleau
  0 siblings, 1 reply; 4+ messages in thread
From: Yuri Khan @ 2023-08-08  6:19 UTC (permalink / raw)
  To: Spencer Baugh; +Cc: help-gnu-emacs

On Tue, 8 Aug 2023 at 03:39, Spencer Baugh <sbaugh@janestreet.com> wrote:

> Example in emacs -Q:
>
> C-h v -matching-lines- TAB
>
> All possible completions for -matching-lines- start with
> list-matching-lines-.  So there would be no harm in inserting "list" at
> the start of the completion input.  But Emacs does not do this.

It does do that if you put the point at the start of line.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Teach completion to insert a common prefix
  2023-08-08  6:19 ` Yuri Khan
@ 2023-08-09  4:09   ` Pierre Rouleau
  2023-08-10 11:33     ` sbaugh
  0 siblings, 1 reply; 4+ messages in thread
From: Pierre Rouleau @ 2023-08-09  4:09 UTC (permalink / raw)
  To: Yuri Khan; +Cc: Spencer Baugh, help-gnu-emacs

> All possible completions for -matching-lines- start with
> > list-matching-lines-.  So there would be no harm in inserting "list" at
> > the start of the completion input.  But Emacs does not do this.
>
> It does do that if you put the point at the start of line.
>
> Note that older versions of Emacs was also doing that even when point was
at the end of the line, as in Emacs 26.3

Do you know when that changed and why?

-- 
/Pierre


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Teach completion to insert a common prefix
  2023-08-09  4:09   ` Pierre Rouleau
@ 2023-08-10 11:33     ` sbaugh
  0 siblings, 0 replies; 4+ messages in thread
From: sbaugh @ 2023-08-10 11:33 UTC (permalink / raw)
  To: help-gnu-emacs

Pierre Rouleau <prouleau001@gmail.com> writes:

>> All possible completions for -matching-lines- start with
>> > list-matching-lines-.  So there would be no harm in inserting "list" at
>> > the start of the completion input.  But Emacs does not do this.
>>
>> It does do that if you put the point at the start of line.
>>
>> Note that older versions of Emacs was also doing that even when point was
> at the end of the line, as in Emacs 26.3
>
> Do you know when that changed and why?

I think this is just a bug, maybe introduced in Emacs 26.  I fixed it in
bug#65137: 29.1; completion-substring-try-completion doesn't return the
longest common substring.




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-08-10 11:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-07 20:38 Teach completion to insert a common prefix Spencer Baugh
2023-08-08  6:19 ` Yuri Khan
2023-08-09  4:09   ` Pierre Rouleau
2023-08-10 11:33     ` sbaugh

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).