From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thien-Thi Nguyen Newsgroups: gmane.emacs.help Subject: Re: Clear trailing whitespace on save, but not at the cursor Date: Tue, 06 Mar 2012 09:23:17 +0100 Message-ID: <87booarvd6.fsf@gnuvola.org> References: <87aa3vwbsf.fsf@gnuvola.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1331022286 1678 80.91.229.3 (6 Mar 2012 08:24:46 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 6 Mar 2012 08:24:46 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Juanma Barranquero Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Mar 06 09:24:45 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 1S4phM-0002CB-6t for geh-help-gnu-emacs@m.gmane.org; Tue, 06 Mar 2012 09:24:44 +0100 Original-Received: from localhost ([::1]:50954 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S4phL-0006N2-HV for geh-help-gnu-emacs@m.gmane.org; Tue, 06 Mar 2012 03:24:43 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:49618) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S4ph9-0006Mu-Lb for help-gnu-emacs@gnu.org; Tue, 06 Mar 2012 03:24:39 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S4ph8-0004v9-0M for help-gnu-emacs@gnu.org; Tue, 06 Mar 2012 03:24:31 -0500 Original-Received: from smtp209.alice.it ([82.57.200.105]:37539) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S4ph7-0004uy-K8 for help-gnu-emacs@gnu.org; Tue, 06 Mar 2012 03:24:29 -0500 Original-Received: from ambire (79.10.157.145) by smtp209.alice.it (8.6.023.02) id 4EF08A6308606AE1; Tue, 6 Mar 2012 09:24:26 +0100 Original-Received: from ttn by ambire with local (Exim 4.72) (envelope-from ) id 1S4pfy-00016C-JO; Tue, 06 Mar 2012 09:23:18 +0100 In-Reply-To: (Juanma Barranquero's message of "Mon, 5 Mar 2012 16:07:51 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 82.57.200.105 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:83950 Archived-At: () Juanma Barranquero () Mon, 5 Mar 2012 16:07:51 +0100 That does not answer to this part of the request: > 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. If you add =E2=80=98delete-trailing-whitespace=E2=80=99 to =E2=80=98before-= save-hook=E2=80=99, then the re-adding of the string is also saved and the buffer is left with (buffer-modified-p) =3D> nil. There is, anyway, a bug: The condition: (looking-back "\\s-+" (line-beginning-position) t) should be expanded to something like: (and (looking-at "\\s-*$") (looking-back "\\s-+" (line-beginning-position) t))