aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Mackenzie2019-11-09 14:30:52 +0000
committerAlan Mackenzie2019-11-09 14:37:55 +0000
commit7362554eafd7e255b3d96a4f711e11708dee950f (patch)
tree65ef0b1bfd4da1761fe3f3b25a72b6aed951b5b0
parentb293aa91bcc7f553ffbc6c67027f3c86d06ffbd7 (diff)
downloademacs-7362554eafd7e255b3d96a4f711e11708dee950f.tar.gz
emacs-7362554eafd7e255b3d96a4f711e11708dee950f.zip
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.
-rw-r--r--lisp/progmodes/cc-mode.el78
1 files changed, 40 insertions, 38 deletions
diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el
index 6bdfb170f1b..73160fc7a42 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....\".")
2232 ;; 2232 ;;
2233 ;; Type a space in the first blank line, and the fontification of the next 2233 ;; Type a space in the first blank line, and the fontification of the next
2234 ;; line was fouled up by context fontification. 2234 ;; line was fouled up by context fontification.
2235 (let (new-beg new-end new-region case-fold-search) 2235 (save-restriction
2236 (if (and c-in-after-change-fontification 2236 (widen)
2237 (< beg c-new-END) (> end c-new-BEG)) 2237 (let (new-beg new-end new-region case-fold-search)
2238 ;; Region and the latest after-change fontification region overlap. 2238 (if (and c-in-after-change-fontification
2239 ;; Determine the upper and lower bounds of our adjusted region 2239 (< beg c-new-END) (> end c-new-BEG))
2240 ;; separately. 2240 ;; Region and the latest after-change fontification region overlap.
2241 (progn 2241 ;; Determine the upper and lower bounds of our adjusted region
2242 (if (<= beg c-new-BEG) 2242 ;; separately.
2243 (setq c-in-after-change-fontification nil)) 2243 (progn
2244 (setq new-beg 2244 (if (<= beg c-new-BEG)
2245 (if (and (>= beg (c-point 'bol c-new-BEG)) 2245 (setq c-in-after-change-fontification nil))
2246 (<= beg c-new-BEG)) 2246 (setq new-beg
2247 ;; Either jit-lock has accepted `c-new-BEG', or has 2247 (if (and (>= beg (c-point 'bol c-new-BEG))
2248 ;; (probably) extended the change region spuriously to 2248 (<= beg c-new-BEG))
2249 ;; BOL, which position likely has a syntactically 2249 ;; Either jit-lock has accepted `c-new-BEG', or has
2250 ;; different position. To ensure correct fontification, 2250 ;; (probably) extended the change region spuriously to
2251 ;; we start at `c-new-BEG', assuming any characters to the 2251 ;; BOL, which position likely has a syntactically
2252 ;; left of `c-new-BEG' on the line do not require 2252 ;; different position. To ensure correct fontification,
2253 ;; fontification. 2253 ;; we start at `c-new-BEG', assuming any characters to the
2254 c-new-BEG 2254 ;; left of `c-new-BEG' on the line do not require
2255 (setq new-region (c-before-context-fl-expand-region beg end) 2255 ;; fontification.
2256 new-end (cdr new-region)) 2256 c-new-BEG
2257 (car new-region))) 2257 (setq new-region (c-before-context-fl-expand-region beg end)
2258 (setq new-end 2258 new-end (cdr new-region))
2259 (if (and (>= end (c-point 'bol c-new-END)) 2259 (car new-region)))
2260 (<= end c-new-END)) 2260 (setq new-end
2261 c-new-END 2261 (if (and (>= end (c-point 'bol c-new-END))
2262 (or new-end 2262 (<= end c-new-END))
2263 (cdr (c-before-context-fl-expand-region beg end)))))) 2263 c-new-END
2264 ;; Context (etc.) fontification. 2264 (or new-end
2265 (setq new-region (c-before-context-fl-expand-region beg end) 2265 (cdr (c-before-context-fl-expand-region beg end))))))
2266 new-beg (car new-region) new-end (cdr new-region))) 2266 ;; Context (etc.) fontification.
2267 (c-save-buffer-state nil 2267 (setq new-region (c-before-context-fl-expand-region beg end)
2268 (unwind-protect 2268 new-beg (car new-region) new-end (cdr new-region)))
2269 (progn (c-restore-string-fences new-beg new-end) 2269 (c-save-buffer-state nil
2270 (funcall (default-value 'font-lock-fontify-region-function) 2270 (unwind-protect
2271 new-beg new-end verbose)) 2271 (progn (c-restore-string-fences new-beg new-end)
2272 (c-clear-string-fences))))) 2272 (funcall (default-value 'font-lock-fontify-region-function)
2273 new-beg new-end verbose))
2274 (c-clear-string-fences))))))
2273 2275
2274(defun c-after-font-lock-init () 2276(defun c-after-font-lock-init ()
2275 ;; Put on `font-lock-mode-hook'. This function ensures our after-change 2277 ;; Put on `font-lock-mode-hook'. This function ensures our after-change