about summary refs log tree commit diff
path: root/tools
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2020-04-02T00·35+0100
committerVincent Ambo <tazjin@google.com>2020-04-02T00·35+0100
commit40d13cc87f2e35cab5c5428f259153690cd58733 (patch)
treedce80f8a66a36418e570f92a17542863c5a4b31f /tools
parent5aaeaa406a5d84b9408746988beb6a5d682d797f (diff)
feat(tools/emacs): Bindings for (un)collapsing notmuch subthreads r/608
Modifies notmuch-show-open-or-close-subthread to take a parameter
instead of using prefix to toggle the argument, and binds that
function to C-, and C-. in notmuch-show-mode-map to enable convenient
collapsing/uncollapsing of subthreads from point.
Diffstat (limited to 'tools')
-rw-r--r--tools/emacs/config/bindings.el10
-rw-r--r--tools/emacs/config/functions.el12
2 files changed, 15 insertions, 7 deletions
diff --git a/tools/emacs/config/bindings.el b/tools/emacs/config/bindings.el
index e77af338951f..f66a6ab551c1 100644
--- a/tools/emacs/config/bindings.el
+++ b/tools/emacs/config/bindings.el
@@ -41,4 +41,14 @@
 ;; Insert TODO comments
 (global-set-key (kbd "C-c t") 'insert-todo-comment)
 
+;; Add subthread collapsing to notmuch-show.
+;;
+;; C-, closes a thread, C-. opens a thread. This mirrors stepping
+;; in/out of definitions.
+(define-key notmuch-show-mode-map (kbd "C-,") 'notmuch-show-open-or-close-subthread)
+(define-key notmuch-show-mode-map (kbd "C-.")
+  (lambda ()
+    (interactive)
+    (notmuch-show-open-or-close-subthread t))) ;; open
+
 (provide 'bindings)
diff --git a/tools/emacs/config/functions.el b/tools/emacs/config/functions.el
index 47d25f2ad555..feec2bb60c8d 100644
--- a/tools/emacs/config/functions.el
+++ b/tools/emacs/config/functions.el
@@ -1,5 +1,6 @@
 (require 'chart)
 (require 'dash)
+(require 'map)
 
 (defun load-file-if-exists (filename)
   (if (file-exists-p filename)
@@ -289,17 +290,14 @@
      (-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."
+(defun notmuch-show-open-or-close-subthread (&optional open)
+  "Open or close the subthread from (and including) the message at point."
   (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))
+      (loop do (notmuch-show-message-visible (notmuch-show-get-message-properties) open)
             until (or (not (notmuch-show-goto-message-next))
-                      (= (map-elt (notmuch-show-get-message-properties) :depth 0) current-depth)))))
+                      (= (map-elt (notmuch-show-get-message-properties)) current-depth)))))
   (force-window-update))
 
 (provide 'functions)