From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Deniz Dogan Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] delete-trailing-whitespace on active region Date: Fri, 11 Feb 2011 07:33:49 +0100 Message-ID: References: <87pqqza86f.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary=90e6ba6e8f60ba2bbc049bfbe214 X-Trace: dough.gmane.org 1297406068 3179 80.91.229.12 (11 Feb 2011 06:34:28 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 11 Feb 2011 06:34:28 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Feb 11 07:34:24 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 1PnmaE-0004a9-GE for ged-emacs-devel@m.gmane.org; Fri, 11 Feb 2011 07:34:22 +0100 Original-Received: from localhost ([127.0.0.1]:60553 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PnmaD-0007gS-Rv for ged-emacs-devel@m.gmane.org; Fri, 11 Feb 2011 01:34:21 -0500 Original-Received: from [140.186.70.92] (port=51833 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pnma5-0007dk-51 for emacs-devel@gnu.org; Fri, 11 Feb 2011 01:34:14 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pnma2-0006ab-MF for emacs-devel@gnu.org; Fri, 11 Feb 2011 01:34:12 -0500 Original-Received: from mail-iy0-f169.google.com ([209.85.210.169]:34578) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pnma2-0006aJ-DR for emacs-devel@gnu.org; Fri, 11 Feb 2011 01:34:10 -0500 Original-Received: by iyi20 with SMTP id 20so2317990iyi.0 for ; Thu, 10 Feb 2011 22:34:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=gQz28x5ubwP7HwhLfn2Pz8Xx1UiAyN+1cvh+Q7GKnDI=; b=QUoC4mIiev7Va13pCCJQ6XWKuqYwBbYQ6bT8+T0z/X5kShqmnzQ/NcN6zZE+9wM1s8 zESglp3cwykGuJjm/Q1BI6WQ1a4qyvSYLWtwSzFGxGNYk1Hd6oo5YPlipsqHraRVVlsm iMZDZ1ECaMU44VYsiO41hNISFulqo+DlSwCoA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; b=UWDC37EYT9FntH6EE48vHu/HJMAj4v8RjoIH47nk2MykCDMnKl0UO9ySRl9ou4POEG Ibzo9dVvsnn0l8yL+TjSSzeAfcxX4WQvntmxfhmFqiaUy+xWsJIOTjihqBa+X0AEXMEW ETV8G7pM9Lt/Lcg8ywa7WFQfXvy9pWJO+rXFo= Original-Received: by 10.42.172.70 with SMTP id m6mr158671icz.314.1297406049790; Thu, 10 Feb 2011 22:34:09 -0800 (PST) Original-Received: by 10.231.19.67 with HTTP; Thu, 10 Feb 2011 22:33:49 -0800 (PST) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.210.169 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:135871 Archived-At: --90e6ba6e8f60ba2bbc049bfbe214 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 2011/2/11 Stefan Monnier : >>> + =A0 =A0 =A0(while (re-search-forward "\\s-$" end t) >>> + =A0 =A0 =A0 =A0(skip-syntax-backward "-" (save-excursion (forward-lin= e 0) (point))) >>> + =A0 =A0 =A0 =A0;; Don't delete formfeeds, even if they are considered= whitespace. >>> + =A0 =A0 =A0 =A0(save-match-data >>> + =A0 =A0 =A0 =A0 =A0(if (looking-at ".*\f") >>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0(goto-char (match-end 0)))) >>> + =A0 =A0 =A0 =A0(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.) > > Good point, thanks. =A0...or do it from the end. > This patch is teaching me a lot... Attached is a last attempt, if it's not good then I give up and hope that someone else will take care of it. Thanks, Deniz Dogan --90e6ba6e8f60ba2bbc049bfbe214 Content-Type: application/octet-stream; name="dtw3.patch" Content-Disposition: attachment; filename="dtw3.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_gk0q1ioh0 PT09IG1vZGlmaWVkIGZpbGUgJ2xpc3Avc2ltcGxlLmVsJw0KLS0tIGxpc3Avc2ltcGxlLmVsCTIw MTEtMDItMDEgMjE6MjI6MjEgKzAwMDANCisrKyBsaXNwL3NpbXBsZS5lbAkyMDExLTAyLTExIDA2 OjMxOjQxICswMDAwDQpAQCAtNjE0LDIyICs2MTQsMzAgQEANCiAgICAgKGlmIChsb29raW5nLWF0 ICJeWyBcdF0qXG5cXCciKQ0KIAkoZGVsZXRlLXJlZ2lvbiAocG9pbnQpIChwb2ludC1tYXgpKSkp KQ0KIA0KLShkZWZ1biBkZWxldGUtdHJhaWxpbmctd2hpdGVzcGFjZSAoKQ0KKyhkZWZ1biBkZWxl dGUtdHJhaWxpbmctd2hpdGVzcGFjZSAoJm9wdGlvbmFsIHN0YXJ0IGVuZCkNCiAgICJEZWxldGUg YWxsIHRoZS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