diff options
| author | Štěpán Němec | 2019-08-29 19:32:08 +0200 |
|---|---|---|
| committer | Noam Postavsky | 2020-03-01 22:54:32 -0500 |
| commit | 1939f7580bd283286dce8be7c99ab5dec1bb0814 (patch) | |
| tree | 557f4f5d5bae6bb36218f2cd49ce3fb731705324 | |
| parent | 13a69c829e162b162c35037634744d7272e0e2c4 (diff) | |
| download | emacs-1939f7580bd283286dce8be7c99ab5dec1bb0814.tar.gz emacs-1939f7580bd283286dce8be7c99ab5dec1bb0814.zip | |
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.
| -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." | |||
| 2067 | ,@(when (or (memq 'lines whitespace-active-style) | 2067 | ,@(when (or (memq 'lines whitespace-active-style) |
| 2068 | (memq 'lines-tail whitespace-active-style)) | 2068 | (memq 'lines-tail whitespace-active-style)) |
| 2069 | ;; Show "long" lines. | 2069 | ;; Show "long" lines. |
| 2070 | `((,(let ((line-column (or whitespace-line-column fill-column))) | 2070 | `((,#'whitespace-lines-regexp |
| 2071 | (format | ||
| 2072 | "^\\([^\t\n]\\{%s\\}\\|[^\t\n]\\{0,%s\\}\t\\)\\{%d\\}%s\\(.+\\)$" | ||
| 2073 | tab-width | ||
| 2074 | (1- tab-width) | ||
| 2075 | (/ line-column tab-width) | ||
| 2076 | (let ((rem (% line-column tab-width))) | ||
| 2077 | (if (zerop rem) | ||
| 2078 | "" | ||
| 2079 | (format ".\\{%d\\}" rem))))) | ||
| 2080 | ,(if (memq 'lines whitespace-active-style) | 2071 | ,(if (memq 'lines whitespace-active-style) |
| 2081 | 0 ; whole line | 2072 | 0 ; whole line |
| 2082 | 2) ; line tail | 2073 | 2) ; line tail |
| @@ -2177,6 +2168,19 @@ resultant list will be returned." | |||
| 2177 | (setq status nil))) ;; end of buffer | 2168 | (setq status nil))) ;; end of buffer |
| 2178 | status)) | 2169 | status)) |
| 2179 | 2170 | ||
| 2171 | (defun whitespace-lines-regexp (limit) | ||
| 2172 | (re-search-forward | ||
| 2173 | (let ((line-column (or whitespace-line-column fill-column))) | ||
| 2174 | (format | ||
| 2175 | "^\\([^\t\n]\\{%s\\}\\|[^\t\n]\\{0,%s\\}\t\\)\\{%d\\}%s\\(.+\\)$" | ||
| 2176 | tab-width | ||
| 2177 | (1- tab-width) | ||
| 2178 | (/ line-column tab-width) | ||
| 2179 | (let ((rem (% line-column tab-width))) | ||
| 2180 | (if (zerop rem) | ||
| 2181 | "" | ||
| 2182 | (format ".\\{%d\\}" rem))))) | ||
| 2183 | limit t)) | ||
| 2180 | 2184 | ||
| 2181 | (defun whitespace-empty-at-bob-regexp (limit) | 2185 | (defun whitespace-empty-at-bob-regexp (limit) |
| 2182 | "Match spaces at beginning of buffer which do not contain the point at \ | 2186 | "Match spaces at beginning of buffer which do not contain the point at \ |