Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make git-gutter+-next/prev-hunk repeatable by last keystroke #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
20 changes: 18 additions & 2 deletions git-gutter+.el
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
(require 'tramp)
(require 'log-edit)
(require 'git-commit)
(require 'repeat)

(defgroup git-gutter+ nil
"Manage Git hunks straight from the buffer"
Expand Down Expand Up @@ -566,12 +567,27 @@ Returns t on zero exit code, nil otherwise."
(let ((next (if is-reverse (1+ index) (1- index))))
(mod (+ arg next) len))
(if is-reverse (1- (length diffinfos)) 0)))
(diffinfo (nth real-index diffinfos)))
(diffinfo (nth real-index diffinfos))
(repeat-char
(if (eq repeat-on-final-keystroke t)
last-command-event
(car (memq last-command-event
(listify-key-sequence
repeat-on-final-keystroke))))))
(goto-char (point-min))
(forward-line (1- (plist-get diffinfo :start-line)))
(when (buffer-live-p (get-buffer git-gutter+-popup-buffer))
(save-window-excursion
(git-gutter+-show-hunk diffinfo)))))))
(git-gutter+-show-hunk diffinfo)))
(when repeat-char
(let ((map (make-sparse-keymap)))
(define-key map (vector repeat-char)
`(lambda ()
(interactive)
(git-gutter+-next-hunk ,arg)))
(cond ((fboundp 'set-transient-map) (set-transient-map map))
((fboundp 'set-temporary-overlay-map) (set-temporary-overlay-map map))
(t))))))))

(defun git-gutter+-previous-hunk (arg)
"Move to previous diff hunk"
Expand Down