[PATCH] VIM: Use notmuch CLI for config
authorIan Main <imain@stemwinder.org>
Thu, 2 Oct 2014 21:53:16 +0000 (14:53 +1700)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 18:04:52 +0000 (10:04 -0800)
2e/79bcbd3e148a74c97710d7bbc570ead5b268f5 [new file with mode: 0644]

diff --git a/2e/79bcbd3e148a74c97710d7bbc570ead5b268f5 b/2e/79bcbd3e148a74c97710d7bbc570ead5b268f5
new file mode 100644 (file)
index 0000000..6f626a8
--- /dev/null
@@ -0,0 +1,103 @@
+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 46496431FBC\r
+       for <notmuch@notmuchmail.org>; Thu,  2 Oct 2014 14:53:25 -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 6Ua3J8oc4B9E for <notmuch@notmuchmail.org>;\r
+       Thu,  2 Oct 2014 14:53:19 -0700 (PDT)\r
+Received: from cmta3.telus.net (cmta3.telus.net [209.171.16.76])\r
+       by olra.theworths.org (Postfix) with ESMTP id 8A207431FB6\r
+       for <notmuch@notmuchmail.org>; Thu,  2 Oct 2014 14:53:19 -0700 (PDT)\r
+Received: from ovo.mains.priv ([207.102.88.62]) by cmta3.telus.net with TELUS\r
+       id yMtJ1o00Y1LiWEf01MtJqG; Thu, 02 Oct 2014 15:53:19 -0600\r
+X-Authority-Analysis: v=2.0 cv=GePJa3rL c=1 sm=2\r
+       a=EcQDfIwDZEqJA1f7rVUV8Q==:17 a=S-IsBHyFrF4A:10 a=tsa3CZZnAAAA:8\r
+       a=lnbEfRDau6mwN6_a2jMA:9 a=982h0VeBkKRggbAd:21 a=CmYvmRXf5uR-RLfk: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: Use notmuch CLI for config\r
+Date: Thu,  2 Oct 2014 14:53:16 -0700\r
+Message-Id: <1412286796-27479-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: Thu, 02 Oct 2014 21:53:25 -0000\r
+\r
+This patch switches from reading .notmuch-config directly to using\r
+the CLI the same way that emacs does it.  It actually uses less code\r
+and is probably less error prone.\r
+\r
+    Ian\r
+---\r
+ vim/notmuch.vim | 31 ++++++++++++-------------------\r
+ 1 file changed, 12 insertions(+), 19 deletions(-)\r
+\r
+diff --git a/vim/notmuch.vim b/vim/notmuch.vim\r
+index 331e930..faee3d2 100644\r
+--- a/vim/notmuch.vim\r
++++ b/vim/notmuch.vim\r
+@@ -471,28 +471,21 @@ ruby << EOF\r
+       $searches = []\r
+       $threads = []\r
+       $messages = []\r
+-      $config = {}\r
+       $mail_installed = defined?(Mail)\r
\r
+-      def get_config\r
+-              group = nil\r
+-              config = ENV['NOTMUCH_CONFIG'] || '~/.notmuch-config'\r
+-              File.open(File.expand_path(config)).each do |l|\r
+-                      l.chomp!\r
+-                      case l\r
+-                      when /^\[(.*)\]$/\r
+-                              group = $1\r
+-                      when ''\r
+-                      when /^(.*)=(.*)$/\r
+-                              key = "%s.%s" % [group, $1]\r
+-                              value = $2\r
+-                              $config[key] = value\r
+-                      end\r
+-              end\r
++      def get_config_item(item)\r
++              result = nil\r
++              IO.popen(['notmuch', 'config', 'get', item]) { |out|\r
++                      result = out.read\r
++              }\r
++              return result.rstrip\r
++      end\r
\r
+-              $db_name = $config['database.path']\r
+-              $email_name = $config['user.name']\r
+-              $email_address = $config['user.primary_email']\r
++      def get_config\r
++              $db_name = get_config_item('database.path')\r
++              $email_name = get_config_item('user.name')\r
++              $email_address = get_config_item('user.primary_email')\r
++              $email_name = get_config_item('user.name')\r
+               $email = "%s <%s>" % [$email_name, $email_address]\r
+       end\r
\r
+-- \r
+1.9.3\r
+\r