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