Commit a8097641 authored by Richard M. Stallman's avatar Richard M. Stallman

(ispell-local-dictionary-overridden): Fix the

make-variable-buffer-local call that was supposed to be for this variable.
(ispell-aspell-supports-utf8): Doc fix.
(ispell-find-aspell-dictionaries): Preserve elements of
ispell-dictionary-alist for dictionaries that aspell doesn't report.
(ispell-aspell-find-dictionary): Return nil on error.
parent a8bccd82
...@@ -445,7 +445,7 @@ where DICTNAME is the name of your default dictionary." ...@@ -445,7 +445,7 @@ where DICTNAME is the name of your default dictionary."
(defvar ispell-local-dictionary-overridden nil (defvar ispell-local-dictionary-overridden nil
"Non-nil means the user has explicitly set this buffer's Ispell dictionary.") "Non-nil means the user has explicitly set this buffer's Ispell dictionary.")
(make-variable-buffer-local 'ispell-local-dictionary) (make-variable-buffer-local 'ispell-local-dictionary-overridden)
(defcustom ispell-local-dictionary nil (defcustom ispell-local-dictionary nil
"If non-nil, the dictionary to be used for Ispell commands in this buffer. "If non-nil, the dictionary to be used for Ispell commands in this buffer.
...@@ -721,7 +721,7 @@ LANGUAGE.aff file \(e.g., english.aff\).") ...@@ -721,7 +721,7 @@ LANGUAGE.aff file \(e.g., english.aff\).")
(defvar ispell-aspell-supports-utf8 nil (defvar ispell-aspell-supports-utf8 nil
"Non-nil means to try to automatically find aspell dictionaries. "Non-nil means to try to automatically find aspell dictionaries.
This is set to t in ispell-check-version for aspell >= 0.60. This is set to t in `ispell-check-version' for aspell >= 0.60.
Earlier aspell versions do not consistently support UTF-8. Handling Earlier aspell versions do not consistently support UTF-8. Handling
this would require some extra guessing in `ispell-aspell-find-dictionary'.") this would require some extra guessing in `ispell-aspell-find-dictionary'.")
...@@ -894,13 +894,22 @@ and added as a submenu of the \"Edit\" menu.") ...@@ -894,13 +894,22 @@ and added as a submenu of the \"Edit\" menu.")
"Find Aspell's dictionaries, and record in `ispell-dictionary-alist'." "Find Aspell's dictionaries, and record in `ispell-dictionary-alist'."
(unless ispell-really-aspell (unless ispell-really-aspell
(error "This function only works with aspell")) (error "This function only works with aspell"))
(let ((dictionaries (let* ((dictionaries
(split-string (split-string
(with-temp-buffer (with-temp-buffer
(call-process ispell-program-name nil t nil "dicts") (call-process ispell-program-name nil t nil "dicts")
(buffer-string))))) (buffer-string))))
(setq ispell-dictionary-alist ;; Search for the named dictionaries.
(mapcar #'ispell-aspell-find-dictionary dictionaries)) (found
(delq nil
(mapcar #'ispell-aspell-find-dictionary dictionaries))))
;; Merge into FOUND any elements from the standard ispell-dictionary-alist
;; which have no element in FOUND at all.
(dolist (dict ispell-dictionary-alist)
(unless (assoc (car dict) found)
(setq found (nconc found (list dict)))))
(setq ispell-dictionary-alist found)
(ispell-aspell-add-aliases) (ispell-aspell-add-aliases)
;; Add a default entry ;; Add a default entry
(let* ((english-dict (assoc "en" ispell-dictionary-alist)) (let* ((english-dict (assoc "en" ispell-dictionary-alist))
...@@ -922,6 +931,9 @@ Assumes that value contains no whitespace." ...@@ -922,6 +931,9 @@ Assumes that value contains no whitespace."
(car (split-string (buffer-string))))) (car (split-string (buffer-string)))))
(defun ispell-aspell-find-dictionary (dict-name) (defun ispell-aspell-find-dictionary (dict-name)
;; This returns nil if the data file does not exist.
;; Can someone please explain the return value format when the
;; file does exist -- rms?
(let* ((lang ;; Strip out region, variant, etc. (let* ((lang ;; Strip out region, variant, etc.
(and (string-match "^[[:alpha:]]+" dict-name) (and (string-match "^[[:alpha:]]+" dict-name)
(match-string 0 dict-name))) (match-string 0 dict-name)))
...@@ -931,35 +943,37 @@ Assumes that value contains no whitespace." ...@@ -931,35 +943,37 @@ Assumes that value contains no whitespace."
(ispell-get-aspell-config-value "data-dir"))) (ispell-get-aspell-config-value "data-dir")))
"/" lang ".dat")) "/" lang ".dat"))
otherchars) otherchars)
;; This file really should exist; there is no sensible recovery. (condition-case ()
(with-temp-buffer (with-temp-buffer
(insert-file-contents data-file) (insert-file-contents data-file)
;; There is zero or one line with special characters declarations. ;; There is zero or one line with special characters declarations.
(when (search-forward-regexp "^special" nil t) (when (search-forward-regexp "^special" nil t)
(let ((specials (split-string (let ((specials (split-string
(buffer-substring (point) (buffer-substring (point)
(progn (end-of-line) (point)))))) (progn (end-of-line) (point))))))
;; The line looks like: special ' -** - -** . -** : -*- ;; The line looks like: special ' -** - -** . -** : -*-
;; -** means that this character ;; -** means that this character
;; - doesn't appear at word start ;; - doesn't appear at word start
;; * may appear in the middle of a word ;; * may appear in the middle of a word
;; * may appear at word end ;; * may appear at word end
;; `otherchars' is about the middle case. ;; `otherchars' is about the middle case.
(while specials (while specials
(when (eq (aref (cadr specials) 1) ?*) (when (eq (aref (cadr specials) 1) ?*)
(push (car specials) otherchars)) (push (car specials) otherchars))
(setq specials (cddr specials)))))) (setq specials (cddr specials)))))
(list dict-name (list dict-name
"[[:alpha:]]" "[[:alpha:]]"
"[^[:alpha:]]" "[^[:alpha:]]"
(regexp-opt otherchars) (regexp-opt otherchars)
t ; We can't tell, so set this to t t ; We can't tell, so set this to t
(list "-d" dict-name "--encoding=utf-8") (list "-d" dict-name "--encoding=utf-8")
nil ; aspell doesn't support this nil ; aspell doesn't support this
;; Here we specify the encoding to use while communicating with ;; Here we specify the encoding to use while communicating with
;; aspell. This doesn't apply to command line arguments, so ;; aspell. This doesn't apply to command line arguments, so
;; just don't pass words to spellcheck as arguments... ;; just don't pass words to spellcheck as arguments...
'utf-8))) 'utf-8))
(file-error
nil))))
(defun ispell-aspell-add-aliases () (defun ispell-aspell-add-aliases ()
"Find aspell's dictionary aliases and add them to `ispell-dictionary-alist'." "Find aspell's dictionary aliases and add them to `ispell-dictionary-alist'."
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment