(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)))
(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))