[Top][All Lists]

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

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

From: Stefan Monnier
Subject: Re: master 7362554: Widen around c-font-lock-fontify-region. This fixes bug #38049.
Date: Fri, 15 Nov 2019 18:27:21 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

>> IIUC this can't be fixed in font-lock or jit-lock.
> Why not?

Good question.  Looks like I was wrong.
I think the patch below is a better general solution.


diff --git a/lisp/font-lock.el b/lisp/font-lock.el
index 01c19e6e87..9c1c193eda 100644
--- a/lisp/font-lock.el
+++ b/lisp/font-lock.el
@@ -1071,7 +1071,9 @@ font-lock-fontify-region
 If LOUDLY is non-nil, print status messages while fontifying.
 This works by calling `font-lock-fontify-region-function'."
-  (funcall font-lock-fontify-region-function beg end loudly))
+  (save-restriction
+    (unless font-lock-dont-widen (widen))
+    (funcall font-lock-fontify-region-function beg end loudly)))
 (defun font-lock-unfontify-region (beg end)
   "Unfontify the text between BEG and END.
@@ -1221,8 +1221,6 @@
     ;; Use the fontification syntax table, if any.
     (with-syntax-table (or font-lock-syntax-table (syntax-table))
-      (save-restriction
-        (unless font-lock-dont-widen (widen))
         ;; Extend the region to fontify so that it starts and ends at
         ;; safe places.
         (let ((funs font-lock-extend-region-functions)
@@ -1251,7 +1249,7 @@
         (unless font-lock-keywords-only
           (font-lock-fontify-syntactically-region beg end loudly))
         (font-lock-fontify-keywords-region beg end loudly)
-        `(jit-lock-bounds ,beg . ,end)))))
+     `(jit-lock-bounds ,beg . ,end))))
 ;; The following must be rethought, since keywords can override fontification.
 ;;    ;; Now scan for keywords, but not if we are inside a comment now.

reply via email to

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