/[emacs]/emacs/lisp/textmodes/ispell.el
ViewVC logotype

Diff of /emacs/lisp/textmodes/ispell.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.181 by rfrancoise, Sun Oct 9 12:54:23 2005 UTC revision 1.182 by rms, Sun Oct 23 18:22:06 2005 UTC
# Line 445  where DICTNAME is the name of your defau Line 445  where DICTNAME is the name of your defau
445    
446  (defvar ispell-local-dictionary-overridden nil  (defvar ispell-local-dictionary-overridden nil
447    "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.")
448  (make-variable-buffer-local 'ispell-local-dictionary)  (make-variable-buffer-local 'ispell-local-dictionary-overridden)
449    
450  (defcustom ispell-local-dictionary nil  (defcustom ispell-local-dictionary nil
451    "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.
# Line 721  LANGUAGE.aff file \(e.g., english.aff\). Line 721  LANGUAGE.aff file \(e.g., english.aff\).
721    
722  (defvar ispell-aspell-supports-utf8 nil  (defvar ispell-aspell-supports-utf8 nil
723    "Non-nil means to try to automatically find aspell dictionaries.    "Non-nil means to try to automatically find aspell dictionaries.
724  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.
725    
726  Earlier aspell versions do not consistently support UTF-8.  Handling  Earlier aspell versions do not consistently support UTF-8.  Handling
727  this would require some extra guessing in `ispell-aspell-find-dictionary'.")  this would require some extra guessing in `ispell-aspell-find-dictionary'.")
# Line 894  and added as a submenu of the \"Edit\" m Line 894  and added as a submenu of the \"Edit\" m
894    "Find Aspell's dictionaries, and record in `ispell-dictionary-alist'."    "Find Aspell's dictionaries, and record in `ispell-dictionary-alist'."
895    (unless ispell-really-aspell    (unless ispell-really-aspell
896      (error "This function only works with aspell"))      (error "This function only works with aspell"))
897    (let ((dictionaries    (let* ((dictionaries
898           (split-string            (split-string
899            (with-temp-buffer             (with-temp-buffer
900              (call-process ispell-program-name nil t nil "dicts")               (call-process ispell-program-name nil t nil "dicts")
901              (buffer-string)))))               (buffer-string))))
902      (setq ispell-dictionary-alist           ;; Search for the named dictionaries.
903            (mapcar #'ispell-aspell-find-dictionary dictionaries))           (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    
913      (ispell-aspell-add-aliases)      (ispell-aspell-add-aliases)
914      ;; Add a default entry      ;; Add a default entry
915      (let* ((english-dict (assoc "en" ispell-dictionary-alist))      (let* ((english-dict (assoc "en" ispell-dictionary-alist))
# Line 922  Assumes that value contains no whitespac Line 931  Assumes that value contains no whitespac
931      (car (split-string (buffer-string)))))      (car (split-string (buffer-string)))))
932    
933  (defun ispell-aspell-find-dictionary (dict-name)  (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?
937    (let* ((lang ;; Strip out region, variant, etc.    (let* ((lang ;; Strip out region, variant, etc.
938            (and (string-match "^[[:alpha:]]+" dict-name)            (and (string-match "^[[:alpha:]]+" dict-name)
939                 (match-string 0 dict-name)))                 (match-string 0 dict-name)))
# Line 931  Assumes that value contains no whitespac Line 943  Assumes that value contains no whitespac
943                              (ispell-get-aspell-config-value "data-dir")))                              (ispell-get-aspell-config-value "data-dir")))
944                    "/" lang ".dat"))                    "/" lang ".dat"))
945           otherchars)           otherchars)
946      ;; This file really should exist; there is no sensible recovery.      (condition-case ()
947      (with-temp-buffer          (with-temp-buffer
948        (insert-file-contents data-file)            (insert-file-contents data-file)
949        ;; There is zero or one line with special characters declarations.            ;; There is zero or one line with special characters declarations.
950        (when (search-forward-regexp "^special" nil t)            (when (search-forward-regexp "^special" nil t)
951          (let ((specials (split-string              (let ((specials (split-string
952                           (buffer-substring (point)                               (buffer-substring (point)
953                                             (progn (end-of-line) (point))))))                                                 (progn (end-of-line) (point))))))
954            ;; The line looks like: special ' -** - -** . -** : -*-                ;; The line looks like: special ' -** - -** . -** : -*-
955            ;; -** means that this character                ;; -** means that this character
956            ;;    - doesn't appear at word start                ;;    - doesn't appear at word start
957            ;;    * may appear in the middle of a word                ;;    * may appear in the middle of a word
958            ;;    * may appear at word end                ;;    * may appear at word end
959            ;; `otherchars' is about the middle case.                ;; `otherchars' is about the middle case.
960            (while specials                (while specials
961              (when (eq (aref (cadr specials) 1) ?*)                  (when (eq (aref (cadr specials) 1) ?*)
962                (push (car specials) otherchars))                    (push (car specials) otherchars))
963              (setq specials (cddr specials))))))                  (setq specials (cddr specials)))))
964      (list dict-name            (list dict-name
965            "[[:alpha:]]"                  "[[:alpha:]]"
966            "[^[:alpha:]]"                  "[^[:alpha:]]"
967            (regexp-opt otherchars)                  (regexp-opt otherchars)
968            t                             ; We can't tell, so set this to t                  t                            ; We can't tell, so set this to t
969            (list "-d" dict-name "--encoding=utf-8")                  (list "-d" dict-name "--encoding=utf-8")
970            nil                           ; aspell doesn't support this                  nil                             ; aspell doesn't support this
971            ;; Here we specify the encoding to use while communicating with                  ;; Here we specify the encoding to use while communicating with
972            ;; aspell.  This doesn't apply to command line arguments, so                  ;; aspell.  This doesn't apply to command line arguments, so
973            ;; just don't pass words to spellcheck as arguments...                  ;; just don't pass words to spellcheck as arguments...
974            'utf-8)))                  'utf-8))
975          (file-error
976           nil))))
977    
978  (defun ispell-aspell-add-aliases ()  (defun ispell-aspell-add-aliases ()
979    "Find aspell's dictionary aliases and add them to `ispell-dictionary-alist'."    "Find aspell's dictionary aliases and add them to `ispell-dictionary-alist'."

Legend:
Removed from v.1.181  
changed lines
  Added in v.1.182

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26