From: Eli Zaretskii Date: Sat, 25 Mar 2017 16:12:07 +0000 (+0300) Subject: Support in ispell.el multiple dictionaries loaded by Hunspell X-Git-Tag: emacs-26.0.90~522^2~41 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=501d07981ed1840ae72fe7dd599ab0b9f85b4a7f;p=emacs.git Support in ispell.el multiple dictionaries loaded by Hunspell * lisp/textmodes/ispell.el (ispell-find-hunspell-dictionaries): Support Hunspell configurations that load more than one dictionary by default. Doc fix. (Bug#25830) --- diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el index 9747bd6cc12..db733fe661b 100644 --- a/lisp/textmodes/ispell.el +++ b/lisp/textmodes/ispell.el @@ -1094,10 +1094,10 @@ in the list must have an affix file where Hunspell affix files are kept." (defun ispell-find-hunspell-dictionaries () "Look for installed Hunspell dictionaries. -Will initialize `ispell-hunspell-dictionary-alist' and -`ispell-hunspell-dictionary-alist' after values found -and remove `ispell-dicts-name2locale-equivs-alist' -entries if a specific dictionary was found." +Will initialize `ispell-hunspell-dictionary-alist' according +to dictionaries found, and will remove aliases from the list +in `ispell-dicts-name2locale-equivs-alist' if an explicit +dictionary from that list was found." (let ((hunspell-found-dicts (split-string (with-temp-buffer @@ -1110,18 +1110,27 @@ entries if a specific dictionary was found." "[\n\r]+" t)) hunspell-default-dict - hunspell-default-dict-entry) + hunspell-default-dict-entry + hunspell-multi-dict) (dolist (dict hunspell-found-dicts) (let* ((full-name (file-name-nondirectory dict)) (basename (file-name-sans-extension full-name)) (affix-file (concat dict ".aff"))) (if (string-match "\\.aff$" dict) ;; Found default dictionary - (if hunspell-default-dict - (error "ispell-fhd: Default dict already defined as %s. Not using %s.\n" - hunspell-default-dict dict) - (setq affix-file dict) - (setq hunspell-default-dict (list basename affix-file))) + (progn + (if hunspell-default-dict + (setq hunspell-multi-dict + (concat (or hunspell-multi-dict + (car hunspell-default-dict)) + "," basename)) + (setq affix-file dict) + ;; FIXME: The cdr of the list we cons below is never + ;; used. Why do we need a list? + (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)) ;; Entry has an associated .aff file and no previous value. @@ -1161,7 +1170,8 @@ entries if a specific dictionary was found." (cl-pushnew (list dict-equiv-key affix-file) ispell-hunspell-dict-paths-alist :test #'equal))))) ;; Parse and set values for default dictionary. - (setq hunspell-default-dict (car hunspell-default-dict)) + (setq hunspell-default-dict (or hunspell-multi-dict + (car hunspell-default-dict))) (setq hunspell-default-dict-entry (ispell-parse-hunspell-affix-file hunspell-default-dict)) ;; Create an alist of found dicts with only names, except for default dict.