shift or die

security. photography. foobar.

Language-dependant spellchecking within sup

As we all know, all mail clients suck. In the eternal search for the one that sucks the least, I have come across Sup. I tried it a while ago and it wouldn't import my mailbox, so I gave it up pretty quickly. Apparently, it has become better in that regard so that I now have a full-text searchable index over roughly 200.000 mails and am seriously considering moving away from mutt.

One feature that I like particularly is the extensibility by using Ruby code in so-called hooks. One quick hack I did tonight allows me to set the spellchecking language of my editor (vim) based on the language of the message I am replying to by using the whatlanguage gem. This code in ~/.sup/hooks/reply-from.rb replaces the spelllang parameter on the (default) vim commandline in the configuration:

require 'whatlanguage'

case message.quotable_body_lines.join("\n").language
when :german then
    $config[:editor].gsub!(/spelllang=[^']+'/, %q|spelllang=de_de'|)
else
    $config[:editor].gsub!(/spelllang=[^']+'/, %q|spelllang=en_us'|)
end

nil