GNU bug report logs - #13837
24.2; Make it possible to turn whitespace-mode only when there are no existing problems

Previous Next

Package: emacs;

Reported by: Reuben Thomas <rrt <at> sc3d.org>

Date: Wed, 27 Feb 2013 21:45:02 UTC

Severity: wishlist

Found in version 24.2

Fixed in version 25.1

Done: Glenn Morris <rgm <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


Message #8 received at 13837 <at> debbugs.gnu.org (full text, mbox):

From: Reuben Thomas <rrt <at> sc3d.org>
To: 13837 <at> debbugs.gnu.org
Subject: Update to code
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




This bug report was last modified 10 years and 235 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.