[Mailman-Developers] Scrubber.py confusion, 2.1b3

Barry A. Warsaw barry@python.org
Tue, 20 Aug 2002 14:59:34 -0400


>>>>> "DN" == Dale Newfield <Dale@Newfield.org> writes:

    DN> Noticed that.  Great catch--thanks for the quick fix.  Let me
    DN> reiterate my earlier plea (for others to hear, since you've
    DN> already followed it :-) for the entire codebase:

    DN> "Spaces!  No tabs, please!"

+1

For (X)Emacs heads, here's the little bit of elisp I use to clean
files up -- when I think about it.

-Barry

;; untabify and clean up lines with just whitespace
(defun baw-whitespace-normalization (start end)
  "Like untabify, but also cleans up lines with trailing whitespace."
  (interactive "r")
  (save-excursion
    (save-restriction
      (untabify start end)
      (narrow-to-region (point-min) end)
      (goto-char start)
      (while (re-search-forward "\\s +$" nil t)
	(let ((bol (save-excursion (beginning-of-line) (point)))
	      (eol (save-excursion (end-of-line) (point))))
	  (goto-char (match-beginning 0))
	  (if (and (bolp)
		   (eq (char-after) ?\))
	      (forward-char 1))
	  (skip-chars-backward " \t" bol)
	  (delete-region (point) eol)
	  ))
      )))