Hunspell for Emacs in Debain
This post is written with e[ ⎋Esc
]m[ ⌥Meta
]a[ ⌥Alt
]c[ ^Ctrl
]s[ ⇧Shift
] org-mode.
System Environments
Operating Systems
- Main- : OS X Yosemite (10.10.3)
- Sub- : Debian GNU/Linux Wheezy (7.8)
- Server: Debian GNU/Linux Wheezy || Squeeze
- Mobile: iOS 7.1.2
Table of Contents
Hunspell and Emacs in Debian GNU/Linux
Debian GNU/Linux Wheezy doesn't have Hunspell preinstalled, but does GNU Emacs by all means. The version of the default emacs in the system is 23.4.1, which can be seen under Bash with emacs --version
. I have testified not only the default version of Emacs, but the manually compiled 24.3.2 version as well. The following will work for both.
Using hunsepll for GNU Emacs in Debian GNU/Linux is much simpler than that in OSX, because all needs can be easily installed and configured via Debian repositories, i.e. apt
. Here a English-Korean multilingual environment is taken as an example.
Additionally, dictionary-toggling in Emacs will be also at issue of this post.
Installation and configuration
- Get necessary packages: Open Bash, and run
$ sudo apt-get install hunspell hunspell-ko hunspell-en-us
- Check detailed information of Hunspell:
$ hunspell -D
Two most important things are a) being executable with the above command and b) dictionaries you installed. The later must be
en_US
andko_KR
. Information could be as similar as the screenshot of mine.Figure 1: Hunspell information in Debian 7.8
- Open the Emacs preference file, i.e.
~/.emacs
and add the followingelisp
code into it(setq ispell-local-dictionary-alist '( ("english-hunspell" "[A-Za-z]" "[^A-Za-z]" "[0-9a-zA-Z]" t ("-d" "en_US") nil utf-8) ("korean-hunspell" ;; "[가-힝]" "[^가-힝]" "[0-9a-zA-Z]" nil ;; <--- emacs 22 or lower "[가-힣]" "[^가-힣]" "[0-9a-zA-Z]" nil ;; <--- emacs 23 or higher ("-d" "ko_KR") nil utf-8) ;; ("german" ;; "[a-zäöüßA-ZÄÖÜ]" "[^a-zäöüßA-ZÄÖÜ]" "[']" t ;; ("-d" "de_DE") ;; nil utf-8) ) ) (setq ispell-program-name "hunspell" ispell-dictionary "english-hunspell") (setq ispell-really-hunspell t) ;; <--- optional??? working w/o it in emacs(cocoa)
FYI) If you wanna use a triple lingual environment such as German together, you can uncomment the last four sentences and modify a library.
Toggle two dictionaries
If you can change libraries with a single keyboard stroke, like C-\
for toggle-input-method
rather than type it after M-x
, it must then be great. I set the toggle for libraries by S-SPC
. And it works after adding the following into ~/.emacs
;; ;; ### korean-english (let ((langs '("korean-hunspell" "english-hunspell"))) (setq lang-ring (make-ring (length langs))) (dolist (elem langs) (ring-insert lang-ring elem))) (defun cycle-ispell-languages () (interactive) (let ((lang (ring-ref lang-ring -1))) (ring-insert lang-ring lang) (ispell-change-dictionary lang))) ;; ### key bindings (global-set-key (kbd "S-SPC") 'cycle-ispell-languages)
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
No comments:
Post a Comment