tools/magit: only expand git path

On closer inspection it isn't necessary to expand the gitk and perl
executable paths, since a) gitk is a GUI application that doesn't get
called often enough (only once at a time) to warrant being optimized,
and b) magit uses it to set an envvar for git (so git itself handles
locating the executable internally -- much faster than Emacs can (esp
over TRAMP), so it only benefits us to expand magit-git-executable.
This commit is contained in:
Henrik Lissner 2020-08-15 12:25:34 -04:00
parent 10edc92bce
commit 4ad9b764e1
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -104,16 +104,14 @@ For example, diffs and log buffers. Accepts `left', `right', `up', and `down'.")
(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 ;; An optimization that particularly affects macOS and Windows users: by
;; resolving `magit-git-executable' (and others) Emacs does less work to find ;; resolving `magit-git-executable' Emacs does less work to find the
;; the executable in your PATH, which is great because it is called so ;; executable in your PATH, which is great because it is called so frequently.
;; frequently. However, absolute paths will break magit in TRAMP/remote ;; However, absolute paths will break magit in TRAMP/remote projects if the
;; projects if the git executable isn't in the exact same location. ;; git executable isn't in the exact same location.
(add-hook! 'magit-status-mode-hook (add-hook! 'magit-status-mode-hook
(defun +magit-optimize-process-calls-h () (defun +magit-optimize-process-calls-h ()
(dolist (sym '(magit-git-executable magit-perl-executable magit-gitk-executable)) (when-let (path (executable-find magit-git-executable))
(when-let* ((exe (symbol-value sym)) (setq-local magit-git-executable path)))))
(path (executable-find exe)))
(set (make-local-variable sym) path))))))
(use-package! forge (use-package! forge