sponsor Vim development Vim logo Vim Book Ad

mutt-query-complete.vim : complete e-mail addresses in Vim by your favorite query_command

 script karma  Rating 5/2, Downloaded by 688  Comments, bugs, improvements  Vim wiki

created by
Enno Nagel
 
script type
ftplugin
 
description
Complete names and email addresses using the mutt address_query tool defined by query_command (such as abook, notmuch-addrlookup, mutt_ldap.py, mutt-ldap.pl, ...).

1. Usage

When you're editing a mail file in Vim that reads

    From: Lu Guanqun <guanqun.lu@gmail.com>
    To:   foo

and your query tool has an entry

    foo@bar.com Foo Bar

and your cursor is right after foo, then hit Ctrl+X Ctrl+O (which could be remapped, say to Ctrl-Space) to obtain:

    From: Lu Guanqun <guanqun.lu@gmail.com>
    To:   Foo Bar foo@bar.com


2. Setup

Completion is enabled in all mail buffers by default. Add additional file types to the list g:muttquery_filetypes which defaults to [ 'mail' ].

The mutt query command is automatically set to the value of the variable $query_command used by mutt. To explicitly set the path to a command $command, add to your .vimrc the line

  let g:muttquery_command = '$command

For example, $command could be mutt_ldap.py %s.

As a suggestion, if you use different mail accounts with different query commands, add in .muttrc a folder hook, say for the account mailo,

folder-hook '~/.local/share/mbsync/mailo/' 'source "$XDG_CONFIG_HOME/mutt/accounts/mailo"'

and in "$XDG_CONFIG_HOME/mutt/accounts/mailo" tell Vim about it by

set editor = 'vim +"let g:muttquery_command=\"mutt_ldap.py --config \"$XDG_CONFIG_HOME/mutt-ldap/mailo.cfg\" %%s'


3. Related Plug-in:

The vim-mutt-aliases plug-in lets you complete e-mail addresses in Vim by those in your mutt alias file and (when the alias file is periodically populated by the mutt-alias.sh shell script) gives a more static alternative to this plug-in. (Best run by a, say weekly, (ana)cronjob.)

The plugin vim-notmuch-addrlookup lets you complete e-mail addresses in Vim by those indexed by notmuch.

==

This plug-in is developed at https://github.com/Konfekt/mutt-query-complete.vim
where issues can be filed.

 
install details
Unzip mutt-query-complete.vim.zip into  ~/.vim on Linux or or MacOS.
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
mutt-query-complete.vim.zip 1.0 2024-09-03 7.0 Enno Nagel ignition
ip used for rating: 3.236.112.101

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github