From: Aaron Meurer <asmeurer@gmail.com>
To: Thien-Thi Nguyen <ttn@gnuvola.org>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Clear trailing whitespace on save, but not at the cursor
Date: Wed, 21 Mar 2012 18:13:08 -0600 [thread overview]
Message-ID: <CAKgW=6Jc=Dbq6o_iO5Yp3AaaBxSppzLpjuwVnszQraxr1K_p=Q@mail.gmail.com> (raw)
In-Reply-To: <87booarvd6.fsf@gnuvola.org>
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))
next prev parent reply other threads:[~2012-03-22 0:13 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-05 0:48 Clear trailing whitespace on save, but not at the cursor Aaron Meurer
2012-03-05 11:02 ` Thien-Thi Nguyen
2012-03-05 15:07 ` Juanma Barranquero
2012-03-06 8:23 ` Thien-Thi Nguyen
2012-03-22 0:13 ` Aaron Meurer [this message]
2012-03-22 15:45 ` Le Wang
2012-03-22 16:56 ` Aaron Meurer
2012-03-05 16:04 ` Deniz Dogan
-- strict thread matches above, loose matches on Subject: below --
2012-03-22 21:08 Doug Lewan
2012-03-23 19:57 ` Aaron Meurer
2012-03-25 14:12 ` Le Wang
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='CAKgW=6Jc=Dbq6o_iO5Yp3AaaBxSppzLpjuwVnszQraxr1K_p=Q@mail.gmail.com' \
--to=asmeurer@gmail.com \
--cc=help-gnu-emacs@gnu.org \
--cc=ttn@gnuvola.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).