From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Reuben Thomas Newsgroups: gmane.emacs.bugs 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 Message-ID: <1390857567.273549.1665@skwd> References: <878v69fn8q.fsf@sc3d.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1390857612 5495 80.91.229.3 (27 Jan 2014 21:20:12 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 27 Jan 2014 21:20:12 +0000 (UTC) Cc: 13837@debbugs.gnu.org, Dmitry Gutov To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Jan 27 22:20:18 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1W7tbO-0001UO-72 for geb-bug-gnu-emacs@m.gmane.org; Mon, 27 Jan 2014 22:20:18 +0100 Original-Received: from localhost ([::1]:33676 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W7tbN-00017P-Ok for geb-bug-gnu-emacs@m.gmane.org; Mon, 27 Jan 2014 16:20:17 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36144) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W7tbE-00016O-Fr for bug-gnu-emacs@gnu.org; Mon, 27 Jan 2014 16:20:14 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W7tb8-0000Z3-D8 for bug-gnu-emacs@gnu.org; Mon, 27 Jan 2014 16:20:08 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:52659) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W7tb8-0000Wu-7U for bug-gnu-emacs@gnu.org; Mon, 27 Jan 2014 16:20:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1W7tb7-0005p8-Qk for bug-gnu-emacs@gnu.org; Mon, 27 Jan 2014 16:20:01 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: <878v69fn8q.fsf@sc3d.org> Resent-From: Reuben Thomas Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 27 Jan 2014 21:20:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 13837 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 13837-submit@debbugs.gnu.org id=B13837.139085757322343 (code B ref 13837); Mon, 27 Jan 2014 21:20:01 +0000 Original-Received: (at 13837) by debbugs.gnu.org; 27 Jan 2014 21:19:33 +0000 Original-Received: from localhost ([127.0.0.1]:38445 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W7tae-0005oJ-TW for submit@debbugs.gnu.org; Mon, 27 Jan 2014 16:19:33 -0500 Original-Received: from mail-wg0-f51.google.com ([74.125.82.51]:37450) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W7tab-0005o7-Lm for 13837@debbugs.gnu.org; Mon, 27 Jan 2014 16:19:30 -0500 Original-Received: by mail-wg0-f51.google.com with SMTP id z12so6160129wgg.6 for <13837@debbugs.gnu.org>; Mon, 27 Jan 2014 13:19:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sc3d.org; s=google; h=from:to:cc:subject:mime-version:content-type :content-transfer-encoding:date:message-id; bh=N+0tSlTDDNU4lipVcYqSJhhiHPpahE+3nKD1xVAbqH0=; b=rgjQi6c7Ns6j2bXL54h5VZ7XUw4Bf2LAy+bVTAs22gGLFid0lSb1lS0UXp7rjGmNp8 JnsjLUTIl1HJ7DORNYu86nLtUOJR0aHunk6gkU4w17eSioh1zfeOz15Nd7eTrpJAL4il fh5pnQd4V48GjTNAriD8X+Eim3XKVkO4FCUhs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:mime-version:content-type :content-transfer-encoding:date:message-id; bh=N+0tSlTDDNU4lipVcYqSJhhiHPpahE+3nKD1xVAbqH0=; b=J7KoDJJSmOFPUEbwFgUYazGn6sFP+tHFAQ2wNcEzqum8rSMVaaFxgYqJmYoUccu1tF sPOLCa5AnMmKcdKATSYyHcocUJcWnSLCmkACr4HqPbSZ5yKW2zm4Y+N7W65Oo0UNQY99 2KuwD0AkUlVrCDRHQZaNAQjRLXE6OV7OFPGeQm8lOSDdcPeCvmqHqGcgOApRw0IyW9NX 5Ahcnz/VtH36MZhOFAhCybSAR+c5p05sDVSlpZQZTDy9CS1E0ED0NkKLFvcLSyxERLSn zQuQo8oHlQ9z2/gEOydxxVslaUYsFhecRM4ZOX7gvmB79Y5cQhehHYebQEJbQDB4Gqjo Tgow== X-Gm-Message-State: ALoCoQkLHBX5hI/pvj0LhIHqgxHc6AoNSwdLpU1N4HE+DZcSFUY0LztulQBwTBOIhIie4XpH3+uS X-Received: by 10.180.96.228 with SMTP id dv4mr447054wib.24.1390857568873; Mon, 27 Jan 2014 13:19:28 -0800 (PST) Original-Received: from skwd ([90.212.124.146]) by mx.google.com with ESMTPSA id jw4sm28120468wjc.20.2014.01.27.13.19.27 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 27 Jan 2014 13:19:27 -0800 (PST) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:84142 Archived-At: 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/