ui/doom-modeline: fix (some) void-variable errors w/ blank buffer-file-truename
This commit is contained in:
parent
b92a83752a
commit
5acd952c47
1 changed files with 22 additions and 19 deletions
|
@ -197,21 +197,23 @@ active."
|
||||||
|
|
||||||
(defun +doom-modeline-buffer-file-name ()
|
(defun +doom-modeline-buffer-file-name ()
|
||||||
"Propertized `buffer-file-name' based on `+doom-modeline-buffer-file-name-style'."
|
"Propertized `buffer-file-name' based on `+doom-modeline-buffer-file-name-style'."
|
||||||
(propertize
|
(let ((buffer-file-name (or buffer-file-name ""))
|
||||||
(pcase +doom-modeline-buffer-file-name-style
|
(buffer-file-truename (or buffer-file-truename "")))
|
||||||
('truncate-upto-project (+doom-modeline--buffer-file-name 'shrink))
|
(propertize
|
||||||
('truncate-upto-root (+doom-modeline--buffer-file-name-truncate))
|
(pcase +doom-modeline-buffer-file-name-style
|
||||||
('truncate-all (+doom-modeline--buffer-file-name-truncate t))
|
('truncate-upto-project (+doom-modeline--buffer-file-name 'shrink))
|
||||||
('relative-to-project (+doom-modeline--buffer-file-name-relative))
|
('truncate-upto-root (+doom-modeline--buffer-file-name-truncate))
|
||||||
('relative-from-project (+doom-modeline--buffer-file-name-relative 'include-project))
|
('truncate-all (+doom-modeline--buffer-file-name-truncate t))
|
||||||
('file-name (propertize (file-name-nondirectory buffer-file-name)
|
('relative-to-project (+doom-modeline--buffer-file-name-relative))
|
||||||
'face
|
('relative-from-project (+doom-modeline--buffer-file-name-relative 'include-project))
|
||||||
(let ((face (or (and (buffer-modified-p)
|
('file-name (propertize (file-name-nondirectory buffer-file-name)
|
||||||
'doom-modeline-buffer-modified)
|
'face
|
||||||
(and (active)
|
(let ((face (or (and (buffer-modified-p)
|
||||||
'doom-modeline-buffer-file))))
|
'doom-modeline-buffer-modified)
|
||||||
(when face `(:inherit ,face))))))
|
(and (active)
|
||||||
'help-echo buffer-file-truename))
|
'doom-modeline-buffer-file))))
|
||||||
|
(when face `(:inherit ,face))))))
|
||||||
|
'help-echo buffer-file-truename)))
|
||||||
|
|
||||||
(defun +doom-modeline--buffer-file-name-truncate (&optional truncate-tail)
|
(defun +doom-modeline--buffer-file-name-truncate (&optional truncate-tail)
|
||||||
"Propertized `buffer-file-name' that truncates every dir along path.
|
"Propertized `buffer-file-name' that truncates every dir along path.
|
||||||
|
@ -239,13 +241,14 @@ If TRUNCATE-TAIL is t also truncate the parent directory of the file."
|
||||||
(if (null root)
|
(if (null root)
|
||||||
(propertize "%b" 'face (if active 'doom-modeline-buffer-file))
|
(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))
|
||||||
(relative-dirs (file-relative-name (file-name-directory (file-truename buffer-file-name))
|
(true-filename (file-truename buffer-file-name))
|
||||||
|
(relative-dirs (file-relative-name (file-name-directory true-filename)
|
||||||
(if include-project (concat root "../") root)))
|
(if include-project (concat root "../") 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))))
|
||||||
(if (equal "./" relative-dirs) (setq relative-dirs ""))
|
(if (equal "./" relative-dirs) (setq relative-dirs ""))
|
||||||
(concat (propertize relative-dirs 'face (if relative-faces `(:inherit ,relative-faces)))
|
(concat (propertize relative-dirs 'face (if relative-faces `(:inherit ,relative-faces)))
|
||||||
(propertize (file-name-nondirectory (file-truename buffer-file-name))
|
(propertize (file-name-nondirectory true-filename)
|
||||||
'face (if file-faces `(:inherit ,file-faces))))))))
|
'face (if file-faces `(:inherit ,file-faces))))))))
|
||||||
|
|
||||||
(defun +doom-modeline--buffer-file-name (truncate-project-root-parent)
|
(defun +doom-modeline--buffer-file-name (truncate-project-root-parent)
|
||||||
|
@ -257,8 +260,8 @@ Example:
|
||||||
~/Projects/FOSS/emacs/lisp/comint.el => ~/P/F/emacs/lisp/comint.el"
|
~/Projects/FOSS/emacs/lisp/comint.el => ~/P/F/emacs/lisp/comint.el"
|
||||||
(let* ((project-root (doom-project-root))
|
(let* ((project-root (doom-project-root))
|
||||||
(file-name-split (shrink-path-file-mixed project-root
|
(file-name-split (shrink-path-file-mixed project-root
|
||||||
(file-name-directory buffer-file-truename)
|
(file-name-directory buffer-file-name)
|
||||||
buffer-file-truename))
|
buffer-file-name))
|
||||||
(active (active)))
|
(active (active)))
|
||||||
(if (null file-name-split)
|
(if (null file-name-split)
|
||||||
(propertize "%b" 'face (if active 'doom-modeline-buffer-file))
|
(propertize "%b" 'face (if active 'doom-modeline-buffer-file))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue