ui/doom-modeline: fix {dir,file}-path variable errors
This commit is contained in:
parent
88126079ab
commit
3c8acec33f
1 changed files with 15 additions and 16 deletions
|
@ -1,5 +1,7 @@
|
||||||
;;; ui/doom-modeline/config.el
|
;;; ui/doom-modeline/config.el
|
||||||
|
|
||||||
|
(eval-when-compile (require 'subr-x))
|
||||||
|
|
||||||
(line-number-mode -1)
|
(line-number-mode -1)
|
||||||
|
|
||||||
;; all-the-icons doesn't work in the terminal, so we "disable" it.
|
;; all-the-icons doesn't work in the terminal, so we "disable" it.
|
||||||
|
@ -241,7 +243,7 @@ active."
|
||||||
(defun +doom-modeline--buffer-file ()
|
(defun +doom-modeline--buffer-file ()
|
||||||
"Display the base of the current buffer's filename."
|
"Display the base of the current buffer's filename."
|
||||||
(if buffer-file-name
|
(if buffer-file-name
|
||||||
(file-name-nondirectory buffer-file-truename)
|
(file-name-nondirectory (or buffer-file-truename (file-truename buffer-file-name)))
|
||||||
"%b"))
|
"%b"))
|
||||||
|
|
||||||
(defun +doom-modeline--buffer-path ()
|
(defun +doom-modeline--buffer-path ()
|
||||||
|
@ -249,7 +251,8 @@ active."
|
||||||
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
|
(let ((buffer-path
|
||||||
(file-relative-name (file-name-directory buffer-file-truename)
|
(file-relative-name (file-name-directory
|
||||||
|
(or buffer-file-truename (file-truename buffer-file-name)))
|
||||||
(doom-project-root))))
|
(doom-project-root))))
|
||||||
(unless (equal buffer-path "./")
|
(unless (equal buffer-path "./")
|
||||||
(let ((max-length (truncate (* (window-body-width) 0.4))))
|
(let ((max-length (truncate (* (window-body-width) 0.4))))
|
||||||
|
@ -289,11 +292,10 @@ buffer where knowing the current project directory is important."
|
||||||
(def-modeline-segment! buffer-info
|
(def-modeline-segment! buffer-info
|
||||||
"Combined information about the current buffer, including the current working
|
"Combined information about the current buffer, including the current working
|
||||||
directory, the file name, and its state (modified, read-only or non-existent)."
|
directory, the file name, and its state (modified, read-only or non-existent)."
|
||||||
(let ((all-the-icons-scale-factor 1.2)
|
(let* ((all-the-icons-scale-factor 1.2)
|
||||||
(modified-p (buffer-modified-p))
|
(modified-p (buffer-modified-p))
|
||||||
(active (active))
|
(active (active))
|
||||||
faces)
|
(faces (if modified-p 'doom-modeline-buffer-modified)))
|
||||||
(if modified-p (push 'doom-modeline-buffer-modified faces))
|
|
||||||
(concat (if buffer-read-only
|
(concat (if buffer-read-only
|
||||||
(concat (all-the-icons-octicon
|
(concat (all-the-icons-octicon
|
||||||
"lock"
|
"lock"
|
||||||
|
@ -312,15 +314,12 @@ directory, the file name, and its state (modified, read-only or non-existent)."
|
||||||
:face 'doom-modeline-urgent
|
:face 'doom-modeline-urgent
|
||||||
:v-adjust -0.05)
|
:v-adjust -0.05)
|
||||||
" "))
|
" "))
|
||||||
(let ((dir-path (+doom-modeline--buffer-path))
|
(when-let (dir-path (+doom-modeline--buffer-path))
|
||||||
(faces (or faces (if active 'doom-modeline-buffer-path))))
|
(if-let (faces (or faces (if active 'doom-modeline-buffer-path)))
|
||||||
(when dir-path
|
(propertize dir-path 'face `(:inherit ,faces))
|
||||||
(if faces
|
dir-path))
|
||||||
(propertize dir-path 'face `(:inherit ,faces))
|
(when-let (file-path (+doom-modeline--buffer-file))
|
||||||
dir-path)))
|
(if-let (faces (or faces (if active 'doom-modeline-buffer-file)))
|
||||||
(let ((file-path (+doom-modeline--buffer-file))
|
|
||||||
(faces (or faces (if active 'doom-modeline-buffer-file))))
|
|
||||||
(if faces
|
|
||||||
(propertize file-path 'face `(:inherit ,faces))
|
(propertize file-path 'face `(:inherit ,faces))
|
||||||
file-path)))))
|
file-path)))))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue