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

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

Re: delete-trailing-whitespace on save


From: Will Parsons
Subject: Re: delete-trailing-whitespace on save
Date: 27 Nov 2007 17:27:51 GMT
User-agent: slrn/0.9.8.1 (FreeBSD)

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


reply via email to

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