Konfekt / vim-notmuch-addrlookup

complete e-mail addresses in Vim by those found in your Inbox or Sent (or any other mail) folder

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

This plug-in lets you complete e-mail addresses in Vim by those found in your inbox (or any other mail folder) via notmuch. Useful, for example, when using Vim as editor for mutt (especially with $edit_headers set).

The more recent plugin mutt-query-complete.vim lets you complete e-mail addresses in Vim by the more general $query_command set up in Mutt. It encompasses this plug-in by setting in your muttrc

    set query_command="notmuch-addrlookup --format=mutt '%s'"

and is therefore obsoleted.

Usage

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

    From: Fulano <Fulano@Silva.com>
    To:   foo

and in your Inbox there is an e-mail from

    Mister Foo <foo@bar.com>

and your cursor is right after foo, then hit Ctrl+X Ctrl+O to obtain:

    From: Fulano <Fulano@Silva.com>
    To:   Mister Foo <foo@bar.com>

Commands

To complete an e-mail address inside Vim press CTRL-X CTRL-O in insert mode. See :help i_CTRL-X_CTRL-O and :help compl-omni.

Installation

  1. Copy the folders of this repository into your Vim runtime path (~/.vim on Linux and macOS), and

  2. download and install (by make && sudo cp notmuch-addrlookup /usr/local/bin) notmuch-addrlookup. If you are missing superuser rights, then compile it (by make) and add the path of the folder that contains the obtained executable notmuch-addrlookup (say ~/bin) to your environment variable $PATH: If you use bash or zsh, by adding to ~/.profile or ~/.zshenv the line

        PATH=$PATH:~/bin

    If the executable notmuch-addrlookup is unavailable, but notmuch is, then notmuch address will be used instead; whose results are however less pertinent.

If you use vim-plug, then both steps can be achieved at once by pasting the following code snippet into your vimrc (between call plug#begin() and call plug#end()):

Plug 'Konfekt/vim-notmuch-addrlookup'

if !executable('notmuch-addrlookup')
  Plug 'aperezdc/notmuch-addrlookup-c', { 'do': 'make' }
  let $PATH .= expand(':~/.vim/plugged/notmuch-addrlookup-c')
endif
  1. Completion is enabled in all mail buffers by default. Add additional file types to the list g:notmuch_filetypes which defaults to [ 'mail' ]. To enable completion in other buffers, run :NotmuchCompletion.

  2. If you like to filter out most probably impersonal e-mail addresses such as those that come from mailer daemons or accept no reply, then try adding

    let g:notmuch_filter = 1

    to your vimrc, which will discard all e-mail addresses that satisfy the regular expression given by the variable g:notmuch_filter_regex that defaults to

      let g:notmuch_filter_regex = '\v^[[:alnum:]._%+-]*%([0-9]{9,}|([0-9]+[a-z]+){3,}|\+|nicht-?antworten|ne-?pas-?repondre|not?([-_.])?reply|<(un)?subscribe>|<MAILER\-DAEMON>)[[:alnum:]._%+-]*\@'

Related Plug-ins

  • The plug-ins vim-notmuch-address and vim-notmuch-addresses achieve the same, but use notmuch address exclusively.
  • The plugin mutt-query-complete.vim lets you complete e-mail addresses in Vim by the $query_command set up in Mutt
  • 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.

Credits

License

Distributable under the same terms as Vim itself. See :help license.

About

complete e-mail addresses in Vim by those found in your Inbox or Sent (or any other mail) folder


Languages

Language:Vim Script 100.0%