Code Monkey home page Code Monkey logo

vim-mutt-aliases's Introduction

Complete mutt aliases (listed in ~/.mutt/aliases) inside Vim; useful

  • when using Vim as editor for mutt (especially with $edit_headers set), and
  • even more so with the shell script mutt-alias.sh to populate the aliases file with recent e-mail addresses in your Inbox (or Sent folder).

Usage

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

    From: Lu Guanqun <[email protected]>
    To:   foo

and in your mutt aliases file there is an entry

    alias foo [email protected]

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

    From: Lu Guanqun <[email protected]>
    To:   [email protected]

Commands

The command :EditAliases opens the mutt aliases file in Vim. (For less typing, you can (command-line) alias it to ea by vim-alias)

To complete e-mail addresses press CTRL-X CTRL-U in insert mode. See :help i_CTRL-X_CTRL-U and :help compl-function.

Setup

Completion is enabled in all mail buffers by default. Add additional file types to the list g:muttaliases_filetypes which defaults to [ 'mail' ]. To enable completion in other buffers, run :MuttAliasesCompletion.

The mutt aliases file is automatically set to the value of the variable $alias_file used by mutt. To explicitly set the path to a mutt aliases file $file, add to your .vimrc the line

  let g:muttaliases_file = '$file'

For example, $file could be

  ~/.mutt/aliases

As a suggestion, if you use different mail accounts with different aliases, 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 the alias file by

set editor = 'vim +"let g:muttaliases_file=\"$XDG_CONFIG_HOME/mutt/accounts/mailo.aliases\"" %s'

Related:

  • To add aliases

  • The plugin mutt-query-complete.vim lets you complete e-mail addresses in Vim by the $query_command set up in Mutt

Credits

Forked from Lu Guanqun's vim-mutt-aliases-plugin.

License

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

vim-mutt-aliases's People

Contributors

konfekt avatar

Stargazers

Andreas Hallberg avatar Max Savchenko avatar Joseph Harriott avatar Phelipe Teles avatar

Watchers

James Cloos avatar  avatar

Forkers

macovsky

vim-mutt-aliases's Issues

ftdetect and filetype functions / commands: why not just global configuration?

First, thanks for working on this code which is quite useful.

Concerning the usage of ftdetect, I don't think that the usage is correct here. Normally, ftdetect/* files should be used to detect file types which are not detected by default. For example, see this file which tells how to detect the filetype pyrex which is not detected by default by Vim. The code written in ftdetect/muttaliases.vim doesn't do anything similar. Therefore, I think that this code should at least be moved from this file to ftplugin/mail.vim which would be loaded upon setting ft=mail which is done automatically by Vim when entering a mail file after begin launched by Mutt.

However, I don't think the any of the above or what is already in place is even best. I think that completion functionality should be available in all file types. I find it useful to complete mailing addresses in markdown files or other types of files. May be a combination of the two ideas could be used:

  • Automatic mail filetype setting should be used to trigger the configs;
  • Also, there should be a command (and/or a mapping) that one could use to enable mail completion in the current buffer through CTRL+X CTRL+U. Something like :MailCompleteOn.

What do you think?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.