From: Reuben Thomas <rrt@sc3d.org>
To: Dmitry Gutov <dgutov@yandex.ru>
Cc: 24745@debbugs.gnu.org
Subject: bug#24745: 25.1.50; whitespace.el: fix beginning/end of buffer checks
Date: Wed, 26 Oct 2016 00:26:03 +0100 [thread overview]
Message-ID: <CAOnWdoi_iDOdXGoL7MNR+2zhuveiEP6kJVRKcN2Kq8v0uB-vzg@mail.gmail.com> (raw)
In-Reply-To: <39a8c955-928a-1551-3943-b8ccfda38eca@yandex.ru>
[-- Attachment #1.1: Type: text/plain, Size: 1855 bytes --]
On 25 October 2016 at 23:45, Dmitry Gutov <dgutov@yandex.ru> wrote:
> On 25.10.2016 21:44, Reuben Thomas wrote:
>
> I should check some context: my understanding is that inline
>> documentation in .el files is mainly useful for high-level documentation
>> for standalone packages. Packages that form part of Emacs should be
>> documented in the manual (as whitespace.el is); details of functions and
>> variables should be in docstrings (as is the case for whitespace.el).
>> The docstrings of customizable options are readable in the customize
>> interface.
>>
>
> Maybe you're right. I'd leave at least "to change behavior, do M-x
> customize-group whitespace", though.
I've re-added that.
> You can automate the adherence to most of these rules by first entering
> the messages in a local-only ChangeLog file, using 'C-x 4 a'. Also see
> "Generating ChangeLog entries" in CONTRIBUTE.
Thanks, I was confused by the fact that since I last submitted patches, we
no longer update ChangeLog files directly when committing.
Thanks. Do you have commit access?
>
I have.
I attach the patch series again with the documentation fix above, and two
more patches which complete my intended work. The last two are:
1. Fix documentation to mention `tab-width', not `8'.
2. Fix whitespace-report-region to a) use the currently active
whitespace-style, that is, whitespace-style-active, and b) take a copy of
it, so that use of the `force' parameter does not cause the style to be
updated outside the function. It falls back to `whitespace-style' if
`whitespace-active-style' is not set, so that whitespace-report can be used
when the mode is not already active (I use it thus to turn the mode on only
in whitespace-clean buffers in my whitespace-enable-predicate).
--
http://rrt.sc3d.org
[-- Attachment #1.2: Type: text/html, Size: 3448 bytes --]
[-- Attachment #2: 0001-Fix-bob-eob-checks.patch --]
[-- Type: text/x-patch, Size: 1832 bytes --]
From fe36f176566d13fcaa2f805737328191adf6dd4f Mon Sep 17 00:00:00 2001
From: Reuben Thomas <rrt@sc3d.org>
Date: Thu, 20 Oct 2016 13:17:58 +0100
Subject: [PATCH 1/6] Fix bob/eob checks
* lisp/whitespace.el (whitespace-empty-at-bob-regexp)
(whitespace-empty-at-eob-regexp, whitespace-cleanup): Make `empty' checks
work at beginning & end of buffer in whitespace-report-region, and only
there (i.e. they will never match in regions that don't include the
start or end of the buffer). See bug #24745.
---
lisp/whitespace.el | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lisp/whitespace.el b/lisp/whitespace.el
index 0f6b8df..6164585 100644
--- a/lisp/whitespace.el
+++ b/lisp/whitespace.el
@@ -828,7 +828,7 @@ whitespace-indentation-regexp
:group 'whitespace)
-(defcustom whitespace-empty-at-bob-regexp "^\\(\\([ \t]*\n\\)+\\)"
+(defcustom whitespace-empty-at-bob-regexp "\\`\\(\\([ \t]*\n\\)+\\)"
"Specify regexp for empty lines at beginning of buffer.
Used when `whitespace-style' includes `empty'."
@@ -836,7 +836,7 @@ whitespace-empty-at-bob-regexp
:group 'whitespace)
-(defcustom whitespace-empty-at-eob-regexp "^\\([ \t\n]+\\)"
+(defcustom whitespace-empty-at-eob-regexp "^\\([ \t\n]*\\(\n\\{2,\\}\\|[ \t]+\\)\\)\\'"
"Specify regexp for empty lines at end of buffer.
Used when `whitespace-style' includes `empty'."
@@ -1515,7 +1515,7 @@ whitespace-cleanup
(when (looking-at whitespace-empty-at-bob-regexp)
(delete-region (match-beginning 1) (match-end 1)))
(when (re-search-forward
- (concat whitespace-empty-at-eob-regexp "\\'") nil t)
+ whitespace-empty-at-eob-regexp nil t)
(delete-region (match-beginning 1) (match-end 1)))))))
;; PROBLEM 3: 8 or more SPACEs at bol
;; PROBLEM 4: SPACEs before TAB
--
2.7.4
[-- Attachment #3: 0002-Remove-duplicate-documentation.patch --]
[-- Type: text/x-patch, Size: 5357 bytes --]
From dc87bc3ef6b732da89e993c8d510d882be75a82a Mon Sep 17 00:00:00 2001
From: Reuben Thomas <rrt@sc3d.org>
Date: Fri, 21 Oct 2016 15:20:07 +0100
Subject: [PATCH 2/6] Remove duplicate documentation
* lisp/whitespace.el: Remove duplicate documentation from the Commentary
section which duplicate and in some places contradict (due to being
out of date) the docstrings. See bug #24745.
---
lisp/whitespace.el | 122 +++--------------------------------------------------
1 file changed, 7 insertions(+), 115 deletions(-)
diff --git a/lisp/whitespace.el b/lisp/whitespace.el
index 6164585..f5c2f2f 100644
--- a/lisp/whitespace.el
+++ b/lisp/whitespace.el
@@ -178,48 +178,17 @@
;;
;; `whitespace-cleanup'
;; Cleanup some blank problems in all buffer or at region.
+;; See the function's docstring for more information.
;;
;; `whitespace-cleanup-region'
;; Cleanup some blank problems at region.
;;
-;; The problems, which are cleaned up, are:
-;;
-;; 1. empty lines at beginning of buffer.
-;; 2. empty lines at end of buffer.
-;; If `whitespace-style' includes the value `empty', remove all
-;; empty lines at beginning and/or end of buffer.
-;;
-;; 3. 8 or more SPACEs at beginning of line.
-;; If `whitespace-style' includes the value `indentation':
-;; replace 8 or more SPACEs at beginning of line by TABs, if
-;; `indent-tabs-mode' is non-nil; otherwise, replace TABs by
-;; SPACEs.
-;; If `whitespace-style' includes the value `indentation::tab',
-;; replace 8 or more SPACEs at beginning of line by TABs.
-;; If `whitespace-style' includes the value `indentation::space',
-;; replace TABs by SPACEs.
-;;
-;; 4. SPACEs before TAB.
-;; If `whitespace-style' includes the value `space-before-tab':
-;; replace SPACEs by TABs, if `indent-tabs-mode' is non-nil;
-;; otherwise, replace TABs by SPACEs.
-;; If `whitespace-style' includes the value
-;; `space-before-tab::tab', replace SPACEs by TABs.
-;; If `whitespace-style' includes the value
-;; `space-before-tab::space', replace TABs by SPACEs.
-;;
-;; 5. SPACEs or TABs at end of line.
-;; If `whitespace-style' includes the value `trailing', remove all
-;; SPACEs or TABs at end of line.
-;;
-;; 6. 8 or more SPACEs after TAB.
-;; If `whitespace-style' includes the value `space-after-tab':
-;; replace SPACEs by TABs, if `indent-tabs-mode' is non-nil;
-;; otherwise, replace TABs by SPACEs.
-;; If `whitespace-style' includes the value `space-after-tab::tab',
-;; replace SPACEs by TABs.
-;; If `whitespace-style' includes the value
-;; `space-after-tab::space', replace TABs by SPACEs.
+;;
+;; Options
+;; -------
+;;
+;; Whitespace's behavior can be changed with M-x customize-group
+;; whitespace, which see for a full list of options.
;;
;;
;; Hooks
@@ -237,83 +206,6 @@
;; It is evaluated after whitespace package is loaded.
;;
;;
-;; Options
-;; -------
-;;
-;; Below it's shown a brief description of whitespace options, please,
-;; see the options declaration in the code for a long documentation.
-;;
-;; `whitespace-style' Specify which kind of blank is
-;; visualized.
-;;
-;; `whitespace-space' Face used to visualize SPACE.
-;;
-;; `whitespace-hspace' Face used to visualize HARD SPACE.
-;;
-;; `whitespace-tab' Face used to visualize TAB.
-;;
-;; `whitespace-newline' Face used to visualize NEWLINE char
-;; mapping.
-;;
-;; `whitespace-trailing' Face used to visualize trailing
-;; blanks.
-;;
-;; `whitespace-line' Face used to visualize "long" lines.
-;;
-;; `whitespace-space-before-tab' Face used to visualize SPACEs
-;; before TAB.
-;;
-;; `whitespace-indentation' Face used to visualize 8 or more
-;; SPACEs at beginning of line.
-;;
-;; `whitespace-big-indent' Face used to visualize big indentation.
-;;
-;; `whitespace-empty' Face used to visualize empty lines at
-;; beginning and/or end of buffer.
-;;
-;; `whitespace-space-after-tab' Face used to visualize 8 or more
-;; SPACEs after TAB.
-;;
-;; `whitespace-space-regexp' Specify SPACE characters regexp.
-;;
-;; `whitespace-hspace-regexp' Specify HARD SPACE characters regexp.
-;;
-;; `whitespace-tab-regexp' Specify TAB characters regexp.
-;;
-;; `whitespace-trailing-regexp' Specify trailing characters regexp.
-;;
-;; `whitespace-space-before-tab-regexp' Specify SPACEs before TAB
-;; regexp.
-;;
-;; `whitespace-indentation-regexp' Specify regexp for 8 or more
-;; SPACEs at beginning of line.
-;;
-;; `whitespace-big-indent-regexp' Specify big indentation at beginning of line
-;; regexp.
-;;
-;; `whitespace-empty-at-bob-regexp' Specify regexp for empty lines
-;; at beginning of buffer.
-;;
-;; `whitespace-empty-at-eob-regexp' Specify regexp for empty lines
-;; at end of buffer.
-;;
-;; `whitespace-space-after-tab-regexp' Specify regexp for 8 or more
-;; SPACEs after TAB.
-;;
-;; `whitespace-line-column' Specify column beyond which the line
-;; is highlighted.
-;;
-;; `whitespace-display-mappings' Specify an alist of mappings
-;; for displaying characters.
-;;
-;; `whitespace-global-modes' Modes for which global
-;; `whitespace-mode' is automagically
-;; turned on.
-;;
-;; `whitespace-action' Specify which action is taken when a
-;; buffer is visited or written.
-;;
-;;
;; Acknowledgments
;; ---------------
;;
--
2.7.4
[-- Attachment #4: 0003-Fix-whitespace-space-after-tab-regexp.patch --]
[-- Type: text/x-patch, Size: 1713 bytes --]
From ca1ff683b14384cc0b1e8a6b8ffa297131767e08 Mon Sep 17 00:00:00 2001
From: Reuben Thomas <rrt@sc3d.org>
Date: Fri, 21 Oct 2016 15:23:08 +0100
Subject: [PATCH 3/6] Fix whitespace-space-after-tab-regexp
* lisp/whitespace.el (whitespace-space-after-tab-regexp)
(whitespace-regexp): match all the spaces after tabs for highlighting,
not just the first tab-width. Fix whitespace-space-after-tab::space
version so that it requires at least tab-width spaces, not just 1.
See bug #24745.
---
lisp/whitespace.el | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/lisp/whitespace.el b/lisp/whitespace.el
index f5c2f2f..f1f7605 100644
--- a/lisp/whitespace.el
+++ b/lisp/whitespace.el
@@ -737,8 +737,8 @@ whitespace-empty-at-eob-regexp
(defcustom whitespace-space-after-tab-regexp
- '("\t+\\(\\( \\{%d\\}\\)+\\)"
- . "\\(\t+\\) +")
+ '("\t+\\(\\( \\{%d,\\}\\)+\\)"
+ . "\\(\t+\\) \\{%d,\\}")
"Specify regexp for 8 or more SPACEs after TAB.
It is a cons where the cons car is used for SPACEs visualization
@@ -1566,13 +1566,15 @@ whitespace-replace-action
(defun whitespace-regexp (regexp &optional kind)
"Return REGEXP depending on `whitespace-indent-tabs-mode'."
- (cond
- ((or (eq kind 'tab)
- whitespace-indent-tabs-mode)
- (format (car regexp) whitespace-tab-width))
- ((or (eq kind 'space)
- (not whitespace-indent-tabs-mode))
- (cdr regexp))))
+ (format
+ (cond
+ ((or (eq kind 'tab)
+ whitespace-indent-tabs-mode)
+ (car regexp))
+ ((or (eq kind 'space)
+ (not whitespace-indent-tabs-mode))
+ (cdr regexp)))
+ whitespace-tab-width))
(defun whitespace-indentation-regexp (&optional kind)
--
2.7.4
[-- Attachment #5: 0004-Make-whitespace-report-region-respect-current-settin.patch --]
[-- Type: text/x-patch, Size: 1289 bytes --]
From a08a69ee68002d2cfac7b94643779b1a0cca7f23 Mon Sep 17 00:00:00 2001
From: Reuben Thomas <rrt@sc3d.org>
Date: Fri, 21 Oct 2016 15:25:12 +0100
Subject: [PATCH 4/6] Make whitespace-report-region respect current settings
* lisp/whitespace.el (whitespace-report-region): make it respect
whitespace-style, including any additions made by the force parameter.
This means that the function does not return t unless a whitespace
problem that the user cares about is reported. See bug #24745.
---
lisp/whitespace.el | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/lisp/whitespace.el b/lisp/whitespace.el
index f1f7605..f08a757 100644
--- a/lisp/whitespace.el
+++ b/lisp/whitespace.el
@@ -1740,8 +1740,10 @@ whitespace-report-region
(whitespace-space-after-tab-regexp 'space))
(t
(cdr option)))))
- (and (re-search-forward regexp rend t)
- (setq has-bogus t))))
+ (when (re-search-forward regexp rend t)
+ (unless has-bogus
+ (setq has-bogus (memq (car option) whitespace-style)))
+ t)))
whitespace-report-list)))
(when (pcase report-if-bogus (`nil t) (`never nil) (_ has-bogus))
(whitespace-kill-buffer whitespace-report-buffer-name)
--
2.7.4
[-- Attachment #6: 0005-Document-use-of-tab-width.patch --]
[-- Type: text/x-patch, Size: 13677 bytes --]
From 67663dcc6e84a6a0dc171f8a87863a82914b7cb8 Mon Sep 17 00:00:00 2001
From: Reuben Thomas <rrt@sc3d.org>
Date: Tue, 25 Oct 2016 23:04:18 +0100
Subject: [PATCH 5/6] Document use of `tab-width'
* lisp/whitespace.el: when talking about `8 or more spaces', mention
`tab-width' instead of 8. See bug #24745.
---
lisp/whitespace.el | 103 +++++++++++++++++++++++++++--------------------------
1 file changed, 52 insertions(+), 51 deletions(-)
diff --git a/lisp/whitespace.el b/lisp/whitespace.el
index f08a757..5abd3cb 100644
--- a/lisp/whitespace.el
+++ b/lisp/whitespace.el
@@ -332,8 +332,8 @@ whitespace-style
It has effect only if `face' (see above)
is present in `whitespace-style'.
- indentation::tab 8 or more SPACEs at beginning of line are
- visualized via faces.
+ indentation::tab `tab-width' or more SPACEs at beginning of line
+ are visualized via faces.
It has effect only if `face' (see above)
is present in `whitespace-style'.
@@ -342,10 +342,10 @@ whitespace-style
It has effect only if `face' (see above)
is present in `whitespace-style'.
- indentation 8 or more SPACEs at beginning of line are
- visualized, if `indent-tabs-mode' (which see)
- is non-nil; otherwise, TABs at beginning of
- line are visualized via faces.
+ indentation `tab-width' or more SPACEs at beginning of line
+ are visualized, if `indent-tabs-mode' (which
+ see) is non-nil; otherwise, TABs at beginning
+ of line are visualized via faces.
It has effect only if `face' (see above)
is present in `whitespace-style'.
@@ -353,18 +353,19 @@ whitespace-style
It has effect only if `face' (see above)
is present in `whitespace-style'.
- space-after-tab::tab 8 or more SPACEs after a TAB are
- visualized via faces.
+ space-after-tab::tab `tab-width' or more SPACEs after a TAB
+ are visualized via faces.
It has effect only if `face' (see above)
is present in `whitespace-style'.
- space-after-tab::space TABs are visualized when 8 or more
- SPACEs occur after a TAB, via faces.
+ space-after-tab::space TABs are visualized when `tab-width' or
+ more SPACEs occur after a TAB, via
+ faces.
It has effect only if `face' (see above)
is present in `whitespace-style'.
- space-after-tab 8 or more SPACEs after a TAB are
- visualized, if `indent-tabs-mode'
+ space-after-tab `tab-width' or more SPACEs after a TAB
+ are visualized, if `indent-tabs-mode'
(which see) is non-nil; otherwise,
the TABs are visualized via faces.
It has effect only if `face' (see above)
@@ -569,14 +570,14 @@ whitespace-space-before-tab
(defvar whitespace-indentation 'whitespace-indentation
- "Symbol face used to visualize 8 or more SPACEs at beginning of line.
-Used when `whitespace-style' includes the value `indentation'.")
+ "Symbol face used to visualize `tab-width' or more SPACEs at beginning of
+line. Used when `whitespace-style' includes the value `indentation'.")
(make-obsolete-variable 'whitespace-indentation "use the face instead." "24.4")
(defface whitespace-indentation
'((((class mono)) :inverse-video t :weight bold :underline t)
(t :background "yellow" :foreground "firebrick"))
- "Face used to visualize 8 or more SPACEs at beginning of line."
+ "Face used to visualize `tab-width' or more SPACEs at beginning of line."
:group 'whitespace)
(defface whitespace-big-indent
@@ -599,7 +600,7 @@ whitespace-empty
(defvar whitespace-space-after-tab 'whitespace-space-after-tab
- "Symbol face used to visualize 8 or more SPACEs after TAB.
+ "Symbol face used to visualize `tab-width' or more SPACEs after TAB.
Used when `whitespace-style' includes the value `space-after-tab'.")
(make-obsolete-variable 'whitespace-space-after-tab
"use the face instead." "24.4")
@@ -607,7 +608,7 @@ whitespace-space-after-tab
(defface whitespace-space-after-tab
'((((class mono)) :inverse-video t :weight bold :underline t)
(t :background "yellow" :foreground "firebrick"))
- "Face used to visualize 8 or more SPACEs after TAB."
+ "Face used to visualize `tab-width' or more SPACEs after TAB."
:group 'whitespace)
@@ -708,7 +709,7 @@ whitespace-space-before-tab-regexp
(defcustom whitespace-indentation-regexp
'("^\t*\\(\\( \\{%d\\}\\)+\\)[^\n\t]"
. "^ *\\(\t+\\)[^\n]")
- "Specify regexp for 8 or more SPACEs at beginning of line.
+ "Specify regexp for `tab-width' or more SPACEs at beginning of line.
It is a cons where the cons car is used for SPACEs visualization
and the cons cdr is used for TABs visualization.
@@ -739,7 +740,7 @@ whitespace-empty-at-eob-regexp
(defcustom whitespace-space-after-tab-regexp
'("\t+\\(\\( \\{%d,\\}\\)+\\)"
. "\\(\t+\\) \\{%d,\\}")
- "Specify regexp for 8 or more SPACEs after TAB.
+ "Specify regexp for `tab-width' or more SPACEs after TAB.
It is a cons where the cons car is used for SPACEs visualization
and the cons cdr is used for TABs visualization.
@@ -1345,13 +1346,13 @@ whitespace-cleanup
If `whitespace-style' includes the value `empty', remove all
empty lines at beginning and/or end of buffer.
-3. 8 or more SPACEs at beginning of line.
+3. `tab-width' or more SPACEs at beginning of line.
If `whitespace-style' includes the value `indentation':
- replace 8 or more SPACEs at beginning of line by TABs, if
- `indent-tabs-mode' is non-nil; otherwise, replace TABs by
+ replace `tab-width' or more SPACEs at beginning of line by
+ TABs, if `indent-tabs-mode' is non-nil; otherwise, replace TABs by
SPACEs.
If `whitespace-style' includes the value `indentation::tab',
- replace 8 or more SPACEs at beginning of line by TABs.
+ replace `tab-width' or more SPACEs at beginning of line by TABs.
If `whitespace-style' includes the value `indentation::space',
replace TABs by SPACEs.
@@ -1368,7 +1369,7 @@ whitespace-cleanup
If `whitespace-style' includes the value `trailing', remove
all SPACEs or TABs at end of line.
-6. 8 or more SPACEs after TAB.
+6. `tab-width' or more SPACEs after TAB.
If `whitespace-style' includes the value `space-after-tab':
replace SPACEs by TABs, if `indent-tabs-mode' is non-nil;
otherwise, replace TABs by SPACEs.
@@ -1389,10 +1390,10 @@ whitespace-cleanup
current-prefix-arg)
mark-active)
;; PROBLEMs 1 and 2 are not handled in region
- ;; PROBLEM 3: 8 or more SPACEs at bol
+ ;; PROBLEM 3: `tab-width' or more SPACEs at bol
;; PROBLEM 4: SPACEs before TAB
;; PROBLEM 5: SPACEs or TABs at eol
- ;; PROBLEM 6: 8 or more SPACEs after TAB
+ ;; PROBLEM 6: `tab-width' or more SPACEs after TAB
(whitespace-cleanup-region (region-beginning) (region-end)))
;; whole buffer
(t
@@ -1409,10 +1410,10 @@ whitespace-cleanup
(when (re-search-forward
whitespace-empty-at-eob-regexp nil t)
(delete-region (match-beginning 1) (match-end 1)))))))
- ;; PROBLEM 3: 8 or more SPACEs at bol
+ ;; PROBLEM 3: `tab-width' or more SPACEs at bol
;; PROBLEM 4: SPACEs before TAB
;; PROBLEM 5: SPACEs or TABs at eol
- ;; PROBLEM 6: 8 or more SPACEs after TAB
+ ;; PROBLEM 6: `tab-width' or more SPACEs after TAB
(whitespace-cleanup-region (point-min) (point-max)))))
(defun whitespace-ensure-local-variables ()
@@ -1428,13 +1429,13 @@ whitespace-cleanup-region
The problems cleaned up are:
-1. 8 or more SPACEs at beginning of line.
+1. `tab-width' or more SPACEs at beginning of line.
If `whitespace-style' includes the value `indentation':
- replace 8 or more SPACEs at beginning of line by TABs, if
- `indent-tabs-mode' is non-nil; otherwise, replace TABs by
+ replace `tab-width' or more SPACEs at beginning of line by TABs,
+ if `indent-tabs-mode' is non-nil; otherwise, replace TABs by
SPACEs.
If `whitespace-style' includes the value `indentation::tab',
- replace 8 or more SPACEs at beginning of line by TABs.
+ replace `tab-width' or more SPACEs at beginning of line by TABs.
If `whitespace-style' includes the value `indentation::space',
replace TABs by SPACEs.
@@ -1451,7 +1452,7 @@ whitespace-cleanup-region
If `whitespace-style' includes the value `trailing', remove
all SPACEs or TABs at end of line.
-4. 8 or more SPACEs after TAB.
+4. `tab-width' or more SPACEs after TAB.
If `whitespace-style' includes the value `space-after-tab':
replace SPACEs by TABs, if `indent-tabs-mode' is non-nil;
otherwise, replace TABs by SPACEs.
@@ -1476,9 +1477,9 @@ whitespace-cleanup-region
tmp)
(save-excursion
(save-match-data ;FIXME: Why?
- ;; PROBLEM 1: 8 or more SPACEs at bol
+ ;; PROBLEM 1: `tab-width' or more SPACEs at bol
(cond
- ;; ACTION: replace 8 or more SPACEs at bol by TABs, if
+ ;; ACTION: replace `tab-width' or more SPACEs at bol by TABs, if
;; `indent-tabs-mode' is non-nil; otherwise, replace TABs
;; by SPACEs.
((memq 'indentation whitespace-style)
@@ -1490,7 +1491,7 @@ whitespace-cleanup-region
(delete-horizontal-space)
(unless (eolp)
(indent-to tmp)))))
- ;; ACTION: replace 8 or more SPACEs at bol by TABs.
+ ;; ACTION: replace `tab-width' or more SPACEs at bol by TABs.
((memq 'indentation::tab whitespace-style)
(whitespace-replace-action
'tabify rstart rend
@@ -1506,16 +1507,16 @@ whitespace-cleanup-region
(whitespace-replace-action
'delete-region rstart rend
whitespace-trailing-regexp 1))
- ;; PROBLEM 4: 8 or more SPACEs after TAB
+ ;; PROBLEM 4: `tab-width' or more SPACEs after TAB
(cond
- ;; ACTION: replace 8 or more SPACEs by TABs, if
+ ;; ACTION: replace `tab-width' or more SPACEs by TABs, if
;; `indent-tabs-mode' is non-nil; otherwise, replace TABs
;; by SPACEs.
((memq 'space-after-tab whitespace-style)
(whitespace-replace-action
(if whitespace-indent-tabs-mode 'tabify 'untabify)
rstart rend (whitespace-space-after-tab-regexp) 1))
- ;; ACTION: replace 8 or more SPACEs by TABs.
+ ;; ACTION: replace `tab-width' or more SPACEs by TABs.
((memq 'space-after-tab::tab whitespace-style)
(whitespace-replace-action
'tabify rstart rend
@@ -1615,15 +1616,15 @@ whitespace-report-text
empty [] [] empty lines at beginning of buffer
empty [] [] empty lines at end of buffer
trailing [] [] SPACEs or TABs at end of line
- indentation [] [] 8 or more SPACEs at beginning of line
- indentation::tab [] [] 8 or more SPACEs at beginning of line
+ indentation [] [] >= `tab-width' SPACEs at beginning of line
+ indentation::tab [] [] >= `tab-width' SPACEs at beginning of line
indentation::space [] [] TABs at beginning of line
space-before-tab [] [] SPACEs before TAB
space-before-tab::tab [] [] SPACEs before TAB: SPACEs
space-before-tab::space [] [] SPACEs before TAB: TABs
- space-after-tab [] [] 8 or more SPACEs after TAB
- space-after-tab::tab [] [] 8 or more SPACEs after TAB: SPACEs
- space-after-tab::space [] [] 8 or more SPACEs after TAB: TABs
+ space-after-tab [] [] >= `tab-width' SPACEs after TAB
+ space-after-tab::tab [] [] >= `tab-width' SPACEs after TAB: SPACEs
+ space-after-tab::space [] [] >= `tab-width' SPACEs after TAB: TABs
indent-tabs-mode =
tab-width = \n\n"
@@ -1637,14 +1638,14 @@ whitespace-report-text
empty [] [] empty lines at end of buffer
trailing [] [] SPACEs or TABs at end of line
indentation [] [] TABs at beginning of line
- indentation::tab [] [] 8 or more SPACEs at beginning of line
+ indentation::tab [] [] >= `tab-width' SPACEs at beginning of line
indentation::space [] [] TABs at beginning of line
space-before-tab [] [] SPACEs before TAB
space-before-tab::tab [] [] SPACEs before TAB: SPACEs
space-before-tab::space [] [] SPACEs before TAB: TABs
- space-after-tab [] [] 8 or more SPACEs after TAB
- space-after-tab::tab [] [] 8 or more SPACEs after TAB: SPACEs
- space-after-tab::space [] [] 8 or more SPACEs after TAB: TABs
+ space-after-tab [] [] >= `tab-width' SPACEs after TAB
+ space-after-tab::tab [] [] >= `tab-width' SPACEs after TAB: SPACEs
+ space-after-tab::space [] [] >= `tab-width' SPACEs after TAB: TABs
indent-tabs-mode =
tab-width = \n\n")
@@ -1696,9 +1697,9 @@ whitespace-report-region
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.
+ indentation 4. line starts with `tab-width' or more SPACEs.
space-before-tab 5. SPACEs before TAB.
- space-after-tab 6. 8 or more SPACEs after TAB.
+ space-after-tab 6. `tab-width' or more SPACEs after TAB.
* If `indent-tabs-mode' is nil:
empty 1. empty lines at beginning of buffer.
@@ -1706,7 +1707,7 @@ whitespace-report-region
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.
+ space-after-tab 6. `tab-width' or more SPACEs after TAB.
See `whitespace-style' for documentation.
See also `whitespace-cleanup' and `whitespace-cleanup-region' for
--
2.7.4
[-- Attachment #7: 0006-Stop-force-parameter-of-whitespace-report-region-hav.patch --]
[-- Type: text/x-patch, Size: 2688 bytes --]
From 3b6ec1d285b5460b180008541897c816c08c46c9 Mon Sep 17 00:00:00 2001
From: Reuben Thomas <rrt@sc3d.org>
Date: Tue, 25 Oct 2016 23:20:59 +0100
Subject: [PATCH 6/6] Stop force parameter of whitespace-report-region having
global effect
* lisp/whitespace.el (whitespace-report-region): force parameter
previously changed whitespace-style globally. Fix this, and use
whitespace-active-style, to take account of any changes the user may
have made. Simplify the documentation: the force parameter simply
forces all classes of whitespace problem to be considered.
See bug #24745.
---
lisp/whitespace.el | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/lisp/whitespace.el b/lisp/whitespace.el
index 5abd3cb..b62bd62 100644
--- a/lisp/whitespace.el
+++ b/lisp/whitespace.el
@@ -1679,13 +1679,8 @@ whitespace-report-region
If FORCE is non-nil or \\[universal-argument] was pressed just
before calling `whitespace-report-region' interactively, it
-forces `whitespace-style' to have:
-
- empty
- trailing
- indentation
- space-before-tab
- space-after-tab
+forces all classes of whitespace problem to be considered
+significant.
If REPORT-IF-BOGUS is t, it reports only when there are any
whitespace problems in buffer; if it is `never', it does not
@@ -1719,11 +1714,15 @@ whitespace-report-region
(let* ((has-bogus nil)
(rstart (min start end))
(rend (max start end))
+ ;; Fall back to whitespace-style so we can run before
+ ;; before the mode is active.
+ (style (copy-sequence
+ (or whitespace-active-style whitespace-style)))
(bogus-list
(mapcar
#'(lambda (option)
(when force
- (add-to-list 'whitespace-style (car option)))
+ (add-to-list 'style (car option)))
(goto-char rstart)
(let ((regexp
(cond
@@ -1743,7 +1742,7 @@ whitespace-report-region
(cdr option)))))
(when (re-search-forward regexp rend t)
(unless has-bogus
- (setq has-bogus (memq (car option) whitespace-style)))
+ (setq has-bogus (memq (car option) style)))
t)))
whitespace-report-list)))
(when (pcase report-if-bogus (`nil t) (`never nil) (_ has-bogus))
@@ -1763,7 +1762,7 @@ whitespace-report-region
(dolist (option whitespace-report-list)
(forward-line 1)
(whitespace-mark-x
- 27 (memq (car option) whitespace-style))
+ 27 (memq (car option) style))
(whitespace-mark-x 7 (car bogus-list))
(setq bogus-list (cdr bogus-list)))
(forward-line 1)
--
2.7.4
next prev parent reply other threads:[~2016-10-25 23:26 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-20 12:32 bug#24745: 25.1.50; whitespace.el: fix beginning/end of buffer checks Reuben Thomas
2016-10-20 22:43 ` Dmitry Gutov
2016-10-21 14:42 ` Reuben Thomas
2016-10-21 14:45 ` Dmitry Gutov
2016-10-21 14:52 ` Reuben Thomas
2016-10-24 23:36 ` Dmitry Gutov
2016-10-25 18:44 ` Reuben Thomas
2016-10-25 22:45 ` Dmitry Gutov
2016-10-25 23:26 ` Reuben Thomas [this message]
2016-11-01 15:32 ` Reuben Thomas
2016-11-03 1:07 ` Dmitry Gutov
2016-11-03 12:39 ` Reuben Thomas
2016-11-03 1:06 ` Dmitry Gutov
2016-11-03 12:38 ` Reuben Thomas
[not found] ` <handler.24745.B.14769667565022.ack@debbugs.gnu.org>
2016-10-21 14:38 ` bug#24745: Acknowledgement (25.1.50; whitespace.el: fix beginning/end of buffer checks) 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=CAOnWdoi_iDOdXGoL7MNR+2zhuveiEP6kJVRKcN2Kq8v0uB-vzg@mail.gmail.com \
--to=rrt@sc3d.org \
--cc=24745@debbugs.gnu.org \
--cc=dgutov@yandex.ru \
/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).