From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "jdh2358@gmail.com" Newsgroups: gmane.emacs.help Subject: delete-trailing-whitespace on save Date: Tue, 27 Nov 2007 06:34:08 -0800 (PST) Organization: http://groups.google.com Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1196250863 17233 80.91.229.12 (28 Nov 2007 11:54:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 28 Nov 2007 11:54:23 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Nov 28 12:54:31 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 1IxLUn-0002Pu-1B for geh-help-gnu-emacs@m.gmane.org; Wed, 28 Nov 2007 12:54:25 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IxLUX-0002Fk-BO for geh-help-gnu-emacs@m.gmane.org; Wed, 28 Nov 2007 06:54:09 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!y43g2000hsy.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 20 Original-NNTP-Posting-Host: 192.160.124.68 Original-X-Trace: posting.google.com 1196174049 8348 127.0.0.1 (27 Nov 2007 14:34:09 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Tue, 27 Nov 2007 14:34:09 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: y43g2000hsy.googlegroups.com; posting-host=192.160.124.68; posting-account=DLlhGQoAAAD3ROJ4-nYRqvMUJhy5yw70 User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:1.8.1.6) Gecko/20070731 Firefox/2.0.0.6,gzip(gfe),gzip(gfe) Content-Disposition: inline Original-Xref: shelby.stanford.edu gnu.emacs.help:154153 X-Mailman-Approved-At: Wed, 28 Nov 2007 06:53:52 -0500 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:49612 Archived-At: 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