From 89463c6c5aeeae14868a69922719b5c154fbf69d Mon Sep 17 00:00:00 2001 From: Morgan Willcock Date: Wed, 25 Sep 2024 14:30:13 +0100 Subject: [PATCH] Restore comment/string check for electric-layout-mode This reverts an accidental change which allowed electric-layout-mode to insert newlines inside strings and comments. * lisp/electric.el (electric-layout-post-self-insert-function-1): Restore the previous default behavior of not inserting newlines within comments or strings. --- lisp/electric.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lisp/electric.el b/lisp/electric.el index d02bcb4735b..2fcb90efe7d 100644 --- a/lisp/electric.el +++ b/lisp/electric.el @@ -409,7 +409,9 @@ electric-layout-post-self-insert-function-1 (goto-char pos) (funcall probe last-command-event)))) (when res (throw 'done res)))))))))) - (when rule + (when (and rule + ;; Not in a string or comment. + (not (nth 8 (save-excursion (syntax-ppss pos))))) (goto-char pos) (when (functionp rule) (setq rule (funcall rule))) (dolist (sym (if (symbolp rule) (list rule) rule)) -- 2.39.5