From 84cc57c947cda2d20e3f94a6a0067dafd6438ef8 Mon Sep 17 00:00:00 2001 From: Siavash Askari Nasr Date: Sun, 22 Jan 2023 15:01:46 +0330 Subject: [PATCH 1/3] Add support for flymake errors --- file-info.el | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/file-info.el b/file-info.el index 3000f02..6b3fb1e 100644 --- a/file-info.el +++ b/file-info.el @@ -105,7 +105,7 @@ (:handler (file-info--get-headline "Analytics") :face font-lock-comment-face) (:name "Line count" :handler (number-to-string (count-lines (point-min) (point-max))) :face font-lock-number-face :bind "l") (:name "Words count" :handler (number-to-string (count-words (point-min) (point-max))) :face font-lock-number-face :bind "w") - (:name "Errors/info count" :handler (file-info--get-flycheck-errors-count) :bind "e")) + (:name "Errors/info count" :handler (file-info--get-errors-count) :bind "e")) "List of handlers for file info." :group 'file-info :type 'list) @@ -200,14 +200,31 @@ (when (and grand-total (gethash "human_readable_total" grand-total)) (gethash "human_readable_total" grand-total)))))))))) +(defun file-info--get-errors-count () + "Return count of flymake/flycheck errors." + (cond + ((bound-and-true-p flymake-mode) + (file-info--get-flymake-errors-count)) + ((fboundp 'flycheck-count-errors) + (file-info--get-flymake-errors-count)) + (t nil))) + (defun file-info--get-flycheck-errors-count () "Return count of flycheck errors." - (when (fboundp 'flycheck-count-errors) - (let ((flycheck-info (flycheck-count-errors flycheck-current-errors))) - (concat - (propertize (number-to-string (or (cdr (assq 'error flycheck-info)) 0)) 'face 'flycheck-fringe-error) - "/" - (propertize (number-to-string (or (cdr (assq 'warning flycheck-info)) 0)) 'face 'flycheck-error-list-warning))))) + (let ((flycheck-info (flycheck-count-errors flycheck-current-errors))) + (concat + (propertize (number-to-string (or (cdr (assq 'error flycheck-info)) 0)) 'face 'flycheck-fringe-error) + "/" + (propertize (number-to-string (or (cdr (assq 'warning flycheck-info)) 0)) 'face 'flycheck-error-list-warning)))) + +(defun file-info--get-flymake-errors-count () + "Return count of flymake errors." + (let ((flymake-error-counter (flymake--mode-line-counter :error t)) + (flymake-warning-counter (flymake--mode-line-counter :warning t))) + (concat + (propertize (nth 1 (cadr flymake-error-counter)) 'face 'error) + "/" + (propertize (nth 1 (cadr flymake-warning-counter)) 'face 'warning)))) (defun file-info--get-project-name () "Return project name." From 4006db24d43ec8dd5c499dece48649a14d758e32 Mon Sep 17 00:00:00 2001 From: Siavash Askari Nasr Date: Sun, 22 Jan 2023 15:45:50 +0330 Subject: [PATCH 2/3] Fix flycheck name in function --- file-info.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/file-info.el b/file-info.el index 6b3fb1e..f22bfec 100644 --- a/file-info.el +++ b/file-info.el @@ -206,7 +206,7 @@ ((bound-and-true-p flymake-mode) (file-info--get-flymake-errors-count)) ((fboundp 'flycheck-count-errors) - (file-info--get-flymake-errors-count)) + (file-info--get-flycheck-errors-count)) (t nil))) (defun file-info--get-flycheck-errors-count () From 2e777de8fc5edede7687dea8f5dc59b27efc4ef1 Mon Sep 17 00:00:00 2001 From: Siavash Askari Nasr Date: Mon, 23 Jan 2023 11:17:45 +0330 Subject: [PATCH 3/3] Use error and warning faces for flycheck as well --- file-info.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/file-info.el b/file-info.el index f22bfec..2af40e8 100644 --- a/file-info.el +++ b/file-info.el @@ -213,9 +213,9 @@ "Return count of flycheck errors." (let ((flycheck-info (flycheck-count-errors flycheck-current-errors))) (concat - (propertize (number-to-string (or (cdr (assq 'error flycheck-info)) 0)) 'face 'flycheck-fringe-error) + (propertize (number-to-string (or (cdr (assq 'error flycheck-info)) 0)) 'face 'error) "/" - (propertize (number-to-string (or (cdr (assq 'warning flycheck-info)) 0)) 'face 'flycheck-error-list-warning)))) + (propertize (number-to-string (or (cdr (assq 'warning flycheck-info)) 0)) 'face 'warning)))) (defun file-info--get-flymake-errors-count () "Return count of flymake errors."