ui/doom-modeline: propertize plain buffer names

This commit is contained in:
Henrik Lissner 2017-10-03 02:53:28 +02:00
parent 1bd096ceb8
commit e69ed84e8a
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -225,11 +225,11 @@ active."
If TRUNCATE-TAIL is t also truncate the parent directory of the file." If TRUNCATE-TAIL is t also truncate the parent directory of the file."
(let ((dirs (shrink-path-prompt (file-name-directory (let ((dirs (shrink-path-prompt (file-name-directory
(or buffer-file-truename (or buffer-file-truename
(file-truename buffer-file-name)))))) (file-truename buffer-file-name)))))
(if (null dirs)
"%b"
(let ((modified-faces (if (buffer-modified-p) 'doom-modeline-buffer-modified))
(active (active))) (active (active)))
(if (null dirs)
(propertize "%b" 'face (if active 'doom-modeline-buffer-file))
(let ((modified-faces (if (buffer-modified-p) 'doom-modeline-buffer-modified)))
(let ((dirname (car dirs)) (let ((dirname (car dirs))
(basename (cdr dirs)) (basename (cdr dirs))
(dir-faces (or modified-faces (if active 'doom-modeline-project-root-dir))) (dir-faces (or modified-faces (if active 'doom-modeline-project-root-dir)))
@ -243,11 +243,11 @@ If TRUNCATE-TAIL is t also truncate the parent directory of the file."
(defun +doom-modeline--buffer-file-name-relative () (defun +doom-modeline--buffer-file-name-relative ()
"Propertized `buffer-file-name' showing directories relative to project's root only." "Propertized `buffer-file-name' showing directories relative to project's root only."
(let ((root (doom-project-root))) (let ((root (doom-project-root))
(active (active)))
(if (null root) (if (null root)
"%b" (propertize "%b" 'face (if active 'doom-modeline-buffer-file))
(let* ((modified-faces (if (buffer-modified-p) 'doom-modeline-buffer-modified)) (let* ((modified-faces (if (buffer-modified-p) 'doom-modeline-buffer-modified))
(active (active))
(relative-dirs (file-relative-name (file-name-directory buffer-file-name) root)) (relative-dirs (file-relative-name (file-name-directory buffer-file-name) root))
(relative-faces (or modified-faces (if active 'doom-modeline-buffer-path))) (relative-faces (or modified-faces (if active 'doom-modeline-buffer-path)))
(file-faces (or modified-faces (if active 'doom-modeline-buffer-file)))) (file-faces (or modified-faces (if active 'doom-modeline-buffer-file))))
@ -268,12 +268,12 @@ Example:
(file-name-directory (file-name-directory
(or buffer-file-truename (or buffer-file-truename
(file-truename buffer-file-name))) (file-truename buffer-file-name)))
(file-truename buffer-file-name)))) (file-truename buffer-file-name)))
(if (null file-name-split)
"%b"
(pcase-let ((`(,root-path-parent ,project ,relative-path ,filename) file-name-split))
(let ((modified-faces (if (buffer-modified-p) 'doom-modeline-buffer-modified))
(active (active))) (active (active)))
(if (null file-name-split)
(propertize "%b" 'face (if active 'doom-modeline-buffer-file))
(pcase-let ((`(,root-path-parent ,project ,relative-path ,filename) file-name-split))
(let ((modified-faces (if (buffer-modified-p) 'doom-modeline-buffer-modified)))
(let ((sp-faces (or modified-faces (if active 'font-lock-comment-face))) (let ((sp-faces (or modified-faces (if active 'font-lock-comment-face)))
(project-faces (or modified-faces (if active 'font-lock-string-face))) (project-faces (or modified-faces (if active 'font-lock-string-face)))
(relative-faces (or modified-faces (if active 'doom-modeline-buffer-path))) (relative-faces (or modified-faces (if active 'doom-modeline-buffer-path)))