Thanks. I hadn't gotten around to a recipe yet. How do other editors handle this situation? On March 28, 2023 18:09:11 João Távora wrote: > João Távora writes: > >> I think it's easier that c++-ts-mode doesn't touch that variable at all >> and leave it set to "\n". I can't see it being much use, with or >> without electric-pair-mode in the mix. > > Following up on this, I have now tried c++-ts-mode for a while now and > can confirm this jumping-around-while-typing is terrible without > electric-pair-mode, and still pretty bad even with electric-pair-mode. > > Here's just an example with emacs -Q + electric-pair-mode + c++-ts-mode > > Start typing > > i n t SPC m a i n ( ) SPC { RET > > The buffer becomes > > int main() { > <- point here > } > > So far so good. Point is correctly indented at column 2 (because > electric-pair-mode has balanced the buffer and electric-indent-mode did > its thing on RET). > > Type 'std'. Nothing surpising happens, good. Now type one ':' and see > the 'std:' be electrically indented to column 1, type the other ':' and > the 'std::' now jumps to column 2 again. > > In bug#62412, Theo said is was OK with killing the custom setting of > electric-indent-chars in c-ts-mode.el and leave it set to the default. > > Though a number of indenting problems would remain after that, at least > this one clear annoyance would be solved. So if there are no > objections, I propose to apply this patch. > > diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el > index 59eb9fc23e6..88360716381 100644 > --- a/lisp/progmodes/c-ts-mode.el > +++ b/lisp/progmodes/c-ts-mode.el > @@ -956,10 +956,6 @@ c-ts-base-mode > ;; Comment > (c-ts-common-comment-setup) > > - ;; Electric > - (setq-local electric-indent-chars > - (append "{}():;,#" electric-indent-chars)) > - > ;; Imenu. > (setq-local treesit-simple-imenu-settings > (let ((pred #'c-ts-mode--defun-valid-p)) > > In master? In emacs-29? > > João