From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?iso-8859-1?Q?=D3scar_Fuentes?= Newsgroups: gmane.emacs.devel Subject: Re: Proposal: diff-remove-trailing-blanks Date: Sun, 27 Apr 2008 22:05:56 +0200 Message-ID: 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=us-ascii X-Trace: ger.gmane.org 1209326796 16180 80.91.229.12 (27 Apr 2008 20:06:36 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 27 Apr 2008 20:06:36 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Apr 27 22:07:11 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 1JqD9H-0008BP-TL for ged-emacs-devel@m.gmane.org; Sun, 27 Apr 2008 22:07:00 +0200 Original-Received: from localhost ([127.0.0.1]:33406 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JqD8b-00080R-AK for ged-emacs-devel@m.gmane.org; Sun, 27 Apr 2008 16:06:17 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JqD8X-000805-0v for emacs-devel@gnu.org; Sun, 27 Apr 2008 16:06:13 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JqD8W-0007zt-IX for emacs-devel@gnu.org; Sun, 27 Apr 2008 16:06:12 -0400 Original-Received: from [199.232.76.173] (port=56317 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JqD8W-0007zq-Bk for emacs-devel@gnu.org; Sun, 27 Apr 2008 16:06:12 -0400 Original-Received: from main.gmane.org ([80.91.229.2] helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JqD8V-00082h-Rw for emacs-devel@gnu.org; Sun, 27 Apr 2008 16:06:12 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1JqD8R-0006CZ-Sc for emacs-devel@gnu.org; Sun, 27 Apr 2008 20:06:07 +0000 Original-Received: from 112.red-81-38-8.dynamicip.rima-tde.net ([81.38.8.112]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 27 Apr 2008 20:06:07 +0000 Original-Received: from ofv by 112.red-81-38-8.dynamicip.rima-tde.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 27 Apr 2008 20:06:07 +0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 57 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 112.red-81-38-8.dynamicip.rima-tde.net User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (windows-nt) Cancel-Lock: sha1:aCZYlzIyVj8s9dwoYxd9hS0wxnw= X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) 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:96012 Archived-At: Vinicius Jose Latorre writes: >>> (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. [snip] > (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 :-) > (add-hook 'diff-mode-hook 'diff-show-trailing-blanks) Of course this is left for the .emacs file of each own. 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? -- Oscar