Enable git-gutter backends conditionally

Follow up to #2634
This commit is contained in:
Henrik Lissner 2020-03-01 01:36:16 -05:00
parent bbd1561a3c
commit aa1f11af4f
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -51,7 +51,6 @@ is deferred until the file is saved. Respects `git-gutter:disabled-modes'."
(git-gutter-mode +1) (git-gutter-mode +1)
(remove-hook 'after-save-hook #'+vc-gutter-init-maybe-h 'local))))))) (remove-hook 'after-save-hook #'+vc-gutter-init-maybe-h 'local)))))))
(setq git-gutter:handled-backends '(git hg svn bzr))
;; Disable in Org mode, as per ;; Disable in Org mode, as per
;; <https://github.com/syl20bnr/spacemacs/issues/10555> and ;; <https://github.com/syl20bnr/spacemacs/issues/10555> and
;; <https://github.com/syohex/emacs-git-gutter/issues/24>. Apparently, the ;; <https://github.com/syohex/emacs-git-gutter/issues/24>. Apparently, the
@ -61,6 +60,13 @@ is deferred until the file is saved. Respects `git-gutter:disabled-modes'."
;; here fixes the issue. ;; here fixes the issue.
(setq git-gutter:disabled-modes '(fundamental-mode image-mode pdf-view-mode)) (setq git-gutter:disabled-modes '(fundamental-mode image-mode pdf-view-mode))
:config :config
;; Only enable the backends that are available, so it doesn't have to check
;; when opening each buffer.
(setq git-gutter:handled-backends '(git))
(dolist (backend '(hg svn bzr))
(when (executable-find (symbol-name backend))
(add-to-list 'git-gutter:handled-backends backend)))
(set-popup-rule! "^\\*git-gutter" :select nil :size '+popup-shrink-to-fit) (set-popup-rule! "^\\*git-gutter" :select nil :size '+popup-shrink-to-fit)
;; Update git-gutter on focus (in case I was using git externally) ;; Update git-gutter on focus (in case I was using git externally)