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: Tue, 25 Oct 2016 19:44:27 +0100 [thread overview]
Message-ID: <CAOnWdohXbozzfjFPY2u1uWcvz+m7pNoEVzszoHi_bBNG2DyThQ@mail.gmail.com> (raw)
In-Reply-To: <83402aab-73d0-eeae-1df1-c717caf198ba@yandex.ru>
[-- Attachment #1.1: Type: text/plain, Size: 1708 bytes --]
On 25 October 2016 at 00:36, Dmitry Gutov <dgutov@yandex.ru> wrote:
>
>
> A few comments on the patches themselves:
>
Thanks very much for the review.
- "remove duplicate documentation from the Commentary" sounds fine to me,
> but maybe we should leave something in its stead. The first part can be
> replaced with a reference to the `whitespace-style' docstring. The second
> one... is it really that out of date? The list of variables seems like it
> can be useful.
>
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.
I have updated my patch to provide a cross-reference to the documentation
for whitespace-style, as you suggest. The other section of documentation
that I removed is for customizable options, which are fully documented in
the defcustom docstrings. (I have now checked this exhaustively.)
> - The commit messages don't follow the ChangeLog format, see
> https://www.gnu.org/prep/standards/html_node/Change-Logs.html, or simply
> the existing commit messages.
>
Apologies. As far as I could see, the main things that were wrong were the
summary lines and the lack of function names (or equivalent) in the
detailed log. I have rewritten all of them.
I have rebased the patch series against master and attach the new version.
--
http://rrt.sc3d.org
[-- Attachment #1.2: Type: text/html, Size: 3051 bytes --]
[-- Attachment #2: 0001-Fix-bob-eob-checks.patch --]
[-- Type: text/x-patch, Size: 1814 bytes --]
From 72c12c6574305285219bff94aab79cf45e37ac13 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/4] 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).
---
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: 5192 bytes --]
From d01c97745bad85999b304a96c4fc1372a1c2cce8 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/4] Remove duplicate documentation
* whitespace.el: remove duplicate documentation from the Commentary
section which duplicate and in some places contradict (due to being
out of date) the docstrings.
---
lisp/whitespace.el | 117 +----------------------------------------------------
1 file changed, 1 insertion(+), 116 deletions(-)
diff --git a/lisp/whitespace.el b/lisp/whitespace.el
index 6164585..affddc3 100644
--- a/lisp/whitespace.el
+++ b/lisp/whitespace.el
@@ -178,49 +178,11 @@
;;
;; `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.
-;;
;;
;; Hooks
;; -----
@@ -237,83 +199,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: 1702 bytes --]
From b03f66acced06fda5ecc694e37b25bbf32ce4da2 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/4] 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.
---
lisp/whitespace.el | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/lisp/whitespace.el b/lisp/whitespace.el
index affddc3..f8dc950 100644
--- a/lisp/whitespace.el
+++ b/lisp/whitespace.el
@@ -730,8 +730,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
@@ -1559,13 +1559,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: 1273 bytes --]
From ec93eca67bda549886709ff8c13d563560c88c99 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/4] Make whitespace-report-region respect current settings
* 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.
---
lisp/whitespace.el | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/lisp/whitespace.el b/lisp/whitespace.el
index f8dc950..bbec06e 100644
--- a/lisp/whitespace.el
+++ b/lisp/whitespace.el
@@ -1733,8 +1733,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
next prev parent reply other threads:[~2016-10-25 18:44 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 [this message]
2016-10-25 22:45 ` Dmitry Gutov
2016-10-25 23:26 ` Reuben Thomas
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=CAOnWdohXbozzfjFPY2u1uWcvz+m7pNoEVzszoHi_bBNG2DyThQ@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).