Subject: bug#34517: tmm menubar menu items have no effect on Android

From: Stefan Monnier <[email-masked]>
Date: Wed, 27 Feb 2019 17:10:23 -0500

> Stefan, please advise shouldn't selecting a completion from the
> *Completions* buffer clear the minibuffer's content before
> inserting the selected completion?

No, for example when you complete file name "C-x C-f ~/.e TAB"  the
*Completions* buffer will only show ".emacs" so we should clear the
minibuffer before inserting ".emacs" because that would lose the leading
"~/".  There are other circumstances where trailing text needs to
be preserved.

The completion code handles this with `completion-base-position` which
holds the beginning and end of the text that should be replaced when you
choose an item in *Completions*.

>> 0. emacs -Q
>> 1. ‘C-h f TAB’ displays a list of completions
>> 2. type a nonexistent function name, i.e. some random text
>>    in the minibuffer, e.g. “blabla”

The *Completions* content is now "out of date" compared to the minibuffer.

>> 3. click on an existing valid completion in the *Completions* buffer,
>>    e.g. on “append”

completion-base-position was set at step (1) to cover the empty text
after the prompt, so this empty text (which is now right in front of
"blabla") is replaced with "append" resulting in "appendblabla".

Obviously, the result is not what we want.
Now sure how to change which part, tho.  Maybe instead of
completion-base-position we should store the prefix and suffix strings,
so when you select an entry from *Completions* we just clear the
minibuffer and replace it with (concat prefix selection suffix)?

        Stefan