unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Franz Fellner <alpine.art.de@gmail.com>
To: notmuch@notmuchmail.org
Subject: Re: [PATCH v2] VIM: Use notmuch CLI for config
Date: Fri, 10 Oct 2014 11:32:02 +0200	[thread overview]
Message-ID: <20141010113202.GE28601@TP_L520.localdomain> (raw)
In-Reply-To: <1412293635-31273-1-git-send-email-imain@stemwinder.org>

On Thu,  2 Oct 2014 16:47:15 -0700, Ian Main <imain@stemwinder.org> 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

  parent reply	other threads:[~2014-10-10  9:32 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-02 21:53 [PATCH] VIM: Use notmuch CLI for config Ian Main
2014-10-02 23:47 ` [PATCH v2] " Ian Main
2014-10-03  6:54   ` David Bremner
2014-10-03 10:50     ` Sergei Shilovsky
2014-10-03 18:41     ` Ian Main
2014-10-10  9:32   ` Franz Fellner [this message]
2014-10-19 18:11   ` David Bremner
2014-10-20 17:47     ` Ian Main
2014-10-21  8:31   ` David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20141010113202.GE28601@TP_L520.localdomain \
    --to=alpine.art.de@gmail.com \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).