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: Sat, 26 Apr 2008 23:30:26 -0300 Message-ID: <4813E542.10802@ig.com.br> References: <200804261845.m3QIixvX026773@sallyv1.ics.uci.edu> <4813879E.8030700@ig.com.br> <4813A244.4050908@ig.com.br> <8wz09so0.fsf@telefonica.net> 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 1209263480 20153 80.91.229.12 (27 Apr 2008 02:31:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 27 Apr 2008 02:31:20 +0000 (UTC) Cc: emacs-devel@gnu.org To: =?ISO-8859-1?Q?=D3scar_Fuentes?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Apr 27 04:31:55 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 1JpwgE-0007ZV-73 for ged-emacs-devel@m.gmane.org; Sun, 27 Apr 2008 04:31:54 +0200 Original-Received: from localhost ([127.0.0.1]:39250 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JpwfX-00021x-Mp for ged-emacs-devel@m.gmane.org; Sat, 26 Apr 2008 22:31:11 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JpwfU-00021O-5P for emacs-devel@gnu.org; Sat, 26 Apr 2008 22:31:08 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JpwfR-0001y9-Ar for emacs-devel@gnu.org; Sat, 26 Apr 2008 22:31:07 -0400 Original-Received: from [199.232.76.173] (port=42543 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JpwfR-0001y0-8Y for emacs-devel@gnu.org; Sat, 26 Apr 2008 22:31:05 -0400 Original-Received: from yw-out-1718.google.com ([74.125.46.156]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JpwfQ-0006Lt-UO for emacs-devel@gnu.org; Sat, 26 Apr 2008 22:31:05 -0400 Original-Received: by yw-out-1718.google.com with SMTP id 9so3249399ywk.66 for ; Sat, 26 Apr 2008 19:31:02 -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=ZroLp3+aMBhWxx+W3W1ggafVNjI3zgFqtuUqlJ/8zi8=; b=b1bs9PvWI747nv6SikGaH6ZKhrh5EiPyVGrSbFFVq6Ln0C0PwB73ELQyGo0goeHkFI6TKV6muKhlv/vpggfa+zkArt0/WiwQsu0VKyj9OEPlc5F5bjFYKHqEfHJzWz99nt88jcH5a5Z+VtkC+TzHIbTpY/dJ5vcYmzViiy9djxY= 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=h7gwpbPrGAATqhDlp673vDs6iaYwuYAd8DJ75BJTTZmIJhGskDHw7M9QelR7fJEmgL7UJg/wzCupIm7dpSJsZdHqYC9Am2Ic2daROyWkyzsvLviixtGNg7ewP+9Y11vFlWRXVBAKS83OfwIB5fMQnDvBGGZoyFwXhu2252ZdVlc= Original-Received: by 10.150.86.10 with SMTP id j10mr2301206ybb.202.1209263462412; Sat, 26 Apr 2008 19:31:02 -0700 (PDT) Original-Received: from ?192.168.0.100? ( [200.208.45.144]) by mx.google.com with ESMTPS id 6sm8091971ywi.7.2008.04.26.19.30.59 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 26 Apr 2008 19:31:00 -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: <8wz09so0.fsf@telefonica.net> 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:95996 Archived-At: >>>> What relevant things would you like to see (or to be done) in a diff buffer? >>>> >>> Here, we are interested on parts of the buffer, we don't care much about >>> trailing whitespace out of the diff part that shows changed lines. That >>> is, we are not interested on trailing whitespace on context lines, nor >>> on those that are artifacts of diff-mode. >>> >> Hummm, I'm confused, the original mail said: >> >> "When on a buffer that contains a diff, inspects the >> differences and removes trailing whitespace (spaces, tabs) from >> the lines modified or introduced by this diff. Shows a message >> with the name of the altered buffers, which are unsaved. If a >> file referenced on the diff has no buffer and needs to be fixed, >> a buffer visiting that file is created." >> >> >> So, I thought it was to remove trailing whitespaces from a diff buffer. > > The "removing" part is accomplished by my function. We are discussing > the "displaying" part, which shows to the user that there is trailing > whitespace to be removed. > > But I'm afraid I confused things out relating `show-trailing-whitespace' > to whitespace-mode'. Well, both parts, the "removing" part and the "displaying" part, related with trailing whitespaces can be done by whitespace-mode. Does the following function do the job? (defun diff-remove-trailing-blanks () "When on a buffer that contains a diff, inspects the differences and removes trailing whitespace (spaces, tabs). Shows a message with the name of the altered buffers, which are unsaved. If a file referenced on the diff has no buffer and needs to be fixed, a buffer visiting that file is created." (interactive) (goto-char (point-min)) ;; We assume that the diff header has no trailing whitespace. (let (modified-buffers) (while (re-search-forward "^[+!>].*[ \t]+$" (point-max) t) (save-excursion (destructuring-bind (buf line-offset pos src dst &optional switched) (diff-find-source-location t t) (unless (member buf modified-buffers) (when line-offset (set-buffer buf) (when (re-search-forward "\\([ \t]+\\)$" (point-max) t) (push buf modified-buffers) (let ((whitespace-style '(trailing))) (whitespace-cleanup)))))))) ; cleanup trailing blanks in buf (if modified-buffers (let ((bufs (mapconcat #(lambda (buf) (format "`%s'" (buffer-name buf))) modified-buffers " ")) (whitespace-style '(trailing))) (whitespace-mode) ; display trailing blanks in diff buffer (message "Deleted trailing whitespace from: %s" bufs)) (message "No fixes needed.")))) >> What are the relevant parts of the buffer? > > Those that correspond to added or modified lines in the diff. So, should lines beginning with +, - and ! have a face to display the change?