From 343ecf32200da2b1d8e93b7d3cc16da288ec851e Mon Sep 17 00:00:00 2001 From: Reuben Thomas Date: Thu, 20 Oct 2016 13:17:58 +0100 Subject: [PATCH 1/4] whitespace: fix bob/eob checks * whitespace.el: 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