Subject: 30.0.50; c-indent-new-comment-line does not respect electric-pair-open-newline-between-pairs

From: areg05 <[email-masked]>
Date: Mon, 30 Jan 2023 13:00:53 +0000

When I use c-indent-new-comment-line in between a pair (for example {} in c-mode), it does not correctly insert the extra newline and indent it, according to electric-pair-open-newline-between-pairs. After some debugging I discovered that this is because in c-indent-new-comment-line the `newline' function gets called non-interactively, which makes electric-pair's hooks not execute. A simple solution is to simply replace the call to `do-line-break' in c-indent-new-comment-line with (newline 1 t) in cc-cmds.el, line 5049. It does not seem break other functionality as the code in question is in a branch that gets executed only when the point is outside a comment or a macro. Also, I think it would be correct to remove the call to indent-to on line 5050 and rely on electric-indent to handle that for us instead.

Thank you.