emacs-diffs
[Top][All Lists]
Advanced

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

master 7362554: Widen around c-font-lock-fontify-region. This fixes bug


From: Alan Mackenzie
Subject: master 7362554: Widen around c-font-lock-fontify-region. This fixes bug #38049.
Date: Sat, 9 Nov 2019 09:40:27 -0500 (EST)

branch: master
commit 7362554eafd7e255b3d96a4f711e11708dee950f
Author: Alan Mackenzie <address@hidden>
Commit: Alan Mackenzie <address@hidden>

    Widen around c-font-lock-fontify-region.  This fixes bug #38049.
    
    * lisp/progmodes/cc-mode (c-font-lock-fontify-region): Widen in this 
function,
    to ensure that the CC Mode font locking mechanism can examine characters
    outside the given region.
---
 lisp/progmodes/cc-mode.el | 78 ++++++++++++++++++++++++-----------------------
 1 file changed, 40 insertions(+), 38 deletions(-)

diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el
index 6bdfb17..73160fc 100644
--- a/lisp/progmodes/cc-mode.el
+++ b/lisp/progmodes/cc-mode.el
@@ -2232,44 +2232,46 @@ Note that this is a strict tail, so won't match, e.g. 
\"0x....\".")
   ;;
   ;; Type a space in the first blank line, and the fontification of the next
   ;; line was fouled up by context fontification.
-  (let (new-beg new-end new-region case-fold-search)
-    (if (and c-in-after-change-fontification
-            (< beg c-new-END) (> end c-new-BEG))
-       ;; Region and the latest after-change fontification region overlap.
-       ;; Determine the upper and lower bounds of our adjusted region
-       ;; separately.
-       (progn
-         (if (<= beg c-new-BEG)
-             (setq c-in-after-change-fontification nil))
-         (setq new-beg
-               (if (and (>= beg (c-point 'bol c-new-BEG))
-                        (<= beg c-new-BEG))
-                   ;; Either jit-lock has accepted `c-new-BEG', or has
-                   ;; (probably) extended the change region spuriously to
-                   ;; BOL, which position likely has a syntactically
-                   ;; different position.  To ensure correct fontification,
-                   ;; we start at `c-new-BEG', assuming any characters to the
-                   ;; left of `c-new-BEG' on the line do not require
-                   ;; fontification.
-                   c-new-BEG
-                 (setq new-region (c-before-context-fl-expand-region beg end)
-                       new-end (cdr new-region))
-                 (car new-region)))
-         (setq new-end
-               (if (and (>= end (c-point 'bol c-new-END))
-                        (<= end c-new-END))
-                   c-new-END
-                 (or new-end
-                     (cdr (c-before-context-fl-expand-region beg end))))))
-      ;; Context (etc.) fontification.
-      (setq new-region (c-before-context-fl-expand-region beg end)
-           new-beg (car new-region)  new-end (cdr new-region)))
-    (c-save-buffer-state nil
-      (unwind-protect
-         (progn (c-restore-string-fences new-beg new-end)
-                (funcall (default-value 'font-lock-fontify-region-function)
-                         new-beg new-end verbose))
-       (c-clear-string-fences)))))
+  (save-restriction
+    (widen)
+    (let (new-beg new-end new-region case-fold-search)
+      (if (and c-in-after-change-fontification
+              (< beg c-new-END) (> end c-new-BEG))
+         ;; Region and the latest after-change fontification region overlap.
+         ;; Determine the upper and lower bounds of our adjusted region
+         ;; separately.
+         (progn
+           (if (<= beg c-new-BEG)
+               (setq c-in-after-change-fontification nil))
+           (setq new-beg
+                 (if (and (>= beg (c-point 'bol c-new-BEG))
+                          (<= beg c-new-BEG))
+                     ;; Either jit-lock has accepted `c-new-BEG', or has
+                     ;; (probably) extended the change region spuriously to
+                     ;; BOL, which position likely has a syntactically
+                     ;; different position.  To ensure correct fontification,
+                     ;; we start at `c-new-BEG', assuming any characters to the
+                     ;; left of `c-new-BEG' on the line do not require
+                     ;; fontification.
+                     c-new-BEG
+                   (setq new-region (c-before-context-fl-expand-region beg end)
+                         new-end (cdr new-region))
+                   (car new-region)))
+           (setq new-end
+                 (if (and (>= end (c-point 'bol c-new-END))
+                          (<= end c-new-END))
+                     c-new-END
+                   (or new-end
+                       (cdr (c-before-context-fl-expand-region beg end))))))
+       ;; Context (etc.) fontification.
+       (setq new-region (c-before-context-fl-expand-region beg end)
+             new-beg (car new-region)  new-end (cdr new-region)))
+      (c-save-buffer-state nil
+       (unwind-protect
+           (progn (c-restore-string-fences new-beg new-end)
+                  (funcall (default-value 'font-lock-fontify-region-function)
+                           new-beg new-end verbose))
+         (c-clear-string-fences))))))
 
 (defun c-after-font-lock-init ()
   ;; Put on `font-lock-mode-hook'.  This function ensures our after-change



reply via email to

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