Evaluating in the scratch buffer:
(setq ispell-program-name "hunspell")
"hunspell"
(require 'ispell)
ispell
(ispell-find-hunspell-dictionaries)
Causes this error:
Debugger entered--Lisp error: (wrong-type-argument stringp nil)
string-match("," nil 0)
split-string(nil "," t)
(let ((dict-list (split-string dict-key "," t)) (first-p t) (dict-arg "") otherchars-list) (let ((--dolist-tail-- dict-list)) (while --dolist-tail-- (let ((dict-key (car --dolist-tail--))) (let ((affix-file (car (cdr (assoc dict-key ispell-hunspell-dict-paths-alist))))) (if affix-file nil (error "ispell-phaf: No matching entry for %s in `ispell-hunspell-dict-paths-alist'.\n" dict-key)) (if (and first-p (not (file-exists-p affix-file))) (error "ispell-phaf: File \"%s\" not found.\n" affix-file)) (and first-p (setq first-p nil)) (let ((dict-name (file-name-sans-extension (file-name-nondirectory affix-file))) otherchars-string) (let ((temp-buffer (generate-new-buffer " *temp*"))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (insert-file-contents affix-file) (setq otherchars-string (save-excursion (goto-char (point-min)) (if (search-forward-regexp "^WORDCHARS +" nil t) (buffer-substring (point) (progn (end-of-line) (point)))))) (if otherchars-string (let* ((otherchars-string (substring otherchars-string 0 (string-match " +" otherchars-string))) (chars-list (append otherchars-string nil))) (setq chars-list (delq 32 chars-list)) (let ((--dolist-tail-- chars-list)) (while --dolist-tail-- (let ((ch (car --dolist-tail--))) (setq otherchars-list (if (member ch otherchars-list) otherchars-list (cons ch otherchars-list))) (setq --dolist-tail-- (cdr --dolist-tail--)))))))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer))))) (setq dict-arg (concat dict-arg (if (> (length dict-arg) 0) ",") dict-name)))) (setq --dolist-tail-- (cdr --dolist-tail--))))) (list dict-key "[[:alpha:]]" "[^[:alpha:]]" (if otherchars-list (regexp-opt (mapcar (function char-to-string) otherchars-list)) "") t (list "-d" dict-arg) nil 'utf-8))
ispell-parse-hunspell-affix-file(nil)
(setq hunspell-default-dict-entry (ispell-parse-hunspell-affix-file hunspell-default-dict))
(let ((hunspell-found-dicts (split-string (let ((temp-buffer (generate-new-buffer " *temp*"))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (ispell-call-process ispell-program-name null-device t nil "-D") (buffer-string)) (and (buffer-name temp-buffer) (kill-buffer temp-buffer))))) "[\n\015]+" t)) hunspell-default-dict hunspell-default-dict-entry hunspell-multi-dict) (let ((--dolist-tail-- hunspell-found-dicts)) (while --dolist-tail-- (let ((dict (car --dolist-tail--))) (let* ((full-name (file-name-nondirectory dict)) (basename (file-name-sans-extension full-name)) (affix-file (concat dict ".aff"))) (if (string-match "\\.aff$" dict) (progn (if hunspell-default-dict (setq hunspell-multi-dict (concat (or hunspell-multi-dict (car hunspell-default-dict)) "," basename)) (setq affix-file dict) (setq hunspell-default-dict (list basename affix-file))) (ispell-print-if-debug "++ ispell-fhd: default dict-entry:%s name:%s basename:%s\n" dict full-name basename)) (if (and (not (assoc basename ispell-hunspell-dict-paths-alist)) (file-exists-p affix-file)) (let ((affix-file (expand-file-name affix-file))) (ispell-print-if-debug "++ ispell-fhd: dict-entry:%s name:%s basename:%s affix-file:%s\n" dict full-name basename affix-file) (setq ispell-hunspell-dict-paths-alist (let* ((va (list basename affix-file))) (if (member va ispell-hunspell-dict-paths-alist) ispell-hunspell-dict-paths-alist (cons va ispell-hunspell-dict-paths-alist))))) (ispell-print-if-debug "-- ispell-fhd: Skipping entry: %s\n" dict)))) (setq --dolist-tail-- (cdr --dolist-tail--))))) (let (newlist) (let ((--dolist-tail-- ispell-dicts-name2locale-equivs-alist)) (while --dolist-tail-- (let ((dict (car --dolist-tail--))) (if (assoc (car dict) ispell-hunspell-dict-paths-alist) (ispell-print-if-debug "-- ispell-fhd: Excluding %s alias. Standalone dict found.\n" (car dict)) (setq newlist (if (member dict newlist) newlist (cons dict newlist)))) (setq --dolist-tail-- (cdr --dolist-tail--))))) (setq ispell-dicts-name2locale-equivs-alist newlist)) (let ((--dolist-tail-- ispell-dicts-name2locale-equivs-alist)) (while --dolist-tail-- (let ((dict-equiv (car --dolist-tail--))) (let ((dict-equiv-key (car dict-equiv)) (dict-equiv-value (car (cdr dict-equiv))) (exclude-aliases (list "esperanto-tex" "francais7" "francais-tex" "norsk7-tex"))) (if (and (assoc dict-equiv-value ispell-hunspell-dict-paths-alist) (not (assoc dict-equiv-key ispell-hunspell-dict-paths-alist)) (not (member dict-equiv-key exclude-aliases))) (let ((affix-file (car (cdr (assoc dict-equiv-value ispell-hunspell-dict-paths-alist))))) (ispell-print-if-debug "++ ispell-fhd: Adding alias %s -> %s.\n" dict-equiv-key affix-file) (setq ispell-hunspell-dict-paths-alist (let* ((va (list dict-equiv-key affix-file))) (if (member va ispell-hunspell-dict-paths-alist) ispell-hunspell-dict-paths-alist (cons va ispell-hunspell-dict-paths-alist))))))) (setq --dolist-tail-- (cdr --dolist-tail--))))) (setq hunspell-default-dict (or ispell-dictionary hunspell-multi-dict (car hunspell-default-dict))) (setq hunspell-default-dict-entry (ispell-parse-hunspell-affix-file hunspell-default-dict)) (setq ispell-hunspell-dictionary-alist (list (cons nil (cdr hunspell-default-dict-entry)))) (let ((--dolist-tail-- (mapcar (function car) ispell-hunspell-dict-paths-alist))) (while --dolist-tail-- (let ((dict (car --dolist-tail--))) (setq ispell-hunspell-dictionary-alist (let* ((va (if (string= dict hunspell-default-dict) hunspell-default-dict-entry (list dict)))) (if (member va ispell-hunspell-dictionary-alist) ispell-hunspell-dictionary-alist (cons va ispell-hunspell-dictionary-alist)))) (setq --dolist-tail-- (cdr --dolist-tail--))))))
ispell-find-hunspell-dictionaries()
eval((ispell-find-hunspell-dictionaries) nil)
elisp--eval-last-sexp(t)
eval-last-sexp(t)
eval-print-last-sexp(nil)
funcall-interactively(eval-print-last-sexp nil)
call-interactively(eval-print-last-sexp nil nil)
command-execute(eval-print-last-sexp)
The output of hunspell -D is:
SEARCH PATH:
.::/home/gregor/.config/libreoffice/4/user/wordbook::/usr/share/hunspell:/usr/share/myspell:/usr/share/myspell/dicts:/Library/Spelling:/home/gregor/.
openoffice.org/3/user/wordbook:/home/gregor/.openoffice.org2/user/wordbook:/home/gregor/.openoffice.org2.0/user/wordbook:/home/gregor/Library/Spelling:/opt/openoffice.org/basis3.0/share/dict/ooo:/usr/lib/openoffice.org/basis3.0/share/dict/ooo:/opt/openoffice.org2.4/share/dict/ooo:/usr/lib/openoffice.org2.4/share/dict/ooo:/opt/openoffice.org2.3/share/dict/ooo:/usr/lib/openoffice.org2.3/share/dict/ooo:/opt/openoffice.org2.2/share/dict/ooo:/usr/lib/openoffice.org2.2/share/dict/ooo:/opt/openoffice.org2.1/share/dict/ooo:/usr/lib/openoffice.org2.1/share/dict/ooo:/opt/openoffice.org2.0/share/dict/ooo:/usr/lib/openoffice.org2.0/share/dict/oooAVAILABLE DICTIONARIES (path is not mandatory for -d option):
/home/gregor/.config/libreoffice/4/user/wordbook/standard
/usr/share/hunspell/en_PH
/usr/share/hunspell/en_US-large
/usr/share/hunspell/en_US
/usr/share/myspell/dicts/en_PH
/usr/share/myspell/dicts/en_US-large
/usr/share/myspell/dicts/en_US
/home/gregor/Library/Spelling/en_GB
/home/gregor/Library/Spelling/sl_SI
Which causes the error since none of the listed dictionary files ends in
.aff, which causes the hunspell-default-dict to be nil on line 1179 in
ispell.el, which causes the error in the next sexp. The consequences of
this error are that spell checking does not work with hunspell and it is
not possible to set a dictionary via ispell-change-dictionary.
The quick and dirty fix of changing the line to
(setq hunspell-default-dict (or "british"
hunspell-multi-dict
(car hunspell-default-dict)))
(added "british" to the or) the problem goes away, and spell checking works
as expected.