[PATCH 1/4] emacs: new customization variable to exclude "deleted" messages from search
Jameson Graef Rollins
jrollins at finestructure.net
Sat Jan 7 14:28:11 PST 2012
The new customization variable, notmuch-search-exclude-deleted, when
set to t, will exclude any messages with the "deleted" tag from
searches.
Additionally, specifying "tag:deleted" in the search directly will
override the exclusion and will included deleted messages in the
search results.
---
emacs/notmuch.el | 8 ++++
test/emacs | 42 ++++++++++++++++++++
.../notmuch-search-tag-inbox-deleted-excluded | 24 +++++++++++
3 files changed, 74 insertions(+), 0 deletions(-)
create mode 100644 test/emacs.expected-output/notmuch-search-tag-inbox-deleted-excluded
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index fde2377..c519687 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -905,6 +905,11 @@ PROMPT is the string to prompt with."
(read-from-minibuffer prompt nil keymap nil
'notmuch-query-history nil nil))))
+(defcustom notmuch-search-exclude-deleted nil
+ "Exclude deleted messages (with \"deleted\" tag) from search results."
+ :group 'notmuch
+ :type 'boolean)
+
;;;###autoload
(defun notmuch-search (query &optional oldest-first target-thread target-line continuation)
"Run \"notmuch search\" with the given query string and display results.
@@ -927,6 +932,9 @@ The optional parameters are used as follows:
(set 'notmuch-search-target-thread target-thread)
(set 'notmuch-search-target-line target-line)
(set 'notmuch-search-continuation continuation)
+ (when (and notmuch-search-exclude-deleted
+ (not (string-match "tag:deleted[ )]*" query)))
+ (setq query (concat query " and not tag:deleted")))
(let ((proc (get-buffer-process (current-buffer)))
(inhibit-read-only t))
(if proc
diff --git a/test/emacs b/test/emacs
index a06c223..1d78fbe 100755
--- a/test/emacs
+++ b/test/emacs
@@ -35,6 +35,48 @@ test_emacs '(notmuch-search "tag:inbox")
(test-output)'
test_expect_equal_file OUTPUT $EXPECTED/notmuch-search-tag-inbox
+test_begin_subtest "Exclude \"deleted\" messages from search"
+notmuch tag +deleted id:1258506353-20352-1-git-send-email-stewart at flamingspork.com
+# we "delete" a second message that's part of a multi-message thread
+# to make sure the rest of the thread is still returned
+notmuch tag +deleted id:1258471718-6781-1-git-send-email-dottedmag at dottedmag.net
+test_emacs '(let ((notmuch-search-exclude-deleted t))
+ (notmuch-search "tag:inbox")
+ (notmuch-test-wait)
+ (test-output))'
+notmuch tag -deleted id:1258506353-20352-1-git-send-email-stewart at flamingspork.com
+notmuch tag -deleted id:1258471718-6781-1-git-send-email-dottedmag at dottedmag.net
+test_expect_equal_file OUTPUT $EXPECTED/notmuch-search-tag-inbox-deleted-excluded
+
+test_begin_subtest "Exclude \"deleted\" messages from search, manual override"
+notmuch tag +deleted id:1258506353-20352-1-git-send-email-stewart at flamingspork.com
+notmuch tag +deleted id:1258471718-6781-1-git-send-email-dottedmag at dottedmag.net
+cat <<EOF >EXPECTED
+ 2009-11-18 [1/1] Stewart Smith [notmuch] [PATCH] Fix linking with gcc to use g++ to link in C++ libs. (deleted inbox unread)
+ 2009-11-17 [1/5] Mikhail Gusarov, Carl Worth, Keith Packard [notmuch] [PATCH 1/2] Close message file after parsing message headers (deleted inbox unread)
+End of search results.
+EOF
+test_emacs '(let ((notmuch-search-exclude-deleted t))
+ (notmuch-search "tag:inbox and tag:deleted")
+ (notmuch-test-wait)
+ (test-output))'
+notmuch tag -deleted id:1258506353-20352-1-git-send-email-stewart at flamingspork.com
+notmuch tag -deleted id:1258471718-6781-1-git-send-email-dottedmag at dottedmag.net
+test_expect_equal_file OUTPUT EXPECTED
+
+test_begin_subtest "Exclude \"deleted\" messages from search, but not \"deleted*\""
+notmuch tag +deleted-patch id:1258506353-20352-1-git-send-email-stewart at flamingspork.com
+cat <<EOF >EXPECTED
+ 2009-11-18 [1/1] Stewart Smith [notmuch] [PATCH] Fix linking with gcc to use g++ to link in C++ libs. (deleted-patch inbox unread)
+End of search results.
+EOF
+test_emacs '(let ((notmuch-search-exclude-deleted t))
+ (notmuch-search "tag:inbox and tag:deleted-patch")
+ (notmuch-test-wait)
+ (test-output))'
+notmuch tag -deleted-patch id:1258506353-20352-1-git-send-email-stewart at flamingspork.com
+test_expect_equal_file OUTPUT EXPECTED
+
test_begin_subtest "Navigation of notmuch-hello to search results"
test_emacs '(notmuch-hello)
(goto-char (point-min))
diff --git a/test/emacs.expected-output/notmuch-search-tag-inbox-deleted-excluded b/test/emacs.expected-output/notmuch-search-tag-inbox-deleted-excluded
new file mode 100644
index 0000000..39b4c51
--- /dev/null
+++ b/test/emacs.expected-output/notmuch-search-tag-inbox-deleted-excluded
@@ -0,0 +1,24 @@
+ 2010-12-29 [1/1] François Boulogne [aur-general] Guidelines: cp, mkdir vs install (inbox unread)
+ 2010-12-16 [1/1] Olivier Berger Essai accentué (inbox unread)
+ 2009-11-18 [1/1] Chris Wilson [notmuch] [PATCH 1/2] Makefile: evaluate pkg-config once (inbox unread)
+ 2009-11-18 [2/2] Alex Botero-Lowry, Carl Worth [notmuch] [PATCH] Error out if no query is supplied to search instead of going into an infinite loop (attachment inbox unread)
+ 2009-11-18 [2/2] Ingmar Vanhassel, Carl Worth [notmuch] [PATCH] Typsos (inbox unread)
+ 2009-11-18 [3/3] Adrian Perez de Castro, Keith Packard, Carl Worth [notmuch] Introducing myself (inbox signed unread)
+ 2009-11-18 [3/3] Israel Herraiz, Keith Packard, Carl Worth [notmuch] New to the list (inbox unread)
+ 2009-11-18 [3/3] Jan Janak, Carl Worth [notmuch] What a great idea! (inbox unread)
+ 2009-11-18 [2/2] Jan Janak, Carl Worth [notmuch] [PATCH] Older versions of install do not support -C. (inbox unread)
+ 2009-11-18 [3/3] Aron Griffis, Keith Packard, Carl Worth [notmuch] archive (inbox unread)
+ 2009-11-18 [2/2] Keith Packard, Carl Worth [notmuch] [PATCH] Make notmuch-show 'X' (and 'x') commands remove inbox (and unread) tags (inbox unread)
+ 2009-11-18 [7/7] Lars Kellogg-Stedman, Mikhail Gusarov, Keith Packard, Carl Worth [notmuch] Working with Maildir storage? (inbox signed unread)
+ 2009-11-18 [4/5] Mikhail Gusarov, Carl Worth, Keith Packard [notmuch] [PATCH 1/2] Close message file after parsing message headers (deleted inbox unread)
+ 2009-11-18 [2/2] Keith Packard, Alexander Botero-Lowry [notmuch] [PATCH] Create a default notmuch-show-hook that highlights URLs and uses word-wrap (inbox unread)
+ 2009-11-18 [1/1] Alexander Botero-Lowry [notmuch] request for pull (inbox unread)
+ 2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry [notmuch] Mac OS X/Darwin compatibility issues (inbox unread)
+ 2009-11-18 [1/1] Rolland Santimano [notmuch] Link to mailing list archives ? (inbox unread)
+ 2009-11-18 [1/1] Jan Janak [notmuch] [PATCH] notmuch new: Support for conversion of spool subdirectories into tags (inbox unread)
+ 2009-11-18 [1/1] Stewart Smith [notmuch] [PATCH] count_files: sort directory in inode order before statting (inbox unread)
+ 2009-11-18 [1/1] Stewart Smith [notmuch] [PATCH 2/2] Read mail directory in inode number order (inbox unread)
+ 2009-11-18 [2/2] Lars Kellogg-Stedman [notmuch] "notmuch help" outputs to stderr? (attachment inbox signed unread)
+ 2009-11-17 [1/1] Mikhail Gusarov [notmuch] [PATCH] Handle rename of message file (inbox unread)
+ 2009-11-17 [2/2] Alex Botero-Lowry, Carl Worth [notmuch] preliminary FreeBSD support (attachment inbox unread)
+End of search results.
--
1.7.7.3
More information about the notmuch
mailing list