From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Vinicius Jose Latorre Newsgroups: gmane.emacs.devel Subject: Re: Proposal: diff-remove-trailing-blanks Date: Wed, 30 Apr 2008 21:34:37 -0300 Message-ID: <4819101D.5010004@ig.com.br> References: <200804261845.m3QIixvX026773@sallyv1.ics.uci.edu> <4813879E.8030700@ig.com.br> <4813A244.4050908@ig.com.br> <8wz09so0.fsf@telefonica.net> <4813E542.10802@ig.com.br> <3ap89c5j.fsf@telefonica.net> <48146DF3.3090706@ig.com.br> <48147BC0.6080406@ig.com.br> <4814B81C.8030407@ig.com.br> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1209602143 8132 80.91.229.12 (1 May 2008 00:35:43 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 1 May 2008 00:35:43 +0000 (UTC) Cc: "ema >> \"GNU Emacs \(devel\)\"" To: =?ISO-8859-1?Q?=D3scar_Fuentes?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu May 01 02:36:19 2008 connect(): Connection refused 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.50) id 1JrMmV-00014i-N8 for ged-emacs-devel@m.gmane.org; Thu, 01 May 2008 02:36:16 +0200 Original-Received: from localhost ([127.0.0.1]:59803 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JrMlo-0000yq-B2 for ged-emacs-devel@m.gmane.org; Wed, 30 Apr 2008 20:35:32 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JrMlk-0000yl-Rj for emacs-devel@gnu.org; Wed, 30 Apr 2008 20:35:28 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JrMlh-0000yF-Ky for emacs-devel@gnu.org; Wed, 30 Apr 2008 20:35:27 -0400 Original-Received: from [199.232.76.173] (port=54153 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JrMlh-0000yB-FS for emacs-devel@gnu.org; Wed, 30 Apr 2008 20:35:25 -0400 Original-Received: from yw-out-1718.google.com ([74.125.46.152]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JrMlh-0008Rn-9c for emacs-devel@gnu.org; Wed, 30 Apr 2008 20:35:25 -0400 Original-Received: by yw-out-1718.google.com with SMTP id 5so505095ywm.66 for ; Wed, 30 Apr 2008 17:35:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding:sender; bh=9abUXJ3K7EzqC/5/K5LV8DVJVLla+DODrNNfNxNlhR8=; b=Q61XCszkzJVEm+hm6EbozzzRlu8AGtfW0OWilZ7SXqGUuRk22H8OuITuD2SVQQNwDmHjis1rd89Nc9TbVwP0QBYOVzJuFDdDIlQp6Ql89cTzdkWo3LWL7sNCHspmIaCUwVqwBaD0w7cmQ+M5Ts6mdya9eLFwjt+1ze4lNQxjwKQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding:sender; b=nSyg54CqI9ELzX5zSHCLR7wBF1Reubjjnj22KFcZT+jEgynilh1Pr7wXMbZOwSuYTlVGmYlbKgcorKG0F6rnCn4/7fyeyT4AvJfbdc0pDNS7S/J39m6N7Cc6/bInVFYo2he7G6RO0g9FycDbSd8lLxGXz+QRtpPRxU3lc9Rj5SU= Original-Received: by 10.150.82.41 with SMTP id f41mr1816868ybb.169.1209602110658; Wed, 30 Apr 2008 17:35:10 -0700 (PDT) Original-Received: from ?192.168.0.100? ( [201.82.228.209]) by mx.google.com with ESMTPS id 6sm310592ywi.9.2008.04.30.17.35.03 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 30 Apr 2008 17:35:05 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.13) Gecko/20080313 SeaMonkey/1.1.9 In-Reply-To: X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 2) 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:96255 Archived-At: >>>> (while (re-search-forward "^[+!>] .*?[ \t]+$" (point-max) t) >>>> >>> In unified diffs, there is no white space after `+'. In other diff >>> types, its seems that there is: >>> >>> +foo (changed or added line, unified diff) >>> >>>> foo (changed or added line, normal diff) >>>> >>> ! foo (changed line, context diff) >>> + foo (added line, context diff) >>> >>> The solution is to test the format type and adapt the regexp for it: >>> >>> (diff-beginning-of-hunk 'try-harder) >>> (setq (diff-hunk-style)) >>> (case style >>> (unified (setq re ...)) ;; (+) >>> (context (setq re ...)) ;; (+! ) >>> (t (setq re ...))) ;; (> ) >>> >>> >> Ok, so, maybe the functions below fix all of this. >> > [snip] > >> (while (re-search-forward "^[+!>].*?[ \t]+$" (point-max) t) >> > > As every change indicator is followed by a white space in non-unified > format, this regexp matches every change on normal and context > formats. This is not bad, as the trailing whitespace condition is tested > again below for the source file, which is what matters. But then, you > could use a simpler regexp above ("^[+!>]", for instance), for behaving > the same with diff formats. > Ok, but the search in diff buffer is only for modified lines with trailing blanks, so there is less finds/replacements in the source file. >> (defun diff-show-trailing-blanks () >> "Show trailing blanks in modified lines for diff-mode." >> (interactive) >> (let ((whitespace-style '(trailing)) >> (whitespace-trailing-regexp "^[+!>].*?\\([\t ]+\\)$")) >> (whitespace-mode 1))) ; display trailing blanks in diff buffer >> > > My CVS Emacs is a few weeks old, son I can't test this, but it looks > good to me :-) > Ok. >> (add-hook 'diff-mode-hook 'diff-show-trailing-blanks) >> > > Of course this is left for the .emacs file of each own. > Of course, this line is there only as an usage example. > However, I suggest adding a key sequence to diff-mode that executes > diff-remove-trailing-blanks. I use C-c C-k. And perhaps a more adequate > name is diff-kill-trailing-whitespace. > > Do you intend to install it on CVS soon? > Well, can I install diff-kill-trailing-whitespace and diff-show-trailing-whitespace into diff-mode?