modeline: join buffer path and name
+ Also fixes an issue with ivy calls when default-directory is altered, thus changing the buffer path in the mode-line.
This commit is contained in:
parent
e870ec1bc6
commit
d2f483ea92
1 changed files with 20 additions and 26 deletions
|
@ -136,24 +136,24 @@ cached the first time."
|
||||||
"Displays the buffer's full path relative to the project root (includes the
|
"Displays the buffer's full path relative to the project root (includes the
|
||||||
project root). Excludes the file basename. See `doom-buffer-name' for that."
|
project root). Excludes the file basename. See `doom-buffer-name' for that."
|
||||||
(when buffer-file-name
|
(when buffer-file-name
|
||||||
(let ((buffer-path (f-relative (f-dirname buffer-file-name) (doom/project-root)))
|
(let* ((default-directory (f-dirname buffer-file-name))
|
||||||
(max-length (truncate (/ (window-body-width) 1.75))))
|
(buffer-path (f-relative buffer-file-name (doom/project-root)))
|
||||||
|
(max-length (truncate (* (window-body-width) 0.4))))
|
||||||
(when (and buffer-path (not (equal buffer-path ".")))
|
(when (and buffer-path (not (equal buffer-path ".")))
|
||||||
(concat (if (> (length buffer-path) max-length)
|
(if (> (length buffer-path) max-length)
|
||||||
(let ((path (reverse (split-string buffer-path "/" t)))
|
(let ((path (reverse (split-string buffer-path "/" t)))
|
||||||
(output ""))
|
(output ""))
|
||||||
(when (and path (equal "" (car path)))
|
(when (and path (equal "" (car path)))
|
||||||
(setq path (cdr path)))
|
(setq path (cdr path)))
|
||||||
(while (and path (<= (length output) (- max-length 4)))
|
(while (and path (<= (length output) (- max-length 4)))
|
||||||
(setq output (concat (car path) "/" output))
|
(setq output (concat (car path) "/" output))
|
||||||
(setq path (cdr path)))
|
(setq path (cdr path)))
|
||||||
(when path
|
(when path
|
||||||
(setq output (concat "../" output)))
|
(setq output (concat "../" output)))
|
||||||
(when (string-suffix-p "/" output)
|
(when (string-suffix-p "/" output)
|
||||||
(setq output (substring output 0 -1)))
|
(setq output (substring output 0 -1)))
|
||||||
output)
|
output)
|
||||||
buffer-path)
|
buffer-path)))))
|
||||||
"/")))))
|
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
@ -204,15 +204,9 @@ directory, the file name, and its state (modified, read-only or non-existent)."
|
||||||
:v-adjust -0.05)
|
:v-adjust -0.05)
|
||||||
" "))
|
" "))
|
||||||
|
|
||||||
(if modified-p
|
(propertize (doom-buffer-path)
|
||||||
(propertize (concat (doom-buffer-path)
|
'face `(inherit (,(if modified-p 'doom-modeline-buffer-modified)
|
||||||
"%b")
|
,(if active 'doom-modeline-buffer-path))))
|
||||||
'face 'doom-modeline-buffer-modified)
|
|
||||||
(concat
|
|
||||||
(propertize (or (doom-buffer-path) "")
|
|
||||||
'face (if active 'doom-modeline-buffer-path))
|
|
||||||
(propertize "%b"
|
|
||||||
'face (if active 'doom-modeline-buffer-name))))
|
|
||||||
" %l:%c %p ")))
|
" %l:%c %p ")))
|
||||||
|
|
||||||
(defun *buffer-encoding ()
|
(defun *buffer-encoding ()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue