Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I spell check for multiple languages in emacs?

Tags:

emacs

ispell

I write mostly my documentation in HTML using emacs as my main editor. Emacs let you interactively spell-check the current buffer with the command ispell-buffer.

Since I switch between a number of languages, I have an HTML comment at the end of the file specifying the main dictionary and personal dictionary for that file, E.g. for Norwegian (norsk) I use the following pair of dictionaries:

<!-- Local IspellDict: norsk -->
<!-- Local IspellPersDict: ~/.aspell/personal.dict -->

This works great.

However, sometimes I have a paragraph in another language (e.g. English) embedded in an otherwise Norwegian document. Example:

<p xml:lang="en">This paragraph is in English.</p>

The spell-checker naturally flag all the words in such a paragraph as misspellings (since the dictionary only contain Norwegian words).

To avoid this, I've tried to add a "british" dictionary to the document, like this:

<!-- Local IspellDict: british -->
<!-- Local IspellDict: norsk -->
<!-- Local IspellPersDict: ~/.aspell/personal.dict -->

Unfortunately, this does not work. The "british" dictionary is simply ignored.

My prefered solution would to load an additional dictionary and use this, toghether with the primary dictionary, for spell-checking. Is this possible?

However, I am also interested in a solution that let me mark paragraphs for not being spell checked. It is not ideal, but it would stop valid English words from being flagged as misspellings.

PS: I have also looked at the answer to this question: Multilingual spell checking with language detection, but it is much broader and does not address the specific use emacs ispell for doing the spell-check.

like image 982
Free Radical Avatar asked Jun 02 '13 10:06

Free Radical


People also ask

How do I spell check in Emacs?

The basic way to do it is to run M-x ispell-change-dictionary , then hit return, then type the name of the dictionary that you want to use.

How to use flyspell?

Flyspell mode is a minor mode that performs automatic spell-checking of the text you type as you type it. When it finds a word that it does not recognize, it highlights that word. Type M-x flyspell-mode to toggle Flyspell mode in the current buffer.

How do I spell check in Vim?

If you want to turn it on, run setlocal spell in the Vim command line (if you want spell check to always be on, add set spell to your . vimrc). After turning spell check on, misspelled words will now be highlighted. To move your cursor to the next misspelled word, enter ]s .


1 Answers

Try ispell-multi and flyspell-xml-lang http://www.dur.ac.uk/p.j.heslin/Software/Emacs/

You can spawn multiple instances of ispell, and use the xml:lang tag to decide which language to check for.

like image 90
grm Avatar answered Nov 15 '22 18:11

grm