3

Is it possible to detect and set the correct ispell language based on the contents of the buffer?

And beyond that: A markdown file can contain multiple human languages at the same time, perhaps Swedish in paragraphs but english in code sections, is it possible to use different dictionaries for different parts of the buffer?

1

2 Answers 2

3

As for the first question, there is a package guess-language that you can use. See also this post by Manuel Uberti http://manuel-uberti.github.io/emacs/2017/02/04/guess-language/

1

For multiple languages in the same buffer an option would be to use hunspell.

Based on rom Spell check with multiple dictionaries :

(eval-after-load "ispell"
  (defun myflyspell-multilingual-setup ()
    ;; POSSIBLE FIXES FOR MISSING DICTIONARIES FOR HUNSPELL:
    ;;   - zypper install myspell-de_DE
    ;; COULD NOT GET IT TO WORK ON WINDOWS
    (unless (eq system-type 'windows-nt)
      (condition-case err
          (progn
            (setq ispell-program-name "hunspell")
            (setq ispell-dictionary "en_US,de_DE")
            (let ((null-device (make-temp-file "nuldevice")))
              (ispell-set-spellchecker-params))
            (ispell-hunspell-add-multi-dic ispell-dictionary))
        ('error (warn "In myflyspell-multilingual-setup: %S" err))))))

Fun fact: The only other spell-checker that I've seen to be able to check multiple languages without explicitly switching is the one built into Chrome. No Office suite or offline Email client I know of has this ability, which is extremely annoying for a non-native English speaker regularly writing with international contacts.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.