about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2020-04-01T21·28+0100
committerVincent Ambo <tazjin@google.com>2020-04-01T21·28+0100
commit5aaeaa406a5d84b9408746988beb6a5d682d797f (patch)
tree1c03aa54e9bc1b26e2a7efebe6981dd9cb385d41
parentdb74ffb4b1667a42ac09603d81dc81401f7b85fd (diff)
feat(tools/emacs): Implement 'notmuch-show-open-or-close-subthread' r/607
Does what it says on the tin.
-rw-r--r--tools/emacs/config/functions.el13
1 files changed, 13 insertions, 0 deletions
diff --git a/tools/emacs/config/functions.el b/tools/emacs/config/functions.el
index 72e29ae1a856..47d25f2ad555 100644
--- a/tools/emacs/config/functions.el
+++ b/tools/emacs/config/functions.el
@@ -289,4 +289,17 @@
      (-map #'car tag-counts) "Tag:"
      (-map #'cdr tag-counts) "Count:")))
 
+(defun notmuch-show-open-or-close-subthread ()
+  "Open or close the subthread from (and including) the message
+  at point. Opens by default, closes if the prefix argument is
+  set."
+  (interactive)
+  (save-excursion
+    (let ((current-depth (map-elt (notmuch-show-get-message-properties) :depth 0)))
+      (loop do (notmuch-show-message-visible (notmuch-show-get-message-properties)
+                                             (not current-prefix-arg))
+            until (or (not (notmuch-show-goto-message-next))
+                      (= (map-elt (notmuch-show-get-message-properties) :depth 0) current-depth)))))
+  (force-window-update))
+
 (provide 'functions)