Subject: Re: bug#62700: 29.0.60; minibuffer-{previous,next,choose}-completion behave unintuitively when point is not at end of buffer

From: Stefan Monnier <[email-masked]>
Date: Thu, 06 Apr 2023 16:42:13 -0400

>> > I think it's the intended behavior.  In this case, it looks not
>> > useful, because the string you typed before starting to use M-<UP> and
>> > M-<DOWN> happens to be at the end of each completion candidate.  But
>> > this is not the only situation possible.  Basically, completion always
>> > modifies only the text before point, leaving what's after point
>> > intact, so that the user could have after point stuff that completion
>> > should ignore, and that eventually will be appended to the selected
>> > candidate.
>> 
>> Could you give an example of when this would be desirable?
>
> When completing on shell commands, for example: the text after point
> is usually the command-line arguments to the command, and the
> completion is on command names or on some file name.

That shouldn't be a worry: when you complete shell commands, you're not
really using "minibuffer completion" (as is the case in `C-h v`) but
"in-buffer completion" (i.e. TAB is bound to `completion-at-point`
rather than to `minibuffer-complete`), so the completion code knows that
you're only completing the command part and will (hopefully) be careful
not to touch anything before or after it.

More specifically, in `M-!` if you're at

    echo hello; e!s world

where `!` shows where point is, the *Completions* buffer should show all
command that start with `e` and end in `s` (assuming we're using
`basic` or `partial-completion` styles) and if you use
minibuffer-{previous,next,choose}-completion, they should replace `e!s`
with the selection.  IOW it should neither "leave the text after point
alone" nor "replace all the text after point".

>> For example, suppose I wanted to wanted to complete filenames starting
>> with x and ending in .c.
> I don't think the default completion supports such functionality, at
> least not with the styles we have by default in completion-styles.

The behavior Spencer describes is very much part of our default (it's
provided both by the `basic` and the `partial-completion` styles, both
of which are enabled by default).

        Stefan