Function: diff--iterate-hunks

diff--iterate-hunks is a byte-compiled function defined in diff-mode.el.gz.

Signature

(diff--iterate-hunks MAX FUN)

Documentation

Iterate over all hunks between point and MAX.

Call FUN with two args (BEG and END) for each hunk.

Source Code

;; Defined in /usr/src/emacs/lisp/vc/diff-mode.el.gz
(defun diff--iterate-hunks (max fun)
  "Iterate over all hunks between point and MAX.
Call FUN with two args (BEG and END) for each hunk."
  (save-excursion
    (catch 'malformed
      (let* ((beg (or (ignore-errors (diff-beginning-of-hunk))
                      (ignore-errors (diff-hunk-next) (point))
                      max)))
        (while (< beg max)
          (goto-char beg)
          (unless (looking-at diff-hunk-header-re)
            (throw 'malformed nil))
          (let ((end
                 (save-excursion (diff-end-of-hunk) (point))))
            (unless (< beg end)
              (throw 'malformed nil))
            (funcall fun beg end)
            (goto-char end)
            (setq beg (if (looking-at diff-hunk-header-re)
                          end
                        (or (ignore-errors (diff-hunk-next) (point))
                            max)))))))))