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

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

Clear trailing whitespace on save, but not at the cursor


From: Aaron Meurer
Subject: Clear trailing whitespace on save, but not at the cursor
Date: Sun, 4 Mar 2012 17:48:21 -0700

Hi.

I have the following line in my .emacs

(add-hook 'before-save-hook 'delete-trailing-whitespace)

This clears trailing whitespace on save. I like this behavior, except
that it's a little disorienting if I happen to save in the middle of
typing something.  Is there a way to clear whitespace on save, but
then "put it back" where the cursor is?  I imagine I could write a
custom hook to do this, but 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.  I
don't want to ever save the trailing whitespace to the file itself,
even at the cursor.

Let me know if any of that doesn't make sense, and I will try to
explain it better.

Aaron Meurer



reply via email to

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