From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Will Parsons Newsgroups: gmane.emacs.help Subject: Re: delete-trailing-whitespace on save Date: 27 Nov 2007 17:27:51 GMT Organization: Westinghouse Electric Company Message-ID: <5r32cnF12hsuoU1@mid.individual.net> References: Reply-To: william.b.parsons@us.westinghouse.com NNTP-Posting-Host: lo.gmane.org X-Trace: ger.gmane.org 1196185265 29939 80.91.229.12 (27 Nov 2007 17:41:05 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 27 Nov 2007 17:41:05 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Nov 27 18:41:12 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Ix4Qd-0000cb-ON for geh-help-gnu-emacs@m.gmane.org; Tue, 27 Nov 2007 18:40:59 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ix4QO-0001PG-EI for geh-help-gnu-emacs@m.gmane.org; Tue, 27 Nov 2007 12:40:44 -0500 Original-Path: shelby.stanford.edu!headwall.stanford.edu!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 21 Original-X-Trace: individual.net OGJETI9z5dOwN3q4pVf3TAvi0woN/M8jKPU9yWk30rFINupnaD Cancel-Lock: sha1:sPPBI2oscUZ+tMAzQ2XOsVbqOnc= User-Agent: slrn/0.9.8.1 (FreeBSD) Original-Xref: shelby.stanford.edu gnu.emacs.help:154163 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:49589 Archived-At: 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