bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#36837: 26.2; whitespace-mode: whitespace-line-column is not set to l


From: Štěpán Němec
Subject: bug#36837: 26.2; whitespace-mode: whitespace-line-column is not set to local fill-column
Date: Sat, 03 Aug 2019 11:23:27 +0200
User-agent: Notmuch/0.29.1 (https://notmuchmail.org) Emacs/27.0.50 (x86_64-pc-linux-gnu)

On Sat, 03 Aug 2019 09:50:56 +0200
tastytea@tastytea.de wrote:

> Maybe whitespace-mode could watch fill-column for changes, at least
> until the file-local variables are loaded?
> There is also the possibility that fill-column is changed afterwards by
> the user, but I guess that's not too common…

Ah, the new variable watcher thing. I suppose that would be a
possibility, though so far its use in Emacs seems to be quite limited.

Less avant-garde perhaps would be to do what's being done for some of
the other regexps already: turn it into a function:

diff --git a/lisp/whitespace.el b/lisp/whitespace.el
index d0368b54a8..a67e5efee5 100644
--- a/lisp/whitespace.el
+++ b/lisp/whitespace.el
@@ -2066,16 +2066,7 @@ whitespace-color-on
        ,@(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
@@ -2176,6 +2167,19 @@ whitespace-trailing-regexp
             (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 \

reply via email to

[Prev in Thread] Current Thread [Next in Thread]