From 30d882b9aa0542ec598e98cb30c1e50c9fd91393 Mon Sep 17 00:00:00 2001 From: Vincent Zhang Date: Wed, 2 Jan 2019 22:35:02 +0800 Subject: [PATCH] Optimize performance for flymake segment. --- doom-modeline.el | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/doom-modeline.el b/doom-modeline.el index 542c1ae..f3be149 100644 --- a/doom-modeline.el +++ b/doom-modeline.el @@ -1130,7 +1130,7 @@ icons." ;; (defvar-local doom-modeline--flymake nil) -(defun doom-modeline-update-flymake-segment () +(defun doom-modeline-update-flymake-segment (&rest _) "Update flymake segment via STATUS." (setq flymake--mode-line-format nil) ; remove the lighter of minor mode (setq doom-modeline--flymake @@ -1200,24 +1200,28 @@ wheel-up/wheel-down: Previous/Next warning or error" (with-selected-window (posn-window (event-start event)) (flymake-goto-next-error 1 '(:error :warning) t)))) map)))))) -;; (add-hook 'flymake-diagnostic-functions #'doom-modeline-update-flymake-segment) -;; (add-hook 'flymake-mode-hook #'doom-modeline-update-flymake-segment) +(add-hook 'flymake-mode-hook #'doom-modeline-update-flymake-segment) +(advice-add #'flymake--handle-report :after #'doom-modeline-update-flymake-segment) (doom-modeline-def-segment flymake "Displays color-coded flymake error status in the current buffer with pretty icons." (if (doom-modeline--active) - (doom-modeline-update-flymake-segment) + doom-modeline--flymake "")) +;; +;; checker: flymake/flycheck +;; + (doom-modeline-def-segment checker "Displays color-coded error status in the current buffer with pretty icons." (when (doom-modeline--active) (cond ((and (bound-and-true-p flymake-mode) (bound-and-true-p flymake--backend-state)) ; only support 26+ - (doom-modeline-update-flymake-segment)) + doom-modeline--flymake) ((bound-and-true-p flycheck-mode) doom-modeline--flycheck))))