mirror of
https://github.com/correl/doom-modeline.git
synced 2024-11-27 11:09:52 +00:00
Fix #42: refactor doom-modeline-project-root to avoid errors.
This commit is contained in:
parent
f0e882dbe6
commit
813adefbfa
1 changed files with 13 additions and 13 deletions
|
@ -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)))))
|
||||
(or
|
||||
(when (featurep 'projectile) (projectile-project-root))
|
||||
(when (featurep 'project)
|
||||
(when-let ((project (project-current)))
|
||||
(car (project-roots project)))))))
|
||||
(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)
|
||||
|
@ -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))
|
||||
|
|
Loading…
Reference in a new issue