Saturday July 08, 2006 at 17:24
Subject: vim Helper for mutt Aliases.
Keywords:
mutt, vim
Posted by: Sean Reifschneider
I use vim as my editor for messages I write using the mutt mail user
agent. I'm pretty happy with it in general, but I do have problems
remembering aliases. I was wishing for something that would allow me to
type an alias in and it would provide help with when I had correct aliases,
and expand them. I started off trying to make a completion thing, but most
of my aliases aren't the same as what they'd expand to. So, I built a
helper that expands correct aliases, and does nothing for incorrect ones.
This shows some of the flexibility of mutt with Python. In this, I
can set up aliases in my ~/.aliases file, and then just type an alias in
and hit the tab key to complete them. It only completes on To or Cc lines,
so it doesn't muck up tabs I might type elsewhere.
I've released this code and uploaded it to our FTP site at
ftp://ftp.tummy.com/pub/tummy/vim-mutt/
Included below is the README, for more information.
This code requires vim with Python extensions, and cooperates with mutt to
do tab completion of To and Cc aliases. It reads the ~/.aliases file, and
puts alias expansions into the message as you edit it.
To use, you will need to add the following to your ~/.vimrc:
(Post Reply)
autocmd BufRead,BufNewFile /tmp/mutt-* source $HOME/.vimrc-muttIn the ~/.vimrc-mutt, you will need copy the "vimrc-mutt" file from this package. You may also want to set any things you want dealt with specially when editing messages in mutt in here. Now, when you are on a line starting with 'To:' or 'Cc:' when editing a message in mutt, in the first 10 lines of the file, you can type an alias and hit "tab" and it will be expanded. For example, if you have in your ~/.aliases file:
alias alice Alice <alice@example.com> alias bob Bob <bob@example.com> alias group alice, bobYou can type "alice<Tab>" and it will expand to "Alice <alice@example.com>" or "group<Tab>" and it will expand to "alice, bob". Enjoy.
(Post Reply)
| Comment |
Josh Neal Subject: Excellent work! |
This is a wonderful helper for mutt.
On my system, alas, it didn't work quite out of the box. I needed to add:
import string, os, re, vimto the python beginning in order to import the modules correctly.
| Comment |
Dani Subject: Similar helper for Queries? |
This is a great helper.
I wonder if it is possible to extend it so that it also allows queries to external programs, such as abook. [See http://wiki.mutt.org/?action=history&id=MuttGuide/Aliases, section 'Query Command']
In any case, that's exactly what I was looking for. Thanks a lot to the developer.