[Top][All Lists]

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

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

From: Dmitry Gutov
Subject: Re: newline-and-indent vs. electric-indent-mode
Date: Tue, 26 Jan 2021 04:04:32 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0

On 25.01.2021 17:15, Stefan Monnier wrote:
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": 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.

Indeed, there are a lot of hooks involved, but it seemed to work last time I tried it.

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.

Or if I just did C-n C-p, or something more complex to the same effect. But I suppose somebody could try creating a prototype, and then we'd see just how jarring this approach is (or not).

Alternatively, one could start with looking into how others editors do it.

whitespace-cleanup-mode is working out just fine for me, though, because by
default is only cleans files that were clean previously.

I'd like a feature that is also active in non-clean files.

I just clean such a file manually once, and then the feature is active. Or I don't, and use whitespace-mode to make sure I don't leave new trailing whitespace around.

Files like that are a minority in my experience, so it's not too big a price to pay for being able to rely on a simple implementation. YMMV, of course.

reply via email to

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