RE: [PATCH] VIM: Respect exclude_tags specified in .notmuch-config

Subject: RE: [PATCH] VIM: Respect exclude_tags specified in .notmuch-config

Date: Mon, 20 Oct 2014 21:30:46 +0200

To: Franz Fellner, notmuch@notmuchmail.org

Cc:

From: Franz Fellner


Exclude mails tagged with any tag specified in
notmuch config get search.exclude_tags
in folders list and search list.

diff --git a/vim/notmuch.vim b/vim/notmuch.vim
index 5c86fcd..522a366 100644
--- a/vim/notmuch.vim
+++ b/vim/notmuch.vim
@@ -647,6 +647,7 @@ ruby << EOF
 	$db_name = nil
 	$all_emails = []
 	$email = $email_name = $email_address = nil
+	$exclude_tags = []
 	$searches = []
 	$threads = []
 	$messages = []
@@ -672,6 +673,8 @@ ruby << EOF
 		# Add the primary to this too as we use it for checking
 		# addresses when doing a reply
 		$all_emails.unshift($email_address)
+		ignore_tags = get_config_item('search.exclude_tags')
+		$exclude_tags = ignore_tags.split("\n")
 	end
 
 	def vim_puts(s)
@@ -859,6 +862,9 @@ ruby << EOF
 			end
 			folders.each do |name, search|
 				q = $curbuf.query(search)
+				$exclude_tags.each { |t|
+					q.add_tag_exclude(t)
+				}
 				$searches << search
 				count = count_threads ? q.search_threads.count : q.search_messages.count
 				if name == ''
@@ -874,6 +880,9 @@ ruby << EOF
 		date_fmt = VIM::evaluate('g:notmuch_date_format')
 		q = $curbuf.query(search)
 		q.sort = Notmuch::SORT_NEWEST_FIRST
+		$exclude_tags.each { |t|
+			q.add_tag_exclude(t)
+		}
 		$threads.clear
 		t = q.search_threads
 

Thread: