diff options
| author | Stefan Monnier | 2021-05-29 09:22:57 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2021-05-29 09:22:57 -0400 |
| commit | 246a41759c4d2fab1705f40a228260dc5bb55369 (patch) | |
| tree | 0bdaf0c9ca4cfc9a30f80a6423eaf78ad2ec6c38 | |
| parent | 4d4c73da5a0aa4233b1dcdcf7db068fc79db6513 (diff) | |
| download | emacs-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/NEWS | 7 | ||||
| -rw-r--r-- | lisp/electric.el | 5 |
2 files changed, 8 insertions, 4 deletions
| @@ -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). | ||
| 2456 | To 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. |
| 2455 | To restore the old binding, say something like: | 2462 | To 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* |