Commit c5935389 authored by Karl Fogel's avatar Karl Fogel
Browse files

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 bd4f04f8), and adjusts a new test he added right afterwards
(Sat Oct 24 23:43:06 2015 +0100, git commit 207f235e) 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
parent d81b0e13
...@@ -458,15 +458,10 @@ A non-nil INTERACTIVE argument means to run the `post-self-insert-hook'." ...@@ -458,15 +458,10 @@ A non-nil INTERACTIVE argument means to run the `post-self-insert-hook'."
(put-text-property from (point) 'rear-nonsticky (put-text-property from (point) 'rear-nonsticky
(cons 'hard sticky))))) (cons 'hard sticky)))))
(declare-function electric-indent-just-newline "electric")
(defun open-line (n &optional interactive) (defun open-line (n &optional interactive)
"Insert a newline and leave point before it. "Insert a newline and leave point before it.
If `electric-indent-mode' is enabled, indent the new line if it's
not empty.
If there is a fill prefix and/or a `left-margin', insert them on If there is a fill prefix and/or a `left-margin', insert them on
the new line. If the old line would have been blank, insert them the new line if the line would have been blank.
on the old line as well.
With arg N, insert N newlines. With arg N, insert N newlines.
A non-nil INTERACTIVE argument means to run the `post-self-insert-hook'." A non-nil INTERACTIVE argument means to run the `post-self-insert-hook'."
(interactive "*p\np") (interactive "*p\np")
...@@ -475,10 +470,7 @@ A non-nil INTERACTIVE argument means to run the `post-self-insert-hook'." ...@@ -475,10 +470,7 @@ A non-nil INTERACTIVE argument means to run the `post-self-insert-hook'."
(loc (point-marker)) (loc (point-marker))
;; Don't expand an abbrev before point. ;; Don't expand an abbrev before point.
(abbrev-mode nil)) (abbrev-mode nil))
(if (and interactive (newline n interactive)
(looking-at-p "[[:space:]]*$"))
(electric-indent-just-newline n)
(newline n interactive))
(goto-char loc) (goto-char loc)
(while (> n 0) (while (> n 0)
(cond ((bolp) (cond ((bolp)
......
...@@ -138,6 +138,21 @@ ...@@ -138,6 +138,21 @@
(open-line 1))) (open-line 1)))
'("- - " . "\n(a b c d)")))) '("- - " . "\n(a b c d)"))))
;; For a while, from 24 Oct - 19 Nov 2015, `open-line' in the Emacs
;; development tree became sensitive to `electric-indent-mode', which
;; it had not been before. This sensitivity was reverted for the
;; Emacs 25 release, so it could be discussed further (see thread
;; "Questioning the new behavior of `open-line'." on the Emacs Devel
;; mailing list). The only test case here that started failing after
;; the reversion is the third one, the one that currently expects
;; `("(a b" . "\n \n c d)")'. If `open-line' were again sensitive
;; to electric indent, then the three spaces between the two newlines
;; would go away, leaving `("(a b" . "\n\n c d)")'.
;;
;; If electric indent sensitivity were re-enabled, we might also want
;; to make the test cases below a bit stricter, or add some more test
;; cases that are specific to `electric-indent-mode', since right now
;; all but one of the cases pass with or without electric indent.
(ert-deftest open-line-indent () (ert-deftest open-line-indent ()
(should (equal (simple-test--dummy-buffer (should (equal (simple-test--dummy-buffer
(electric-indent-local-mode 1) (electric-indent-local-mode 1)
...@@ -152,7 +167,7 @@ ...@@ -152,7 +167,7 @@
(let ((current-prefix-arg nil)) (let ((current-prefix-arg nil))
(call-interactively #'open-line) (call-interactively #'open-line)
(call-interactively #'open-line))) (call-interactively #'open-line)))
'("(a b" . "\n\n c d)"))) '("(a b" . "\n \n c d)")))
(should (equal (simple-test--dummy-buffer (should (equal (simple-test--dummy-buffer
(electric-indent-local-mode 1) (electric-indent-local-mode 1)
(open-line 5 'interactive)) (open-line 5 'interactive))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment