I have something in my configuration that may be of help. Since I write both in English and Italian, I want Flyspell to check the spelling for the current language of the buffer. So I like to see in the mode-line if Flyspell is set on the correct language, and I want to be able to change the language when I need.
This is what I have in my configuration:
(setq ispell-dictionary "en_GB"
ispell-program-name (executable-find "hunspell"))
(defun mu-current-dictionary-mode-line (language)
"Return the current dictionary from LANGUAGE for the mode line."
(interactive)
(let ((dict (substring language 0 2)))
(concat " FlyS:" dict)))
(defvar mu-languages-ring nil "Languages ring for Ispell")
(let ((languages '("it_IT" "en_GB")))
(setq mu-languages-ring (make-ring (length languages)))
(dolist (elem languages) (ring-insert mu-languages-ring elem)))
(defun mu-cycle-ispell-languages ()
"Cycle ispell languages in `mu-languages-ring'.
Change dictionary and mode-line lighter accordingly."
(interactive)
(let ((language (ring-ref mu-languages-ring -1)))
(ring-insert mu-languages-ring language)
(ispell-change-dictionary language)
(setq flyspell-mode-line-string (mu-current-dictionary-mode-line language))
(force-mode-line-update)))
(setq flyspell-mode-line-string (mu-current-dictionary-mode-line ispell-dictionary))
Now I see what the current spell-checker language is in the modeline and I can switch to the language I want with mu-cycle-ispell-languages
, with the mode-line lighter updated accordingly.
You can use only mu-current-dictionary-mode-line
with flyspell-mode-line-string
if you only need to display one language.
Note that I am using hunspell
as ispell-program-name
, your settings for ispell
may have to change if you use a different program. You will also need to check the value your spell-checker uses to identify the current language and understand if mu-current-dictionary-mode-line
needs to be changed.