Function: diff-hl-split-away-changes

diff-hl-split-away-changes is a natively compiled function defined in diff-hl.el.

Signature

(diff-hl-split-away-changes MAX-CONTEXT)

Documentation

Split away the minimal hunk at point from the rest of the hunk.

The minimal hunk is the hunk a diff program would produce if asked for 0 lines of context. Add MAX-CONTEXT lines of context at most (stop when encounter another minimal hunk).

Move point to the beginning of the delineated hunk and return its end position.

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-split-away-changes (max-context)
  "Split away the minimal hunk at point from the rest of the hunk.

The minimal hunk is the hunk a diff program would produce if
asked for 0 lines of context. Add MAX-CONTEXT lines of context at
most (stop when encounter another minimal hunk).

Move point to the beginning of the delineated hunk and return
its end position."
  (let (end-marker)
    (save-excursion
      (while (looking-at "[-+\\]") (forward-line 1))
      (dotimes (_i max-context)
        (unless (looking-at "@\\|[-+]")
          (forward-line 1)))
      (setq end-marker (point-marker))
      (unless (or (eobp)
                  (looking-at "@"))
        (diff-split-hunk)))
    (unless (looking-at "[-+]") (forward-line -1))
    (while (looking-at "[-+\\]") (forward-line -1))
    (dotimes (_i max-context)
      (unless (looking-at "@\\|[-+]")
        (forward-line -1)))
    (unless (looking-at "@")
      (forward-line 1)
      (diff-split-hunk)
      (forward-line -1))
    end-marker))