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

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

Re: Clear trailing whitespace on save, but not at the cursor


From: Aaron Meurer
Subject: Re: Clear trailing whitespace on save, but not at the cursor
Date: Wed, 21 Mar 2012 18:13:08 -0600

On Tue, Mar 6, 2012 at 1:23 AM, Thien-Thi Nguyen <ttn@gnuvola.org> wrote:
> () Juanma Barranquero <lekktu@gmail.com>
> () Mon, 5 Mar 2012 16:07:51 +0100
>
>   That does not answer to this part of the request:
>
>   > I'm wondering if it's possible to do it in
>   > such a way that if I save and then quit, it doesn't bug me about
>   > saving because it modified the file again with the new whitespace.
>
> If you add ‘delete-trailing-whitespace’ to ‘before-save-hook’,
> then the re-adding of the string is also saved and the buffer
> is left with (buffer-modified-p) => nil.

Sorry, I'm still *very* new to emacs lisp (lisp in general, actually).
 Does this mean that it's possible to modify the above defadvice
function you gave above so that it actually clears it before the save,
but then puts it back?  The function works just fine in not clearing
at the cursor, but as noted, this is not quite what I want, because I
do *not* want to save trailing whitespace to file at all (I would
rather have my current annoyance).

Aaron Meurer

>
> There is, anyway, a bug: The condition:
>
>  (looking-back "\\s-+" (line-beginning-position) t)
>
> should be expanded to something like:
>
>  (and (looking-at "\\s-*$")
>       (looking-back "\\s-+" (line-beginning-position) t))



reply via email to

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