]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/electric.el: Do auto-indent inside strings and comments by default
authorStefan Monnier <monnier@iro.umontreal.ca>
Sat, 29 May 2021 13:22:57 +0000 (09:22 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Sat, 29 May 2021 13:22:57 +0000 (09:22 -0400)
This fixes bug#20846 where it transpired that there is no good reason
to shy away from auto-indenting inside comments and strings.

(electric-indent-post-self-insert-function): Don't check syntax-ppss.

etc/NEWS
lisp/electric.el

index 49bde94e8dc8a67f78de2676332e4454568e864c..c6e7084118fbfef7f61d668f14b1c06cc47d79e0 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -2451,6 +2451,13 @@ similar to prefix arguments, but are more flexible and discoverable.
 \f
 * Incompatible Editing Changes in Emacs 28.1
 
+** `electric-indent-mode` now also indents inside strings and comments,
+(unless the indentation function doesn't, of course).
+To recover the previous behavior you can use:
+
+    (add-hook 'electric-indent-functions
+              (lambda (_) (if (nth 8 (syntax-ppss)) 'no-indent)))
+
 ** The 'M-o' ('facemenu-keymap') global binding has been removed.
 To restore the old binding, say something like:
 
index 6701a36d8bb2112a66fce94a5653e79f49eb018b..4394fae43667df69a2e034613ac4ea80ce915201 100644 (file)
@@ -245,10 +245,7 @@ or comment."
                              'electric-indent-functions
                              last-command-event)
                             (memq last-command-event electric-indent-chars))))
-               (not
-                (or (memq act '(nil no-indent))
-                    ;; In a string or comment.
-                    (unless (eq act 'do-indent) (nth 8 (syntax-ppss))))))))
+               (not (memq act '(nil no-indent))))))
       ;; If we error during indent, silently give up since this is an
       ;; automatic action that the user didn't explicitly request.
       ;; But we don't want to suppress errors from elsewhere in *this*