Mutt+aspell hint

Archaic archaic at
Thu May 22 11:51:38 PDT 2003


"Guard with jealous attention the public liberty.  Suspect every one who
approaches that jewel.  Unfortunately, nothing will preserve it but
downright force.  Whenever you give up that force, you are inevitably

- Patrick Henry, speech of June 5 1788

-------------- next part --------------
TITLE:		Using Aspell in Mutt
AUTHOR:		Archaic <archaic at>

	Multiple ways of setting up Mutt and/or Vim to use Aspell.

	This hint will be split into two parts. The first part will be
configuring Vim to spell check, the other will be for Mutt alone.

You do not need to do both, but it won't hurt if you do. You will just
have many different ways of spell-checking.

1) Setting up Vim to use Aspell.

Install aspell as per the BLFS book:

edit your vimrc to include:

map ^T :w!<CR>:!aspell check %<CR>:e! %<CR>

NOTE: ^T is <ctrl-t>, but in Vim you have to type <ctrl-v> to type
control characters. Thus you need to replace ^T with <ctrl-v><ctrl-t>

Once you save your vimrc, any time you are in Vim's command mode, typing
<ctrl-t> will cause the screen to split showing the aspell commands at
the bottom.

If you use Vim as your editor in Mutt, you're all set to spell-check.

But wait! There's more!

If you are replying to an email and you hit <ctrl-t> aspell will attempt
to spell-check the headers, signature, and all the quoted lines in
addition to what you actually wrote. There is a nifty little app called
newsbody that will allow us to copy just the body of the message to a
temporary file, edit it (spell-check it), then put it back into the
original message, leaving headers and sigs alone. It also allows us to
ignore quoted lines.

You can get newsbody in a package called spellutils (current version is
4.7) here:

./configure &&
make &&
install -m755 newsbody /usr/bin
install -m644 newsbody.1 /usr/share/man/man1

NOTE: spellutils also builds a file pospell if you're interested in
spell-checking .po files.

Now that newsbody is installed add the following lines to your vimrc:
map ^R \1\2<CR>:e! %<CR>
map \1 :w!<CR>
map \2 :!newsbody -qs -n % -p aspell check \%f<CR>

These lines simply let you run aspell without having to check the sig,
headers, or quoted text. Treat ^R the same as ^T above. You can also
change the letter to suit your needs.

Now you have a way to spell-check regular documents and emails with
either <ctrl-t> or <ctrl-r>. You can stop here, or optionally continue
on. There is no added functionality below. Just a different way of doing
the same thing.

2) Setting up Mutt to use Aspell

NOTE: I use Vim in mutt but the following should work on your editor of
choice as these are mutt-specific, not editor-specific.

The default command to spell-check in Mutt is "i". There are 2 ways in
which to invoke newsbody and aspell in mutt. We can either call a simple
script, or we can write a macro. I will discuss both.

Script method:

cat >/usr/bin/spellcheck <<"EOF"
newsbody -hqs -n $2 -p aspell check %f
chmod 755 /usr/bin/spellcheck

add the following to your muttrc:

set ispell="/usr/bin/spellcheck"


Macro method:

add the following to your muttrc:

macro compose i \
        "<filter-entry>newsbody -hqs -n - -p aspell check %f<enter>" \
        "run aspell on the selected part"

I hope you've found this useful. Please email any suggestions or
corrections to the above address. Remove the "remvoe-this." from my

More information about the hints mailing list