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: Re: Clear trailing whitespace on save, but not at the cursor Date: Wed, 21 Mar 2012 18:13:08 -0600 Message-ID: References: <87aa3vwbsf.fsf@gnuvola.org> <87booarvd6.fsf@gnuvola.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1332375227 11262 80.91.229.3 (22 Mar 2012 00:13:47 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 22 Mar 2012 00:13:47 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Thien-Thi Nguyen Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Mar 22 01:13:46 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 1SAVet-0006bN-Il for geh-help-gnu-emacs@m.gmane.org; Thu, 22 Mar 2012 01:13:39 +0100 Original-Received: from localhost ([::1]:34974 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SAVes-0002OX-Hy for geh-help-gnu-emacs@m.gmane.org; Wed, 21 Mar 2012 20:13:38 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:59007) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SAVen-0002O5-9g for help-gnu-emacs@gnu.org; Wed, 21 Mar 2012 20:13:34 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SAVel-0006pY-G6 for help-gnu-emacs@gnu.org; Wed, 21 Mar 2012 20:13:32 -0400 Original-Received: from mail-gx0-f169.google.com ([209.85.161.169]:48782) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SAVel-0006pI-9Y for help-gnu-emacs@gnu.org; Wed, 21 Mar 2012 20:13:31 -0400 Original-Received: by ggeq1 with SMTP id q1so1692041gge.0 for ; Wed, 21 Mar 2012 17:13:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=DNfiGyEo9L0SGFlt4Kyl6Yz9WBrDRpnYBFzSQKXn0i0=; b=tlg9G6AK3jwmsGF9JeNyw6MIEFgJIlxG9fX2zJbOHFHC9T4eEpA1+AEs62oNOtuiWU tXfWwTCrg1wi2YXn6N6cKHI33QomU5q/VVxHvrcKcy/dIRRvpOmlKL1XqkloBnCiHR3z /ACrw0g/0wXAH0Q1jAPNNRE4mtKdBO+EpFKhl7uban9Bp2nrBNdhAkE7M9c+4OdhOwlC TTbTsWn+4vTqBXyDcavcRetydGjvsAFNYNhHVMIgCkA9/bZ8yPGOzZso1dpAs9MfVGnX SYt42NacgCHBPpp2BUJL7tTYX6AXiVeitHB05IsTVqYrsS+nWu9aFGCHyaptpmJBq3pr O0+w== Original-Received: by 10.60.3.104 with SMTP id b8mr7035676oeb.13.1332375208492; Wed, 21 Mar 2012 17:13:28 -0700 (PDT) Original-Received: by 10.182.109.41 with HTTP; Wed, 21 Mar 2012 17:13:08 -0700 (PDT) In-Reply-To: <87booarvd6.fsf@gnuvola.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.161.169 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:84084 Archived-At: On Tue, Mar 6, 2012 at 1:23 AM, Thien-Thi Nguyen wrote: > () Juanma Barranquero > () Mon, 5 Mar 2012 16:07:51 +0100 > > =A0 That does not answer to this part of the request: > > =A0 > I'm wondering if it's possible to do it in > =A0 > such a way that if I save and then quit, it doesn't bug me about > =A0 > saving because it modified the file again with the new whitespace. > > If you add =91delete-trailing-whitespace=92 to =91before-save-hook=92, > then the re-adding of the string is also saved and the buffer > is left with (buffer-modified-p) =3D> nil. Sorry, I'm still *very* new to emacs lisp (lisp in general, actually). Does this mean that it's possible to modify the above defadvice function you gave above so that it actually clears it before the save, but then puts it back? The function works just fine in not clearing at the cursor, but as noted, this is not quite what I want, because I do *not* want to save trailing whitespace to file at all (I would rather have my current annoyance). Aaron Meurer > > There is, anyway, a bug: The condition: > > =A0(looking-back "\\s-+" (line-beginning-position) t) > > should be expanded to something like: > > =A0(and (looking-at "\\s-*$") > =A0 =A0 =A0 (looking-back "\\s-+" (line-beginning-position) t))