mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-12-22 09:24:54 +01:00
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
This commit is contained in:
parent
dd8373fb57
commit
e0ce86119c
1 changed files with 12 additions and 19 deletions
|
@ -471,28 +471,21 @@ ruby << EOF
|
||||||
$searches = []
|
$searches = []
|
||||||
$threads = []
|
$threads = []
|
||||||
$messages = []
|
$messages = []
|
||||||
$config = {}
|
|
||||||
$mail_installed = defined?(Mail)
|
$mail_installed = defined?(Mail)
|
||||||
|
|
||||||
def get_config
|
def get_config_item(item)
|
||||||
group = nil
|
result = ''
|
||||||
config = ENV['NOTMUCH_CONFIG'] || '~/.notmuch-config'
|
IO.popen(['notmuch', 'config', 'get', item]) { |out|
|
||||||
File.open(File.expand_path(config)).each do |l|
|
result = out.read
|
||||||
l.chomp!
|
}
|
||||||
case l
|
return result.rstrip
|
||||||
when /^\[(.*)\]$/
|
|
||||||
group = $1
|
|
||||||
when ''
|
|
||||||
when /^(.*)=(.*)$/
|
|
||||||
key = "%s.%s" % [group, $1]
|
|
||||||
value = $2
|
|
||||||
$config[key] = value
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
$db_name = $config['database.path']
|
def get_config
|
||||||
$email_name = $config['user.name']
|
$db_name = get_config_item('database.path')
|
||||||
$email_address = $config['user.primary_email']
|
$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]
|
$email = "%s <%s>" % [$email_name, $email_address]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue