* delete-trailing-whitespace on save
@ 2007-11-27 14:34 jdh2358
2007-11-27 14:42 ` Joost Kremers
2007-11-27 17:27 ` Will Parsons
0 siblings, 2 replies; 5+ messages in thread
From: jdh2358 @ 2007-11-27 14:34 UTC (permalink / raw)
To: help-gnu-emacs
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)
Thanks,
JDH
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: delete-trailing-whitespace on save
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
1 sibling, 1 reply; 5+ messages in thread
From: Joost Kremers @ 2007-11-27 14:42 UTC (permalink / raw)
To: help-gnu-emacs
jdh2358@gmail.com wrote:
> thought I could use an after-save-hook
>
> but that deletes the whitespace *after* saving.
as the name implies... ;-)
> 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)
there is in my version (GNU Emacs 23.0.0.1), so i find it odd that you
don't have it. have you tried <C-h v before-save-hook RET>?
--
Joost Kremers joostkremers@yahoo.com
Selbst in die Unterwelt dringt durch Spalten Licht
EN:SiS(9)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: delete-trailing-whitespace on save
2007-11-27 14:42 ` Joost Kremers
@ 2007-11-27 14:56 ` jdh2358
0 siblings, 0 replies; 5+ messages in thread
From: jdh2358 @ 2007-11-27 14:56 UTC (permalink / raw)
To: help-gnu-emacs
On Nov 27, 8:42 am, Joost Kremers <joostkrem...@yahoo.com> wrote:
> jdh2...@gmail.com wrote:
> there is in my version (GNU Emacs 23.0.0.1), so i find it odd that you
> don't have it. have you tried <C-h v before-save-hook RET>?
Yes, and it is not there... Unfortunately, upgrading is probably not
an option for me.
JDH
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: delete-trailing-whitespace on save
2007-11-27 14:34 delete-trailing-whitespace on save jdh2358
2007-11-27 14:42 ` Joost Kremers
@ 2007-11-27 17:27 ` Will Parsons
1 sibling, 0 replies; 5+ messages in thread
From: Will Parsons @ 2007-11-27 17:27 UTC (permalink / raw)
To: help-gnu-emacs
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* delete-trailing-whitespace on save
@ 2007-11-28 13:21 martin rudalics
0 siblings, 0 replies; 5+ messages in thread
From: martin rudalics @ 2007-11-28 13:21 UTC (permalink / raw)
To: jdh2358; +Cc: help-gnu-emacs
Your `basic-save-buffer' should give you three ways to do that:
(or (run-hook-with-args-until-success 'write-contents-hooks)
(run-hook-with-args-until-success 'local-write-file-hooks)
(run-hook-with-args-until-success 'write-file-hooks)
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2007-11-28 13:21 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
-- strict thread matches above, loose matches on Subject: below --
2007-11-28 13:21 martin rudalics
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).