From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?utf-8?Q?Johan_Bockg=C3=A5rd?= Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] delete-trailing-whitespace on active region Date: Thu, 10 Feb 2011 22:31:04 +0100 Message-ID: <87pqqza86f.fsf@gnu.org> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1297373511 27596 80.91.229.12 (10 Feb 2011 21:31:51 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 10 Feb 2011 21:31:51 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Feb 10 22:31:47 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Pne78-0004zo-6d for ged-emacs-devel@m.gmane.org; Thu, 10 Feb 2011 22:31:46 +0100 Original-Received: from localhost ([127.0.0.1]:43532 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pne77-00050S-EH for ged-emacs-devel@m.gmane.org; Thu, 10 Feb 2011 16:31:45 -0500 Original-Received: from [140.186.70.92] (port=56654 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pne6Y-0004c3-6a for emacs-devel@gnu.org; Thu, 10 Feb 2011 16:31:11 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pne6X-0007sQ-69 for emacs-devel@gnu.org; Thu, 10 Feb 2011 16:31:10 -0500 Original-Received: from smtprelay-h21.telenor.se ([195.54.99.196]:42050) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pne6W-0007sA-Rf for emacs-devel@gnu.org; Thu, 10 Feb 2011 16:31:09 -0500 Original-Received: from ipb2.telenor.se (ipb2.telenor.se [195.54.127.165]) by smtprelay-h21.telenor.se (Postfix) with ESMTP id 9F453C665 for ; Thu, 10 Feb 2011 22:31:07 +0100 (CET) X-SMTPAUTH-B2: [bocjoh] X-SENDER-IP: [85.228.195.226] X-LISTENER: [smtp.bredband.net] X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AmI5ACnoU01V5MPiPGdsb2JhbACIZo5mjh0MAQEBATUvulaFXASSNw X-IronPort-AV: E=Sophos;i="4.60,451,1291590000"; d="scan'208";a="172069916" Original-Received: from c-e2c3e455.04-211-6c6b701.cust.bredbandsbolaget.se (HELO muon.localdomain) ([85.228.195.226]) by ipb2.telenor.se with ESMTP; 10 Feb 2011 22:31:06 +0100 Original-Received: by muon.localdomain (Postfix, from userid 1000) id 3ACE14842FE; Thu, 10 Feb 2011 22:31:05 +0100 (CET) Mail-Copies-To: never In-Reply-To: (Deniz Dogan's message of "Thu, 10 Feb 2011 16:31:36 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 195.54.99.196 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:135866 Archived-At: Deniz Dogan writes: > + (while (re-search-forward "\\s-$" end t) > + (skip-syntax-backward "-" (save-excursion (forward-line 0) (point))) > + ;; Don't delete formfeeds, even if they are considered whitespace. > + (save-match-data > + (if (looking-at ".*\f") > + (goto-char (match-end 0)))) > + (delete-region (point) (match-end 0)))))) You can't use the value of `end' to limit the search like that, since the deletion changes the size of the region. (Use narrowing or a marker.)