aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman2005-10-23 18:22:06 +0000
committerRichard M. Stallman2005-10-23 18:22:06 +0000
commita8097641a57645192b24da8b6f695cac9ab5dbac (patch)
tree7a100a3b515d1923e8d8513ed3295028f53f19bc
parenta8bccd82cf55cae764952265c39c41411daf82c1 (diff)
downloademacs-a8097641a57645192b24da8b6f695cac9ab5dbac.tar.gz
emacs-a8097641a57645192b24da8b6f695cac9ab5dbac.zip
(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.
-rw-r--r--lisp/textmodes/ispell.el90
1 files changed, 52 insertions, 38 deletions
diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el
index 95a3cce5144..7c438b4269e 100644
--- a/lisp/textmodes/ispell.el
+++ b/lisp/textmodes/ispell.el
@@ -445,7 +445,7 @@ where DICTNAME is the name of your default dictionary."
445 445
446(defvar ispell-local-dictionary-overridden nil 446(defvar ispell-local-dictionary-overridden nil
447 "Non-nil means the user has explicitly set this buffer's Ispell dictionary.") 447 "Non-nil means the user has explicitly set this buffer's Ispell dictionary.")
448(make-variable-buffer-local 'ispell-local-dictionary) 448(make-variable-buffer-local 'ispell-local-dictionary-overridden)
449 449
450(defcustom ispell-local-dictionary nil 450(defcustom ispell-local-dictionary nil
451 "If non-nil, the dictionary to be used for Ispell commands in this buffer. 451 "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 721
722(defvar ispell-aspell-supports-utf8 nil 722(defvar ispell-aspell-supports-utf8 nil
723 "Non-nil means to try to automatically find aspell dictionaries. 723 "Non-nil means to try to automatically find aspell dictionaries.
724This is set to t in ispell-check-version for aspell >= 0.60. 724This is set to t in `ispell-check-version' for aspell >= 0.60.
725 725
726Earlier aspell versions do not consistently support UTF-8. Handling 726Earlier aspell versions do not consistently support UTF-8. Handling
727this would require some extra guessing in `ispell-aspell-find-dictionary'.") 727this would require some extra guessing in `ispell-aspell-find-dictionary'.")
@@ -894,13 +894,22 @@ and added as a submenu of the \"Edit\" menu.")
894 "Find Aspell's dictionaries, and record in `ispell-dictionary-alist'." 894 "Find Aspell's dictionaries, and record in `ispell-dictionary-alist'."
895 (unless ispell-really-aspell 895 (unless ispell-really-aspell
896 (error "This function only works with aspell")) 896 (error "This function only works with aspell"))
897 (let ((dictionaries 897 (let* ((dictionaries
898 (split-string 898 (split-string
899 (with-temp-buffer 899 (with-temp-buffer
900 (call-process ispell-program-name nil t nil "dicts") 900 (call-process ispell-program-name nil t nil "dicts")
901 (buffer-string))))) 901 (buffer-string))))
902 (setq ispell-dictionary-alist 902 ;; Search for the named dictionaries.
903 (mapcar #'ispell-aspell-find-dictionary dictionaries)) 903 (found
904 (delq nil
905 (mapcar #'ispell-aspell-find-dictionary dictionaries))))
906 ;; Merge into FOUND any elements from the standard ispell-dictionary-alist
907 ;; which have no element in FOUND at all.
908 (dolist (dict ispell-dictionary-alist)
909 (unless (assoc (car dict) found)
910 (setq found (nconc found (list dict)))))
911 (setq ispell-dictionary-alist found)
912
904 (ispell-aspell-add-aliases) 913 (ispell-aspell-add-aliases)
905 ;; Add a default entry 914 ;; Add a default entry
906 (let* ((english-dict (assoc "en" ispell-dictionary-alist)) 915 (let* ((english-dict (assoc "en" ispell-dictionary-alist))
@@ -922,6 +931,9 @@ Assumes that value contains no whitespace."
922 (car (split-string (buffer-string))))) 931 (car (split-string (buffer-string)))))
923 932
924(defun ispell-aspell-find-dictionary (dict-name) 933(defun ispell-aspell-find-dictionary (dict-name)
934 ;; This returns nil if the data file does not exist.
935 ;; Can someone please explain the return value format when the
936 ;; file does exist -- rms?
925 (let* ((lang ;; Strip out region, variant, etc. 937 (let* ((lang ;; Strip out region, variant, etc.
926 (and (string-match "^[[:alpha:]]+" dict-name) 938 (and (string-match "^[[:alpha:]]+" dict-name)
927 (match-string 0 dict-name))) 939 (match-string 0 dict-name)))
@@ -931,35 +943,37 @@ Assumes that value contains no whitespace."
931 (ispell-get-aspell-config-value "data-dir"))) 943 (ispell-get-aspell-config-value "data-dir")))
932 "/" lang ".dat")) 944 "/" lang ".dat"))
933 otherchars) 945 otherchars)
934 ;; This file really should exist; there is no sensible recovery. 946 (condition-case ()
935 (with-temp-buffer 947 (with-temp-buffer
936 (insert-file-contents data-file) 948 (insert-file-contents data-file)
937 ;; There is zero or one line with special characters declarations. 949 ;; There is zero or one line with special characters declarations.
938 (when (search-forward-regexp "^special" nil t) 950 (when (search-forward-regexp "^special" nil t)
939 (let ((specials (split-string 951 (let ((specials (split-string
940 (buffer-substring (point) 952 (buffer-substring (point)
941 (progn (end-of-line) (point)))))) 953 (progn (end-of-line) (point))))))
942 ;; The line looks like: special ' -** - -** . -** : -*- 954 ;; The line looks like: special ' -** - -** . -** : -*-
943 ;; -** means that this character 955 ;; -** means that this character
944 ;; - doesn't appear at word start 956 ;; - doesn't appear at word start
945 ;; * may appear in the middle of a word 957 ;; * may appear in the middle of a word
946 ;; * may appear at word end 958 ;; * may appear at word end
947 ;; `otherchars' is about the middle case. 959 ;; `otherchars' is about the middle case.
948 (while specials 960 (while specials
949 (when (eq (aref (cadr specials) 1) ?*) 961 (when (eq (aref (cadr specials) 1) ?*)
950 (push (car specials) otherchars)) 962 (push (car specials) otherchars))
951 (setq specials (cddr specials)))))) 963 (setq specials (cddr specials)))))
952 (list dict-name 964 (list dict-name
953 "[[:alpha:]]" 965 "[[:alpha:]]"
954 "[^[:alpha:]]" 966 "[^[:alpha:]]"
955 (regexp-opt otherchars) 967 (regexp-opt otherchars)
956 t ; We can't tell, so set this to t 968 t ; We can't tell, so set this to t
957 (list "-d" dict-name "--encoding=utf-8") 969 (list "-d" dict-name "--encoding=utf-8")
958 nil ; aspell doesn't support this 970 nil ; aspell doesn't support this
959 ;; Here we specify the encoding to use while communicating with 971 ;; Here we specify the encoding to use while communicating with
960 ;; aspell. This doesn't apply to command line arguments, so 972 ;; aspell. This doesn't apply to command line arguments, so
961 ;; just don't pass words to spellcheck as arguments... 973 ;; just don't pass words to spellcheck as arguments...
962 'utf-8))) 974 'utf-8))
975 (file-error
976 nil))))
963 977
964(defun ispell-aspell-add-aliases () 978(defun ispell-aspell-add-aliases ()
965 "Find aspell's dictionary aliases and add them to `ispell-dictionary-alist'." 979 "Find aspell's dictionary aliases and add them to `ispell-dictionary-alist'."