[WIP PATCH 4/4] emacs: search: add key binding for marking a thread

Mark Walters markwalters1009 at gmail.com
Tue Apr 22 13:11:50 PDT 2014


Add a function for toggling the mark on a thread, by default bound to
",".  Also make a marked thread clearly visible: this uses inverse
video as being a bit like selecting. Perhaps actually using the same
face (mainly backgorund colour) as a selection would make sense?
---
 emacs/notmuch.el |   15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index e1ece47..4976f0a 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -179,6 +179,7 @@ (defvar notmuch-search-mode-map
     (define-key map "+" 'notmuch-search-add-tag)
     (define-key map (kbd "RET") 'notmuch-search-show-thread)
     (define-key map "Z" 'notmuch-tree-from-search-current-query)
+    (define-key map "," 'notmuch-search-mark-thread)
     map)
   "Keymap for \"notmuch search\" buffers.")
 (fset 'notmuch-search-mode-map notmuch-search-mode-map)
@@ -604,6 +605,17 @@ (defun notmuch-search-archive-thread (&optional unarchive beg end thread-list)
      (notmuch-tag-change-list notmuch-archive-tags unarchive) beg end thread-list))
   (notmuch-search-next-thread))
 
+(defun notmuch-search-mark-thread ()
+  "Toggle the mark on the currently selected thread."
+  (interactive)
+  (let ((thread (notmuch-search-find-thread-id)))
+    (if (member thread notmuch-search-marked-threads)
+	(setq notmuch-search-marked-threads
+	      (delete thread notmuch-search-marked-threads))
+      (push (notmuch-search-find-thread-id) notmuch-search-marked-threads)))
+  (notmuch-search-update-result (notmuch-search-get-result))
+  (notmuch-search-next-thread))
+
 (defun notmuch-search-update-result (result &optional pos)
   "Replace the result object of the thread at POS (or point) by
 RESULT and redraw it.
@@ -806,6 +818,9 @@ (defun notmuch-search-show-result (result pos)
       (dolist (spec notmuch-search-result-format)
 	(notmuch-search-insert-field (car spec) (cdr spec) result))
       (insert "\n")
+      (when (member (concat "thread:" (plist-get result :thread))
+		    notmuch-search-marked-threads)
+	(notmuch-apply-face nil '(:inverse-video t) nil pos (point)))
       (notmuch-search-color-line pos (point) (plist-get result :tags))
       (put-text-property pos (point) 'notmuch-search-result result))))
 
-- 
1.7.10.4



More information about the notmuch mailing list