diff options
| author | Karl Fogel | 2015-11-19 17:32:37 -0600 |
|---|---|---|
| committer | Karl Fogel | 2015-11-19 17:32:43 -0600 |
| commit | c593538968a6d6c3d03da9ef6f489da6210e70e1 (patch) | |
| tree | 63bf4fd20e7e3c32ce4698c6d3ede93980d58762 | |
| parent | d81b0e1326a1ce3b588fa1b812b868fa877d41da (diff) | |
| download | emacs-c593538968a6d6c3d03da9ef6f489da6210e70e1.tar.gz emacs-c593538968a6d6c3d03da9ef6f489da6210e70e1.zip | |
Revert `open-line' electric-indent sensitivity
* lisp/simple.el (open-line): Remove electric indent code.
(electric-indent-just-newline): Don't declare.
* test/automated/simple-test.el (open-line-indent): Adjust test.
This partly reverts Artur Malabarba's change that added electric
indent sensitivity to `open-line' (Oct 24 22:26:27 2015 +0100, git
commit bd4f04f86), and adjusts a new test he added right afterwards
(Sat Oct 24 23:43:06 2015 +0100, git commit 207f235e3) accordingly.
However, the new INTERACTIVE argument to `open-line', which he also
added in the first commit, is not reverted here.
See the thread "Questioning the new behavior of `open-line'." on the
Emacs Devel mailing list, and in particular this message:
From: Artur Malabarba
Subject: Re: Questioning the new behavior of `open-line'.
To: Karl Fogel
Cc: David Kastrup, Pierpaolo Bernardi, emacs-devel
Date: Wed, 18 Nov 2015 21:03:58 +0000
Message-ID: \
<CAAdUY-KN06pvCMy5bt3+Buk3yeKjf6n9iB2FaSTTOPpCqPwyhA@mail.gmail.com>
https://lists.gnu.org/archive/html/emacs-devel/2015-11/msg01707.html
| -rw-r--r-- | lisp/simple.el | 12 | ||||
| -rw-r--r-- | test/automated/simple-test.el | 17 |
2 files changed, 18 insertions, 11 deletions
diff --git a/lisp/simple.el b/lisp/simple.el index dc19bd6e512..8b57bf04bea 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -458,15 +458,10 @@ A non-nil INTERACTIVE argument means to run the `post-self-insert-hook'." | |||
| 458 | (put-text-property from (point) 'rear-nonsticky | 458 | (put-text-property from (point) 'rear-nonsticky |
| 459 | (cons 'hard sticky))))) | 459 | (cons 'hard sticky))))) |
| 460 | 460 | ||
| 461 | (declare-function electric-indent-just-newline "electric") | ||
| 462 | (defun open-line (n &optional interactive) | 461 | (defun open-line (n &optional interactive) |
| 463 | "Insert a newline and leave point before it. | 462 | "Insert a newline and leave point before it. |
| 464 | If `electric-indent-mode' is enabled, indent the new line if it's | ||
| 465 | not empty. | ||
| 466 | If there is a fill prefix and/or a `left-margin', insert them on | 463 | If there is a fill prefix and/or a `left-margin', insert them on |
| 467 | the new line. If the old line would have been blank, insert them | 464 | the new line if the line would have been blank. |
| 468 | on the old line as well. | ||
| 469 | |||
| 470 | With arg N, insert N newlines. | 465 | With arg N, insert N newlines. |
| 471 | A non-nil INTERACTIVE argument means to run the `post-self-insert-hook'." | 466 | A non-nil INTERACTIVE argument means to run the `post-self-insert-hook'." |
| 472 | (interactive "*p\np") | 467 | (interactive "*p\np") |
| @@ -475,10 +470,7 @@ A non-nil INTERACTIVE argument means to run the `post-self-insert-hook'." | |||
| 475 | (loc (point-marker)) | 470 | (loc (point-marker)) |
| 476 | ;; Don't expand an abbrev before point. | 471 | ;; Don't expand an abbrev before point. |
| 477 | (abbrev-mode nil)) | 472 | (abbrev-mode nil)) |
| 478 | (if (and interactive | 473 | (newline n interactive) |
| 479 | (looking-at-p "[[:space:]]*$")) | ||
| 480 | (electric-indent-just-newline n) | ||
| 481 | (newline n interactive)) | ||
| 482 | (goto-char loc) | 474 | (goto-char loc) |
| 483 | (while (> n 0) | 475 | (while (> n 0) |
| 484 | (cond ((bolp) | 476 | (cond ((bolp) |
diff --git a/test/automated/simple-test.el b/test/automated/simple-test.el index 07b5eaa93e4..7e0dbb786a7 100644 --- a/test/automated/simple-test.el +++ b/test/automated/simple-test.el | |||
| @@ -138,6 +138,21 @@ | |||
| 138 | (open-line 1))) | 138 | (open-line 1))) |
| 139 | '("- - " . "\n(a b c d)")))) | 139 | '("- - " . "\n(a b c d)")))) |
| 140 | 140 | ||
| 141 | ;; For a while, from 24 Oct - 19 Nov 2015, `open-line' in the Emacs | ||
| 142 | ;; development tree became sensitive to `electric-indent-mode', which | ||
| 143 | ;; it had not been before. This sensitivity was reverted for the | ||
| 144 | ;; Emacs 25 release, so it could be discussed further (see thread | ||
| 145 | ;; "Questioning the new behavior of `open-line'." on the Emacs Devel | ||
| 146 | ;; mailing list). The only test case here that started failing after | ||
| 147 | ;; the reversion is the third one, the one that currently expects | ||
| 148 | ;; `("(a b" . "\n \n c d)")'. If `open-line' were again sensitive | ||
| 149 | ;; to electric indent, then the three spaces between the two newlines | ||
| 150 | ;; would go away, leaving `("(a b" . "\n\n c d)")'. | ||
| 151 | ;; | ||
| 152 | ;; If electric indent sensitivity were re-enabled, we might also want | ||
| 153 | ;; to make the test cases below a bit stricter, or add some more test | ||
| 154 | ;; cases that are specific to `electric-indent-mode', since right now | ||
| 155 | ;; all but one of the cases pass with or without electric indent. | ||
| 141 | (ert-deftest open-line-indent () | 156 | (ert-deftest open-line-indent () |
| 142 | (should (equal (simple-test--dummy-buffer | 157 | (should (equal (simple-test--dummy-buffer |
| 143 | (electric-indent-local-mode 1) | 158 | (electric-indent-local-mode 1) |
| @@ -152,7 +167,7 @@ | |||
| 152 | (let ((current-prefix-arg nil)) | 167 | (let ((current-prefix-arg nil)) |
| 153 | (call-interactively #'open-line) | 168 | (call-interactively #'open-line) |
| 154 | (call-interactively #'open-line))) | 169 | (call-interactively #'open-line))) |
| 155 | '("(a b" . "\n\n c d)"))) | 170 | '("(a b" . "\n \n c d)"))) |
| 156 | (should (equal (simple-test--dummy-buffer | 171 | (should (equal (simple-test--dummy-buffer |
| 157 | (electric-indent-local-mode 1) | 172 | (electric-indent-local-mode 1) |
| 158 | (open-line 5 'interactive)) | 173 | (open-line 5 'interactive)) |