GNU bug report logs - #36837
26.2; whitespace-mode: whitespace-line-column is not set to local fill-column

Previous Next

Package: emacs;

Reported by: tastytea <tastytea <at> tastytea.de>

Date: Mon, 29 Jul 2019 14:40:02 UTC

Severity: minor

Found in version 26.2

Fixed in version 28.1

Done: Noam Postavsky <npostavs <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


Message #67 received at 36837 <at> debbugs.gnu.org (full text, mbox):

From: Štěpán Němec <stepnem <at> gmail.com>
To: Noam Postavsky <npostavs <at> gmail.com>
Cc: tastytea <tastytea <at> tastytea.de>, 36837 <at> debbugs.gnu.org
Subject: Re: bug#36837: 26.2; whitespace-mode: whitespace-line-column is not
 set to local fill-column
Date: Mon, 24 Feb 2020 21:12:03 +0100
[Message part 1 (text/plain, inline)]
tags 36837 patch
thanks

On Mon, 24 Feb 2020 14:56:25 -0500
Noam Postavsky wrote:

>> Less avant-garde perhaps would be to do what's being done for some of
>> the other regexps already: turn it into a function:
>
> I think this would make more sense, and also fix #39427 "whitespace-mode
> doesn't track fill-column changes".

FWIW, I have been running with this change ever since I suggested it.

Here it is as proper patch with a commit message on top of recent
master. Let me know if anything else is needed (I've been a bit out of
the loop lately but I think it could still go to emacs-27, and doesn't
warrant a NEWS entry?).

-- 
Štěpán

[0001-whitespace-Turn-long-lines-regexp-into-a-function-bu.patch (text/x-patch, inline)]
From a4fe6400e6a5ddf3f63d6f059058ed2abf04f1b5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C5=A0t=C4=9Bp=C3=A1n=20N=C4=9Bmec?= <stepnem <at> gmail.com>
Date: Thu, 29 Aug 2019 19:32:08 +0200
Subject: [PATCH] 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.
---
 lisp/whitespace.el | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/lisp/whitespace.el b/lisp/whitespace.el
index 0137ddcf04..47434bf3d2 100644
--- a/lisp/whitespace.el
+++ b/lisp/whitespace.el
@@ -2067,16 +2067,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
@@ -2177,6 +2168,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 \
-- 
2.25.1


This bug report was last modified 5 years and 85 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.