Function: diff-bounds-of-hunk

diff-bounds-of-hunk is a byte-compiled function defined in diff-mode.el.gz.

Signature

(diff-bounds-of-hunk)

Documentation

Return the bounds of the diff hunk at point.

The return value is a list (BEG END), which are the hunk's start and end positions. Signal an error if no hunk is found. If point is in a file header, return the bounds of the next hunk.

Source Code

;; Defined in /usr/src/emacs/lisp/vc/diff-mode.el.gz
(defun diff-bounds-of-hunk ()
  "Return the bounds of the diff hunk at point.
The return value is a list (BEG END), which are the hunk's start
and end positions.  Signal an error if no hunk is found.  If
point is in a file header, return the bounds of the next hunk."
  (save-excursion
    (let ((pos (point))
	  (beg (diff-beginning-of-hunk t))
	  (end (diff-end-of-hunk)))
      (cond ((>= end pos)
	     (list beg end))
	    ;; If this hunk ends above POS, consider the next hunk.
	    ((re-search-forward diff-hunk-header-re nil t)
	     (list (match-beginning 0) (diff-end-of-hunk)))
	    (t (error "No hunk found"))))))