Function: magit-diff--update-hunk-syntax

magit-diff--update-hunk-syntax is a byte-compiled function defined in magit-diff.el.

Signature

(magit-diff--update-hunk-syntax &optional HUNK)

Source Code

;; Defined in ~/.emacs.d/elpa/magit-20260411.1452/magit-diff.el
;;;; Syntax

(defun magit-diff--update-hunk-syntax (&optional hunk)
  (if hunk
      (pcase-let (((eieio fontified content end) hunk))
        (unless fontified
          (oset hunk fontified t)
          (save-excursion
            (goto-char content)
            (pcase-let*
                ((`(,old ,new) (magit-diff-visit--sides))
                 (old (apply #'magit-diff--get-hunk-syntax hunk 'old old))
                 (new (apply #'magit-diff--get-hunk-syntax hunk 'new new)))
              (while (< (point) end)
                (pcase-dolist (`(,b ,e ,face)
                               (pcase (char-after (point))
                                 (?-  (pop old))
                                 (?+  (pop new))
                                 (?\s (pop old)
                                      (pop new))))
                  (let ((o (make-overlay (+ (point) 1 b) (+ (point) 1 e) nil t)))
                    (overlay-put o 'evaporate t)
                    (overlay-put o 'face face)))
                (forward-line 1))))))
    (named-let update ((section magit-root-section))
      (if (magit-section-match 'hunk section)
          (unless (magit--meta-hunk-p section)
            (magit-diff--update-hunk-syntax section))
        (dolist (child (oref section children))
          (update child))))))