From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 1405240F3E5 for ; Sat, 7 Jan 2012 14:28:29 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -2.3 X-Spam-Level: X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1uhlcanHSDCf for ; Sat, 7 Jan 2012 14:28:26 -0800 (PST) Received: from outgoing-mail.its.caltech.edu (outgoing-mail.its.caltech.edu [131.215.239.19]) by olra.theworths.org (Postfix) with ESMTP id 7199540EF0C for ; Sat, 7 Jan 2012 14:28:24 -0800 (PST) Received: from earth-doxen.imss.caltech.edu (localhost [127.0.0.1]) by earth-doxen-postvirus (Postfix) with ESMTP id 2394566E00BD for ; Sat, 7 Jan 2012 14:28:24 -0800 (PST) X-Spam-Scanned: at Caltech-IMSS on earth-doxen by amavisd-new Received: from finestructure.net (cpe-76-174-137-84.socal.res.rr.com [76.174.137.84]) (Authenticated sender: jrollins) by earth-doxen-submit (Postfix) with ESMTP id 6716D66E012E for ; Sat, 7 Jan 2012 14:28:21 -0800 (PST) Received: by finestructure.net (Postfix, from userid 1000) id CE75F52; Sat, 7 Jan 2012 14:28:20 -0800 (PST) From: Jameson Graef Rollins To: Notmuch Mail Subject: [PATCH 1/4] emacs: new customization variable to exclude "deleted" messages from search Date: Sat, 7 Jan 2012 14:28:11 -0800 Message-Id: <1325975294-646-2-git-send-email-jrollins@finestructure.net> X-Mailer: git-send-email 1.7.7.3 In-Reply-To: <1325975294-646-1-git-send-email-jrollins@finestructure.net> References: <1325975294-646-1-git-send-email-jrollins@finestructure.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Jan 2012 22:28:29 -0000 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@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@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@flamingspork.com +notmuch tag -deleted id:1258471718-6781-1-git-send-email-dottedmag@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@flamingspork.com +notmuch tag +deleted id:1258471718-6781-1-git-send-email-dottedmag@dottedmag.net +cat <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@flamingspork.com +notmuch tag -deleted id:1258471718-6781-1-git-send-email-dottedmag@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@flamingspork.com +cat <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@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