Re: [PATCH v2] VIM: Use notmuch CLI for config
authorFranz Fellner <alpine.art.de@gmail.com>
Fri, 10 Oct 2014 09:32:02 +0000 (11:32 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 18:05:11 +0000 (10:05 -0800)
ab/206bf626179e6f20a94334797f453e3e9512a2 [new file with mode: 0644]

diff --git a/ab/206bf626179e6f20a94334797f453e3e9512a2 b/ab/206bf626179e6f20a94334797f453e3e9512a2
new file mode 100644 (file)
index 0000000..5f16198
--- /dev/null
@@ -0,0 +1,147 @@
+Return-Path: <alpine.art.de@gmail.com>\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 11D31431FBD\r
+       for <notmuch@notmuchmail.org>; Fri, 10 Oct 2014 02:32:09 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.799\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] 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 FdVJyeiI-Cnh for <notmuch@notmuchmail.org>;\r
+       Fri, 10 Oct 2014 02:32:01 -0700 (PDT)\r
+Received: from mail-la0-f52.google.com (mail-la0-f52.google.com\r
+       [209.85.215.52]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 62823431FBC\r
+       for <notmuch@notmuchmail.org>; Fri, 10 Oct 2014 02:32:01 -0700 (PDT)\r
+Received: by mail-la0-f52.google.com with SMTP id hz20so2804070lab.25\r
+       for <notmuch@notmuchmail.org>; Fri, 10 Oct 2014 02:31:54 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+       h=date:message-id:from:to:subject:in-reply-to:references:mime-version\r
+       :content-type:content-disposition:content-transfer-encoding;\r
+       bh=5Dlity+fPMEVPz7hZQjE+0/hQHuVBNK+rvO5r6SPMzM=;\r
+       b=GMlKs+JqSVPogpf3Ft4Ck6d3slgmSYBAQVfoEO5RI9DRwCjkjy2jngJO5HF5y22ALu\r
+       CECBg52jFyiVcM6QzChRdn+r6WDMeVDRQKENXougbsXHpCNzk9F6h9tPmlqjgfvTp0Gm\r
+       01cGGF7K7jCI67QJ2LCYBfJdnV2BnxW+SVPjkxwAVwZ6z5IDYqGx0p/mBoQ9cWDGVweU\r
+       qlomV328vK4F9wUp8RiKz/Q/b6l1DvJ8tVtyqH1tagePPSShHMsy0LNsa6LKICvZEyhO\r
+       OST91DVKZBF9q3cOgoPVAFOih3dliFSFrpG2c0h2nGG03voslI1+Sb9bAXhRdZNMK5tY\r
+       EofA==\r
+X-Received: by 10.112.134.229 with SMTP id pn5mr3355576lbb.22.1412933514470;\r
+       Fri, 10 Oct 2014 02:31:54 -0700 (PDT)\r
+Received: from localhost (p5B00C9E6.dip0.t-ipconnect.de. [91.0.201.230])\r
+       by mx.google.com with ESMTPSA id z1sm867808lad.40.2014.10.10.02.31.52\r
+       for <notmuch@notmuchmail.org>\r
+       (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+       Fri, 10 Oct 2014 02:31:53 -0700 (PDT)\r
+Date: Fri, 10 Oct 2014 11:32:02 +0200\r
+Message-ID: <20141010113202.GE28601@TP_L520.localdomain>\r
+From: Franz Fellner <alpine.art.de@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: Re: [PATCH v2] VIM: Use notmuch CLI for config\r
+In-Reply-To: <1412293635-31273-1-git-send-email-imain@stemwinder.org>\r
+References: <1412286796-27479-1-git-send-email-imain@stemwinder.org>\r
+       <1412293635-31273-1-git-send-email-imain@stemwinder.org>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=utf-8\r
+Content-Disposition: inline\r
+Content-Transfer-Encoding: 8bit\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: Fri, 10 Oct 2014 09:32:09 -0000\r
+\r
+On Thu,  2 Oct 2014 16:47:15 -0700, Ian Main <imain@stemwinder.org> wrote:\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
+> \r
+> This update changes result to be '' instead of nil\r
+> by default so missing config items won't cause an error.\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..b251af6 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 = ''\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
+\r
+Just wanted to note that you read user.name twice.\r
+\r
+>              $email = "%s <%s>" % [$email_name, $email_address]\r
+This is not related to this patch:\r
+I don't know if it is a good idea to force $email_name on every\r
+$email_address. Maybe use it as a fallback and introduce an optional\r
+mailaddress-sendername map. So the user can specify which name should be\r
+used. (Imagine a "Dr." who wants to have "Dr. P. Harmony" for his official\r
+mails, but "Phil Harmony" for private ones. Or a writer who uses several\r
+psudonyms.)\r
+Maybe this can be solved by the sendmail application, but probably\r
+that requires leaving out email_name entirely. Will setup a test env\r
+later to evaluate.\r
+\r
+>      end\r
+>  \r
+> -- \r
+> 1.9.3\r
+> \r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r