unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Will Parsons <wbp@nodomain.invalid>
To: help-gnu-emacs@gnu.org
Subject: Re: delete-trailing-whitespace on save
Date: 27 Nov 2007 17:27:51 GMT	[thread overview]
Message-ID: <5r32cnF12hsuoU1@mid.individual.net> (raw)
In-Reply-To: b99d3863-0712-443e-98c7-2bbf4552627e@y43g2000hsy.googlegroups.com

jdh2358@gmail.com wrote:
> I would like to automatically call delete-trailing-whitespace in
> python-mode when I execute save-buffer.  I assume there is some way
> using advice, but my emacs lisp skills are very rusty!  At first I
> thought I could use an after-save-hook
>
>
> (add-hook 'python-mode-hook
>           (lambda ()
> 	    (setq show-trailing-whitespace t)
> 	    (make-local-hook 'after-save-hook)
> 	    (add-hook 'after-save-hook 'delete-trailing-whitespace)))
>
> but that deletes the whitespace *after* saving.  I need something like
> a before-save-hook.  I googled before-save-hook and it appears there
> was once such a beast, but it does not appear to be a variable in my
> version of emacs (GNU Emacs 21.3.1)
>
Try 'write-file-hooks.

- Will

  parent reply	other threads:[~2007-11-27 17:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-27 14:34 delete-trailing-whitespace on save jdh2358
2007-11-27 14:42 ` Joost Kremers
2007-11-27 14:56   ` jdh2358
2007-11-27 17:27 ` Will Parsons [this message]
  -- strict thread matches above, loose matches on Subject: below --
2007-11-28 13:21 martin rudalics

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=5r32cnF12hsuoU1@mid.individual.net \
    --to=wbp@nodomain.invalid \
    --cc=help-gnu-emacs@gnu.org \
    --cc=william.b.parsons@us.westinghouse.com \
    /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).