diff options
author | Vincent Ambo <tazjin@google.com> | 2020-03-08T23·58+0000 |
---|---|---|
committer | Vincent Ambo <tazjin@google.com> | 2020-03-08T23·58+0000 |
commit | 28ec16e6180d2f523dd8f3f9916b3e8e8e7c7102 (patch) | |
tree | f2dc74cea7eead09f26764d77d90881f491443cd /tools | |
parent | 65e533431acd89473c58386b4e30013fab835a16 (diff) |
feat(tools/emacs): Add a function to graph unread emails per label r/594
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.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/emacs/config/functions.el | 24 |
1 files changed, 24 insertions, 0 deletions
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) |