Fix magit in remote repos
And backport executable-find from Emacs 27.1 so we don't have to do these version checks every time we use it.
This commit is contained in:
parent
fcdd238291
commit
7ec623593e
3 changed files with 38 additions and 24 deletions
|
@ -672,5 +672,25 @@ set earlier in the ‘setq-local’. The return value of the
|
|||
(setq pairs (cdr (cdr pairs))))
|
||||
(macroexp-progn (nreverse expr)))))
|
||||
|
||||
(eval-when! (version< emacs-version "27.1")
|
||||
;; DEPRECATED Backported from Emacs 27; earlier verisons don't have REMOTE arg
|
||||
(defun executable-find (command &optional remote)
|
||||
"Search for COMMAND in `exec-path' and return the absolute file name.
|
||||
Return nil if COMMAND is not found anywhere in `exec-path'. If
|
||||
REMOTE is non-nil, search on the remote host indicated by
|
||||
`default-directory' instead."
|
||||
(if (and remote (file-remote-p default-directory))
|
||||
(let ((res (locate-file
|
||||
command
|
||||
(mapcar
|
||||
(lambda (x) (concat (file-remote-p default-directory) x))
|
||||
(exec-path))
|
||||
exec-suffixes 'file-executable-p)))
|
||||
(when (stringp res) (file-local-name res)))
|
||||
;; Use 1 rather than file-executable-p to better match the
|
||||
;; behavior of call-process.
|
||||
(let ((default-directory (file-name-quote default-directory 'top)))
|
||||
(locate-file command exec-path exec-suffixes 1)))))
|
||||
|
||||
(provide 'core-lib)
|
||||
;;; core-lib.el ends here
|
||||
|
|
|
@ -166,29 +166,23 @@ And if it's a function, evaluate it."
|
|||
projectile-indexing-method 'hybrid
|
||||
projectile-generic-command
|
||||
(lambda (_)
|
||||
(let ((find-exe-fn
|
||||
(if EMACS27+
|
||||
(doom-rpartial #'executable-find t)
|
||||
#'executable-find)))
|
||||
;; If fd exists, use it for git and generic projects. fd is a rust
|
||||
;; program that is significantly faster than git ls-files or find, and
|
||||
;; it respects .gitignore. This is recommended in the projectile docs.
|
||||
(cond
|
||||
((when-let
|
||||
(bin (if (ignore-errors (file-remote-p default-directory nil t))
|
||||
(cl-find-if find-exe-fn (list "fdfind" "fd"))
|
||||
doom-projectile-fd-binary))
|
||||
(concat (format "%s . -0 -H -E .git --color=never --type file --type symlink --follow"
|
||||
bin)
|
||||
(if IS-WINDOWS " --path-separator=/"))))
|
||||
;; Otherwise, resort to ripgrep, which is also faster than find
|
||||
((funcall find-exe-fn "rg")
|
||||
(concat "rg -0 --files --follow --color=never --hidden"
|
||||
(cl-loop for dir in projectile-globally-ignored-directories
|
||||
concat " --glob "
|
||||
concat (shell-quote-argument (concat "!" dir)))
|
||||
(if IS-WINDOWS " --path-separator /")))
|
||||
("find . -type f -print0")))))
|
||||
;; If fd exists, use it for git and generic projects. fd is a rust
|
||||
;; program that is significantly faster than git ls-files or find, and
|
||||
;; it respects .gitignore. This is recommended in the projectile docs.
|
||||
(cond
|
||||
((when-let
|
||||
(bin (if (ignore-errors (file-remote-p default-directory nil t))
|
||||
(cl-find-if (doom-rpartial #'executable-find t)
|
||||
(list "fdfind" "fd"))
|
||||
doom-projectile-fd-binary))
|
||||
(concat (format "%s . -0 -H --color=never --type file --type symlink --follow"
|
||||
bin)
|
||||
(if IS-WINDOWS " --path-separator=/"))))
|
||||
;; Otherwise, resort to ripgrep, which is also faster than find
|
||||
((executable-find "rg" t)
|
||||
(concat "rg -0 --files --follow --color=never --hidden"
|
||||
(if IS-WINDOWS " --path-separator /")))
|
||||
("find . -type f -print0"))))
|
||||
|
||||
(defadvice! doom--projectile-default-generic-command-a (orig-fn &rest args)
|
||||
"If projectile can't tell what kind of project you're in, it issues an error
|
||||
|
|
|
@ -112,7 +112,7 @@ For example, diffs and log buffers. Accepts `left', `right', `up', and `down'.")
|
|||
;; git executable isn't in the exact same location.
|
||||
(add-hook! 'magit-status-mode-hook
|
||||
(defun +magit-optimize-process-calls-h ()
|
||||
(when-let (path (executable-find magit-git-executable))
|
||||
(when-let (path (executable-find magit-git-executable t))
|
||||
(setq-local magit-git-executable path)))))
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue