;;; -*- lexical-binding: t -*- ;; ;; OpenBSD: ;; In the ispell packge, amazingly, there is no "english"; ;; instead use "american" (don't use "british" which is also provided) ;; ;; Debian bug: ;; ispell-init-process: Illegal format hash table ;; /usr/lib/ispell/svenska.hash - expected magic2 0x9602, got 0x414c ;; $ sudo buildhash /usr/share/dict/svenska \ ;; /usr/lib/ispell/svenska.aff \ ;; /usr/lib/ispell/svenska.hash ;; ;; user-local supplemental lists: ;; ~/.ispell_american-insane ;; ~/.ispell_svenska ;; ;; -------------------------------------------------------------------------- (require 'luki-lisp) ;; -------------------------------------------------------------------------- (-> 'll-dwim) (-> 'ispell) ;; -------------------------------------------------------------------------- (when (eq system-type 'gnu/linux) (load-file "/usr/share/dictionaries-common/site-elisp/debian-ispell.el") (load-file "/var/cache/dictionaries-common/emacsen-ispell-dicts.el")) ;; -------------------------------------------------------------------------- (setq ispell-program-name "ispell") (setq ispell-silently-savep t) ;; -------------------------------------------------------------------------- ;; single word (defun spell-word-2 (word) (& (ispell-lookup-words word) t)) ;; (spell-word-2 "length") ; t ;; (spell-word-2 "lenght") ; nil (defun spell-word (word) (with-temp-buffer (save-excursion (insert word)) (condition-case nil (! (ispell-word)) (error nil)))) ;; (spell-word "length") ; t ;; (spell-word "lenght") ; nil ;; -------------------------------------------------------------------------- ;; word (defun spell-this-word (dict) "`ispell-word' the word with DICT." (ispell-change-dictionary dict) (ispell-word)) (let ((eng-dict "american")) (defun spell-english () (i) (spell eng-dict)) (defun word () (i) (spell-this-word eng-dict))) ;; test: hello / hxlle (let ((swe-dict "svenska")) (defun spell-swedish () (i) (spell swe-dict)) (defun ord () (i) (spell-this-word swe-dict))) ;; test: hej / hxj (declare-function spell-english nil) (declare-function word nil) (declare-function spell-swedish nil) (declare-function ord nil) ;; -------------------------------------------------------------------------- ;; buffer (defun is-code () (member major-mode '(c++-mode c-mode emacs-lisp-mode python-mode sh-mode Shell-script-mode))) ; add (defun spell (dict) "Spell with DICT. If region is active, use `ispell-region'; if editing code, `ispell-comments-and-strings'; if writing a message, `ispell-message'; else, `ispell-buffer'" (ispell-change-dictionary dict) (save-window-excursion (save-mark-and-excursion (cond ((use-region-p) (ispell-region (region-beginning) (region-end))) ((eq major-mode 'message-mode) (ispell-message)) ((is-code) (ispell-comments-and-strings)) ((ispell-buffer)))))) ;; -------------------------------------------------------------------------- (<- 'll-spell)