unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Ian Main <imain@stemwinder.org>
To: notmuch@notmuchmail.org
Subject: [PATCH] VIM: Improve search list
Date: Mon,  6 Oct 2014 11:50:14 -0700	[thread overview]
Message-ID: <1412621414-31793-1-git-send-email-imain@stemwinder.org> (raw)

Make the width of the search name column expand/contract with the
length of the longest search name string.

Fix syntax highlighting to make the above work right.

Add the ability to use a blank search pattern to create a spacer
to break up searches into groups.
---
 vim/notmuch.txt                |  4 ++++
 vim/notmuch.vim                | 16 ++++++++++++++--
 vim/syntax/notmuch-folders.vim |  2 +-
 3 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/vim/notmuch.txt b/vim/notmuch.txt
index 4374102..3a73912 100644
--- a/vim/notmuch.txt
+++ b/vim/notmuch.txt
@@ -94,11 +94,15 @@ You can add the following configurations to your `.vimrc`, or
 						*g:notmuch_folders*
 
 The first thing you might want to do is set your custom searches.
+
+Adding an empty set of strings results in a blank line which allows you
+to break up searches into groups.
 >
 	let g:notmuch_folders = [
 		\ [ 'new', 'tag:inbox and tag:unread' ],
 		\ [ 'inbox', 'tag:inbox' ],
 		\ [ 'unread', 'tag:unread' ],
+		\ [ '', '' ],
 		\ [ 'to-do', 'tag:to-do' ],
 		\ [ 'to-me', 'to:john.doe and tag:new' ],
 		\ ]
diff --git a/vim/notmuch.vim b/vim/notmuch.vim
index 331e930..61a7260 100644
--- a/vim/notmuch.vim
+++ b/vim/notmuch.vim
@@ -374,7 +374,9 @@ function! s:folders_show_search()
 ruby << EOF
 	n = $curbuf.line_number
 	s = $searches[n - 1]
-	VIM::command("call s:search('#{s}')")
+	if s.length > 0
+		VIM::command("call s:search('#{s}')")
+	end
 EOF
 endfunction
 
@@ -633,11 +635,21 @@ ruby << EOF
 			folders = VIM::evaluate('g:notmuch_folders')
 			count_threads = VIM::evaluate('g:notmuch_folders_count_threads') == 1
 			$searches.clear
+			longest_name = 0
+			folders.each do |name, search|
+				if name.length > longest_name
+					longest_name = name.length
+				end
+			end
 			folders.each do |name, search|
 				q = $curbuf.query(search)
 				$searches << search
 				count = count_threads ? q.search_threads.count : q.search_messages.count
-				b << "%9d %-20s (%s)" % [count, name, search]
+				if name == ''
+					b << ""
+				else
+					b << "%9d %-#{longest_name + 1}s (%s)" % [count, name, search]
+				end
 			end
 		end
 	end
diff --git a/vim/syntax/notmuch-folders.vim b/vim/syntax/notmuch-folders.vim
index 9477f86..03209c1 100644
--- a/vim/syntax/notmuch-folders.vim
+++ b/vim/syntax/notmuch-folders.vim
@@ -1,7 +1,7 @@
 " notmuch folders mode syntax file
 
 syntax region nmFoldersCount     start='^' end='\%10v'
-syntax region nmFoldersName      start='\%11v' end='\%31v'
+syntax region nmFoldersName      start='\%11v' end='  ('me=e-1
 syntax match  nmFoldersSearch    /([^()]\+)$/
 
 highlight link nmFoldersCount     Statement
-- 
1.9.3

             reply	other threads:[~2014-10-06 18:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-06 18:50 Ian Main [this message]
2014-10-18 20:31 ` [PATCH] VIM: Improve search list Franz Fellner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1412621414-31793-1-git-send-email-imain@stemwinder.org \
    --to=imain@stemwinder.org \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).