]> git.eshelyaron.com Git - emacs.git/commitdiff
whitespace: Turn long lines regexp into a function (bug#36837)
authorŠtěpán Němec <stepnem@gmail.com>
Thu, 29 Aug 2019 17:32:08 +0000 (19:32 +0200)
committerNoam Postavsky <npostavs@gmail.com>
Mon, 2 Mar 2020 03:54:32 +0000 (22:54 -0500)
* 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.

lisp/whitespace.el

index 0137ddcf04f86e7999875fb38bef165ecb3acd0c..47434bf3d2ef850d25a8a1746dee8d037e5e72b6 100644 (file)
@@ -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 \