unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] VIM: Improve search list
@ 2014-10-06 18:50 Ian Main
  2014-10-18 20:31 ` Franz Fellner
  0 siblings, 1 reply; 2+ messages in thread
From: Ian Main @ 2014-10-06 18:50 UTC (permalink / raw)
  To: notmuch

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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* RE: [PATCH] VIM: Improve search list
  2014-10-06 18:50 [PATCH] VIM: Improve search list Ian Main
@ 2014-10-18 20:31 ` Franz Fellner
  0 siblings, 0 replies; 2+ messages in thread
From: Franz Fellner @ 2014-10-18 20:31 UTC (permalink / raw)
  To: Ian Main, Ian Main, notmuch

LGTM

Franz

Ian Main wrote:
> 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
> 
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-10-18 20:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-06 18:50 [PATCH] VIM: Improve search list Ian Main
2014-10-18 20:31 ` Franz Fellner

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).