[PATCH 4/5] Introduce g:notmuch_rb_folders_count_threads

Subject: [PATCH 4/5] Introduce g:notmuch_rb_folders_count_threads

Date: Mon, 28 Jan 2013 17:52:19 +0200

To: Felipe Contreras

Cc: notmuch@notmuchmail.org

From: Kirill A. Shutemov


From: "Kirill A. Shutemov" <kirill@shutemov.name>

If the option set, folders list shows count of threads, not messages

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
---
 notmuch-ruby.vim |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/notmuch-ruby.vim b/notmuch-ruby.vim
index 81da9b3..cda5df4 100644
--- a/notmuch-ruby.vim
+++ b/notmuch-ruby.vim
@@ -53,6 +53,7 @@ let s:notmuch_rb_date_format_default = '%d.%m.%y'
 let s:notmuch_rb_datetime_format_default = '%d.%m.%y %H:%M:%S'
 let s:notmuch_rb_reader_default = 'terminal -e "mutt -f %s"'
 let s:notmuch_rb_sendmail_default = '/usr/sbin/sendmail'
+let s:notmuch_rb_folders_count_threads_default = 0
 
 if !exists('g:notmuch_rb_date_format')
 	let g:notmuch_rb_date_format = s:notmuch_rb_date_format_default
@@ -70,6 +71,10 @@ if !exists('g:notmuch_rb_sendmail')
 	let g:notmuch_rb_sendmail = s:notmuch_rb_sendmail_default
 endif
 
+if !exists('g:notmuch_rb_folders_count_threads')
+	let g:notmuch_rb_folders_count_threads = s:notmuch_rb_folders_count_threads_default
+endif
+
 function! s:new_file_buffer(type, fname)
 	exec printf('edit %s', a:fname)
 	execute printf('set filetype=notmuch-%s', a:type)
@@ -536,12 +541,15 @@ ruby << EOF
 	def folders_render()
 		$curbuf.render do |b|
 			folders = VIM::evaluate('g:notmuch_rb_folders')
+			count_threads = VIM::evaluate('g:notmuch_rb_folders_count_threads')
 			$searches.clear
 			do_read do |db|
 				folders.each do |name, search|
 					q = db.query(search)
 					$searches << search
-					b << "%9d %-20s (%s)" % [q.search_messages.count, name, search]
+					count = count_threads == 0 ?
+						q.search_messages.count : q.search_threads.count
+					b << "%9d %-20s (%s)" % [count, name, search]
 				end
 			end
 		end
-- 
1.7.10.4


Thread: