Subject: Update to code

From: Reuben Thomas <[email-masked]>
Date: Thu, 28 Feb 2013 02:00:41 +0000

Apologies, the original code posted contained two lines which
shouldn't've been there, mentioning a non-existent "force" parameter
to whitespace-test-region. The function should read:

(defun whitespace-test-region (start end)
  "Find whether there are whitespace problems in a region.

Return nil if there is no whitespace problem; otherwise, return
non-nil.

A whitespace problem is one of the following:

* If `indent-tabs-mode' is non-nil:
   empty        1. empty lines at beginning of buffer.
   empty        2. empty lines at end of buffer.
   trailing        3. SPACEs or TABs at end of line.
   indentation        4. 8 or more SPACEs at beginning of line.
   space-before-tab    5. SPACEs before TAB.
   space-after-tab    6. 8 or more SPACEs after TAB.

* If `indent-tabs-mode' is nil:
   empty        1. empty lines at beginning of buffer.
   empty        2. empty lines at end of buffer.
   trailing        3. SPACEs or TABs at end of line.
   indentation        4. TABS at beginning of line.
   space-before-tab    5. SPACEs before TAB.
   space-after-tab    6. 8 or more SPACEs after TAB.

See `whitespace-style' for documentation.
See also `whitespace-cleanup' and `whitespace-cleanup-region' for
cleaning up these problems."
  (save-excursion
    (save-match-data                ;FIXME: Why?
      (let* ((has-bogus nil)
             (rstart    (min start end))
             (rend      (max start end))
             (bogus-list
              (mapcar
               #'(lambda (option)
                   (goto-char rstart)
                   (let ((regexp
                          (cond
                           ((eq (car option) 'indentation)
                            (whitespace-indentation-regexp))
                           ((eq (car option) 'indentation::tab)
                            (whitespace-indentation-regexp 'tab))
                           ((eq (car option) 'indentation::space)
                            (whitespace-indentation-regexp 'space))
                           ((eq (car option) 'space-after-tab)
                            (whitespace-space-after-tab-regexp))
                           ((eq (car option) 'space-after-tab::tab)
                            (whitespace-space-after-tab-regexp 'tab))
                           ((eq (car option) 'space-after-tab::space)
                            (whitespace-space-after-tab-regexp 'space))
                           (t
                            (cdr option)))))
                     (and (re-search-forward regexp rend t)
                          (setq has-bogus t))))
               whitespace-report-list)))
        has-bogus))))

--
http://rrt.sc3d.org