Add 'relative-from-project option for +doom-modeline-buffer-file-name-style
This commit is contained in:
parent
59f39576de
commit
a2c2ee3246
1 changed files with 5 additions and 2 deletions
|
@ -87,6 +87,7 @@ Given ~/Projects/FOSS/emacs/lisp/comint.el
|
||||||
truncate-upto-project => ~/P/F/emacs/lisp/comint.el
|
truncate-upto-project => ~/P/F/emacs/lisp/comint.el
|
||||||
truncate-upto-root => ~/P/F/e/lisp/comint.el
|
truncate-upto-root => ~/P/F/e/lisp/comint.el
|
||||||
truncate-all => ~/P/F/e/l/comint.el
|
truncate-all => ~/P/F/e/l/comint.el
|
||||||
|
relative-from-project => emacs/lisp/comint.el
|
||||||
relative-to-project => lisp/comint.el
|
relative-to-project => lisp/comint.el
|
||||||
file-name => comint.el")
|
file-name => comint.el")
|
||||||
|
|
||||||
|
@ -211,6 +212,7 @@ active."
|
||||||
('truncate-upto-root (+doom-modeline--buffer-file-name-truncate))
|
('truncate-upto-root (+doom-modeline--buffer-file-name-truncate))
|
||||||
('truncate-all (+doom-modeline--buffer-file-name-truncate t))
|
('truncate-all (+doom-modeline--buffer-file-name-truncate t))
|
||||||
('relative-to-project (+doom-modeline--buffer-file-name-relative))
|
('relative-to-project (+doom-modeline--buffer-file-name-relative))
|
||||||
|
('relative-from-project (+doom-modeline--buffer-file-name-relative 'include-project))
|
||||||
('file-name (propertize (file-name-nondirectory buffer-file-name)
|
('file-name (propertize (file-name-nondirectory buffer-file-name)
|
||||||
'face
|
'face
|
||||||
(let ((face (or (and (buffer-modified-p)
|
(let ((face (or (and (buffer-modified-p)
|
||||||
|
@ -241,14 +243,15 @@ If TRUNCATE-TAIL is t also truncate the parent directory of the file."
|
||||||
(propertize (file-name-nondirectory buffer-file-name)
|
(propertize (file-name-nondirectory buffer-file-name)
|
||||||
'face (if file-faces `(:inherit ,file-faces)))))))))
|
'face (if file-faces `(:inherit ,file-faces)))))))))
|
||||||
|
|
||||||
(defun +doom-modeline--buffer-file-name-relative ()
|
(defun +doom-modeline--buffer-file-name-relative (&optional include-project)
|
||||||
"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)))
|
(active (active)))
|
||||||
(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 buffer-file-name) root))
|
(relative-dirs (file-relative-name (file-name-directory buffer-file-name)
|
||||||
|
(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 ""))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue