--- ispell.el.orig 2006-09-14 14:59:04.000000000 +0200 +++ ispell.el 2006-10-04 11:08:08.000000000 +0200 @@ -659,11 +659,11 @@ ;;;###autoload -(defvar ispell-dictionary-alist +(defvar ispell-base-dictionary-alist (append ispell-dictionary-alist-1 ispell-dictionary-alist-2 ispell-dictionary-alist-3 ispell-dictionary-alist-4 ispell-dictionary-alist-5 ispell-dictionary-alist-6) - "An alist of dictionaries and their associated parameters. + "Base alist of dictionaries and their associated parameters. Each element of this list is also a list: @@ -716,6 +716,14 @@ contain the same character set as casechars and otherchars in the LANGUAGE.aff file \(e.g., english.aff\).") +;;;###autoload +(defvar ispell-dictionary-alist ispell-base-dictionary-alist + "Runtime alist of dictionaries and their associated parameters. +This alist will be modified to match current spellchecker.") + +(defvar ispell-aspell-dictionary-alist nil + "Parsed alist of aspell dicts and their associated parameters.") + (defvar ispell-really-aspell nil) ; Non-nil if aspell extensions should be used (defvar ispell-aspell-supports-utf8 nil @@ -725,8 +733,6 @@ Earlier aspell versions do not consistently support UTF-8. Handling this would require some extra guessing in `ispell-aspell-find-dictionary'.") - - ;;; ********************************************************************** ;;; The following are used by ispell, and should not be changed. ;;; ********************************************************************** @@ -876,18 +882,29 @@ ;; Make ispell.el work better with aspell. -(defvar ispell-have-aspell-dictionaries nil - "Non-nil if we have queried Aspell for dictionaries at least once.") +(defvar ispell-last-program-name nil + "`ispell-program-name' value used in last spellchecking command.") -(defun ispell-maybe-find-aspell-dictionaries () - "Find Aspell's dictionaries, unless already done." - (when (and (not ispell-have-aspell-dictionaries) - (condition-case () - (progn (ispell-check-version) t) +(defun ispell-initialize-program-params ( &optional force ) + "Set right alist of dict params for current spellchecker. +This will be run if not yet done or `ispell-program-name' is +changed. FORCE will run this unconditionally" + (when (or (not (eq ispell-last-program-name ispell-program-name)) + force) + (ispell-kill-ispell t) + (if (and (condition-case () + (progn + (setq ispell-library-directory (ispell-check-version)) + t) (error nil)) ispell-really-aspell ispell-aspell-supports-utf8) - (ispell-find-aspell-dictionaries))) + (progn + (if (not ispell-aspell-dictionary-alist) + (ispell-find-aspell-dictionaries)) + (setq ispell-dictionary-alist ispell-aspell-dictionary-alist)) + (setq ispell-dictionary-alist ispell-base-dictionary-alist)) + (setq ispell-last-program-name ispell-program-name))) (defun ispell-find-aspell-dictionaries () "Find Aspell's dictionaries, and record in `ispell-dictionary-alist'." @@ -907,17 +924,16 @@ (setq found (ispell-aspell-add-aliases found)) ;; Merge into FOUND any elements from the standard ispell-dictionary-alist ;; which have no element in FOUND at all. - (dolist (dict ispell-dictionary-alist) + (dolist (dict ispell-base-dictionary-alist) (unless (assoc (car dict) found) (setq found (nconc found (list dict))))) - (setq ispell-dictionary-alist found) + (setq ispell-aspell-dictionary-alist found) ;; Add a default entry - (let* ((english-dict (assoc "en" ispell-dictionary-alist)) + (let* ((english-dict (assoc "en" ispell-aspell-dictionary-alist)) (default-dict (cons nil (or (cdr english-dict) (cdr (car ispell-dictionary-alist-1)))))) - (push default-dict ispell-dictionary-alist)) - (setq ispell-have-aspell-dictionaries t))) + (push default-dict ispell-aspell-dictionary-alist)))) (defvar ispell-aspell-data-dir nil "Data directory of Aspell.") @@ -1002,8 +1018,8 @@ (defun ispell-valid-dictionary-list () "Returns a list of valid dictionaries. The variable `ispell-library-directory' defines the library location." - ;; If Ispell is really Aspell, query it for the dictionary list. - (ispell-maybe-find-aspell-dictionaries) + ;; Make sure ispell program is initialized (right dicts lists, paths, ...) + (ispell-initialize-program-params) (let ((dicts (append ispell-local-dictionary-alist ispell-dictionary-alist)) (dict-list (cons "default" nil)) name load-dict) @@ -1582,7 +1598,7 @@ (interactive (list ispell-following-word ispell-quietly current-prefix-arg)) (if continue (ispell-continue) - (ispell-maybe-find-aspell-dictionaries) + (ispell-initialize-program-params) (ispell-accept-buffer-local-defs) ; use the correct dictionary (let ((cursor-location (point)) ; retain cursor location (word (ispell-get-word following)) @@ -2600,6 +2616,7 @@ Without a prefix arg, set it \"locally\", just for this buffer. By just answering RET you can find out what the current dictionary is." + (ispell-initialize-program-params) (interactive (list (completing-read "Use new dictionary (RET for current, SPC to complete): " @@ -2656,7 +2673,7 @@ Return nil if spell session is quit, otherwise returns shift offset amount for last line processed." (interactive "r") ; Don't flag errors on read-only bufs. - (ispell-maybe-find-aspell-dictionaries) + (ispell-initialize-program-params) (if (not recheckp) (ispell-accept-buffer-local-defs)) ; set up dictionary, local words, etc. (let ((skip-region-start (make-marker))