Optimize doom-modeline-project-root.

This commit is contained in:
Vincent Zhang 2019-03-29 21:36:47 +08:00
parent 5cb7c2ddfb
commit 0ead21b91f

View file

@ -478,15 +478,14 @@ If DEFAULT is non-nil, set the default mode-line for all buffers."
(defvar-local doom-modeline-project-root nil)
(defun doom-modeline-project-root ()
"Get the path to the root of your project.
Return `default-directory' if no project was found."
Return `default-directory' if no project was found."
(or doom-modeline-project-root
(setq doom-modeline-project-root
(file-local-name
(or
(when (featurep 'projectile)
(when (bound-and-true-p projectile-mode)
(ignore-errors (projectile-project-root)))
(when (featurep 'project)
(when (fboundp 'project-current)
(ignore-errors
(when-let ((project (project-current)))
(expand-file-name (car (project-roots project))))))