diff --git a/core/core-lib.el b/core/core-lib.el index 61f5d082c..e0553dc77 100644 --- a/core/core-lib.el +++ b/core/core-lib.el @@ -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 diff --git a/core/core-projects.el b/core/core-projects.el index 061b6b9fd..009539d28 100644 --- a/core/core-projects.el +++ b/core/core-projects.el @@ -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 diff --git a/modules/tools/magit/config.el b/modules/tools/magit/config.el index fac4acf1d..65b7edcfa 100644 --- a/modules/tools/magit/config.el +++ b/modules/tools/magit/config.el @@ -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)))))