From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Aaron Meurer Newsgroups: gmane.emacs.help Subject: Clear trailing whitespace on save, but not at the cursor Date: Sun, 4 Mar 2012 17:48:21 -0700 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: dough.gmane.org 1330908532 22967 80.91.229.3 (5 Mar 2012 00:48:52 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 5 Mar 2012 00:48:52 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Mar 05 01:48:51 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1S4M6d-0003q9-4i for geh-help-gnu-emacs@m.gmane.org; Mon, 05 Mar 2012 01:48:51 +0100 Original-Received: from localhost ([::1]:35150 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S4M6c-0003T8-ID for geh-help-gnu-emacs@m.gmane.org; Sun, 04 Mar 2012 19:48:50 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:39793) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S4M6Y-0003T3-5W for help-gnu-emacs@gnu.org; Sun, 04 Mar 2012 19:48:47 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S4M6W-0004z3-HW for help-gnu-emacs@gnu.org; Sun, 04 Mar 2012 19:48:45 -0500 Original-Received: from mail-lpp01m010-f41.google.com ([209.85.215.41]:39386) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S4M6W-0004xm-7m for help-gnu-emacs@gnu.org; Sun, 04 Mar 2012 19:48:44 -0500 Original-Received: by lagz14 with SMTP id z14so5108214lag.0 for ; Sun, 04 Mar 2012 16:48:41 -0800 (PST) Received-SPF: pass (google.com: domain of asmeurer@gmail.com designates 10.112.29.34 as permitted sender) client-ip=10.112.29.34; Authentication-Results: mr.google.com; spf=pass (google.com: domain of asmeurer@gmail.com designates 10.112.29.34 as permitted sender) smtp.mail=asmeurer@gmail.com; dkim=pass header.i=asmeurer@gmail.com Original-Received: from mr.google.com ([10.112.29.34]) by 10.112.29.34 with SMTP id g2mr8824756lbh.40.1330908521231 (num_hops = 1); Sun, 04 Mar 2012 16:48:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=9OOWipULZDFPPpGW6mHOF6CaZE1lyNJJbmnWviKmGhY=; b=ZlCzO5zH1lnRux8EGfEmh8TDzUzdqBYO6G4ogCPA4oXf0JOxVZMUK5DVPcDZCQ6457 DEh5rcradg8pcC5XQjZa+I+g5tDMAEpLWt4ThvUFR0QestOegLMZPv3pI1DJVtey+uYc vliGKicfhcMyol5cNq7LFWtymXkADmYkUk7xaSxzqS4vxzVRx1MGY1eDjhvEuZO/gkg2 DjPOFZ+NW+IyN4yb9Q2CItW096ZQTB2hZtFTNh2M4nTEknxPnJhayOKUdgEH1WJ6jbG1 URJIPLNSSnDuCe8CBLo0UVaE+3Z+1iR8Bz4g2v5sDMxG13bl0F5aLv7zrYECIphRypFg wzFw== Original-Received: by 10.112.29.34 with SMTP id g2mr7211365lbh.40.1330908521133; Sun, 04 Mar 2012 16:48:41 -0800 (PST) Original-Received: by 10.112.54.3 with HTTP; Sun, 4 Mar 2012 16:48:21 -0800 (PST) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.215.41 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:83936 Archived-At: Hi. I have the following line in my .emacs (add-hook 'before-save-hook 'delete-trailing-whitespace) This clears trailing whitespace on save. I like this behavior, except that it's a little disorienting if I happen to save in the middle of typing something. Is there a way to clear whitespace on save, but then "put it back" where the cursor is? I imagine I could write a custom hook to do this, but I'm wondering if it's possible to do it in such a way that if I save and then quit, it doesn't bug me about saving because it modified the file again with the new whitespace. I don't want to ever save the trailing whitespace to the file itself, even at the cursor. Let me know if any of that doesn't make sense, and I will try to explain it better. Aaron Meurer