help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

New line and trailing whitespaces


From: Ergus
Subject: New line and trailing whitespaces
Date: Sat, 20 Apr 2024 14:10:34 +0200

Hi:

Using visualstudio recently I have found a nice behavior I would like to
port to emacs.

When the cursor is in an empty line and I press enter, the cursor jumps
to the new line and indents (similar to what emacs does) but also
removes the trailing whitespaces in the previous/leaving line.

I thought to implement that behavior in emacs but I figured out that the
newline command is 1. much more complex that what I expected (creating a
lambda on the fly that then fsets to finally only use if when
non-interactive mode)
2. That non-interactive function already does something similar to the
cleaning of previous line.

SO the questions are...

1. Isn't there a way to simplify the code newline command at least to not
create a lambda on the fly? Isn't there any penalty for doing that on
every RET?

2. Isn't it better to use some pre/post hooks in order to "modularize"
the newline behavior (like electric-indent-mode, auto-fill-mode)

3. What's the recommended method to implement the desired behavior then?

Thanks in advance,
Ergus


reply via email to

[Prev in Thread] Current Thread [Next in Thread]