Recently, `open-line' has started behaving in a new way due to Arthur
Malabarba's recent commits [1]. Here is how `open-line' behaves before and
after the changes.
Suppose you have this text in a buffer, in just about any mode (i.e., not
necessarily a programming language mode), and it is indented by two spaces as
below:
A lovely haiku
An example for this bug
For Emacs Devel
Now place point where the imaginary "X" is below and do C-o (`open-line'):
X A lovely haiku
An example for this bug
For Emacs Devel
Formerly, that would literally insert a newline, but not remove the the two spaces of
indendation that come *after* the new newline (the two spaces right before "A lovely
haiku"). So this would be the result:
[...this is the new line; imagine it's blank...]
A lovely haiku
An example for this bug
For Emacs Devel
But after the recent commits, those two spaces are removed:
[...this is the new line; imagine it's blank...]
A lovely haiku
An example for this bug
For Emacs Devel
So now one can no longer just put point in column 0 and type C-o to open a line
right before a block of indented text while preserving the block's indentation.
This is just a result of `electric-indent-mode' being on by default and
`open-line' now being sensitive to `electric-indent-mode', I think. But one of
the things I always thought was good about `open-line' was that it *wasn't*
sensitive that way -- that you could just put point in a column of your choice
and insert a newline, and everything to the right of that column would be
preserved after the newline.
Arthur was well aware of this change, and even asked about it in his first post in the
thread "A few questions about open-line" [2]:
3. I think, when electric-indent-mode is on, open-line should indent
the line that was created below if it isn't empty. May I go ahead?
Had I seen that question at the time, I would have answered "Oh, please don't"
:-). But maybe mine is a minority opinion? I encounter the new behavior several times a
day, and don't like it; turning off `electric-indent-mode' seems like a drastic solution.
But if people generally like this new behavior, I'll certainly live with being in the
minority and figure out the appropritae local customization.
So do we think this new behavior is the right one?
(If it stays, then I'll add an item to NEWS about it.)
Best regards,
-Karl
[1] These two commits (note you have to take them together, as the earlier one
accidentally leaves open-line in a syntactically invalid state, and the later
one corrects that):
commit bd4f04f86cea893e3369decdda074a4898491518
Author: Artur Malabarba<address@hidden>
Date: Sat Oct 24 22:26:27 2015 +0100
* lisp/simple.el (open-line): Integrate with electric-indent-mode
Also run `post-self-insert-hook' when called interactively.
M lisp/simple.el
commit 6939896e2ffe2e742954c14bba6129af456f0857
Author: Artur Malabarba<address@hidden>
Date: Sat Oct 24 22:24:09 2015 +0100
* lisp/simple.el (open-line): Fix docstring
Also explain apparently redundant line.
M lisp/simple.el
[2] https://lists.gnu.org/archive/html/emacs-devel/2015-10/threads.html#02107