Function: diff-hl--update-overlays
diff-hl--update-overlays is a natively compiled function defined in
diff-hl.el.
Signature
(diff-hl--update-overlays CHANGES REUSE)
Documentation
Updates the diff-hl overlays based on CHANGES.
REUSE is a list of existing line overlays that can be used. Return a list of line overlays used.
Source Code
;; Defined in /nix/store/cfz56rl3lp066226i0bmmgiicls3gcq7-emacs-packages-deps/share/emacs/site-lisp/elpa/diff-hl-20261001.135/diff-hl.el
(defun diff-hl--update-overlays (changes reuse)
"Updates the diff-hl overlays based on CHANGES.
REUSE is a list of existing line overlays that can be used.
Return a list of line overlays used."
(let ((current-line 1)
ovls)
(save-excursion
(save-restriction
(widen)
(goto-char (point-min))
(dolist (c changes)
(cl-destructuring-bind (line inserts _deletes type) c
(forward-line (- line current-line))
(setq current-line line)
(let ((hunk-beg (point))
(len (if (eq type 'delete) 1 inserts)))
(while (and reuse
(< (overlay-start (car reuse)) (point)))
(setq reuse (cdr reuse)))
(while (cl-plusp len)
(push
(diff-hl-add-highlighting
type
(cond
((not diff-hl-draw-borders) 'empty)
((and (= len 1) (= line current-line)) 'single)
((= len 1) 'bottom)
((= line current-line) 'top)
(t 'middle))
(and reuse
(= (overlay-start (car reuse)) (point))
(pop reuse)))
ovls)
(forward-line 1)
(cl-incf current-line)
(cl-decf len))
(let ((h (make-overlay hunk-beg (point)))
(hook '(diff-hl-overlay-modified)))
(overlay-put h 'diff-hl t)
(overlay-put h 'diff-hl-hunk t)
(overlay-put h 'diff-hl-hunk-type type)
(overlay-put h 'modification-hooks hook)
(overlay-put h 'insert-in-front-hooks hook)
(overlay-put h 'insert-behind-hooks hook)))))))
(nreverse ovls)))