mirror of
https://github.com/correl/doom-modeline.git
synced 2024-11-27 11:09:52 +00:00
Fix #48: [Feature] show the icon for major mode.
New variable `doom-modeline-major-mode-icon' to control.
This commit is contained in:
parent
b91e76b383
commit
34c6f91d36
2 changed files with 56 additions and 29 deletions
|
@ -88,6 +88,9 @@ Recommand to use [doom-themes](https://github.com/hlissner/emacs-doom-themes);
|
||||||
;; The icons may not be showed correctly on Windows. Disable to make it work.
|
;; The icons may not be showed correctly on Windows. Disable to make it work.
|
||||||
(setq doom-modeline-icon t)
|
(setq doom-modeline-icon t)
|
||||||
|
|
||||||
|
;; Whether show the icon for major mode. It should respect `doom-modeline-icon'.
|
||||||
|
(setq doom-modeline-major-mode-icon nil)
|
||||||
|
|
||||||
;; Don’t compact font caches during GC.
|
;; Don’t compact font caches during GC.
|
||||||
;; If you are expereicing the laggy issue especially on Windows, please set to
|
;; If you are expereicing the laggy issue especially on Windows, please set to
|
||||||
;; non-nil.
|
;; non-nil.
|
||||||
|
|
|
@ -96,6 +96,10 @@ Given ~/Projects/FOSS/emacs/lisp/comint.el
|
||||||
"Whether show `all-the-icons' or not (if nil nothing will be showed).
|
"Whether show `all-the-icons' or not (if nil nothing will be showed).
|
||||||
The icons may not be showed correctly on Windows. Disable to make it work.")
|
The icons may not be showed correctly on Windows. Disable to make it work.")
|
||||||
|
|
||||||
|
(defvar doom-modeline-major-mode-icon nil
|
||||||
|
"Whether show the icon for major mode. It should respect `doom-modeline-icon'.")
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
;; externals
|
;; externals
|
||||||
;;
|
;;
|
||||||
|
@ -454,20 +458,25 @@ active.")
|
||||||
;;
|
;;
|
||||||
|
|
||||||
(defun doom-modeline-icon-octicon (&rest args)
|
(defun doom-modeline-icon-octicon (&rest args)
|
||||||
"Display octicon via `ARGS'."
|
"Display octicon via ARGS."
|
||||||
(when doom-modeline-icon
|
(when doom-modeline-icon
|
||||||
(apply 'all-the-icons-octicon args)))
|
(apply 'all-the-icons-octicon args)))
|
||||||
|
|
||||||
(defun doom-modeline-icon-faicon (&rest args)
|
(defun doom-modeline-icon-faicon (&rest args)
|
||||||
"Display font awesome icon via `ARGS'."
|
"Display font awesome icon via ARGS."
|
||||||
(when doom-modeline-icon
|
(when doom-modeline-icon
|
||||||
(apply 'all-the-icons-faicon args)))
|
(apply 'all-the-icons-faicon args)))
|
||||||
|
|
||||||
(defun doom-modeline-icon-material (&rest args)
|
(defun doom-modeline-icon-material (&rest args)
|
||||||
"Display material icon via `ARGS'."
|
"Display material icon via ARGS."
|
||||||
(when doom-modeline-icon
|
(when doom-modeline-icon
|
||||||
(apply 'all-the-icons-material args)))
|
(apply 'all-the-icons-material args)))
|
||||||
|
|
||||||
|
(defun doom-modeline-icon-for-mode (&rest args)
|
||||||
|
"Display icon for major mode via ARGS."
|
||||||
|
(when doom-modeline-icon
|
||||||
|
(apply 'all-the-icons-icon-for-mode 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))
|
||||||
|
@ -670,32 +679,47 @@ buffer where knowing the current project directory is important."
|
||||||
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 ((active (doom-modeline--active)))
|
(let ((active (doom-modeline--active)))
|
||||||
(concat
|
(concat
|
||||||
(if active
|
|
||||||
(cond (buffer-read-only
|
(cond (buffer-read-only
|
||||||
(concat (doom-modeline-icon-octicon
|
(concat (doom-modeline-icon-octicon
|
||||||
"lock"
|
"lock"
|
||||||
:face 'doom-modeline-warning
|
:face (if active 'doom-modeline-warning)
|
||||||
:v-adjust -0.05)
|
:v-adjust -0.05)
|
||||||
" "))
|
" "))
|
||||||
((buffer-modified-p)
|
((buffer-modified-p)
|
||||||
(concat (doom-modeline-icon-faicon
|
(concat (doom-modeline-icon-faicon
|
||||||
"floppy-o"
|
"floppy-o"
|
||||||
:face 'doom-modeline-buffer-modified
|
:face (if active 'doom-modeline-buffer-modified)
|
||||||
:v-adjust -0.0575)
|
:v-adjust -0.0575)
|
||||||
" "))
|
" "))
|
||||||
((and buffer-file-name
|
((and buffer-file-name
|
||||||
(not (file-exists-p buffer-file-name)))
|
(not (file-exists-p buffer-file-name)))
|
||||||
(concat (doom-modeline-icon-octicon
|
(concat (doom-modeline-icon-octicon
|
||||||
"circle-slash"
|
"circle-slash"
|
||||||
:face 'doom-modeline-urgent
|
:face (if active 'doom-modeline-urgent)
|
||||||
:v-adjust -0.05)
|
:v-adjust -0.05)
|
||||||
" "))
|
" "))
|
||||||
((buffer-narrowed-p)
|
((buffer-narrowed-p)
|
||||||
(concat (doom-modeline-icon-octicon
|
(concat (doom-modeline-icon-octicon
|
||||||
"fold"
|
"fold"
|
||||||
:face 'doom-modeline-warning
|
:face (if active 'doom-modeline-warning)
|
||||||
:v-adjust -0.05)
|
:v-adjus t -0.05)
|
||||||
|
" ")))
|
||||||
|
|
||||||
|
(when doom-modeline-major-mode-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)
|
||||||
(propertize "%b" 'face (if active 'doom-modeline-buffer-file))))))
|
(propertize "%b" 'face (if active 'doom-modeline-buffer-file))))))
|
||||||
|
|
Loading…
Reference in a new issue