From 37eef920ec087f395b5859ea5ac3996471d1c91d Mon Sep 17 00:00:00 2001 From: Vincent Zhang Date: Mon, 18 Feb 2019 01:30:59 +0800 Subject: [PATCH] New customization: doom-modeline-checker-simple-format. If non-nil, only display one number for checker information if applicable. --- README.md | 3 +++ doom-modeline-core.el | 3 +++ doom-modeline-segments.el | 38 ++++++++++++++++++++++++-------------- 3 files changed, 30 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index e6f0d64..8dabf48 100644 --- a/README.md +++ b/README.md @@ -163,6 +163,9 @@ Strongly recommend to use ;; If non-nil, a word count will be added to the selection-info modeline segment. (setq doom-modeline-enable-word-count nil) +;; If non-nil, only display one number for checker information if applicable. +(setq doom-modeline-checker-simple-format t) + ;; Whether display perspective name or not. Non-nil to display in mode-line. (setq doom-modeline-persp-name t) diff --git a/doom-modeline-core.el b/doom-modeline-core.el index f272fcd..8712984 100644 --- a/doom-modeline-core.el +++ b/doom-modeline-core.el @@ -107,6 +107,9 @@ The icons may not be showed correctly in terminal and on Windows.") (defvar doom-modeline-enable-word-count nil "If non-nil, a word count will be added to the selection-info modeline segment.") +(defvar doom-modeline-checker-simple-format t + "If non-nil, only display one number for checker information if applicable.") + (defvar doom-modeline-persp-name t "Whether display perspective name or not. Non-nil to display in mode-line.") diff --git a/doom-modeline-segments.el b/doom-modeline-segments.el index 8b0fa42..4b50f35 100644 --- a/doom-modeline-segments.el +++ b/doom-modeline-segments.el @@ -615,13 +615,18 @@ mouse-2: Show help for minor mode") (let ((error (or .error 0)) (warning (or .warning 0)) (info (or .info 0))) - (format "%s/%s/%s" - (doom-modeline-checker-text (number-to-string error) - 'doom-modeline-urgent) - (doom-modeline-checker-text (number-to-string warning) - 'doom-modeline-warning) - (doom-modeline-checker-text (number-to-string info) - 'doom-modeline-info)))))) + (if doom-modeline-checker-simple-format + (doom-modeline-checker-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-urgent) + (doom-modeline-checker-text (number-to-string warning) + 'doom-modeline-warning) + (doom-modeline-checker-text (number-to-string info) + 'doom-modeline-info))))))) (`running nil) (`no-checker (doom-modeline-checker-text "-" 'font-lock-doc-face)) (`errored (doom-modeline-checker-text "Error" 'doom-modeline-urgent)) @@ -762,13 +767,18 @@ mouse-2: Show help for minor mode" ((null known) (doom-modeline-checker-text "-" 'font-lock-doc-face)) (all-disabled (doom-modeline-checker-text "-" 'doom-modeline-urgent)) (t (when (> (+ .error .warning .note) 0) - (format "%s/%s/%s" - (doom-modeline-checker-text (number-to-string .error) - 'doom-modeline-urgent) - (doom-modeline-checker-text (number-to-string .warning) - 'doom-modeline-warning) - (doom-modeline-checker-text (number-to-string .note) - 'doom-modeline-info))))))) + (if doom-modeline-checker-simple-format + (doom-modeline-checker-text (number-to-string (+ .error .warning .note)) + (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-urgent) + (doom-modeline-checker-text (number-to-string .warning) + 'doom-modeline-warning) + (doom-modeline-checker-text (number-to-string .note) + 'doom-modeline-info)))))))) (propertize text 'help-echo (cond