Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions diff-hl.el
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@ enclosed in a `progn' form. ELSE-FORMS may be empty."
:group 'diff-hl
:type 'boolean)

(defcustom diff-hl-next-previous-hunk-auto-recenter nil
"Non-nil to `recenter' after `diff-hl-next-hunk' and `diff-hl-previous-hunk'."
:group 'diff-hl
:type 'boolean)

(defcustom diff-hl-fallback-to-margin t
"Non-nil to use margin instead of fringe on non-graphic displays.

Expand Down Expand Up @@ -1081,17 +1086,20 @@ its end position."
"Go to the beginning of the next hunk in the current buffer."
(interactive)
(let ((overlay (diff-hl-search-next-hunk backward)))
(if overlay
(goto-char (overlay-start overlay))
(user-error "No further hunks found"))))
(unless overlay
(user-error "No further hunks found"))
(goto-char (overlay-start overlay))
(when diff-hl-next-previous-hunk-auto-recenter
(recenter))))

(defun diff-hl-previous-hunk ()
"Go to the beginning of the previous hunk in the current buffer."
(interactive)
(diff-hl-next-hunk t))

(defun diff-hl-find-current-hunk ()
(let (o)
(let ((o)
(diff-hl-next-previous-hunk-auto-recenter nil))
(cond
((diff-hl-hunk-overlay-at (point)))
((setq o (diff-hl-search-next-hunk t))
Expand Down