From: Stefan Monnier Date: Sat, 29 May 2021 13:22:57 +0000 (-0400) Subject: * lisp/electric.el: Do auto-indent inside strings and comments by default X-Git-Tag: emacs-28.0.90~2275 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=246a41759c4d2fab1705f40a228260dc5bb55369;p=emacs.git * lisp/electric.el: Do auto-indent inside strings and comments by default 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. --- diff --git a/etc/NEWS b/etc/NEWS index 49bde94e8dc..c6e7084118f 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2451,6 +2451,13 @@ similar to prefix arguments, but are more flexible and discoverable. * 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: diff --git a/lisp/electric.el b/lisp/electric.el index 6701a36d8bb..4394fae4366 100644 --- a/lisp/electric.el +++ b/lisp/electric.el @@ -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*