unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Reuben Thomas <rrt@sc3d.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 13837@debbugs.gnu.org, Dmitry Gutov <dgutov@yandex.ru>
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	[thread overview]
Message-ID: <1390857567.273549.1665@skwd> (raw)
In-Reply-To: <878v69fn8q.fsf@sc3d.org>

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/





  parent reply	other threads:[~2014-01-27 21:19 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-27 21:41 bug#13837: 24.2; Make it possible to turn whitespace-mode only when there are no existing problems Reuben Thomas
2013-02-28  2:00 ` bug#13837: Update to code Reuben Thomas
2013-02-28 16:23 ` bug#13837: 24.2; Make it possible to turn whitespace-mode only when there are no existing problems Stefan Monnier
2013-02-28 16:32   ` Stefan Monnier
2013-03-01 22:02     ` Reuben Thomas
2013-03-02  3:02       ` Stefan Monnier
2013-03-02  7:46         ` Reuben Thomas
2013-03-03 23:36           ` Stefan Monnier
2013-03-01 22:21   ` Reuben Thomas
2013-03-02  3:01     ` Stefan Monnier
2013-03-02  7:49       ` Reuben Thomas
2013-04-10  0:50         ` Reuben Thomas
2013-10-17 23:09           ` Reuben Thomas
2014-01-26 23:12             ` Reuben Thomas
2014-01-26 23:29               ` Dmitry Gutov
2014-01-26 23:31                 ` Reuben Thomas
2014-01-27  0:27                   ` Dmitry Gutov
2014-01-27  0:41                     ` Reuben Thomas
2014-01-27  1:52                       ` Stefan Monnier
2014-01-27 13:25                         ` Reuben Thomas
2014-01-27 15:00                           ` Stefan Monnier
2014-01-27 21:19 ` Reuben Thomas [this message]
2014-01-28  0:32   ` Stefan Monnier
2014-01-28  0:48     ` Reuben Thomas
2014-05-29 17:26       ` Stefan Monnier
2014-05-29 19:01         ` Reuben Thomas
2014-05-29 20:28           ` Stefan Monnier
2014-05-29 22:53             ` Reuben Thomas
2014-05-30  2:01               ` Glenn Morris
2014-05-29 19:02 ` Reuben Thomas

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=1390857567.273549.1665@skwd \
    --to=rrt@sc3d.org \
    --cc=13837@debbugs.gnu.org \
    --cc=dgutov@yandex.ru \
    --cc=monnier@iro.umontreal.ca \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).