[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 246a417: * lisp/electric.el: Do auto-indent inside strings and co
From: |
Stefan Monnier |
Subject: |
master 246a417: * lisp/electric.el: Do auto-indent inside strings and comments by default |
Date: |
Sat, 29 May 2021 09:23:03 -0400 (EDT) |
branch: master
commit 246a41759c4d2fab1705f40a228260dc5bb55369
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>
* 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.
---
etc/NEWS | 7 +++++++
lisp/electric.el | 5 +----
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/etc/NEWS b/etc/NEWS
index 49bde94..c6e7084 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 6701a36..4394fae 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*
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 246a417: * lisp/electric.el: Do auto-indent inside strings and comments by default,
Stefan Monnier <=