diff options
author | Štěpán Němec <stepnem@gmail.com> | 2019-08-29 19:32:08 +0200 |
---|---|---|
committer | Noam Postavsky <npostavs@gmail.com> | 2020-03-01 22:54:32 -0500 |
commit | 1939f7580bd283286dce8be7c99ab5dec1bb0814 (patch) | |
tree | 557f4f5d5bae6bb36218f2cd49ce3fb731705324 /lisp/whitespace.el | |
parent | 13a69c829e162b162c35037634744d7272e0e2c4 (diff) | |
download | emacs-1939f7580bd283286dce8be7c99ab5dec1bb0814.tar.gz |
whitespace: Turn long lines regexp into a function (bug#36837)
* lisp/whitespace.el (whitespace-color-on): Turn long lines regexp
into a function to ensure it uses current 'whitespace-line-column'
and 'fill-column' values. (Bug#36837)
(whitespace-lines-regexp): New function.
Diffstat (limited to 'lisp/whitespace.el')
-rw-r--r-- | lisp/whitespace.el | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/lisp/whitespace.el b/lisp/whitespace.el index 0137ddcf04f..47434bf3d2e 100644 --- a/lisp/whitespace.el +++ b/lisp/whitespace.el @@ -2067,16 +2067,7 @@ resultant list will be returned." ,@(when (or (memq 'lines whitespace-active-style) (memq 'lines-tail whitespace-active-style)) ;; Show "long" lines. - `((,(let ((line-column (or whitespace-line-column fill-column))) - (format - "^\\([^\t\n]\\{%s\\}\\|[^\t\n]\\{0,%s\\}\t\\)\\{%d\\}%s\\(.+\\)$" - tab-width - (1- tab-width) - (/ line-column tab-width) - (let ((rem (% line-column tab-width))) - (if (zerop rem) - "" - (format ".\\{%d\\}" rem))))) + `((,#'whitespace-lines-regexp ,(if (memq 'lines whitespace-active-style) 0 ; whole line 2) ; line tail @@ -2177,6 +2168,19 @@ resultant list will be returned." (setq status nil))) ;; end of buffer status)) +(defun whitespace-lines-regexp (limit) + (re-search-forward + (let ((line-column (or whitespace-line-column fill-column))) + (format + "^\\([^\t\n]\\{%s\\}\\|[^\t\n]\\{0,%s\\}\t\\)\\{%d\\}%s\\(.+\\)$" + tab-width + (1- tab-width) + (/ line-column tab-width) + (let ((rem (% line-column tab-width))) + (if (zerop rem) + "" + (format ".\\{%d\\}" rem))))) + limit t)) (defun whitespace-empty-at-bob-regexp (limit) "Match spaces at beginning of buffer which do not contain the point at \ |