aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2021-05-29 09:22:57 -0400
committerStefan Monnier2021-05-29 09:22:57 -0400
commit246a41759c4d2fab1705f40a228260dc5bb55369 (patch)
tree0bdaf0c9ca4cfc9a30f80a6423eaf78ad2ec6c38
parent4d4c73da5a0aa4233b1dcdcf7db068fc79db6513 (diff)
downloademacs-246a41759c4d2fab1705f40a228260dc5bb55369.tar.gz
emacs-246a41759c4d2fab1705f40a228260dc5bb55369.zip
* 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.
-rw-r--r--etc/NEWS7
-rw-r--r--lisp/electric.el5
2 files changed, 8 insertions, 4 deletions
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.
2451 2451
2452* Incompatible Editing Changes in Emacs 28.1 2452* Incompatible Editing Changes in Emacs 28.1
2453 2453
2454** `electric-indent-mode` now also indents inside strings and comments,
2455(unless the indentation function doesn't, of course).
2456To recover the previous behavior you can use:
2457
2458 (add-hook 'electric-indent-functions
2459 (lambda (_) (if (nth 8 (syntax-ppss)) 'no-indent)))
2460
2454** The 'M-o' ('facemenu-keymap') global binding has been removed. 2461** The 'M-o' ('facemenu-keymap') global binding has been removed.
2455To restore the old binding, say something like: 2462To restore the old binding, say something like:
2456 2463
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."
245 'electric-indent-functions 245 'electric-indent-functions
246 last-command-event) 246 last-command-event)
247 (memq last-command-event electric-indent-chars)))) 247 (memq last-command-event electric-indent-chars))))
248 (not 248 (not (memq act '(nil no-indent))))))
249 (or (memq act '(nil no-indent))
250 ;; In a string or comment.
251 (unless (eq act 'do-indent) (nth 8 (syntax-ppss))))))))
252 ;; If we error during indent, silently give up since this is an 249 ;; If we error during indent, silently give up since this is an
253 ;; automatic action that the user didn't explicitly request. 250 ;; automatic action that the user didn't explicitly request.
254 ;; But we don't want to suppress errors from elsewhere in *this* 251 ;; But we don't want to suppress errors from elsewhere in *this*