From 813adefbfaac58eb0e0219677f90ba1535b35150 Mon Sep 17 00:00:00 2001 From: Vincent Zhang Date: Tue, 13 Nov 2018 13:24:14 +0800 Subject: [PATCH] Fix #42: refactor doom-modeline-project-root to avoid errors. --- doom-modeline.el | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/doom-modeline.el b/doom-modeline.el index 5cdd5b6..046bd6c 100644 --- a/doom-modeline.el +++ b/doom-modeline.el @@ -331,18 +331,18 @@ active.") (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'." + Return `default-directory' if no project was found." (if (local-variable-p 'doom-modeline-project-root) doom-modeline-project-root - (or - (when (featurep 'projectile) - (let ((projectile-require-project-root nil)) - (setq doom-modeline-project-root - (projectile-ensure-project (projectile-project-root))))) - (when (featurep 'project) - (when-let ((project (project-current))) - (car (project-roots project))))))) + (setq doom-modeline-project-root + (or + (when (featurep 'projectile) (projectile-project-root)) + (when (featurep 'project) + (when-let ((project (project-current))) + (car (project-roots project)))) + default-directory)))) + +(project-roots (project-current)) ;; Disable projectile mode-line segment (setq projectile-dynamic-mode-line nil) @@ -439,7 +439,7 @@ active.") (defun doom-modeline-update-env () "Update environment info on mode-line." (when doom-modeline-env-command - (let ((default-directory (or (doom-modeline-project-root) "")) + (let ((default-directory (doom-modeline-project-root)) (s (shell-command-to-string doom-modeline-env-command))) (setq doom-modeline-env-version (if (string-match "[ \t\n\r]+\\'" s) (replace-match "" t t s) @@ -494,7 +494,7 @@ active.") if (= d 0) collect (string-to-char " ") else collect (string-to-char ".")) (if (eq idx len) "\"};" "\",\n"))))) - 'xpm t :ascent 'center))))) + 'xpm t :ascent 'center))))) (defun doom-modeline-buffer-file-name () "Propertized variable `buffer-file-name' based on `doom-modeline-buffer-file-name-style'." @@ -567,7 +567,7 @@ fish-shell style. Example: ~/Projects/FOSS/emacs/lisp/comint.el => ~/P/F/emacs/lisp/comint.el" - (let* ((project-root (or (doom-modeline-project-root) "")) + (let* ((project-root (doom-modeline-project-root)) (file-name-split (shrink-path-file-mixed project-root (or (file-name-directory file-path) "./") file-path))