emacs-diffs
[Top][All Lists]
Advanced

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

master 53af11a281: Fix whitespace-mode in read-only buffers


From: Lars Ingebrigtsen
Subject: master 53af11a281: Fix whitespace-mode in read-only buffers
Date: Mon, 26 Sep 2022 06:56:51 -0400 (EDT)

branch: master
commit 53af11a2812cef93f8867b5690f0e3a797e0e876
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Fix whitespace-mode in read-only buffers
    
    * lisp/whitespace.el (whitespace--update-bob-eob): Don't bug out
    in read-only buffers (bug#58082).
---
 lisp/whitespace.el | 65 +++++++++++++++++++++++++++---------------------------
 1 file changed, 33 insertions(+), 32 deletions(-)

diff --git a/lisp/whitespace.el b/lisp/whitespace.el
index ae4d8ae3f0..d7b83ef34a 100644
--- a/lisp/whitespace.el
+++ b/lisp/whitespace.el
@@ -2385,38 +2385,39 @@ purposes)."
     (save-excursion
       (save-restriction
         (widen)
-        (when (or (null beg)
-                  (<= beg (save-excursion
-                            (goto-char whitespace-bob-marker)
-                            ;; Any change in the first non-`empty'
-                            ;; line, even if it's not the first
-                            ;; character in the line, can potentially
-                            ;; cause subsequent lines to become
-                            ;; classified as `empty' (e.g., delete the
-                            ;; "x" from " x").
-                            (forward-line 1)
-                            (point))))
-          (goto-char 1)
-          (set-marker whitespace-bob-marker (point))
-          (save-match-data
-            (when (looking-at whitespace-empty-at-bob-regexp)
-              (set-marker whitespace-bob-marker (match-end 1))
-              (put-text-property (match-beginning 1) (match-end 1)
-                                 'font-lock-multiline t))))
-        (when (or (null end)
-                  (>= end (save-excursion
-                            (goto-char whitespace-eob-marker)
-                            ;; See above comment for the BoB case.
-                            (forward-line -1)
-                            (point))))
-          (goto-char (1+ (buffer-size)))
-          (set-marker whitespace-eob-marker (point))
-          (save-match-data
-            (when (whitespace--looking-back
-                   whitespace-empty-at-eob-regexp)
-              (set-marker whitespace-eob-marker (match-beginning 1))
-              (put-text-property (match-beginning 1) (match-end 1)
-                                 'font-lock-multiline t))))))))
+        (let ((inhibit-read-only t))
+          (when (or (null beg)
+                    (<= beg (save-excursion
+                              (goto-char whitespace-bob-marker)
+                              ;; Any change in the first non-`empty'
+                              ;; line, even if it's not the first
+                              ;; character in the line, can potentially
+                              ;; cause subsequent lines to become
+                              ;; classified as `empty' (e.g., delete the
+                              ;; "x" from " x").
+                              (forward-line 1)
+                              (point))))
+            (goto-char 1)
+            (set-marker whitespace-bob-marker (point))
+            (save-match-data
+              (when (looking-at whitespace-empty-at-bob-regexp)
+                (set-marker whitespace-bob-marker (match-end 1))
+                (put-text-property (match-beginning 1) (match-end 1)
+                                   'font-lock-multiline t))))
+          (when (or (null end)
+                    (>= end (save-excursion
+                              (goto-char whitespace-eob-marker)
+                              ;; See above comment for the BoB case.
+                              (forward-line -1)
+                              (point))))
+            (goto-char (1+ (buffer-size)))
+            (set-marker whitespace-eob-marker (point))
+            (save-match-data
+              (when (whitespace--looking-back
+                     whitespace-empty-at-eob-regexp)
+                (set-marker whitespace-eob-marker (match-beginning 1))
+                (put-text-property (match-beginning 1) (match-end 1)
+                                   'font-lock-multiline t)))))))))
 
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;



reply via email to

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