From 28ec16e6180d2f523dd8f3f9916b3e8e8e7c7102 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Sun, 8 Mar 2020 23:58:01 +0000 Subject: feat(tools/emacs): Add a function to graph unread emails per label This uses the built-in chart.el library to create a quick graph of the number of unread emails in each notmuch tag. Some generic tags are excluded from the overview. --- tools/emacs/config/functions.el | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'tools') diff --git a/tools/emacs/config/functions.el b/tools/emacs/config/functions.el index 1bec8ecd98a7..6060df0a23b4 100644 --- a/tools/emacs/config/functions.el +++ b/tools/emacs/config/functions.el @@ -1,3 +1,6 @@ +(require 'chart) +(require 'dash) + (defun load-file-if-exists (filename) (if (file-exists-p filename) (load filename))) @@ -265,4 +268,25 @@ (interactive) (shell-command "scrot '$a_%s.png' -s -e 'mv $f ~/screenshots/'")) +(defun graph-unread-mails () + "Create a bar chart of unread mails based on notmuch tags. + Certain tags are excluded from the overview." + + (interactive) + (let ((tag-counts + (-keep (-lambda ((name . search)) + (let ((count + (string-to-number + (s-trim + (notmuch-command-to-string "count" search "and" "tag:unread"))))) + (when (>= count 1) (cons name count)))) + (notmuch-hello-generate-tag-alist '("unread" "signed" "attachment"))))) + + (chart-bar-quickie + (if (< (length tag-counts) 6) + 'vertical 'horizontal) + "Unread emails" + (-map #'car tag-counts) "Tag:" + (-map #'cdr tag-counts) "Count:"))) + (provide 'functions) -- cgit 1.4.1