[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
newline-and-indent vs. electric-indent-mode
From: |
Harald Jörg |
Subject: |
newline-and-indent vs. electric-indent-mode |
Date: |
Fri, 22 Jan 2021 14:53:55 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) |
Hi all,
in a debugging session for some indenting bugs I noticed with some
surprise how often the mode-specific indenting function is called.
There seems to be a systematic overlap between the keybinding of RET and
electric-indent-mode.
Many (almost all?) modes bind RET to newline-and-indent, but '(?\n) is
also the default value of electric-indent-chars. So, whenever a newline
is entered, there are three calls to the mode-specific indenting
function:
- one call for the current line, caused by electric-indent-mode. This
makes some sense because the line's content might suggest a different
indentation than what could be guessed when the line started out as a
new empty line. It is annoying, however, when the mode gets the
indentation wrong (which occasionally happens). It is also
superfluous if the character which causes a change in indentation
(for example "}") is either itself in electric-indent-chars (as in
perl-mode) or handled by the mode's keymap (as in cperl-mode), both
resulting in a call to the indenting function.
- two calls for the following, empty line. One is caused by '(?\n)
being in electric-indent-chars, the other by the current command
being newline-AND-INDENT. This doesn't make any sense.
Should electric-indent-mode be switched off by modes which map RET to
newline-and-indent? Or should the modes refrain from mapping RET?
--
Cheers,
haj
- newline-and-indent vs. electric-indent-mode,
Harald Jörg <=
- Re: newline-and-indent vs. electric-indent-mode, Stefan Monnier, 2021/01/22
- Re: newline-and-indent vs. electric-indent-mode, Dmitry Gutov, 2021/01/22
- Re: newline-and-indent vs. electric-indent-mode, Stefan Monnier, 2021/01/22
- Re: newline-and-indent vs. electric-indent-mode, Dmitry Gutov, 2021/01/22
- Re: newline-and-indent vs. electric-indent-mode, Stefan Monnier, 2021/01/22
- Re: newline-and-indent vs. electric-indent-mode, Dmitry Gutov, 2021/01/22
- Re: newline-and-indent vs. electric-indent-mode, Stefan Monnier, 2021/01/22
- Re: newline-and-indent vs. electric-indent-mode, Dmitry Gutov, 2021/01/22
- Re: newline-and-indent vs. electric-indent-mode, Stefan Monnier, 2021/01/22
- Re: newline-and-indent vs. electric-indent-mode, Dmitry Gutov, 2021/01/23