[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-30 ba44fc9a447: Restore comment/string check for 'electric-layout-
From: |
Eli Zaretskii |
Subject: |
emacs-30 ba44fc9a447: Restore comment/string check for 'electric-layout-mode' |
Date: |
Sat, 5 Oct 2024 06:12:34 -0400 (EDT) |
branch: emacs-30
commit ba44fc9a447be75eff304f606e0cc9ea7ba7656a
Author: Morgan Willcock <morgan@ice9.digital>
Commit: Eli Zaretskii <eliz@gnu.org>
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. The new behavior can be obtained by setting the
new variable 'electric-layout-allow-in-comment-or-string' to a
non-nil value.
* lisp/electric.el (electric-layout-allow-in-comment-or-string):
New variable to determine whether inserting newlines is
permitted within comments or strings.
(electric-layout-post-self-insert-function-1): Restore the
previous default behavior of not inserting newlines within
comments or strings.
---
lisp/electric.el | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/lisp/electric.el b/lisp/electric.el
index d02bcb4735b..d84faf5433f 100644
--- a/lisp/electric.el
+++ b/lisp/electric.el
@@ -385,6 +385,9 @@ If multiple rules match, only first one is executed.")
(defvar electric-layout-allow-duplicate-newlines nil
"If non-nil, allow duplication of `before' newlines.")
+(defvar electric-layout-allow-in-comment-or-string nil
+ "If non-nil, allow inserting newlines inside a comment or string.")
+
(defun electric-layout-post-self-insert-function ()
(when electric-layout-mode
(electric-layout-post-self-insert-function-1)))
@@ -409,7 +412,10 @@ If multiple rules match, only first one is executed.")
(goto-char pos)
(funcall probe last-command-event))))
(when res (throw 'done res))))))))))
- (when rule
+ (when (and rule
+ (or electric-layout-allow-in-comment-or-string
+ ;; Not in a comment or string.
+ (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))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- emacs-30 ba44fc9a447: Restore comment/string check for 'electric-layout-mode',
Eli Zaretskii <=