[PATCH] VIM: Improve search list
authorIan Main <imain@stemwinder.org>
Mon, 6 Oct 2014 18:50:14 +0000 (11:50 +1700)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 18:05:05 +0000 (10:05 -0800)
dd/068b8b0c0c2e882fbae0ccf85d05563776e0c2 [new file with mode: 0644]

diff --git a/dd/068b8b0c0c2e882fbae0ccf85d05563776e0c2 b/dd/068b8b0c0c2e882fbae0ccf85d05563776e0c2
new file mode 100644 (file)
index 0000000..a8a1113
--- /dev/null
@@ -0,0 +1,133 @@
+Return-Path: <imain@stemwinder.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 19F4C431FC3\r
+       for <notmuch@notmuchmail.org>; Mon,  6 Oct 2014 11:50:23 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_NONE=-0.0001] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id eCNmC8IeftVv for <notmuch@notmuchmail.org>;\r
+       Mon,  6 Oct 2014 11:50:19 -0700 (PDT)\r
+Received: from cmta14.telus.net (cmta14.telus.net [209.171.16.87])\r
+       by olra.theworths.org (Postfix) with ESMTP id 7FEB7431FAE\r
+       for <notmuch@notmuchmail.org>; Mon,  6 Oct 2014 11:50:19 -0700 (PDT)\r
+Received: from ovo.mains.priv ([207.102.88.62]) by cmta14.telus.net with TELUS\r
+       id zuqJ1o00G1LiWEf01uqJwM; Mon, 06 Oct 2014 12:50:19 -0600\r
+X-Authority-Analysis: v=2.0 cv=YvLRsfkX c=1 sm=2\r
+       a=EcQDfIwDZEqJA1f7rVUV8Q==:17 a=S-IsBHyFrF4A:10 a=tsa3CZZnAAAA:8\r
+       a=kgSvjYviLYQrhIuC7O0A:9 a=I9Z9FZpTuu1KLi6k:21 a=AbTiqZD8YlUZ1nUa:21\r
+       a=EcQDfIwDZEqJA1f7rVUV8Q==:117\r
+X-Telus-Outbound-IP: 207.102.88.62\r
+From: Ian Main <imain@stemwinder.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] VIM: Improve search list\r
+Date: Mon,  6 Oct 2014 11:50:14 -0700\r
+Message-Id: <1412621414-31793-1-git-send-email-imain@stemwinder.org>\r
+X-Mailer: git-send-email 1.9.3\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 06 Oct 2014 18:50:23 -0000\r
+\r
+Make the width of the search name column expand/contract with the\r
+length of the longest search name string.\r
+\r
+Fix syntax highlighting to make the above work right.\r
+\r
+Add the ability to use a blank search pattern to create a spacer\r
+to break up searches into groups.\r
+---\r
+ vim/notmuch.txt                |  4 ++++\r
+ vim/notmuch.vim                | 16 ++++++++++++++--\r
+ vim/syntax/notmuch-folders.vim |  2 +-\r
+ 3 files changed, 19 insertions(+), 3 deletions(-)\r
+\r
+diff --git a/vim/notmuch.txt b/vim/notmuch.txt\r
+index 4374102..3a73912 100644\r
+--- a/vim/notmuch.txt\r
++++ b/vim/notmuch.txt\r
+@@ -94,11 +94,15 @@ You can add the following configurations to your `.vimrc`, or\r
+                                               *g:notmuch_folders*\r
\r
+ The first thing you might want to do is set your custom searches.\r
++\r
++Adding an empty set of strings results in a blank line which allows you\r
++to break up searches into groups.\r
+ >\r
+       let g:notmuch_folders = [\r
+               \ [ 'new', 'tag:inbox and tag:unread' ],\r
+               \ [ 'inbox', 'tag:inbox' ],\r
+               \ [ 'unread', 'tag:unread' ],\r
++              \ [ '', '' ],\r
+               \ [ 'to-do', 'tag:to-do' ],\r
+               \ [ 'to-me', 'to:john.doe and tag:new' ],\r
+               \ ]\r
+diff --git a/vim/notmuch.vim b/vim/notmuch.vim\r
+index 331e930..61a7260 100644\r
+--- a/vim/notmuch.vim\r
++++ b/vim/notmuch.vim\r
+@@ -374,7 +374,9 @@ function! s:folders_show_search()\r
+ ruby << EOF\r
+       n = $curbuf.line_number\r
+       s = $searches[n - 1]\r
+-      VIM::command("call s:search('#{s}')")\r
++      if s.length > 0\r
++              VIM::command("call s:search('#{s}')")\r
++      end\r
+ EOF\r
+ endfunction\r
\r
+@@ -633,11 +635,21 @@ ruby << EOF\r
+                       folders = VIM::evaluate('g:notmuch_folders')\r
+                       count_threads = VIM::evaluate('g:notmuch_folders_count_threads') == 1\r
+                       $searches.clear\r
++                      longest_name = 0\r
++                      folders.each do |name, search|\r
++                              if name.length > longest_name\r
++                                      longest_name = name.length\r
++                              end\r
++                      end\r
+                       folders.each do |name, search|\r
+                               q = $curbuf.query(search)\r
+                               $searches << search\r
+                               count = count_threads ? q.search_threads.count : q.search_messages.count\r
+-                              b << "%9d %-20s (%s)" % [count, name, search]\r
++                              if name == ''\r
++                                      b << ""\r
++                              else\r
++                                      b << "%9d %-#{longest_name + 1}s (%s)" % [count, name, search]\r
++                              end\r
+                       end\r
+               end\r
+       end\r
+diff --git a/vim/syntax/notmuch-folders.vim b/vim/syntax/notmuch-folders.vim\r
+index 9477f86..03209c1 100644\r
+--- a/vim/syntax/notmuch-folders.vim\r
++++ b/vim/syntax/notmuch-folders.vim\r
+@@ -1,7 +1,7 @@\r
+ " notmuch folders mode syntax file\r
\r
+ syntax region nmFoldersCount     start='^' end='\%10v'\r
+-syntax region nmFoldersName      start='\%11v' end='\%31v'\r
++syntax region nmFoldersName      start='\%11v' end='  ('me=e-1\r
+ syntax match  nmFoldersSearch    /([^()]\+)$/\r
\r
+ highlight link nmFoldersCount     Statement\r
+-- \r
+1.9.3\r
+\r