1

I use git-gutter to keep track of git changes in my buffer while editing.

I created this hydra for speed up commits a bit more (when I don't feel like using magit - often because this "takes me away" from my current file).

(defhydra my-git-changes-hydra ()
  "Navigate and record git changes"
  ("j" git-gutter:next-hunk "next")
  ("k" git-gutter:previous-hunk "prev")
  ("s" git-gutter:stage-hunk "stage")
  ("v" git-gutter:popup-hunk "view")
  ("x" git-gutter:revert-hunk "revert"))

This worked pretty well. But it's slightly annoying having to type "yes" and "no" whenever I stage stuff. I'm aware that this there for safety... but if I've already gone into a hydra and am moving around commits and am going through a bunch of changes I think I can accept the risk.

Is there a way to disable the "yes/no" prompting... or switching it to a simple y or n keypress.

Att Righ
  • 725
  • 4
  • 14
  • 3
    I haven't installed git-gutter, but could this solve your problem: [git-gutter Homepage](https://github.com/emacsorphanage/git-gutter#dont-ask-whether-commitrevert-or-not) . git-gutter.el always asks you whether commit/revert or not. If you don't want, please set `git-gutter:ask-p` to nil. – Oliver Knodel Mar 08 '23 at 16:13

1 Answers1

1

I hope my unskilled code meets your requirements.

(defun my-stage-hunk ()
  (interactive)
  (git-gutter:awhen (git-gutter:search-here-diffinfo git-gutter:diffinfos)
    (git-gutter:do-stage-hunk it)
    (message "Staged. %s" (buffer-name))))

(defhydra my-git-changes-hydra ()
  ("s" my-stage-hunk "stage"))
roomworoof
  • 394
  • 2
  • 9