mirror of
https://github.com/correl/doom-modeline.git
synced 2024-11-23 19:19:50 +00:00
[Enhancement] Display alternative texts while icons aren't applicable.
This commit is contained in:
parent
4cc816c593
commit
df8c25fcd9
1 changed files with 276 additions and 217 deletions
493
doom-modeline.el
493
doom-modeline.el
|
@ -803,27 +803,40 @@ buffer where knowing the current project directory is important."
|
||||||
(defun doom-modeline-update-buffer-file-icon (&rest _)
|
(defun doom-modeline-update-buffer-file-icon (&rest _)
|
||||||
"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* ((height (/ all-the-icons-scale-factor 1.3))
|
(when (and doom-modeline-icon doom-modeline-major-mode-icon)
|
||||||
(icon (doom-modeline-icon-for-mode major-mode :height height)))
|
(let* ((height (/ all-the-icons-scale-factor 1.3))
|
||||||
(if (symbolp icon)
|
(icon (doom-modeline-icon-for-mode major-mode :height height)))
|
||||||
(setq icon (doom-modeline-icon-for-file (buffer-name) :height height)))
|
(if (symbolp icon)
|
||||||
(unless (symbolp icon)
|
(setq icon (doom-modeline-icon-for-file (buffer-name) :height height)))
|
||||||
(propertize icon
|
(unless (symbolp icon)
|
||||||
'help-echo (format "Major-mode: %s" mode-name)
|
(propertize icon
|
||||||
'display '(raise -0.125))))))
|
'help-echo (format "Major-mode: %s" mode-name)
|
||||||
|
'display '(raise -0.125)))))))
|
||||||
(add-hook 'find-file-hook #'doom-modeline-update-buffer-file-icon)
|
(add-hook 'find-file-hook #'doom-modeline-update-buffer-file-icon)
|
||||||
(add-hook 'after-change-major-mode-hook #'doom-modeline-update-buffer-file-icon)
|
(add-hook 'after-change-major-mode-hook #'doom-modeline-update-buffer-file-icon)
|
||||||
(add-hook 'clone-indirect-buffer-hook #'doom-modeline-update-buffer-file-icon)
|
(add-hook 'clone-indirect-buffer-hook #'doom-modeline-update-buffer-file-icon)
|
||||||
|
|
||||||
(defun doom-modeline-buffer-file-state-icon (icon &optional face height voffset)
|
(when (>= emacs-major-version 26)
|
||||||
|
(add-variable-watcher
|
||||||
|
'all-the-icons-scale-factor
|
||||||
|
(lambda (_sym val op _where)
|
||||||
|
(when (eq op 'set)
|
||||||
|
(setq all-the-icons-scale-factor val)
|
||||||
|
(doom-modeline-update-buffer-file-icon)))))
|
||||||
|
|
||||||
|
(defun doom-modeline-buffer-file-state-icon (icon &optional text face height voffset)
|
||||||
"Displays an ICON with FACE, HEIGHT and VOFFSET.
|
"Displays an ICON with FACE, HEIGHT and VOFFSET.
|
||||||
|
TEXT is the alternative if it is not applicable.
|
||||||
Uses `all-the-icons-material' to fetch the icon."
|
Uses `all-the-icons-material' to fetch the icon."
|
||||||
(when icon
|
(if doom-modeline-icon
|
||||||
(doom-modeline-icon-material
|
(when icon
|
||||||
icon
|
(doom-modeline-icon-material
|
||||||
:face (if (doom-modeline--active) face)
|
icon
|
||||||
:height (or height 1.1)
|
:face (if (doom-modeline--active) face)
|
||||||
:v-adjust (or voffset -0.225))))
|
:height (or height 1.1)
|
||||||
|
:v-adjust (or voffset -0.225)))
|
||||||
|
(when text
|
||||||
|
(propertize text 'face face))))
|
||||||
|
|
||||||
(defvar-local doom-modeline--buffer-file-state-icon nil)
|
(defvar-local doom-modeline--buffer-file-state-icon nil)
|
||||||
(defun doom-modeline-update-buffer-file-state-icon (&rest _)
|
(defun doom-modeline-update-buffer-file-state-icon (&rest _)
|
||||||
|
@ -832,19 +845,23 @@ Uses `all-the-icons-material' to fetch the icon."
|
||||||
(cond (buffer-read-only
|
(cond (buffer-read-only
|
||||||
(doom-modeline-buffer-file-state-icon
|
(doom-modeline-buffer-file-state-icon
|
||||||
"lock"
|
"lock"
|
||||||
|
"%1+"
|
||||||
'doom-modeline-warning))
|
'doom-modeline-warning))
|
||||||
((buffer-modified-p)
|
((buffer-modified-p)
|
||||||
(doom-modeline-buffer-file-state-icon
|
(doom-modeline-buffer-file-state-icon
|
||||||
"save"
|
"save"
|
||||||
|
"%1*"
|
||||||
'doom-modeline-buffer-modified))
|
'doom-modeline-buffer-modified))
|
||||||
((and buffer-file-name
|
((and buffer-file-name
|
||||||
(not (file-exists-p buffer-file-name)))
|
(not (file-exists-p buffer-file-name)))
|
||||||
(doom-modeline-buffer-file-state-icon
|
(doom-modeline-buffer-file-state-icon
|
||||||
"do_not_disturb_alt"
|
"do_not_disturb_alt"
|
||||||
|
"!"
|
||||||
'doom-modeline-urgent))
|
'doom-modeline-urgent))
|
||||||
((buffer-narrowed-p)
|
((buffer-narrowed-p)
|
||||||
(doom-modeline-buffer-file-state-icon
|
(doom-modeline-buffer-file-state-icon
|
||||||
"vertical_align_center"
|
"vertical_align_center"
|
||||||
|
"><"
|
||||||
'doom-modeline-warning)))))
|
'doom-modeline-warning)))))
|
||||||
(add-hook 'find-file-hook #'doom-modeline-update-buffer-file-state-icon)
|
(add-hook 'find-file-hook #'doom-modeline-update-buffer-file-state-icon)
|
||||||
(add-hook 'after-revert-hook #'doom-modeline-update-buffer-file-state-icon)
|
(add-hook 'after-revert-hook #'doom-modeline-update-buffer-file-state-icon)
|
||||||
|
@ -867,12 +884,18 @@ Uses `all-the-icons-material' to fetch the icon."
|
||||||
(setq buffer-read-only val)
|
(setq buffer-read-only val)
|
||||||
(doom-modeline-update-buffer-file-state-icon))))
|
(doom-modeline-update-buffer-file-state-icon))))
|
||||||
|
|
||||||
|
(add-variable-watcher
|
||||||
|
'doom-modeline-icon
|
||||||
|
(lambda (_sym val op _where)
|
||||||
|
(when (eq op 'set)
|
||||||
|
(setq doom-modeline-icon val)
|
||||||
|
(doom-modeline-update-buffer-file-state-icon))))
|
||||||
|
|
||||||
(add-variable-watcher
|
(add-variable-watcher
|
||||||
'all-the-icons-scale-factor
|
'all-the-icons-scale-factor
|
||||||
(lambda (_sym val op _where)
|
(lambda (_sym val op _where)
|
||||||
(when (eq op 'set)
|
(when (eq op 'set)
|
||||||
(setq all-the-icons-scale-factor val)
|
(setq all-the-icons-scale-factor val)
|
||||||
(doom-modeline-update-buffer-file-icon)
|
|
||||||
(doom-modeline-update-buffer-file-state-icon)))))
|
(doom-modeline-update-buffer-file-state-icon)))))
|
||||||
|
|
||||||
(defvar-local doom-modeline--buffer-file-name nil)
|
(defvar-local doom-modeline--buffer-file-name nil)
|
||||||
|
@ -922,23 +945,25 @@ directory, the file name, and its state (modified, read-only or non-existent)."
|
||||||
doom-modeline-vspc)))
|
doom-modeline-vspc)))
|
||||||
|
|
||||||
;; state icon
|
;; state icon
|
||||||
(when doom-modeline-icon
|
(when-let ((icon (or doom-modeline--buffer-file-state-icon
|
||||||
(when-let ((icon (or doom-modeline--buffer-file-state-icon
|
(doom-modeline-update-buffer-file-state-icon))))
|
||||||
(doom-modeline-update-buffer-file-state-icon))))
|
(concat
|
||||||
(concat
|
(if active
|
||||||
(if active
|
icon
|
||||||
icon
|
(propertize icon
|
||||||
(propertize icon
|
'face
|
||||||
'face `(:height
|
(if doom-modeline-icon
|
||||||
,(doom-modeline-icon-height 1.3)
|
`(:height
|
||||||
:family
|
,(doom-modeline-icon-height 1.3)
|
||||||
,(all-the-icons-icon-family icon)
|
:family
|
||||||
:inherit)))
|
,(all-the-icons-icon-family icon)
|
||||||
doom-modeline-vspc)))
|
:inherit)
|
||||||
|
'mode-line-inactive)))
|
||||||
|
doom-modeline-vspc))
|
||||||
|
|
||||||
;; buffer file name
|
;; buffer file name
|
||||||
(let ((name (or doom-modeline--buffer-file-name
|
(when-let ((name (or doom-modeline--buffer-file-name
|
||||||
(doom-modeline-update-buffer-file-name))))
|
(doom-modeline-update-buffer-file-name))))
|
||||||
(if active
|
(if active
|
||||||
name
|
name
|
||||||
(propertize name 'face 'mode-line-inactive))))))
|
(propertize name 'face 'mode-line-inactive))))))
|
||||||
|
@ -1048,12 +1073,10 @@ mouse-1: Display minor modes menu"
|
||||||
TEXT is the alternative if it is not applicable.
|
TEXT is the alternative if it is not applicable.
|
||||||
Uses `all-the-icons-octicon' to fetch the icon."
|
Uses `all-the-icons-octicon' to fetch the icon."
|
||||||
(if doom-modeline-icon
|
(if doom-modeline-icon
|
||||||
(if icon
|
(when icon
|
||||||
(doom-modeline-icon-octicon icon :face face :v-adjust (or voffset -0.1))
|
(doom-modeline-icon-octicon icon :face face :v-adjust (or voffset -0.1)))
|
||||||
"")
|
(when text
|
||||||
(if text
|
(propertize text 'face face))))
|
||||||
(propertize text 'face face)
|
|
||||||
"")))
|
|
||||||
|
|
||||||
(defvar-local doom-modeline--vcs-icon nil)
|
(defvar-local doom-modeline--vcs-icon nil)
|
||||||
(defun doom-modeline--update-vcs-icon (&rest _)
|
(defun doom-modeline--update-vcs-icon (&rest _)
|
||||||
|
@ -1076,8 +1099,16 @@ Uses `all-the-icons-octicon' to fetch the icon."
|
||||||
(add-hook 'after-save-hook #'doom-modeline--update-vcs-icon)
|
(add-hook 'after-save-hook #'doom-modeline--update-vcs-icon)
|
||||||
(advice-add #'vc-refresh-state :after #'doom-modeline--update-vcs-icon)
|
(advice-add #'vc-refresh-state :after #'doom-modeline--update-vcs-icon)
|
||||||
|
|
||||||
|
(when (>= emacs-major-version 26)
|
||||||
|
(add-variable-watcher
|
||||||
|
'doom-modeline-icon
|
||||||
|
(lambda (_sym val op _where)
|
||||||
|
(when (eq op 'set)
|
||||||
|
(setq doom-modeline-icon val)
|
||||||
|
(doom-modeline--update-vcs-icon)))))
|
||||||
|
|
||||||
(defvar-local doom-modeline--vcs-text nil)
|
(defvar-local doom-modeline--vcs-text nil)
|
||||||
(defun doom-modeline--update-vcs-text (&rest _)
|
(defun doom-modeline-update-vcs-text (&rest _)
|
||||||
"Update text of vsc state in mode-line."
|
"Update text of vsc state in mode-line."
|
||||||
(setq doom-modeline--vcs-text
|
(setq doom-modeline--vcs-text
|
||||||
(when (and vc-mode buffer-file-name)
|
(when (and vc-mode buffer-file-name)
|
||||||
|
@ -1089,15 +1120,15 @@ Uses `all-the-icons-octicon' to fetch the icon."
|
||||||
((memq state '(removed conflict unregistered))
|
((memq state '(removed conflict unregistered))
|
||||||
'doom-modeline-urgent)
|
'doom-modeline-urgent)
|
||||||
(t 'doom-modeline-info)))))))
|
(t 'doom-modeline-info)))))))
|
||||||
(add-hook 'find-file-hook #'doom-modeline--update-vcs-text t)
|
(add-hook 'find-file-hook #'doom-modeline-update-vcs-text t)
|
||||||
(add-hook 'after-save-hook #'doom-modeline--update-vcs-text)
|
(add-hook 'after-save-hook #'doom-modeline-update-vcs-text)
|
||||||
(advice-add #'vc-refresh-state :after #'doom-modeline--update-vcs-text)
|
(advice-add #'vc-refresh-state :after #'doom-modeline-update-vcs-text)
|
||||||
|
|
||||||
(doom-modeline-def-segment vcs
|
(doom-modeline-def-segment vcs
|
||||||
"Displays the current branch, colored based on its state."
|
"Displays the current branch, colored based on its state."
|
||||||
(let ((active (doom-modeline--active)))
|
(let ((active (doom-modeline--active)))
|
||||||
(when-let ((icon (or doom-modeline--vcs-icon (doom-modeline--update-vcs-icon)))
|
(when-let ((icon (or doom-modeline--vcs-icon (doom-modeline--update-vcs-icon)))
|
||||||
(text (or doom-modeline--vcs-text (doom-modeline--update-vcs-text))))
|
(text (or doom-modeline--vcs-text (doom-modeline-update-vcs-text))))
|
||||||
(concat
|
(concat
|
||||||
" "
|
" "
|
||||||
(if active
|
(if active
|
||||||
|
@ -1128,118 +1159,128 @@ Uses `all-the-icons-octicon' to fetch the icon."
|
||||||
TEXT is the alternative if it is not applicable.
|
TEXT is the alternative if it is not applicable.
|
||||||
Uses `all-the-icons-material' to fetch the icon."
|
Uses `all-the-icons-material' to fetch the icon."
|
||||||
(if doom-modeline-icon
|
(if doom-modeline-icon
|
||||||
(if icon
|
(when icon
|
||||||
(doom-modeline-icon-material icon :face face :height 1.1 :v-adjust (or voffset -0.225))
|
(doom-modeline-icon-material icon :face face :height 1.1 :v-adjust (or voffset -0.225)))
|
||||||
"")
|
(when text
|
||||||
(if text
|
(propertize text 'face face))))
|
||||||
(propertize text 'face face)
|
|
||||||
"")))
|
|
||||||
|
|
||||||
(defun doom-modeline-checker-text (text &optional face)
|
(defun doom-modeline-checker-text (text &optional face)
|
||||||
"Displays TEXT with FACE."
|
"Displays TEXT with FACE."
|
||||||
(if text
|
(when text
|
||||||
(propertize text 'face face)
|
(propertize text 'face face)))
|
||||||
""))
|
|
||||||
|
|
||||||
(defvar-local doom-modeline--flycheck-icon nil)
|
(defvar-local doom-modeline--flycheck-icon nil)
|
||||||
(defun doom-modeline-update-flycheck-icon (&optional status)
|
(defun doom-modeline-update-flycheck-icon (&optional status)
|
||||||
"Update flycheck icon via STATUS."
|
"Update flycheck icon via STATUS."
|
||||||
(setq doom-modeline--flycheck-icon
|
(setq doom-modeline--flycheck-icon
|
||||||
(propertize
|
(when-let
|
||||||
(pcase status
|
((icon
|
||||||
(`finished (if flycheck-current-errors
|
(pcase status
|
||||||
(let-alist (flycheck-count-errors flycheck-current-errors)
|
(`finished (if flycheck-current-errors
|
||||||
(doom-modeline-checker-icon "do_not_disturb_alt" "!"
|
(let-alist (flycheck-count-errors flycheck-current-errors)
|
||||||
(cond (.error 'doom-modeline-urgent)
|
(doom-modeline-checker-icon "do_not_disturb_alt" "!"
|
||||||
(.warning 'doom-modeline-warning)
|
(cond (.error 'doom-modeline-urgent)
|
||||||
(t 'doom-modeline-info))))
|
(.warning 'doom-modeline-warning)
|
||||||
(doom-modeline-checker-icon "check" "*" 'doom-modeline-info)))
|
(t 'doom-modeline-info))))
|
||||||
(`running (doom-modeline-checker-icon "access_time" "*" 'font-lock-doc-face))
|
(doom-modeline-checker-icon "check" "-" 'doom-modeline-info)))
|
||||||
(`no-checker (doom-modeline-checker-icon "sim_card_alert" "?" 'font-lock-doc-face))
|
(`running (doom-modeline-checker-icon "access_time" "*" 'font-lock-doc-face))
|
||||||
(`errored (doom-modeline-checker-icon "sim_card_alert" "!" 'doom-modeline-urgent))
|
(`no-checker (doom-modeline-checker-icon "sim_card_alert" "?" 'font-lock-doc-face))
|
||||||
(`interrupted (doom-modeline-checker-icon "pause" "!" 'font-lock-doc-face))
|
(`errored (doom-modeline-checker-icon "sim_card_alert" "!" 'doom-modeline-urgent))
|
||||||
(`suspicious (doom-modeline-checker-icon "priority_high" "!" 'doom-modeline-urgent))
|
(`interrupted (doom-modeline-checker-icon "pause" "!" 'font-lock-doc-face))
|
||||||
(_ ""))
|
(`suspicious (doom-modeline-checker-icon "priority_high" "!" 'doom-modeline-urgent))
|
||||||
'help-echo (concat "Flycheck\n"
|
(_ nil))))
|
||||||
(pcase status
|
(propertize
|
||||||
('finished
|
icon
|
||||||
"mouse-1: Display minor mode menu
|
'help-echo (concat "Flycheck\n"
|
||||||
|
(pcase status
|
||||||
|
('finished "mouse-1: Display minor mode menu
|
||||||
mouse-2: Show help for minor mode")
|
mouse-2: Show help for minor mode")
|
||||||
('running "Running...")
|
('running "Running...")
|
||||||
('no-checker "No Checker")
|
('no-checker "No Checker")
|
||||||
('errored "Error")
|
('errored "Error")
|
||||||
('interrupted "Interrupted")
|
('interrupted "Interrupted")
|
||||||
('suspicious "Suspicious")))
|
('suspicious "Suspicious")))
|
||||||
'mouse-face '(:box 1)
|
'mouse-face '(:box 1)
|
||||||
'local-map (let ((map (make-sparse-keymap)))
|
'local-map (let ((map (make-sparse-keymap)))
|
||||||
(define-key map [mode-line down-mouse-1]
|
(define-key map [mode-line down-mouse-1]
|
||||||
flycheck-mode-menu-map)
|
flycheck-mode-menu-map)
|
||||||
(define-key map [mode-line mouse-2]
|
(define-key map [mode-line mouse-2]
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(interactive)
|
(interactive)
|
||||||
(describe-function 'flycheck-mode)))
|
(describe-function 'flycheck-mode)))
|
||||||
map))))
|
map)))))
|
||||||
(add-hook 'flycheck-status-changed-functions #'doom-modeline-update-flycheck-icon)
|
(add-hook 'flycheck-status-changed-functions #'doom-modeline-update-flycheck-icon)
|
||||||
(add-hook 'flycheck-mode-hook #'doom-modeline-update-flycheck-icon)
|
(add-hook 'flycheck-mode-hook #'doom-modeline-update-flycheck-icon)
|
||||||
|
|
||||||
|
(when (>= emacs-major-version 26)
|
||||||
|
(add-variable-watcher
|
||||||
|
'doom-modeline-icon
|
||||||
|
(lambda (_sym val op _where)
|
||||||
|
(when (eq op 'set)
|
||||||
|
(setq doom-modeline-icon val)
|
||||||
|
(when (bound-and-true-p flycheck-mode)
|
||||||
|
(flycheck-buffer))))))
|
||||||
|
|
||||||
(defvar-local doom-modeline--flycheck-text nil)
|
(defvar-local doom-modeline--flycheck-text nil)
|
||||||
(defun doom-modeline-update-flycheck-text (&optional status)
|
(defun doom-modeline-update-flycheck-text (&optional status)
|
||||||
"Update flycheck text via STATUS."
|
"Update flycheck text via STATUS."
|
||||||
(setq doom-modeline--flycheck-text
|
(setq doom-modeline--flycheck-text
|
||||||
(propertize
|
(when-let
|
||||||
(pcase status
|
((text
|
||||||
(`finished (if flycheck-current-errors
|
(pcase status
|
||||||
(let-alist (flycheck-count-errors flycheck-current-errors)
|
(`finished (when flycheck-current-errors
|
||||||
(let ((error (or .error 0))
|
(let-alist (flycheck-count-errors flycheck-current-errors)
|
||||||
(warning (or .warning 0))
|
(let ((error (or .error 0))
|
||||||
(info (or .info 0)))
|
(warning (or .warning 0))
|
||||||
(format "%s/%s/%s"
|
(info (or .info 0)))
|
||||||
(doom-modeline-checker-text (number-to-string error)
|
(format "%s/%s/%s"
|
||||||
'doom-modeline-urgent)
|
(doom-modeline-checker-text (number-to-string error)
|
||||||
(doom-modeline-checker-text (number-to-string warning)
|
'doom-modeline-urgent)
|
||||||
'doom-modeline-warning)
|
(doom-modeline-checker-text (number-to-string warning)
|
||||||
(doom-modeline-checker-text (number-to-string info)
|
'doom-modeline-warning)
|
||||||
'doom-modeline-info))))
|
(doom-modeline-checker-text (number-to-string info)
|
||||||
""))
|
'doom-modeline-info))))))
|
||||||
(`running "")
|
(`running nil)
|
||||||
(`no-checker (doom-modeline-checker-text "-" 'font-lock-doc-face))
|
(`no-checker (doom-modeline-checker-text "-" 'font-lock-doc-face))
|
||||||
(`errored (doom-modeline-checker-text "Error" 'doom-modeline-urgent))
|
(`errored (doom-modeline-checker-text "Error" 'doom-modeline-urgent))
|
||||||
(`interrupted (doom-modeline-checker-text "Interrupted" 'font-lock-doc-face))
|
(`interrupted (doom-modeline-checker-text "Interrupted" 'font-lock-doc-face))
|
||||||
(`suspicious (doom-modeline-checker-text "Suspicious" 'doom-modeline-urgent))
|
(`suspicious (doom-modeline-checker-text "Suspicious" 'doom-modeline-urgent))
|
||||||
(_ ""))
|
(_ nil))))
|
||||||
'help-echo (pcase status
|
(propertize
|
||||||
('finished
|
text
|
||||||
(concat
|
'help-echo (pcase status
|
||||||
(if flycheck-current-errors
|
('finished
|
||||||
(let-alist (flycheck-count-errors flycheck-current-errors)
|
(concat
|
||||||
(format "error: %d, warning: %d, info: %d\n" (or .error 0) (or .warning 0) (or .info 0))))
|
(if flycheck-current-errors
|
||||||
"mouse-1: Show all errors
|
(let-alist (flycheck-count-errors flycheck-current-errors)
|
||||||
|
(format "error: %d, warning: %d, info: %d\n" (or .error 0) (or .warning 0) (or .info 0))))
|
||||||
|
"mouse-1: Show all errors
|
||||||
mouse-3: Next error
|
mouse-3: Next error
|
||||||
wheel-up/wheel-down: Previous/next error"))
|
wheel-up/wheel-down: Previous/next error"))
|
||||||
('running "Running...")
|
('running "Running...")
|
||||||
('no-checker "No Checker")
|
('no-checker "No Checker")
|
||||||
('errored "Error")
|
('errored "Error")
|
||||||
('interrupted "Interrupted")
|
('interrupted "Interrupted")
|
||||||
('suspicious "Suspicious"))
|
('suspicious "Suspicious"))
|
||||||
'mouse-face 'mode-line-highlight
|
'mouse-face 'mode-line-highlight
|
||||||
'local-map (let ((map (make-sparse-keymap)))
|
'local-map (let ((map (make-sparse-keymap)))
|
||||||
(define-key map [mode-line mouse-1]
|
(define-key map [mode-line mouse-1]
|
||||||
#'flycheck-list-errors)
|
#'flycheck-list-errors)
|
||||||
(define-key map [mode-line mouse-3]
|
(define-key map [mode-line mouse-3]
|
||||||
#'flycheck-next-error)
|
#'flycheck-next-error)
|
||||||
(define-key map (vector 'mode-line
|
(define-key map (vector 'mode-line
|
||||||
mouse-wheel-down-event)
|
mouse-wheel-down-event)
|
||||||
(lambda (event)
|
(lambda (event)
|
||||||
(interactive "e")
|
(interactive "e")
|
||||||
(with-selected-window (posn-window (event-start event))
|
(with-selected-window (posn-window (event-start event))
|
||||||
(flycheck-previous-error 1))))
|
(flycheck-previous-error 1))))
|
||||||
(define-key map (vector 'mode-line
|
(define-key map (vector 'mode-line
|
||||||
mouse-wheel-up-event)
|
mouse-wheel-up-event)
|
||||||
(lambda (event)
|
(lambda (event)
|
||||||
(interactive "e")
|
(interactive "e")
|
||||||
(with-selected-window (posn-window (event-start event))
|
(with-selected-window (posn-window (event-start event))
|
||||||
(flycheck-next-error 1))))
|
(flycheck-next-error 1))))
|
||||||
map))))
|
map)))))
|
||||||
(add-hook 'flycheck-status-changed-functions #'doom-modeline-update-flycheck-text)
|
(add-hook 'flycheck-status-changed-functions #'doom-modeline-update-flycheck-text)
|
||||||
(add-hook 'flycheck-mode-hook #'doom-modeline-update-flycheck-text)
|
(add-hook 'flycheck-mode-hook #'doom-modeline-update-flycheck-text)
|
||||||
|
|
||||||
|
@ -1264,40 +1305,52 @@ wheel-up/wheel-down: Previous/next error"))
|
||||||
diags-by-type)))
|
diags-by-type)))
|
||||||
(flymake--backend-state-diags state)))
|
(flymake--backend-state-diags state)))
|
||||||
flymake--backend-state)
|
flymake--backend-state)
|
||||||
(propertize
|
(when-let
|
||||||
(cond
|
((icon
|
||||||
(some-waiting (doom-modeline-checker-icon "access_time" "*" 'font-lock-doc-face))
|
(cond
|
||||||
((null known) (doom-modeline-checker-icon "sim_card_alert" "?" 'font-lock-doc-face))
|
(some-waiting (doom-modeline-checker-icon "access_time" "*" 'font-lock-doc-face))
|
||||||
(all-disabled (doom-modeline-checker-icon "sim_card_alert" "!" 'doom-modeline-urgent))
|
((null known) (doom-modeline-checker-icon "sim_card_alert" "?" 'font-lock-doc-face))
|
||||||
(t (let ((.error (length (gethash :error diags-by-type)))
|
(all-disabled (doom-modeline-checker-icon "sim_card_alert" "!" 'doom-modeline-urgent))
|
||||||
(.warning (length (gethash :warning diags-by-type)))
|
(t (let ((.error (length (gethash :error diags-by-type)))
|
||||||
(.note (length (gethash :note diags-by-type))))
|
(.warning (length (gethash :warning diags-by-type)))
|
||||||
(if (> (+ .error .warning .note) 0)
|
(.note (length (gethash :note diags-by-type))))
|
||||||
(doom-modeline-checker-icon "do_not_disturb_alt" "!"
|
(if (> (+ .error .warning .note) 0)
|
||||||
(cond ((> .error 0) 'doom-modeline-urgent)
|
(doom-modeline-checker-icon "do_not_disturb_alt" "!"
|
||||||
((> .warning 0) 'doom-modeline-warning)
|
(cond ((> .error 0) 'doom-modeline-urgent)
|
||||||
(t 'doom-modeline-info)))
|
((> .warning 0) 'doom-modeline-warning)
|
||||||
(doom-modeline-checker-icon "check" "*" 'doom-modeline-info)))))
|
(t 'doom-modeline-info)))
|
||||||
'help-echo (concat "Flymake\n"
|
(doom-modeline-checker-icon "check" "-" 'doom-modeline-info)))))))
|
||||||
(cond
|
(propertize
|
||||||
(some-waiting "Running...")
|
icon
|
||||||
((null known) "No Checker")
|
'help-echo (concat "Flymake\n"
|
||||||
(all-disabled "All Checkers Disabled")
|
(cond
|
||||||
(t (format "%d/%d backends running
|
(some-waiting "Running...")
|
||||||
|
((null known) "No Checker")
|
||||||
|
(all-disabled "All Checkers Disabled")
|
||||||
|
(t (format "%d/%d backends running
|
||||||
mouse-1: Display minor mode menu
|
mouse-1: Display minor mode menu
|
||||||
mouse-2: Show help for minor mode"
|
mouse-2: Show help for minor mode"
|
||||||
(length running) (length known)))))
|
(length running) (length known)))))
|
||||||
'mouse-face '(:box 1)
|
'mouse-face '(:box 1)
|
||||||
'local-map (let ((map (make-sparse-keymap)))
|
'local-map (let ((map (make-sparse-keymap)))
|
||||||
(define-key map [mode-line down-mouse-1]
|
(define-key map [mode-line down-mouse-1]
|
||||||
flymake-menu)
|
flymake-menu)
|
||||||
(define-key map [mode-line mouse-2]
|
(define-key map [mode-line mouse-2]
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(interactive)
|
(interactive)
|
||||||
(describe-function 'flymake-mode)))
|
(describe-function 'flymake-mode)))
|
||||||
map)))))
|
map))))))
|
||||||
(advice-add #'flymake--handle-report :after #'doom-modeline-update-flymake-icon)
|
(advice-add #'flymake--handle-report :after #'doom-modeline-update-flymake-icon)
|
||||||
|
|
||||||
|
(when (>= emacs-major-version 26)
|
||||||
|
(add-variable-watcher
|
||||||
|
'doom-modeline-icon
|
||||||
|
(lambda (_sym val op _where)
|
||||||
|
(when (eq op 'set)
|
||||||
|
(setq doom-modeline-icon val)
|
||||||
|
(when (bound-and-true-p flymake-mode)
|
||||||
|
(flymake-start))))))
|
||||||
|
|
||||||
(defvar-local doom-modeline--flymake-text nil)
|
(defvar-local doom-modeline--flymake-text nil)
|
||||||
(defun doom-modeline-update-flymake-text (&rest _)
|
(defun doom-modeline-update-flymake-text (&rest _)
|
||||||
"Update flymake text."
|
"Update flymake text."
|
||||||
|
@ -1320,45 +1373,47 @@ mouse-2: Show help for minor mode"
|
||||||
(let ((.error (length (gethash :error diags-by-type)))
|
(let ((.error (length (gethash :error diags-by-type)))
|
||||||
(.warning (length (gethash :warning diags-by-type)))
|
(.warning (length (gethash :warning diags-by-type)))
|
||||||
(.note (length (gethash :note diags-by-type))))
|
(.note (length (gethash :note diags-by-type))))
|
||||||
(propertize
|
(when-let
|
||||||
(cond
|
((text
|
||||||
(some-waiting "Running..." "")
|
(cond
|
||||||
((null known) (doom-modeline-checker-text "-" 'font-lock-doc-face))
|
(some-waiting "Running..." "")
|
||||||
(all-disabled (doom-modeline-checker-text "-" 'doom-modeline-urgent))
|
((null known) (doom-modeline-checker-text "-" 'font-lock-doc-face))
|
||||||
(t (if (> (+ .error .warning .note) 0)
|
(all-disabled (doom-modeline-checker-text "-" 'doom-modeline-urgent))
|
||||||
(format "%s/%s/%s"
|
(t (when (> (+ .error .warning .note) 0)
|
||||||
(doom-modeline-checker-text (number-to-string .error)
|
(format "%s/%s/%s"
|
||||||
'doom-modeline-urgent)
|
(doom-modeline-checker-text (number-to-string .error)
|
||||||
(doom-modeline-checker-text (number-to-string .warning)
|
'doom-modeline-urgent)
|
||||||
'doom-modeline-warning)
|
(doom-modeline-checker-text (number-to-string .warning)
|
||||||
(doom-modeline-checker-text (number-to-string .note)
|
'doom-modeline-warning)
|
||||||
'doom-modeline-info))
|
(doom-modeline-checker-text (number-to-string .note)
|
||||||
"")))
|
'doom-modeline-info)))))))
|
||||||
'help-echo (cond
|
(propertize
|
||||||
(some-waiting "Running...")
|
text
|
||||||
((null known) "No Checker")
|
'help-echo (cond
|
||||||
(all-disabled "All Checkers Disabled")
|
(some-waiting "Running...")
|
||||||
(t (format "error: %d, warning: %d, note: %d
|
((null known) "No Checker")
|
||||||
|
(all-disabled "All Checkers Disabled")
|
||||||
|
(t (format "error: %d, warning: %d, note: %d
|
||||||
mouse-1: List all problems
|
mouse-1: List all problems
|
||||||
wheel-up/wheel-down: Previous/next problem"
|
wheel-up/wheel-down: Previous/next problem"
|
||||||
.error .warning .note)))
|
.error .warning .note)))
|
||||||
'mouse-face 'mode-line-highlight
|
'mouse-face 'mode-line-highlight
|
||||||
'local-map (let ((map (make-sparse-keymap)))
|
'local-map (let ((map (make-sparse-keymap)))
|
||||||
(define-key map [mode-line mouse-1]
|
(define-key map [mode-line mouse-1]
|
||||||
#'flymake-show-diagnostics-buffer)
|
#'flymake-show-diagnostics-buffer)
|
||||||
(define-key map (vector 'mode-line
|
(define-key map (vector 'mode-line
|
||||||
mouse-wheel-down-event)
|
mouse-wheel-down-event)
|
||||||
(lambda (event)
|
(lambda (event)
|
||||||
(interactive "e")
|
(interactive "e")
|
||||||
(with-selected-window (posn-window (event-start event))
|
(with-selected-window (posn-window (event-start event))
|
||||||
(flymake-goto-prev-error 1 nil t))))
|
(flymake-goto-prev-error 1 nil t))))
|
||||||
(define-key map (vector 'mode-line
|
(define-key map (vector 'mode-line
|
||||||
mouse-wheel-up-event)
|
mouse-wheel-up-event)
|
||||||
(lambda (event)
|
(lambda (event)
|
||||||
(interactive "e")
|
(interactive "e")
|
||||||
(with-selected-window (posn-window (event-start event))
|
(with-selected-window (posn-window (event-start event))
|
||||||
(flymake-goto-next-error 1 nil t))))
|
(flymake-goto-next-error 1 nil t))))
|
||||||
map))))))
|
map)))))))
|
||||||
(advice-add #'flymake--handle-report :after #'doom-modeline-update-flymake-text)
|
(advice-add #'flymake--handle-report :after #'doom-modeline-update-flymake-text)
|
||||||
|
|
||||||
(doom-modeline-def-segment checker
|
(doom-modeline-def-segment checker
|
||||||
|
@ -1370,24 +1425,28 @@ icons."
|
||||||
`(,doom-modeline--flymake-icon . ,doom-modeline--flymake-text))
|
`(,doom-modeline--flymake-icon . ,doom-modeline--flymake-text))
|
||||||
((bound-and-true-p flycheck-mode)
|
((bound-and-true-p flycheck-mode)
|
||||||
`(,doom-modeline--flycheck-icon . ,doom-modeline--flycheck-text)))))
|
`(,doom-modeline--flycheck-icon . ,doom-modeline--flycheck-text)))))
|
||||||
(when-let ((icon (car seg))
|
(let ((icon (car seg))
|
||||||
(text (cdr seg)))
|
(text (cdr seg)))
|
||||||
(concat
|
(concat
|
||||||
(if vc-mode " " " ")
|
(if vc-mode " " " ")
|
||||||
(if active
|
(if active
|
||||||
(concat icon doom-modeline-vspc text)
|
(concat icon
|
||||||
|
(when (and icon text) doom-modeline-vspc)
|
||||||
|
text)
|
||||||
(concat
|
(concat
|
||||||
(propertize icon
|
(when icon
|
||||||
'face
|
(propertize icon
|
||||||
(if doom-modeline-icon
|
'face
|
||||||
`(:height
|
(if doom-modeline-icon
|
||||||
,(doom-modeline-icon-height 1.3)
|
`(:height
|
||||||
:family
|
,(doom-modeline-icon-height 1.3)
|
||||||
,(all-the-icons-icon-family icon)
|
:family
|
||||||
:inherit)
|
,(all-the-icons-icon-family icon)
|
||||||
'mode-line-inactive))
|
:inherit)
|
||||||
doom-modeline-vspc
|
'mode-line-inactive)))
|
||||||
(propertize text 'face 'mode-line-inactive)))
|
(when (and icon text) doom-modeline-vspc)
|
||||||
|
(when text
|
||||||
|
(propertize text 'face 'mode-line-inactive))))
|
||||||
" "))))
|
" "))))
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue