From 9337faed5b5816012dca88c042d6e66e05460e21 Mon Sep 17 00:00:00 2001 From: Vincent Zhang Date: Mon, 15 Oct 2018 20:30:22 +0800 Subject: [PATCH] Optimize: cache project root. Refer to https://github.com/seagle0128/doom-modeline/issues/32. --- doom-modeline.el | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/doom-modeline.el b/doom-modeline.el index 2868866..2dcd24d 100644 --- a/doom-modeline.el +++ b/doom-modeline.el @@ -309,13 +309,16 @@ active.") (buffer-local-value 'mode-line-format (current-buffer))) (list "%e" modeline)))) +(defvar-local doom-modeline-project-root nil) (defun doom-modeline-project-root () "Get the path to the root of your project. If STRICT-P, return nil if no project was found, otherwise return `default-directory'." - (let (projectile-require-project-root) - (projectile-project-root))) + (if (local-variable-p 'doom-modeline-project-root) + doom-modeline-project-root + (let (projectile-require-project-root) + (setq doom-modeline-project-root (projectile-project-root))))) ;; Disable projectile mode-line segment (setq projectile-dynamic-mode-line nil)