Skip to content

Commit

Permalink
refactor: checker -> check and bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangou committed Feb 20, 2024
1 parent 9816e6a commit 62890ef
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 48 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,8 @@ Run `M-x customize-group RET doom-modeline RET` or set the variables.
;; Whether display the total line number。
(setq doom-modeline-total-line-number nil)
;; If non-nil, only display one number for checker information if applicable.
(setq doom-modeline-checker-simple-format t)
;; If non-nil, only display one number for check information if applicable.
(setq doom-modeline-check-simple-format t)
;; The maximum number displayed for notifications.
(setq doom-modeline-number-limit 99)
Expand Down
21 changes: 13 additions & 8 deletions doom-modeline-core.el
Original file line number Diff line number Diff line change
Expand Up @@ -445,11 +445,16 @@ in the given order."
:type '(alist :key-type symbol :value-type sexp)
:group 'doom-modeline)

(defcustom doom-modeline-checker-simple-format t
"If non-nil, only display one number for checker information if applicable."
(defcustom doom-modeline-check-simple-format t
"If non-nil, only display one number for check information if applicable."
:type 'boolean
:group 'doom-modeline)

(define-obsolete-variable-alias
'doom-modeline-checker-simple-format
'doom-modeline-check-simple-format
"4.2.0")

(defcustom doom-modeline-number-limit 99
"The maximum number displayed for notifications."
:type 'integer
Expand Down Expand Up @@ -725,22 +730,22 @@ This applies to `anzu', `evil-substitute', `iedit' etc."

(defface doom-modeline-debug
'((t (:inherit (doom-modeline font-lock-doc-face) :slant normal)))
"Face for debug-level messages in the mode-line. Used by vcs, checker, etc."
"Face for debug-level messages in the mode-line. Used by vcs, check, etc."
:group 'doom-modeline-faces)

(defface doom-modeline-info
'((t (:inherit (doom-modeline success))))
"Face for info-level messages in the mode-line. Used by vcs, checker, etc."
"Face for info-level messages in the mode-line. Used by vcs, check, etc."
:group 'doom-modeline-faces)

(defface doom-modeline-warning
'((t (:inherit (doom-modeline warning))))
"Face for warnings in the mode-line. Used by vcs, checker, etc."
"Face for warnings in the mode-line. Used by vcs, check, etc."
:group 'doom-modeline-faces)

(defface doom-modeline-urgent
'((t (:inherit (doom-modeline error))))
"Face for errors in the mode-line. Used by vcs, checker, etc."
"Face for errors in the mode-line. Used by vcs, check, etc."
:group 'doom-modeline-faces)

(defface doom-modeline-notification
Expand Down Expand Up @@ -1012,8 +1017,8 @@ used as an advice to window creation functions."
(redisplay t))))
(advice-add #'fit-window-to-buffer :before #'doom-modeline-redisplay))

;; For `flychecker-color-mode-line'
(with-eval-after-load 'flychecker-color-mode-line
;; For `flycheck-color-mode-line'
(with-eval-after-load 'flycheck-color-mode-line
(defvar flycheck-color-mode-line-face-to-color)
(setq flycheck-color-mode-line-face-to-color 'doom-modeline))

Expand Down
70 changes: 35 additions & 35 deletions doom-modeline-segments.el
Original file line number Diff line number Diff line change
Expand Up @@ -737,18 +737,18 @@ Uses `nerd-icons-octicon' to fetch the icon."


;;
;; Checker
;; Check
;;

(defun doom-modeline-checker-icon (icon unicode text face)
"Displays the checker ICON with FACE.
(defun doom-modeline-check-icon (icon unicode text face)
"Displays the check ICON with FACE.
UNICODE and TEXT are fallbacks.
Uses `nerd-icons-mdicon' to fetch the icon."
(doom-modeline-icon 'mdicon icon unicode text :face face))

(defun doom-modeline-checker-text (text &optional face)
"Displays TEXT with FACE."
(defun doom-modeline-check-text (text &optional face)
"Displays the check TEXT with FACE."
(propertize text 'face (or face 'mode-line)))

;; Flycheck
Expand Down Expand Up @@ -779,17 +779,17 @@ level."
(pcase status
('finished (if flycheck-current-errors
(let-alist (doom-modeline--flycheck-count-errors)
(doom-modeline-checker-icon
(doom-modeline-check-icon
"nf-md-alert_circle_outline" "" "!"
(cond ((> .error 0) 'doom-modeline-urgent)
((> .warning 0) 'doom-modeline-warning)
(t 'doom-modeline-info))))
(doom-modeline-checker-icon "nf-md-check_circle_outline" "" "" 'doom-modeline-info)))
('running (doom-modeline-checker-icon "nf-md-timer_sand" "" "*" 'doom-modeline-debug))
('no-checker (doom-modeline-checker-icon "nf-md-alert_box_outline" "" "-" 'doom-modeline-debug))
('errored (doom-modeline-checker-icon "nf-md-alert_circle_outline" "" "!" 'doom-modeline-urgent))
('interrupted (doom-modeline-checker-icon "nf-md-pause_circle_outline" "" "." 'doom-modeline-debug))
('suspicious (doom-modeline-checker-icon "nf-md-information_outline" "" "?" 'doom-modeline-debug))
(doom-modeline-check-icon "nf-md-check_circle_outline" "" "" 'doom-modeline-info)))
('running (doom-modeline-check-icon "nf-md-timer_sand" "" "*" 'doom-modeline-debug))
('no-checker (doom-modeline-check-icon "nf-md-alert_box_outline" "" "-" 'doom-modeline-debug))
('errored (doom-modeline-check-icon "nf-md-alert_circle_outline" "" "!" 'doom-modeline-urgent))
('interrupted (doom-modeline-check-icon "nf-md-pause_circle_outline" "" "." 'doom-modeline-debug))
('suspicious (doom-modeline-check-icon "nf-md-information_outline" "" "?" 'doom-modeline-debug))
(_ nil))))
(propertize icon
'help-echo (concat "Flycheck\n"
Expand Down Expand Up @@ -842,25 +842,25 @@ mouse-2: Show help for minor mode")
(pcase status
('finished (when flycheck-current-errors
(let-alist (doom-modeline--flycheck-count-errors)
(if doom-modeline-checker-simple-format
(doom-modeline-checker-text
(if doom-modeline-check-simple-format
(doom-modeline-check-text
(number-to-string (+ .error .warning .info))
(cond ((> .error 0) 'doom-modeline-urgent)
((> .warning 0) 'doom-modeline-warning)
(t 'doom-modeline-info)))
(format "%s/%s/%s"
(doom-modeline-checker-text (number-to-string .error)
(doom-modeline-check-text (number-to-string .error)
'doom-modeline-urgent)
(doom-modeline-checker-text (number-to-string .warning)
(doom-modeline-check-text (number-to-string .warning)
'doom-modeline-warning)
(doom-modeline-checker-text (number-to-string .info)
(doom-modeline-check-text (number-to-string .info)
'doom-modeline-info))))))
('running (and doom-modeline--flycheck-text
(propertize doom-modeline--flycheck-text 'face 'doom-modeline-debug)))
;; ('no-checker nil)
;; ('errored (doom-modeline-checker-text "Error" 'doom-modeline-urgent))
;; ('interrupted (doom-modeline-checker-text "Interrupted" 'doom-modeline-debug))
;; ('suspicious (doom-modeline-checker-text "Suspicious" 'doom-modeline-urgent))
;; ('errored (doom-modeline-check-text "Error" 'doom-modeline-urgent))
;; ('interrupted (doom-modeline-check-text "Interrupted" 'doom-modeline-debug))
;; ('suspicious (doom-modeline-check-text "Suspicious" 'doom-modeline-urgent))
(_ nil))))
(propertize
text
Expand Down Expand Up @@ -901,10 +901,10 @@ mouse-3: Next error"
(add-hook 'flycheck-mode-hook #'doom-modeline-update-flycheck-text)

(doom-modeline-add-variable-watcher
'doom-modeline-checker-simple-format
'doom-modeline-check-simple-format
(lambda (_sym val op _where)
(when (eq op 'set)
(setq doom-modeline-checker-simple-format val)
(setq doom-modeline-check-simple-format val)
(dolist (buf (buffer-list))
(with-current-buffer buf
(when (bound-and-true-p flycheck-mode)
Expand Down Expand Up @@ -934,9 +934,9 @@ mouse-3: Next error"
(when-let
((icon
(cond
(some-waiting (doom-modeline-checker-icon "nf-md-timer_sand" "" "*" 'doom-modeline-debug))
((null known) (doom-modeline-checker-icon "nf-md-alert_box_outline" "" "!" 'doom-modeline-urgent))
(all-disabled (doom-modeline-checker-icon "nf-md-alert_outline" "" "!" 'doom-modeline-warning))
(some-waiting (doom-modeline-check-icon "nf-md-timer_sand" "" "*" 'doom-modeline-debug))
((null known) (doom-modeline-check-icon "nf-md-alert_box_outline" "" "!" 'doom-modeline-urgent))
(all-disabled (doom-modeline-check-icon "nf-md-alert_outline" "" "!" 'doom-modeline-warning))
(t (let ((.error 0)
(.warning 0)
(.note 0))
Expand All @@ -954,11 +954,11 @@ mouse-3: Next error"
((> severity note-level) (cl-incf .warning))
(t (cl-incf .note))))))
(if (> (+ .error .warning .note) 0)
(doom-modeline-checker-icon "nf-md-alert_circle_outline" "" "!"
(doom-modeline-check-icon "nf-md-alert_circle_outline" "" "!"
(cond ((> .error 0) 'doom-modeline-urgent)
((> .warning 0) 'doom-modeline-warning)
(t 'doom-modeline-info)))
(doom-modeline-checker-icon "nf-md-check_circle_outline" "" "-" 'doom-modeline-info))))))))
(doom-modeline-check-icon "nf-md-check_circle_outline" "" "-" 'doom-modeline-info))))))))
(propertize
icon
'help-echo (concat "Flymake\n"
Expand Down Expand Up @@ -1035,17 +1035,17 @@ mouse-2: Show help for minor mode"
(all-disabled nil)
(t (let ((num (+ .error .warning .note)))
(when (> num 0)
(if doom-modeline-checker-simple-format
(doom-modeline-checker-text (number-to-string num)
(if doom-modeline-check-simple-format
(doom-modeline-check-text (number-to-string num)
(cond ((> .error 0) 'doom-modeline-urgent)
((> .warning 0) 'doom-modeline-warning)
(t 'doom-modeline-info)))
(format "%s/%s/%s"
(doom-modeline-checker-text (number-to-string .error)
(doom-modeline-check-text (number-to-string .error)
'doom-modeline-urgent)
(doom-modeline-checker-text (number-to-string .warning)
(doom-modeline-check-text (number-to-string .warning)
'doom-modeline-warning)
(doom-modeline-checker-text (number-to-string .note)
(doom-modeline-check-text (number-to-string .note)
'doom-modeline-info)))))))))
(propertize
text
Expand Down Expand Up @@ -1079,16 +1079,16 @@ mouse-1: List all problems%s"
(advice-add #'flymake--handle-report :after #'doom-modeline-update-flymake-text)

(doom-modeline-add-variable-watcher
'doom-modeline-checker-simple-format
'doom-modeline-check-simple-format
(lambda (_sym val op _where)
(when (eq op 'set)
(setq doom-modeline-checker-simple-format val)
(setq doom-modeline-check-simple-format val)
(dolist (buf (buffer-list))
(with-current-buffer buf
(when (bound-and-true-p flymake-mode)
(doom-modeline-update-flymake-text)))))))

(doom-modeline-def-segment checker
(doom-modeline-def-segment check
"Displays color-coded error status in the current buffer with pretty icons."
(let* ((seg (cond
((and (bound-and-true-p flymake-mode)
Expand Down
6 changes: 3 additions & 3 deletions doom-modeline.el
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

;; Author: Vincent Zhang <[email protected]>
;; Homepage: https://github.com/seagle0128/doom-modeline
;; Version: 4.1.0
;; Version: 4.2.0
;; Package-Requires: ((emacs "25.1") (compat "29.1.4.2") (nerd-icons "0.1.0") (shrink-path "0.3.1"))
;; Keywords: faces mode-line

Expand Down Expand Up @@ -89,7 +89,7 @@

(doom-modeline-def-modeline 'main
'(eldoc bar workspace-name window-number modals matches follow buffer-info remote-host buffer-position word-count parrot selection-info)
'(compilation objed-state misc-info persp-name battery grip irc mu4e gnus github debug repl lsp minor-modes input-method indent-info buffer-encoding major-mode process vcs checker time))
'(compilation objed-state misc-info persp-name battery grip irc mu4e gnus github debug repl lsp minor-modes input-method indent-info buffer-encoding major-mode process vcs check time))

(doom-modeline-def-modeline 'minimal
'(bar window-number modals matches buffer-info-simple)
Expand Down Expand Up @@ -133,7 +133,7 @@

(doom-modeline-def-modeline 'org-src
'(eldoc bar window-number modals matches buffer-info buffer-position word-count parrot selection-info)
'(compilation objed-state misc-info debug lsp minor-modes input-method indent-info buffer-encoding major-mode process checker time))
'(compilation objed-state misc-info debug lsp minor-modes input-method indent-info buffer-encoding major-mode process check time))

(doom-modeline-def-modeline 'helm
'(bar helm-buffer-id helm-number helm-follow helm-prefix-argument)
Expand Down

0 comments on commit 62890ef

Please sign in to comment.