about summary refs log tree commit diff
path: root/tools/emacs/config
diff options
context:
space:
mode:
Diffstat (limited to 'tools/emacs/config')
-rw-r--r--tools/emacs/config/functions.el24
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)