emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r101988: ispell.el (ispell-aspell-fin


From: Agustin Martin
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r101988: ispell.el (ispell-aspell-find-dictionary): Fix aspell data file search (bug#7230).
Date: Mon, 18 Oct 2010 18:01:43 +0200
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 101988
committer: Agustin Martin <address@hidden>
branch nick: trunk
timestamp: Mon 2010-10-18 18:01:43 +0200
message:
  ispell.el (ispell-aspell-find-dictionary): Fix aspell data file search 
(bug#7230).
modified:
  lisp/ChangeLog
  lisp/textmodes/ispell.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2010-10-17 00:00:34 +0000
+++ b/lisp/ChangeLog    2010-10-18 16:01:43 +0000
@@ -1,3 +1,8 @@
+2010-10-17  Agustín Martín  <address@hidden>
+
+       * textmodes/ispell.el (ispell-aspell-find-dictionary): Fix
+       aspell data file searching (bug#7230).
+
 2010-10-16  Chong Yidong  <address@hidden>
 
        * cus-theme.el (custom-theme--migrate-settings): New var.

=== modified file 'lisp/textmodes/ispell.el'
--- a/lisp/textmodes/ispell.el  2010-09-20 14:15:27 +0000
+++ b/lisp/textmodes/ispell.el  2010-10-18 16:01:43 +0000
@@ -983,19 +983,32 @@
     (car (split-string (buffer-string)))))
 
 (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 variant, etc.
-         (and (string-match "^[[:alpha:]_]+" dict-name)
-              (match-string 0 dict-name)))
+  "For aspell dictionary DICT-NAME, return a list of parameters if an
+  associated data file is found or nil otherwise.  List format is
+  that of `ispell-dictionary-base-alist' elements."
+  ;; Make sure `ispell-aspell-data-dir' is defined
+  (or ispell-aspell-data-dir
+      (setq ispell-aspell-data-dir
+           (ispell-get-aspell-config-value "data-dir")))
+  ;; Try finding associated datafile
+  (let* ((datafile1
+         (concat ispell-aspell-data-dir "/"
+                 ;; Strip out variant, country code, etc.
+                 (and (string-match "^[[:alpha:]]+" dict-name)
+                      (match-string 0 dict-name)) ".dat"))
+        (datafile2
+         (concat ispell-aspell-data-dir "/"
+                 ;; Strip out anything but xx_YY.
+                 (and (string-match "^[[:alpha:]_]+" dict-name)
+                      (match-string 0 dict-name)) ".dat"))
         (data-file
-         (concat (or ispell-aspell-data-dir
-                     (setq ispell-aspell-data-dir
-                           (ispell-get-aspell-config-value "data-dir")))
-                 "/" lang ".dat"))
+         (if (file-readable-p datafile1)
+             datafile1
+           (if (file-readable-p datafile2)
+               datafile2)))
         otherchars)
-    (condition-case ()
+
+    (if data-file
        (with-temp-buffer
          (insert-file-contents data-file)
          ;; There is zero or one line with special characters declarations.
@@ -1023,9 +1036,7 @@
                ;; Here we specify the encoding to use while communicating with
                ;; aspell.  This doesn't apply to command line arguments, so
                ;; just don't pass words to spellcheck as arguments...
-               'utf-8))
-      (file-error
-       nil))))
+               'utf-8)))))
 
 (defun ispell-aspell-add-aliases (alist)
   "Find aspell's dictionary aliases and add them to dictionary ALIST.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]