emacs-devel
[Top][All Lists]
Advanced

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

Re: newline-and-indent vs. electric-indent-mode


From: martin rudalics
Subject: Re: newline-and-indent vs. electric-indent-mode
Date: Tue, 26 Jan 2021 16:58:29 +0100

>>> The problem with `whitespace-cleanup-mode` is that it's global.
>>> I'd like something that only operates locally, i.e. only touches lines
>>> you've modified.
>> That would be https://github.com/lewang/ws-butler.
>
> That's better, indeed, tho if you look at the implementation you see
> that it has to deal with lots of corner cases, so it ends up "ugly and
> brittle":

It's the best you can get I would say.  You can't really postpone
trimming to 'kill-buffer' and anything before 'save-buffer' can be just
too early.  Yet, saving will irrevocably trim all whitespace so you
can't get it back for future editing.

> I'm not sure "cleanup on save" is the better option.
> I don't mean to say that Le Wang did a bad job, BTW: the issues aren't
> caused by a bad design or implementation, but by a hard problem.
>
> I was thinking instead of something that removes the trailing space(s)
> when point leaves the line (like Madhu suggested).  Of course that's
> also fraught with danger (e.g. you don't want that whitespace to
> disappear just because you did `C-x C-x`), so the result might end up
> just as ugly&brittle.

We could put some phantom space there and restore it as soon as point
reenters that line.  And maybe handle the current line specially when
saving the buffer.

martin



reply via email to

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