Closed d-torrance closed 3 years ago
Hrm, this isn't so simple after all. newline
doesn't properly indent past the first level:
m2-newline-and-indent
(
(
(
(
newline
(
(
(
(
Getting this to work required changing the behavior of M2-electric-indent
. From the corresponding commit message:
We now always tab electrically, even when not at the beginning of a line or on a blank line. This has several advantages:
- The function is now idempotent.
- The "newline" function (when electric-indent-mode is on, the default) will do the correct thing, so we can deprecate "M2-newline-and-indent".
- The new behavior is consistent with other common major modes.
We also always delete leading whitespace and re-indent to clean up tabs and spaces.
These changes make M2-newline-and-indent
obsolete.
Thanks, it seems to work.
It is currently bound to
M2-newline-and-indent
, which callsnewline
and then indents. However,newline
by itself already indents the next line (provided that the user haselectric-indent-mode
enabled, which is the default), and so calling this specialized function is unnecessary. Furthermore, C-m is already bound tonewline
inglobal-map
, so there's no reason to bind it again.Also, if the user has turned off
electric-indent-mode
, then C-m will have the desired behavior -- no electric indents.