Spencer Baugh writes: > 1. touch 'foo bxx' 'foo byy' > 2. emacs -Q > 3. M-x shell > 4. Type "echo foo" and hit TAB; it will complete to "echo foo\ b" > 5. Hit ? to bring up *Completions* > 6. Note that the highlighting is incorrect; the next character should > be highlighted in pink as the next difference, but it's not. > > If you modify minibuffer-completion-help to not bind > completion-lazy-hilit to t (which I recently added), the highlighting > will be correct. > > This is because completion-lazy-hilit=t makes the highlighting function > run on the *quoted* string (with the \), whereas > completion-lazy-hilit=nil runs highlighting on the *unquoted* string, > which is then highlighted correctly. > > IMO, we should fix this by changing the API exposed for > completion-table-with-quoting. As mentioned in a comment in > completion--twq-all: > > ;; The better solution is to not quote the *Completions* display, > ;; which nicely circumvents the problem. > > If we just stopped quoting *Completions*, we would avoid this problem. > > This would necessitate adding some new way to quote the completion > before inserting it. We could add some new piece of completion metadata > which provides a function which gets called when a completion candidate > is about to be inserted, and returns a string that should be inserted > instead - it can perform the quoting. (Or it could even be a new > completion table action?) Fortunately it actually turns out to be much, much simpler than this. We continue to return the quoted completions from completion-all-completions, and just use completion--unquoted for display instead of the quoted completion. Completion UIs should start calling the new completion-for-display function, but even if they don't, nothing new breaks.