Optimize the performance of getting the file names.

This commit is contained in:
Vincent Zhang 2018-11-13 23:00:39 +08:00
parent fafdafc122
commit 97d6b69222

View file

@ -494,8 +494,10 @@ active.")
(if (eq idx len) "\"};" "\",\n")))))
'xpm t :ascent 'center)))))
(defun doom-modeline-buffer-file-name ()
(defvar-local doom-modeline-buffer-file-name nil)
(defun doom-modeline-update-buffer-file-name ()
"Propertized variable `buffer-file-name' based on `doom-modeline-buffer-file-name-style'."
(setq doom-modeline-buffer-file-name
(let ((buffer-file-name (or (buffer-file-name (buffer-base-buffer)) "")))
(unless buffer-file-truename
(setq buffer-file-truename (file-truename buffer-file-name)))
@ -520,6 +522,9 @@ active.")
'doom-modeline-buffer-file))))
(when face `(:inherit ,face))))))
'help-echo buffer-file-truename)))
(message "#####%s####" doom-modeline-buffer-file-name))
(add-hook 'find-file-hook #'doom-modeline-update-buffer-file-name)
(add-hook 'after-save-hook #'doom-modeline-update-buffer-file-name)
(defun doom-modeline--buffer-file-name-truncate (file-path true-file-path &optional truncate-tail)
"Propertized variable `buffer-file-name' that truncates every dir along path.
@ -637,8 +642,8 @@ directory, the file name, and its state (modified, read-only or non-existent)."
:face 'doom-modeline-warning
:v-adjust -0.05)
" ")))
(if buffer-file-name
(doom-modeline-buffer-file-name)
(if doom-modeline-buffer-file-name
doom-modeline-buffer-file-name
"%b")))
(doom-modeline-def-segment buffer-info-simple