+(defun jit-lock-context-fontify ()
+ "Refresh fontification to take new context into account."
+ (dolist (buffer (buffer-list))
+ (with-current-buffer buffer
+ (when jit-lock-context-unfontify-pos
+ ;; (message "Jit-Context %s" (buffer-name))
+ (save-restriction
+ (widen)
+ (when (and (>= jit-lock-context-unfontify-pos (point-min))
+ (< jit-lock-context-unfontify-pos (point-max)))
+ ;; If we're in text that matches a complex multi-line
+ ;; font-lock pattern, make sure the whole text will be
+ ;; redisplayed eventually.
+ ;; Despite its name, we treat jit-lock-defer-multiline here
+ ;; rather than in jit-lock-defer since it has to do with multiple
+ ;; lines, i.e. with context.
+ (when (get-text-property jit-lock-context-unfontify-pos
+ 'jit-lock-defer-multiline)
+ (setq jit-lock-context-unfontify-pos
+ (or (previous-single-property-change
+ jit-lock-context-unfontify-pos
+ 'jit-lock-defer-multiline)
+ (point-min))))
+ (with-buffer-prepared-for-jit-lock
+ ;; Force contextual refontification.
+ (remove-text-properties
+ jit-lock-context-unfontify-pos (point-max)
+ '(fontified nil jit-lock-defer-multiline nil)))
+ (setq jit-lock-context-unfontify-pos (point-max))))))))
+