mirror of
https://github.com/correl/doom-modeline.git
synced 2024-11-23 19:19:50 +00:00
Optimize performance of displaying file icons.
This commit is contained in:
parent
0c9888c5b6
commit
229366ffe5
1 changed files with 30 additions and 14 deletions
|
@ -687,6 +687,35 @@ buffer where knowing the current project directory is important."
|
||||||
file-name
|
file-name
|
||||||
(format "%s[%s]" file-name buffer-name))))
|
(format "%s[%s]" file-name buffer-name))))
|
||||||
|
|
||||||
|
(defvar-local doom-modeline--file-icon nil)
|
||||||
|
(defun doom-modeline-update-file-icon ()
|
||||||
|
"Update file icon in mode-line."
|
||||||
|
(when doom-modeline-major-mode-icon
|
||||||
|
(setq doom-modeline--file-icon
|
||||||
|
(let ((icon (doom-modeline-icon-for-mode major-mode)))
|
||||||
|
(unless (symbolp icon)
|
||||||
|
(concat
|
||||||
|
(propertize icon
|
||||||
|
'help-echo (format "Major-mode: `%s'" major-mode)
|
||||||
|
'display '(raise 0)
|
||||||
|
'face (cond (buffer-read-only 'doom-modeline-warninng)
|
||||||
|
((buffer-modified-p) 'doom-modeline-buffer-modified)
|
||||||
|
((and buffer-file-name
|
||||||
|
(not (file-exists-p buffer-file-name)))
|
||||||
|
'doom-modeline-urgent)
|
||||||
|
((buffer-narrowed-p) 'doom-modeline-warning)))
|
||||||
|
" "))))))
|
||||||
|
(add-hook 'find-file-hook 'doom-modeline-update-file-icon)
|
||||||
|
(add-hook 'after-save-hook 'doom-modeline-update-file-icon)
|
||||||
|
(add-hook 'after-revert-hook 'doom-modeline-update-file-icon)
|
||||||
|
(add-hook 'after-change-major-mode-hook 'doom-modeline-update-file-icon)
|
||||||
|
|
||||||
|
(add-variable-watcher
|
||||||
|
'doom-modeline-major-mode-icon
|
||||||
|
(lambda (_sym _val op _where)
|
||||||
|
(when (eq op 'set)
|
||||||
|
(doom-modeline-update-file-icon))))
|
||||||
|
|
||||||
(doom-modeline-def-segment buffer-info
|
(doom-modeline-def-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)."
|
||||||
|
@ -718,20 +747,7 @@ directory, the file name, and its state (modified, read-only or non-existent)."
|
||||||
:v-adjus t -0.05)
|
:v-adjus t -0.05)
|
||||||
" ")))
|
" ")))
|
||||||
|
|
||||||
(when doom-modeline-major-mode-icon
|
(or doom-modeline--file-icon (doom-modeline-update-file-icon))
|
||||||
(let ((icon (doom-modeline-icon-for-mode major-mode)))
|
|
||||||
(unless (symbolp icon)
|
|
||||||
(concat
|
|
||||||
(propertize icon
|
|
||||||
'help-echo (format "Major-mode: `%s'" major-mode)
|
|
||||||
'display '(raise 0)
|
|
||||||
'face (cond (buffer-read-only 'doom-modeline-warninng)
|
|
||||||
((buffer-modified-p) 'doom-modeline-buffer-modified)
|
|
||||||
((and buffer-file-name
|
|
||||||
(not (file-exists-p buffer-file-name)))
|
|
||||||
'doom-modeline-urgent)
|
|
||||||
((buffer-narrowed-p) 'doom-modeline-warning)))
|
|
||||||
" "))))
|
|
||||||
|
|
||||||
(if buffer-file-name
|
(if buffer-file-name
|
||||||
(doom-modeline-fix-buffer-file-name)
|
(doom-modeline-fix-buffer-file-name)
|
||||||
|
|
Loading…
Reference in a new issue