diff options
author | Ian Main <imain@stemwinder.org> | 2014-10-02 16:47:15 -0700 |
---|---|---|
committer | David Bremner <david@tethera.net> | 2014-10-21 10:22:44 +0200 |
commit | e0ce86119cbae520728c6812c021315a885f52ce (patch) | |
tree | b798628cb3a526ea908345f0705ff9c11e1f8db1 /vim | |
parent | dd8373fb571f93cf3bf824777e00278979ef2e21 (diff) |
VIM: Use notmuch CLI for config
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
Diffstat (limited to 'vim')
-rw-r--r-- | vim/notmuch.vim | 31 |
1 files changed, 12 insertions, 19 deletions
diff --git a/vim/notmuch.vim b/vim/notmuch.vim index 331e9300..b251af6e 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') $email = "%s <%s>" % [$email_name, $email_address] end |