From e49b4a812331c998060baf1d309f44bb27658dea Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 14 Aug 2020 16:49:49 -0400 Subject: [PATCH] tools/magit: speed up git calls in magit But only for local repos. --- modules/tools/magit/config.el | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/modules/tools/magit/config.el b/modules/tools/magit/config.el index f77101034..c3acee00a 100644 --- a/modules/tools/magit/config.el +++ b/modules/tools/magit/config.el @@ -98,7 +98,19 @@ For example, diffs and log buffers. Accepts `left', `right', `up', and `down'.") (define-key magit-status-mode-map [remap magit-mode-bury-buffer] #'+magit/quit) ;; Close transient with ESC - (define-key transient-map [escape] #'transient-quit-one)) + (define-key transient-map [escape] #'transient-quit-one) + + ;; An optimization that particularly affects macOS and Windows users: by + ;; resolving `magit-git-executable' (and others) Emacs does less work to find + ;; the executable in your PATH, which is great because it is called so + ;; frequently. However, absolute paths will break magit in TRAMP/remote + ;; projects if the git executable isn't in the exact same location. + (add-hook! 'magit-status-mode-hook + (defun +magit-optimize-process-calls-h () + (unless (file-remote-p default-directory) + (setq-local magit-git-executable (executable-find magit-git-executable) + magit-perl-executable (executable-find magit-perl-executable) + magit-gitk-executable (executable-find magit-gitk-executable)))))) (use-package! forge