Improve: Construct icon via buffer name if no icon via major mode.

This commit is contained in:
Vincent Zhang 2018-12-25 05:42:47 +08:00
parent 257fcd564b
commit c13d5a3184

View file

@ -554,6 +554,11 @@ If DEFAULT is non-nil, set the default mode-line for all buffers."
(when doom-modeline-icon (when doom-modeline-icon
(apply 'all-the-icons-icon-for-mode args))) (apply 'all-the-icons-icon-for-mode args)))
(defun doom-modeline-icon-for-file (&rest args)
"Display icon for major mode via ARGS."
(when doom-modeline-icon
(apply 'all-the-icons-icon-for-file args)))
(defun doom-modeline--active () (defun doom-modeline--active ()
"Whether is an active window." "Whether is an active window."
(eq (selected-window) doom-modeline-current-window)) (eq (selected-window) doom-modeline-current-window))
@ -743,6 +748,8 @@ buffer where knowing the current project directory is important."
"Update file icon in mode-line." "Update file icon in mode-line."
(setq doom-modeline--buffer-file-icon (setq doom-modeline--buffer-file-icon
(let ((icon (doom-modeline-icon-for-mode major-mode :height 0.92))) (let ((icon (doom-modeline-icon-for-mode major-mode :height 0.92)))
(if (symbolp icon)
(setq icon (doom-modeline-icon-for-file (buffer-name) :height 0.92)))
(unless (symbolp icon) (unless (symbolp icon)
(propertize icon (propertize icon
'help-echo (format "Major-mode: `%s'" major-mode) 'help-echo (format "Major-mode: `%s'" major-mode)