Subject: bug#76817: 30.1; completion-preview and shell

From: Eshel Yaron <[email-masked]>
Date: Fri, 07 Mar 2025 19:47:09 +0100

Hi Rufus,

Rufus Segar <[email-masked]> writes:

> It appears that completion-preview-mode is not quite working as intended
> with shell. When inserting path completions it inserts a trailing space.

The trailing space comes from the :exit-function that the completion
backend specifies.  completion-preview-mode calls that :exit-function
when you insert a completion suggestion, so in that sense it does work
as intended.

Of course, I agree that this trailing space is undesirable for exactly
the reason you describe below.  You can disable it, as I do, by setting
either pcomplete-termination-string or pcomplete-exit-function.  Do you
get a better behavior with (setq pcomplete-termination-string "") ?

> An example will show why this is undesirable:
>
> Say I want to complete path `~/foobar/baz'. I start with `cd ~/foob` and
> completion-preview successfully completes the 'foobar' portion. However,
> after I do completion-preview-insert I'm left with the following:
>
> "cd ~/foobar/ "
>              ^-- Notice the trailing space
>
> This means that if I want to continue completing my path all the way to
> '~/foobar/baz', I have to delete that trailing space. completion-preview
> should not leave a trailing space, and if possible immediately continue
> completing the path, so that in this case I'm given '~/foobar/baz' as my
> next completion candidate and can simply call completion-preview-insert
> again to get the full path.
>
> P.S. I'm loving completion-preview-mode by the way, I can tell that a
> lot of care was put into this mode. I'm looking forward to this issue
> being resolved so that I can use it in my shell too.

Thanks!

Eshel