Skip to content

Instantly share code, notes, and snippets.

@clochix
Created August 9, 2011 23:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save clochix/1135442 to your computer and use it in GitHub Desktop.
Save clochix/1135442 to your computer and use it in GitHub Desktop.
Detect spelllang when answering a message with mutt
# I usually get french and english emails, and would like to auto-detect the language
# to set the spellchecker when answering.
# (I use mutt and vim)
# In .muttrc:
set editor = 'bash ~/bin/spelledit.sh'
# and my ~/bin/spelledit.sh
vim + -c "setlocal spell spelllang=$([ `cat $1 | aspell -l en list | sort -u | wc -l` -lt `cat $1 | aspell -l fr list | sort -u | wc -l` ] && echo "en" || echo "fr") encoding=utf-8" $1
# Yes, this is dirty: I call aspell twice on the file,
# counting the number of bad words in french and english,
# and set spelllang to the lang with the less bad words
#
# Any suggestion welcome !
@Konfekt
Copy link

Konfekt commented Jun 2, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment