forcemerge 48356 49931 thanks > When selecting a candidate the suffix after the completion boundary is > discarded by `choose-completion`/`choose-completion-string`. > `choose-completion` is invoked when a candidate in the *Completions* > buffer is selected with the mouse or RET. > > For example when completing a file path "~/emacs/master/li|/calc", where > "|" is the cursor, and then the candidate "lisp" is selected in the > *Completions* buffer, the result is "~/emacs/master/lisp/". The prefix > "~/emacs/master/" is prepended to the selected candidate, but the suffix > "/calc" is discarded. > > `choose-completion-string` contains logic which checks if the resulting > string equals the car of the completion boundary. In that case the > minibuffer is not exited. Strange, in your test case above, the minibuffer is not exited already. > I propose the following change to the existing logic: When > selecting a candidate with `choose-completion` and a suffix is present, > the minibuffer should not be exited (completion continues) and the > suffix is preserved. Here is a better patch than was posted to bug#49931 to preserve the suffix. It correctly handles at least three different cases: 1. When manually adding a suffix in the minibuffer after completions were displayed, choose-completion discards that suffix. 2. In file name completion in the above case the suffix is preserved. 3. 'M-! command filename TAB' and choosing a completion preserves both prefix and suffix. This works only after customizing 'completion-use-base-affixes' to t: