[PATCH 3/4] emacs: add ability to "delete" messages and threads

Jameson Graef Rollins jrollins at finestructure.net
Sat Jan 7 14:28:13 PST 2012


This completely mimics the behavior of archiving, but instead of
remove the inbox tag it add the "deleted" tag.  The functionality is
bound to the 'd' key in both search and show mode.

Note: this does *not* actually delete any messages.  That is still
left entirely up to the user to figure out how they want to handle
that.  This *just* adds the "deleted" tag to messages, no more.  If
the notmuch-search-exclude-deleted config variable is set, though,
"deleted" messages will be excluded from search results.
---
 emacs/notmuch-show.el |   15 +++++++++++++++
 emacs/notmuch.el      |   12 ++++++++++++
 2 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 1e16f05..e1d15f4 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -944,6 +944,7 @@ thread id.  If a prefix is given, crypto processing is toggled."
 	(define-key map "+" 'notmuch-show-add-tag)
 	(define-key map "x" 'notmuch-show-archive-thread-then-exit)
 	(define-key map "a" 'notmuch-show-archive-thread)
+	(define-key map "d" 'notmuch-show-delete-thread)
 	(define-key map "N" 'notmuch-show-next-message)
 	(define-key map "P" 'notmuch-show-previous-message)
 	(define-key map "n" 'notmuch-show-next-open-message)
@@ -1454,6 +1455,20 @@ buffer."
   (interactive)
   (notmuch-show-tag-thread-internal "-" "inbox" nil))
 
+(defun notmuch-show-delete-thread ()
+  "Delete each message in thread, then show next thread from search.
+
+Delete each message currently shown by adding the \"deleted\"
+tag to each. Then kill this buffer and show the next thread
+from the search from which this thread was originally shown.
+
+Note: This command is safe from any race condition of new messages
+being delivered to the same thread. It does not archive the
+entire thread, but only the messages shown in the current
+buffer."
+  (interactive)
+  (notmuch-show-tag-thread-internal "+" "deleted" t))
+
 (defun notmuch-show-stash-cc ()
   "Copy CC field of current message to kill-ring."
   (interactive)
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index c519687..2b860f4 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -218,6 +218,7 @@ For a mouse binding, return nil."
     (define-key map [mouse-1] 'notmuch-search-show-thread)
     (define-key map "*" 'notmuch-search-operate-all)
     (define-key map "a" 'notmuch-search-archive-thread)
+    (define-key map "d" 'notmuch-search-delete-thread)
     (define-key map "-" 'notmuch-search-remove-tag)
     (define-key map "+" 'notmuch-search-add-tag)
     (define-key map (kbd "RET") 'notmuch-search-show-thread)
@@ -605,6 +606,17 @@ This function advances the next thread when finished."
   (notmuch-search-remove-tag-thread "inbox")
   (forward-line))
 
+(defun notmuch-search-delete-thread ()
+  "Delete the currently selected thread (add the \"deleted\" tag).
+
+This function advances the next thread when finished.
+
+If notmuch-search-exclude-deleted is set, \"deleted\" messages
+will be excluded from searches."
+  (interactive)
+  (notmuch-search-add-tag "deleted")
+  (forward-line))
+
 (defvar notmuch-search-process-filter-data nil
   "Data that has not yet been processed.")
 (make-variable-buffer-local 'notmuch-search-process-filter-data)
-- 
1.7.7.3



More information about the notmuch mailing list