all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Yoni Rabkin Katzenell <yoni-r@actcom.com>
Subject: Re: whitespace-cleanup from /etc/TODO
Date: Wed, 16 Aug 2006 13:51:26 +0300	[thread overview]
Message-ID: <87ac65t0lt.fsf@actcom.com> (raw)
In-Reply-To: 39934.128.165.123.18.1155596038.squirrel@webmail.lanl.gov

"Stuart D. Herring" <herring@lanl.gov> 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"

      reply	other threads:[~2006-08-16 10:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-13 18:45 whitespace-cleanup from /etc/TODO Yoni Rabkin Katzenell
2006-08-14  5:43 ` Adrian Aichner
2006-08-14  8:04   ` Yoni Rabkin Katzenell
2006-08-14 22:53 ` Stuart D. Herring
2006-08-16 10:51   ` Yoni Rabkin Katzenell [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ac65t0lt.fsf@actcom.com \
    --to=yoni-r@actcom.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.