Stefan Monnier writes: >> I will try to think of another approach which is more similar to how >> completion-table-with-quoting does things, but it will be more >> complicated. > > I thought all that's missing is to double the $$ in the text we append > during completion. Yes, actually you're right, that turns out to be relatively simple. And now the quoting behavior doesn't change at all. Updated patch attached. The $ doubling also needs to happen in all-completions, not just try-completion. But, with sufficiently robust logic for figuring out the completion boundaries, that's straightforward: just double the $ in the newly added text.