3.3. Contacts Completion¶
For each account you can define an address book by providing a subsection named abook. Crucially, this section needs an option type that specifies the type of the address book. The only types supported at the moment are “shellcommand” and “abook”. Both respect the ignorecase option which defaults to True and results in case insensitive lookups.
Address books of this type use a shell command in combination with a regular expression to look up contacts.
The value of command will be called with the search prefix as only argument for lookups. Its output is searched for email-name pairs using the regular expression given as regexp, which must include named groups “email” and “name” to match the email address and realname parts respectively. See below for an example that uses abook
[accounts] [[youraccount]] # ... [[[abook]]] type = shellcommand command = abook --mutt-query regexp = '^(?P<email>[^@]+@[^\t]+)\t+(?P<name>[^\t]+)' ignorecase = True
See here for alternative lookup commands. The few others I have tested so far are:
for cached google contacts lookups. Works with the above default regexp
command = goobook query regexp = '^(?P<email>[^@]+@[^\t]+)\t+(?P<name>[^\t]+)'
completes contacts found in the notmuch index:
command = nottoomuch-addresses.sh regexp = \"(?P<name>.+)\"\s*<(?P<email>.*.+?@.+?)>
completes contacts found in database of notmuch-abook:
command = notmuch_abook.py lookup regexp = ^((?P<name>[^(\\s+\<)]*)\s+<)?(?P<email>[^@]+?@[^>]+)>?$
- notmuch address
Since version 0.19, notmuch itself offers a subcommand address, that returns email addresses found in the notmuch index. Combined with the date: syntax to query for mails within a certain timeframe, this allows to search for all recently used contacts:
command = "notmuch address --output=recipients date:1Y.. AND from:firstname.lastname@example.org" regexp = (\"?(?P<name>.+)\"?)?\s*<(?P<email>.*@.+?)> shellcommand_external_filtering = False
Don’t hesitate to send me your custom regexp values to list them here.
Address books of this type directly parse abooks contact files. You may specify a path using the “abook_contacts_file” option, which defaults to
~/.abook/addressbook. To use the default path, simply do this:
[accounts] [[youraccount]] # ... [[[abook]]] type = abook