unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Ergus <spacibba@aol.com>
To: help-gnu-emacs@gnu.org
Subject: New line and trailing whitespaces
Date: Sat, 20 Apr 2024 14:10:34 +0200	[thread overview]
Message-ID: <kcaicxrup2f3usy37v4aupgu7uvmifnxkeyc2hx5n5qpqnuj7b@okar6momrmhs> (raw)
In-Reply-To: kcaicxrup2f3usy37v4aupgu7uvmifnxkeyc2hx5n5qpqnuj7b.ref@okar6momrmhs

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	other threads:[~2024-04-20 12:10 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <kcaicxrup2f3usy37v4aupgu7uvmifnxkeyc2hx5n5qpqnuj7b.ref@okar6momrmhs>
2024-04-20 12:10 ` Ergus [this message]
2024-04-20 13:50   ` New line and trailing whitespaces Eli Zaretskii
2024-04-20 14:16     ` Eli Zaretskii
2024-04-21  1:12       ` Ergus
2024-04-21  5:23         ` Eli Zaretskii
2024-04-21 21:05           ` Ergus
2024-04-22  5:39             ` Eli Zaretskii
2024-04-22 12:22               ` Ergus
2024-04-23  8:06                 ` Eli Zaretskii
2024-04-23 15:38                   ` Ergus
2024-04-23 16:19                     ` Eli Zaretskii
2024-04-24  2:41                       ` Ergus
2024-04-24  7:05                         ` Eli Zaretskii
2024-04-24 14:48                           ` Ergus
2024-04-24 15:45                             ` Eli Zaretskii
2024-04-22 12:34               ` Ergus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=kcaicxrup2f3usy37v4aupgu7uvmifnxkeyc2hx5n5qpqnuj7b@okar6momrmhs \
    --to=spacibba@aol.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).