ui/modeline: fix buffer file path segment

To cope with changes upstream in the projectile package.
This commit is contained in:
Henrik Lissner
2018-09-22 13:14:38 -04:00
parent cffb1d367f
commit 74af5bde26

View File

@ -260,7 +260,8 @@ use `buffer-name'."
(propertize "%s" 'face 'doom-modeline-buffer-path) (propertize "%s" 'face 'doom-modeline-buffer-path)
(cl-loop for spec in (funcall +modeline-buffer-path-function) (cl-loop for spec in (funcall +modeline-buffer-path-function)
if (stringp spec) concat spec if (stringp spec) concat spec
else concat (propertize (car spec) 'face (cdr spec)))))) else if (not (null spec))
concat (propertize (car spec) 'face (cdr spec))))))
;; ;;
@ -271,16 +272,18 @@ use `buffer-name'."
parent. parent.
e.g. project/src/lib/file.c" e.g. project/src/lib/file.c"
(let* ((project-root (doom-project-root)) (let ((filename (or buffer-file-truename (file-truename buffer-file-name))))
(true-filename (file-truename buffer-file-name)) (append (if (doom-project-p)
(relative-dirs (file-relative-name (file-name-directory true-filename) (let* ((project-root (doom-project-root))
(file-truename project-root)))) (relative-dirs (file-relative-name (file-name-directory filename)
(list (cons (concat (doom-project-name) "/") (file-truename project-root))))
'doom-modeline-buffer-project-root) (list (cons (concat (doom-project-name) "/")
(cons (if (equal "./" relative-dirs) "" relative-dirs) 'doom-modeline-buffer-project-root)
'doom-modeline-buffer-path) (unless (equal "./" relative-dirs)
(cons (file-name-nondirectory true-filename) (cons relative-dirs 'doom-modeline-buffer-path))))
'doom-modeline-buffer-file)))) (list nil (cons (file-name-directory filename) 'doom-modeline-buffer-path)))
(list (cons (file-name-nondirectory filename)
'doom-modeline-buffer-file)))))
(defun +modeline-file-path-from-project () (defun +modeline-file-path-from-project ()
"Returns file path relative to the project root. "Returns file path relative to the project root.