bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#13837: 24.2; Make it possible to turn whitespace-mode only when ther


From: Reuben Thomas
Subject: bug#13837: 24.2; Make it possible to turn whitespace-mode only when there are no existing problems
Date: Mon, 27 Jan 2014 21:19:27 -0000

I’ve thought about the approach taken by my original patch and
concluded that it’s wrong: better not to split
whitespace-report-region, but instead allow it not to report. If the
report parameter (renamed from report-if-bogus) is 'never, then it
does not report any problem.

I’ve updated the docstring describing whitespace problems to common up
the indent-tabs-mode true/false lists as promised.

The unconditional updating of whitespace-style remains.

Patch follows.

=== modified file 'lisp/whitespace.el'
--- lisp/whitespace.el  2014-01-27 12:30:17 +0000
+++ lisp/whitespace.el  2014-01-27 21:03:00 +0000
@@ -1714,7 +1714,7 @@
 
 
 ;;;###autoload
-(defun whitespace-report (&optional force report-if-bogus)
+(defun whitespace-report (&optional force report)
   "Report some whitespace problems in buffer.
 
 Return nil if there is no whitespace problem; otherwise, return
@@ -1730,8 +1730,8 @@
    space-before-tab
    space-after-tab
 
-If REPORT-IF-BOGUS is non-nil, it reports only when there are any
-whitespace problems in buffer.
+If REPORT is t, it reports only when there are any whitespace
+problems in buffer; if it is 'never, it does not report problems.
 
 Report if some of the following whitespace problems exist:
 
@@ -1756,11 +1756,11 @@
 cleaning up these problems."
   (interactive (list current-prefix-arg))
   (whitespace-report-region (point-min) (point-max)
-                           force report-if-bogus))
+                           force report))
 
 
 ;;;###autoload
-(defun whitespace-report-region (start end &optional force report-if-bogus)
+(defun whitespace-report-region (start end &optional force report)
   "Report some whitespace problems in a region.
 
 Return nil if there is no whitespace problem; otherwise, return
@@ -1776,26 +1776,22 @@
    trailing
    space-after-tab
 
-If REPORT-IF-BOGUS is non-nil, it reports only when there are any
-whitespace problems in buffer.
+If REPORT is t, it reports only when there are any whitespace
+problems in buffer; if it is 'never, it does not report problems.
 
 Report if some of the following whitespace problems exist:
 
+   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.
+   space-before-tab    4. SPACEs before TAB.
+   space-after-tab     5. 8 or more SPACEs after TAB.
+
 * 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.
+   indentation         6. 8 or more SPACEs at beginning of line.
 
 * 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.
+   indentation         6. TABS at beginning of line.
 
 See `whitespace-style' for documentation.
 See also `whitespace-cleanup' and `whitespace-cleanup-region' for
@@ -1832,7 +1828,7 @@
                     (and (re-search-forward regexp rend t)
                          (setq has-bogus t))))
               whitespace-report-list)))
-       (when (if report-if-bogus has-bogus t)
+       (when (if (equal report t) has-bogus (null report))
          (whitespace-kill-buffer whitespace-report-buffer-name)
          ;; `whitespace-indent-tabs-mode' is local to current buffer
          ;; `whitespace-tab-width' is local to current buffer

-- 
http://rrt.sc3d.org/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]