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 17:15:38 +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> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1209310726 1134 80.91.229.12 (27 Apr 2008 15:38:46 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 27 Apr 2008 15:38:46 +0000 (UTC) Cc: emacs-devel@gnu.org To: Vinicius Jose Latorre Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Apr 27 17:39:22 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 1Jq8yH-0007RB-8W for ged-emacs-devel@m.gmane.org; Sun, 27 Apr 2008 17:39:21 +0200 Original-Received: from localhost ([127.0.0.1]:45919 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Jq8xa-0000v7-U8 for ged-emacs-devel@m.gmane.org; Sun, 27 Apr 2008 11:38:38 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Jq8bR-0003TB-Pp for emacs-devel@gnu.org; Sun, 27 Apr 2008 11:15:45 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Jq8bQ-0003Sz-Qp for emacs-devel@gnu.org; Sun, 27 Apr 2008 11:15:45 -0400 Original-Received: from [199.232.76.173] (port=44641 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Jq8bQ-0003Sw-Le for emacs-devel@gnu.org; Sun, 27 Apr 2008 11:15:44 -0400 Original-Received: from outmailhost.telefonica.net ([213.4.149.242] helo=ctsmtpout2.frontal.correo) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Jq8bQ-0006y4-88 for emacs-devel@gnu.org; Sun, 27 Apr 2008 11:15:44 -0400 Original-Received: from K7 (81.38.8.112) by ctsmtpout2.frontal.correo (7.2.056.6) (authenticated as 981711563$telefonica.net) id 480F4DCA00104550; Sun, 27 Apr 2008 17:15:41 +0200 In-Reply-To: <48147BC0.6080406@ig.com.br> (Vinicius Jose Latorre's message of "Sun, 27 Apr 2008 10:12:32 -0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (windows-nt) X-detected-kernel: by monty-python.gnu.org: Genre and OS details not recognized. X-Mailman-Approved-At: Sun, 27 Apr 2008 11:37:49 -0400 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:96005 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 ...))) ;; (> ) [snip] > (if modified-buffers > (let ((whitespace-style '(trailing)) > (whitespace-trailing-regexp "^[+!>] .*?\\([\t ]+\\)$")) Likewise. > (whitespace-mode 1) ; display trailing blanks in diff buffer Seeing that the diff introduces trailing whitespace is most interesting before removing it too. Actually, you want to highlight trailing withespace on the diff for knowing that you should invoke `diff-remove-trailing-blanks'. (A nice thing would be to automatically test the diff and put something on the buffer's modeline indicating that the diff introduces trailing whitespace. `diff-mode-hook' is handy for this). [snip] -- Oscar