Hi Stefan, First of all, thank you for looking into this. On Sat, Apr 27, 2019 at 4:28 AM Stefan Monnier wrote: > > >> I have now optimized CC Mode, such that each such self-insert-command > >> now takes around 0.07s-0.1s. I used two strategies for this: (i) breaking out > >> of (expensive) fontification routines early, when the region being > >> fontified is nothing but a string; (ii) Not fontifying the entire raw > >> string for a change to only a small part of it. > > > > I have been working with C++ template metaprograms for two years, and > > since quite early, I have experienced CC Mode being very sluggish that > > I often switch back-and-forth between cc-mode and text-mode. > > Could you try out the "quick hack patch" I sent in > https://debbugs.gnu.org/35316 ? > > It has a few known bugs, so it would require further work to be really > useful, but I'd be interested to know if it helps your use case. No, it does not help. > > `emacs -Q' to visit the file locally. Then, to experience the > > sluggishness, I pressed M-> followed by M-v several times. > > FWIW, I don't expect my patch will help this use-case. You are right. I would like to add that C++ template seems to be a specific problem in CC Mode as shown by the attached C++ program file. Using `emacs -Q' with your patch to visit the attached file locally, M-> C-u 10 C-p C-u 6 M-f DEL 10 is not sluggish at all when editing a non template. After that, let's edit a template: M-< C-v C-v C-v C-v C-v C-u 4 M-f DEL is very sluggish. After that, typing 10 is also very sluggish. > Stefan -- Best regards, Tadeus