Function: diff--font-lock-refined
diff--font-lock-refined is a byte-compiled function defined in
diff-mode.el.gz.
Signature
(diff--font-lock-refined MAX)
Documentation
Apply hunk refinement from font-lock.
Source Code
;; Defined in /usr/src/emacs/lisp/vc/diff-mode.el.gz
(defun diff--font-lock-refined (max)
"Apply hunk refinement from font-lock."
(when (eq diff-refine 'font-lock)
(when (get-char-property (point) 'diff--font-lock-refined)
;; Refinement works over a complete hunk, whereas font-lock limits itself
;; to highlighting smallish chunks between point..max, so we may be
;; called N times for a large hunk in which case we don't want to
;; rehighlight that hunk N times (especially since each highlighting
;; of a large hunk can itself take a long time, adding insult to injury).
;; So, after refining a hunk (including a failed attempt), we place an
;; overlay over the whole hunk to mark it as refined, to avoid redoing
;; the job redundantly when asked to highlight subsequent parts of the
;; same hunk.
(goto-char (next-single-char-property-change
(point) 'diff--font-lock-refined nil max)))
;; Ignore errors that diff cannot be found so that custom font-lock
;; keywords after `diff--font-lock-refined' can still be evaluated.
(ignore-error file-missing
(diff--iterate-hunks
max
(lambda (beg end)
(unless (get-char-property beg 'diff--font-lock-refined)
(diff--refine-hunk beg end)
(let ((ol (make-overlay beg end)))
(overlay-put ol 'diff--font-lock-refined t)
(overlay-put ol 'diff-mode 'fine)
(overlay-put ol 'evaporate t)
(overlay-put ol 'modification-hooks
'(diff--overlay-auto-delete)))))))))