From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Yoni Rabkin Katzenell Newsgroups: gmane.emacs.devel Subject: Re: whitespace-cleanup from /etc/TODO Date: Wed, 16 Aug 2006 13:51:26 +0300 Message-ID: <87ac65t0lt.fsf@actcom.com> References: <87zme8tqxx.fsf@actcom.com> <39934.128.165.123.18.1155596038.squirrel@webmail.lanl.gov> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1155725442 24690 80.91.229.2 (16 Aug 2006 10:50:42 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 16 Aug 2006 10:50:42 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Aug 16 12:50:38 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GDIyi-0000tV-QG for ged-emacs-devel@m.gmane.org; Wed, 16 Aug 2006 12:50:29 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GDIyi-0005q8-BS for ged-emacs-devel@m.gmane.org; Wed, 16 Aug 2006 06:50:28 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GDIy3-0005Su-FS for emacs-devel@gnu.org; Wed, 16 Aug 2006 06:49:47 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GDIy2-0005RZ-RK for emacs-devel@gnu.org; Wed, 16 Aug 2006 06:49:47 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GDIy2-0005RQ-Fx for emacs-devel@gnu.org; Wed, 16 Aug 2006 06:49:46 -0400 Original-Received: from [80.91.229.2] (helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1GDJ4H-0000TW-4e for emacs-devel@gnu.org; Wed, 16 Aug 2006 06:56:13 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1GDIxs-0000j2-G0 for emacs-devel@gnu.org; Wed, 16 Aug 2006 12:49:36 +0200 Original-Received: from 192.117.103.37 ([192.117.103.37]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 16 Aug 2006 12:49:36 +0200 Original-Received: from yoni-r by 192.117.103.37 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 16 Aug 2006 12:49:36 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-To: emacs-devel@gnu.org Original-Lines: 101 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: 192.117.103.37 X-Ethics: Use GNU User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.50 (gnu/linux) Cancel-Lock: sha1:YAAaJJw9ueXIyW7wlMG27ZdxGtY= 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:58438 Archived-At: "Stuart D. Herring" writes: >> + (defvar whitespace-region-only nil >> + "Keep track of whether whitespace has been run on a region or >> buffer.") >> + (make-variable-buffer-local 'whitespace-region-only) >> + >> ;; For flavors of Emacs which don't define `defgroup' and `defcustom'. >> (eval-when-compile >> (if (not (fboundp 'defgroup)) >> *************** >> *** 522,528 **** >> (interactive) >> (if (and transient-mark-mode mark-active) >> (whitespace-cleanup-region (region-beginning) (region-end)) >> ! (whitespace-cleanup-internal))) >> >> (defun whitespace-cleanup-internal () >> ;; If this buffer really contains a file, then run, else quit. >> --- 526,534 ---- >> (interactive) >> (if (and transient-mark-mode mark-active) >> (whitespace-cleanup-region (region-beginning) (region-end)) >> ! (progn >> ! (setq whitespace-region-only nil) >> ! (whitespace-cleanup-internal)))) > > This presumably works, but it's the long way around. Just add an argument > REGION to `whitespace-cleanup-internal' instead of defining a new > top-level symbol. Then invoke it from `whitespace-cleanup-region' with > that argument non-nil. If there's some reason that doesn't work, at least > `let'-bind the variable rather than just setting it. You are right. Here is a patch to solve the problem as you suggest: diff -c /home/yrk/devel/sandbox/emacs-hacking/whitespace-original.el /home/yrk/devel/sandbox/emacs-hacking/whitespace.el *** /home/yrk/devel/sandbox/emacs-hacking/whitespace-original.el 2006-08-13 21:23:58.000000000 +0300 --- /home/yrk/devel/sandbox/emacs-hacking/whitespace.el 2006-08-15 21:27:15.066569112 +0300 *************** *** 524,530 **** (whitespace-cleanup-region (region-beginning) (region-end)) (whitespace-cleanup-internal))) ! (defun whitespace-cleanup-internal () ;; If this buffer really contains a file, then run, else quit. (whitespace-check-whitespace-mode current-prefix-arg) (if (and buffer-file-name whitespace-mode) --- 524,530 ---- (whitespace-cleanup-region (region-beginning) (region-end)) (whitespace-cleanup-internal))) ! (defun whitespace-cleanup-internal (&optional region-only) ;; If this buffer really contains a file, then run, else quit. (whitespace-check-whitespace-mode current-prefix-arg) (if (and buffer-file-name whitespace-mode) *************** *** 569,577 **** ;; Call this recursively till everything is taken care of (if whitespace-any (whitespace-cleanup-internal) (progn ! (if (not whitespace-silent) ! (message "%s clean" buffer-file-name)) (whitespace-update-modeline))) (setq tab-width whitespace-tabwith-saved)))) --- 569,580 ---- ;; Call this recursively till everything is taken care of (if whitespace-any (whitespace-cleanup-internal) + ;; if we are done, talk to the user (progn ! (unless whitespace-silent ! (if region-only ! (message "The region is now clean") ! (message "%s is now clean" buffer-file-name))) (whitespace-update-modeline))) (setq tab-width whitespace-tabwith-saved)))) *************** *** 582,588 **** (save-excursion (save-restriction (narrow-to-region s e) ! (whitespace-cleanup-internal)) (whitespace-buffer t))) (defun whitespace-buffer-leading () --- 585,591 ---- (save-excursion (save-restriction (narrow-to-region s e) ! (whitespace-cleanup-internal t)) (whitespace-buffer t))) (defun whitespace-buffer-leading () Diff finished. Tue Aug 15 21:30:17 2006 -- "Cut your own wood and it will warm you twice"