Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 19F4C431FC3 for ; Mon, 6 Oct 2014 11:50:23 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_NONE=-0.0001] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id eCNmC8IeftVv for ; Mon, 6 Oct 2014 11:50:19 -0700 (PDT) Received: from cmta14.telus.net (cmta14.telus.net [209.171.16.87]) by olra.theworths.org (Postfix) with ESMTP id 7FEB7431FAE for ; Mon, 6 Oct 2014 11:50:19 -0700 (PDT) Received: from ovo.mains.priv ([207.102.88.62]) by cmta14.telus.net with TELUS id zuqJ1o00G1LiWEf01uqJwM; Mon, 06 Oct 2014 12:50:19 -0600 X-Authority-Analysis: v=2.0 cv=YvLRsfkX c=1 sm=2 a=EcQDfIwDZEqJA1f7rVUV8Q==:17 a=S-IsBHyFrF4A:10 a=tsa3CZZnAAAA:8 a=kgSvjYviLYQrhIuC7O0A:9 a=I9Z9FZpTuu1KLi6k:21 a=AbTiqZD8YlUZ1nUa:21 a=EcQDfIwDZEqJA1f7rVUV8Q==:117 X-Telus-Outbound-IP: 207.102.88.62 From: Ian Main To: notmuch@notmuchmail.org Subject: [PATCH] VIM: Improve search list Date: Mon, 6 Oct 2014 11:50:14 -0700 Message-Id: <1412621414-31793-1-git-send-email-imain@stemwinder.org> X-Mailer: git-send-email 1.9.3 X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Oct 2014 18:50:23 -0000 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