diff options
| author | João Távora | 2019-05-15 13:10:22 +0100 |
|---|---|---|
| committer | João Távora | 2019-07-02 16:10:45 +0100 |
| commit | 5e88b50d542b6d1c4ff43f8ae0fabe8a647d842e (patch) | |
| tree | 46c5c7e22127d8e6aad017f925514a0fb62c19ca /lisp | |
| parent | 2a2a1bdb8f0f149aaf736a61685feec9380be1b1 (diff) | |
| download | emacs-5e88b50d542b6d1c4ff43f8ae0fabe8a647d842e.tar.gz emacs-5e88b50d542b6d1c4ff43f8ae0fabe8a647d842e.zip | |
Correctly reindent previous line in electric-indent-mode
Fixes: bug#35254
Do this even when electric-indent-inhibit is t, except when the
newline insertion is being performed by electric-layout-mode.
* lisp/electric.el (electric-indent-post-self-insert-function):
Reindent previous line unless operating under
electric-layout-mode.
(electric-layout-post-self-insert-function-1): Bind
electric-indent-inhibit to 'electric-layout-mode.
* test/lisp/electric-tests.el
(electric-layout-control-reindentation): New test.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/electric.el | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/lisp/electric.el b/lisp/electric.el index 53e53bd975c..a14deb71afb 100644 --- a/lisp/electric.el +++ b/lisp/electric.el | |||
| @@ -270,10 +270,13 @@ or comment." | |||
| 270 | (goto-char before) | 270 | (goto-char before) |
| 271 | (condition-case-unless-debug () | 271 | (condition-case-unless-debug () |
| 272 | (indent-according-to-mode) | 272 | (indent-according-to-mode) |
| 273 | (error (throw 'indent-error nil))) | 273 | (error (throw 'indent-error nil)))) |
| 274 | ;; The goal here will be to remove the trailing | 274 | (unless (eq electric-indent-inhibit 'electric-layout-mode) |
| 275 | ;; whitespace after reindentation of the previous line | 275 | ;; Unless we're operating under |
| 276 | ;; because that may have (re)introduced it. | 276 | ;; `electric-layout-mode' (Bug#35254), the goal here |
| 277 | ;; will be to remove the trailing whitespace after | ||
| 278 | ;; reindentation of the previous line because that | ||
| 279 | ;; may have (re)introduced it. | ||
| 277 | (goto-char before) | 280 | (goto-char before) |
| 278 | ;; We were at EOL in marker `before' before the call | 281 | ;; We were at EOL in marker `before' before the call |
| 279 | ;; to `indent-according-to-mode' but after we may | 282 | ;; to `indent-according-to-mode' but after we may |
| @@ -451,7 +454,7 @@ If multiple rules match, only first one is executed.") | |||
| 451 | ;; really wants to reindent, then | 454 | ;; really wants to reindent, then |
| 452 | ;; `last-command-event' should be in | 455 | ;; `last-command-event' should be in |
| 453 | ;; `electric-indent-chars'. | 456 | ;; `electric-indent-chars'. |
| 454 | (let ((electric-indent-inhibit t)) | 457 | (let ((electric-indent-inhibit 'electric-layout-mode)) |
| 455 | (funcall nl-after))))))) | 458 | (funcall nl-after))))))) |
| 456 | (pcase sym | 459 | (pcase sym |
| 457 | ('before (funcall nl-before)) | 460 | ('before (funcall nl-before)) |