Function: diff--track-changes-function

diff--track-changes-function is a byte-compiled function defined in diff-mode.el.gz.

Signature

(diff--track-changes-function BEG END BEFORE)

Source Code

;; Defined in /usr/src/emacs/lisp/vc/diff-mode.el.gz
(defun diff--track-changes-function (beg end _before)
  (with-demoted-errors "%S"
    (save-excursion
      (goto-char beg)
      ;; Maybe we've cut the end of the hunk before point.
      (if (and (bolp) (not (bobp))) (backward-char 1))
      ;; We used to fixup modifs on all the changes, but it turns out that
      ;; it's safer not to do it on big changes, e.g. when yanking a big
      ;; diff, or when the user edits the header, since we might then
      ;; screw up perfectly correct values.  --Stef
      (when (and (not track-changes-undo-only)
                 (ignore-errors (diff-beginning-of-hunk t)))
        (let* ((style (if (looking-at "\\*\\*\\*") 'context))
               (start (line-beginning-position (if (eq style 'context) 3 2)))
               (mid (if (eq style 'context)
                        (save-excursion
                          (re-search-forward diff-context-mid-hunk-header-re
                                             nil t)))))
          (when (and ;; Don't try to fixup changes in the hunk header.
                 (>= beg start)
                 ;; Don't try to fixup changes in the mid-hunk header either.
                 (or (not mid)
                     (< end (match-beginning 0))
                     (> beg (match-end 0)))
                 (save-excursion
		   (diff-end-of-hunk nil 'donttrustheader)
                   ;; Don't try to fixup changes past the end of the hunk.
                   (>= (point) end)))
	   (diff-fixup-modifs (point) end)
	   ;; Ignore the changes we just made ourselves.
	   ;; This is not indispensable since the above `when' skips
	   ;; changes like the ones we make anyway, but it's good practice.
	   (track-changes-fetch diff--track-changes #'ignore)))))))