[PATCH] VIM: Improve search list

Franz Fellner alpine.art.de at gmail.com
Sat Oct 18 13:31:52 PDT 2014


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 at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch




More information about the notmuch mailing list