Skip to content

Commit

Permalink
Merge pull request #3 from CIAvash/add_flymake_info
Browse files Browse the repository at this point in the history
Add flymake info
  • Loading branch information
Artawower authored Jan 23, 2023
2 parents c67c475 + 2e777de commit 0adae16
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions file-info.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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-flycheck-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 'error)
"/"
(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."
(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."
Expand Down

0 comments on commit 0adae16

Please sign in to comment.