Skip to content

Instantly share code, notes, and snippets.

@jordonbiondo
Created April 28, 2014 20:12
Show Gist options
  • Select an option

  • Save jordonbiondo/11382720 to your computer and use it in GitHub Desktop.

Select an option

Save jordonbiondo/11382720 to your computer and use it in GitHub Desktop.
auto refresh git-gutter when staging and unstaging in magit
(defvar my-magit-after-stage-hooks nil)
(defvar my-magit-after-unstage-hooks nil)
(defadvice magit-stage-item (after run-my-after-stage-hooks activate)
(when (called-interactively-p 'interactive)
(run-hooks 'my-magit-after-stage-hooks)))
(defadvice magit-unstage-item (after run-my-after-unstage-hooks activate)
(when (called-interactively-p 'interactive)
(run-hooks 'my-magit-after-unstage-hooks)))
(defun my-refresh-visible-git-gutter-buffers ()
(dolist (buff (buffer-list))
(with-current-buffer buff
(when (and git-gutter-mode (get-buffer-window buff))
(git-gutter-mode t)))))
(add-hook 'my-magit-after-unstage-hooks
'my-refresh-visible-git-gutter-buffers)
(add-hook 'my-magit-after-stage-hooks
'my-refresh-visible-git-gutter-buffers)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment