From 9acba6b269a936921ef05be358c0a2bc3b6fac75 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 27 Apr 2020 17:27:32 -0400 Subject: [PATCH] Speed up project root detection by resolving it less often Projectile can consume a lot of cycles, especially in indirect buffers or because of project-root-sensitive path segments in the modeline. This experimental fix should spare you that heartache. --- core/core-projects.el | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/core/core-projects.el b/core/core-projects.el index daca64c3a..ebb8d803e 100644 --- a/core/core-projects.el +++ b/core/core-projects.el @@ -40,6 +40,16 @@ Emacs.") :config (projectile-mode +1) + ;; REVIEW Resolve the project root once, when the file/buffer is opened. This + ;; speeds up projectile's project root resolution by leaps, but does + ;; put you at risk of having a stale project root. + (setq-hook! '(after-change-major-mode-hook + ;; In case the user saves the file to a new location + after-save-hook + ;; ...or makes external changes then returns to Emacs + focus-in-hook) + projectile-project-root (if default-directory (doom-project-root))) + ;; Projectile runs four functions to determine the root (in this order): ;; ;; + `projectile-root-local' -> checks the `projectile-project-root' variable