ui/modeline: add support for indirect buffers
Indirect buffer support is still dodgy and needs work (some segments don't update at all).
This commit is contained in:
parent
13cee6870e
commit
d9fb1c5ca6
1 changed files with 25 additions and 20 deletions
|
@ -272,7 +272,8 @@ use `buffer-name'."
|
|||
parent.
|
||||
|
||||
e.g. project/src/lib/file.c"
|
||||
(let ((filename (or buffer-file-truename (file-truename buffer-file-name))))
|
||||
(let* ((base (buffer-base-buffer))
|
||||
(filename (file-truename (buffer-file-name base))))
|
||||
(append (if (doom-project-p)
|
||||
(let* ((project-root (doom-project-root))
|
||||
(relative-dirs (file-relative-name (file-name-directory filename)
|
||||
|
@ -314,9 +315,10 @@ e.g. ~/w/project/src/lib/file.c
|
|||
Meant for `+modeline-buffer-path-function'."
|
||||
(pcase-let
|
||||
((`(,root-parent ,root ,dir, file)
|
||||
(shrink-path-file-mixed (or (doom-project-root) default-directory)
|
||||
(file-name-directory buffer-file-name)
|
||||
buffer-file-name)))
|
||||
(let ((buffer-file-name (or buffer-file-name (buffer-file-name (buffer-base-buffer)))))
|
||||
(shrink-path-file-mixed (or (doom-project-root) default-directory)
|
||||
(file-name-directory buffer-file-name)
|
||||
buffer-file-name))))
|
||||
(list (cons root-parent 'font-lock-comment-face)
|
||||
(cons root 'doom-modeline-buffer-project-root)
|
||||
(cons (concat "/" dir) 'doom-modeline-buffer-path)
|
||||
|
@ -344,7 +346,8 @@ Meant for `+modeline-buffer-path-function'."
|
|||
e.g. ~/w/p/s/l/file.c
|
||||
|
||||
Meant for `+modeline-buffer-path-function'."
|
||||
(pcase-let ((`(,dir . ,file) (shrink-path-prompt buffer-file-name)))
|
||||
(pcase-let ((`(,dir . ,file)
|
||||
(shrink-path-prompt (buffer-file-name (buffer-base-buffer)))))
|
||||
(list (cons dir 'doom-modeline-buffer-path)
|
||||
(cons file 'doom-modeline-buffer-file))))
|
||||
|
||||
|
@ -413,21 +416,23 @@ Meant for `+modeline-buffer-path-function'."
|
|||
after-change-functions
|
||||
after-save-hook
|
||||
after-revert-hook)
|
||||
(let ((icon (cond (buffer-read-only
|
||||
(all-the-icons-octicon
|
||||
"lock"
|
||||
:face 'doom-modeline-warning
|
||||
:v-adjust -0.05))
|
||||
((buffer-modified-p)
|
||||
(all-the-icons-faicon
|
||||
"floppy-o"
|
||||
:face 'doom-modeline-buffer-modified
|
||||
:v-adjust -0.05))
|
||||
((and buffer-file-name (not (file-exists-p buffer-file-name)))
|
||||
(all-the-icons-octicon
|
||||
"circle-slash"
|
||||
:face 'doom-modeline-urgent
|
||||
:v-adjust -0.05)))))
|
||||
(let* ((base (buffer-base-buffer))
|
||||
(icon (cond (buffer-read-only
|
||||
(all-the-icons-octicon
|
||||
"lock"
|
||||
:face 'doom-modeline-warning
|
||||
:v-adjust -0.05))
|
||||
((buffer-modified-p base)
|
||||
(all-the-icons-faicon
|
||||
"floppy-o"
|
||||
:face 'doom-modeline-buffer-modified
|
||||
:v-adjust -0.05))
|
||||
((and (buffer-file-name base)
|
||||
(not (file-exists-p (buffer-file-name base))))
|
||||
(all-the-icons-octicon
|
||||
"circle-slash"
|
||||
:face 'doom-modeline-urgent
|
||||
:v-adjust -0.05)))))
|
||||
(if icon (concat icon " "))))
|
||||
|
||||
(def-modeline-segment! +modeline-buffer-id
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue