emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] emacs-24 c4ade11: textmodes/ispell.el: Look for aspell .da


From: Agustin Martin Domingo
Subject: [Emacs-diffs] emacs-24 c4ade11: textmodes/ispell.el: Look for aspell .dat files also under dict-dir, as aspell does.
Date: Tue, 03 Mar 2015 12:20:55 +0000

branch: emacs-24
commit c4ade119ccd1904795b2e8d76cd93aedc86d1b09
Author: Agustin Martin Domingo <address@hidden>
Commit: Agustin Martin Domingo <address@hidden>

    textmodes/ispell.el: Look for aspell .dat files also under dict-dir, as 
aspell does.
    
    Originally reported as http://bugs.debian.org/765349.
    Noticed when aspell has different data-dir and dict-dir.
    
    * textmodes/ispell.el (ispell-aspell-find-dictionary): Make sure
    .dat files for aspell dicts are also searched for in location
    described by `ispell-aspell-dict-dir', matching aspell's dict-dir
    variable.
---
 lisp/ChangeLog           |    7 +++++++
 lisp/textmodes/ispell.el |   42 +++++++++++++++++++++++++-----------------
 2 files changed, 32 insertions(+), 17 deletions(-)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 027664c..11c0271 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,12 @@
 2015-03-03  Agustín Martín Domingo <address@hidden>
 
+       * textmodes/ispell.el (ispell-aspell-find-dictionary): Make sure
+       .dat files for aspell dicts are also searched for in location
+       described by `ispell-aspell-dict-dir', matching aspell's dict-dir
+       variable.
+
+2015-03-03  Agustín Martín Domingo <address@hidden>
+
        * textmodes/ispell.el (ispell-dicts-name2locale-equivs-alist)
        (ispell-hunspell-fill-dictionary-entry)
        (ispell-find-hunspell-dictionaries)
diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el
index d8fca82..a981b52 100644
--- a/lisp/textmodes/ispell.el
+++ b/lisp/textmodes/ispell.el
@@ -1058,27 +1058,35 @@ Assumes that value contains no whitespace."
   "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-dict-dir' is defined
+  (or ispell-aspell-dict-dir
+      (setq ispell-aspell-dict-dir
+           (ispell-get-aspell-config-value "dict-dir")))
+
   ;; 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
-         (if (file-readable-p datafile1)
-             datafile1
-           (if (file-readable-p datafile2)
-               datafile2)))
-        otherchars)
+
+  ;; Try finding associated datafile. aspell will look for master .dat
+  ;; file in `dict-dir' and `data-dir'. Associated .dat files must be
+  ;; in the same directory as master file.
+  (let ((data-file
+        (catch 'datafile
+          (dolist ( tmp-path (list ispell-aspell-dict-dir
+                                   ispell-aspell-data-dir ))
+            ;; Try xx.dat first, strip out variant, country code, etc,
+            ;; then try xx_YY.dat (without stripping country code).
+            (dolist (tmp-regexp (list "^[[:alpha:]]+"
+                                      "^[[:alpha:]_]+"))
+              (let ((fullpath
+                     (concat tmp-path "/"
+                             (and (string-match tmp-regexp dict-name)
+                                  (match-string 0 dict-name)) ".dat")))
+                (if (file-readable-p fullpath)
+                    (throw 'datafile fullpath)))))))
+       otherchars)
 
     (if data-file
        (with-temp-buffer



reply via email to

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