~ubuntu-branches/debian/sid/emacs24/sid

« back to all changes in this revision

Viewing changes to lisp/textmodes/ispell.el

  • Committer: Package Import Robot
  • Author(s): Rob Browning
  • Date: 2015-06-17 00:06:26 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20150617000626-uxmby0fbe538wwry
Tags: 24.5+1-1
* Merge upstream version 24.5 (shift from the bzr->git mirror to the
  new official upstream git repository for the source).
  Remove redundant patches:
    0008-A-race-to-create-info-has-been-eliminated.patch
    0009-Nil-load-path-elements-shouldn-t-crash-Emacs.patch

* Update debian/copyright* for 24.5.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
;;; ispell.el --- interface to International Ispell Versions 3.1 and 3.2
2
2
 
3
 
;; Copyright (C) 1994-1995, 1997-2014 Free Software Foundation, Inc.
 
3
;; Copyright (C) 1994-1995, 1997-2015 Free Software Foundation, Inc.
4
4
 
5
5
;; Author:           Ken Stevens <k.stevens@ieee.org>
6
6
;; Maintainer:       Ken Stevens <k.stevens@ieee.org>
775
775
(make-obsolete-variable 'ispell-aspell-supports-utf8
776
776
                        'ispell-encoding8-command "23.1")
777
777
 
778
 
(defvar ispell-hunspell-dictionary-equivs-alist
 
778
(defvar ispell-dicts-name2locale-equivs-alist
779
779
  '(("american"      "en_US")
780
780
    ("brasileiro"    "pt_BR")
781
781
    ("british"       "en_GB")
807
807
    ("slovenian"     "sl_SI")
808
808
    ("svenska"       "sv_SE")
809
809
    ("hebrew"        "he_IL"))
810
 
  "Alist with matching hunspell dict names for standard dict names in
 
810
  "Alist with known matching locales for standard dict names in
811
811
  `ispell-dictionary-base-alist'.")
812
812
 
813
813
(defvar ispell-emacs-alpha-regexp
1058
1058
  "For aspell dictionary DICT-NAME, return a list of parameters if an
1059
1059
associated data file is found or nil otherwise.  List format is that
1060
1060
of `ispell-dictionary-base-alist' elements."
 
1061
 
 
1062
  ;; Make sure `ispell-aspell-dict-dir' is defined
 
1063
  (or ispell-aspell-dict-dir
 
1064
      (setq ispell-aspell-dict-dir
 
1065
            (ispell-get-aspell-config-value "dict-dir")))
 
1066
 
1061
1067
  ;; Make sure `ispell-aspell-data-dir' is defined
1062
1068
  (or ispell-aspell-data-dir
1063
1069
      (setq ispell-aspell-data-dir
1064
1070
            (ispell-get-aspell-config-value "data-dir")))
1065
 
  ;; Try finding associated datafile
1066
 
  (let* ((datafile1
1067
 
          (concat ispell-aspell-data-dir "/"
1068
 
                  ;; Strip out variant, country code, etc.
1069
 
                  (and (string-match "^[[:alpha:]]+" dict-name)
1070
 
                       (match-string 0 dict-name)) ".dat"))
1071
 
         (datafile2
1072
 
          (concat ispell-aspell-data-dir "/"
1073
 
                  ;; Strip out anything but xx_YY.
1074
 
                  (and (string-match "^[[:alpha:]_]+" dict-name)
1075
 
                       (match-string 0 dict-name)) ".dat"))
1076
 
         (data-file
1077
 
          (if (file-readable-p datafile1)
1078
 
              datafile1
1079
 
            (if (file-readable-p datafile2)
1080
 
                datafile2)))
1081
 
         otherchars)
 
1071
 
 
1072
  ;; Try finding associated datafile. aspell will look for master .dat
 
1073
  ;; file in `dict-dir' and `data-dir'. Associated .dat files must be
 
1074
  ;; in the same directory as master file.
 
1075
  (let ((data-file
 
1076
         (catch 'datafile
 
1077
           (dolist ( tmp-path (list ispell-aspell-dict-dir
 
1078
                                    ispell-aspell-data-dir ))
 
1079
             ;; Try xx.dat first, strip out variant, country code, etc,
 
1080
             ;; then try xx_YY.dat (without stripping country code).
 
1081
             (dolist (tmp-regexp (list "^[[:alpha:]]+"
 
1082
                                       "^[[:alpha:]_]+"))
 
1083
               (let ((fullpath
 
1084
                      (concat tmp-path "/"
 
1085
                              (and (string-match tmp-regexp dict-name)
 
1086
                                   (match-string 0 dict-name)) ".dat")))
 
1087
                 (if (file-readable-p fullpath)
 
1088
                     (throw 'datafile fullpath)))))))
 
1089
        otherchars)
1082
1090
 
1083
1091
    (if data-file
1084
1092
        (with-temp-buffer
1130
1138
                 (realdict (assoc realname alist)))
1131
1139
            (when (and realdict (not already-exists-p))
1132
1140
              (push (cons aliasname (cdr realdict)) alist))))))
 
1141
    ;; Add entries for standard dict-names with found locale-matching entry
 
1142
    (dolist (dict-map-entry ispell-dicts-name2locale-equivs-alist)
 
1143
      (let ((name (car dict-map-entry))
 
1144
            (locale (cadr dict-map-entry)))
 
1145
        (unless (assoc name alist) ;; skip if already present
 
1146
          (if (assoc locale alist)
 
1147
              (push (cons name (cdr (assoc locale alist))) alist)))))
1133
1148
    alist))
1134
1149
 
1135
1150
;; Make ispell.el work better with hunspell.
1153
1168
  (if (cadr (assoc dict ispell-dictionary-alist))
1154
1169
      (message "ispell-hfde: Non void entry for %s. Skipping.\n" dict)
1155
1170
    (let ((dict-alias
1156
 
           (cadr (assoc dict ispell-hunspell-dictionary-equivs-alist)))
 
1171
           (cadr (assoc dict ispell-dicts-name2locale-equivs-alist)))
1157
1172
          (use-for-dicts (list dict))
1158
1173
          (dict-args-cdr (cdr (ispell-parse-hunspell-affix-file dict)))
1159
1174
          newlist)
1160
1175
      ;; Get a list of uninitialized dicts using the same affix file.
1161
 
      (dolist (dict-equiv-alist-entry ispell-hunspell-dictionary-equivs-alist)
 
1176
      (dolist (dict-equiv-alist-entry ispell-dicts-name2locale-equivs-alist)
1162
1177
        (let ((dict-equiv-key (car dict-equiv-alist-entry))
1163
1178
              (dict-equiv-value (cadr dict-equiv-alist-entry)))
1164
1179
          (if (or (member dict dict-equiv-alist-entry)
1223
1238
  "Look for installed hunspell dictionaries.
1224
1239
Will initialize `ispell-hunspell-dictionary-alist' and
1225
1240
`ispell-hunspell-dictionary-alist' after values found
1226
 
and remove `ispell-hunspell-dictionary-equivs-alist'
 
1241
and remove `ispell-dicts-name2locale-equivs-alist'
1227
1242
entries if a specific dict was found."
1228
1243
  (let ((hunspell-found-dicts
1229
1244
         (split-string
1262
1277
             "-- ispell-fhd: Skipping entry: %s\n" dict)))))
1263
1278
    ;; Remove entry from aliases alist if explicit dict was found.
1264
1279
    (let (newlist)
1265
 
      (dolist (dict ispell-hunspell-dictionary-equivs-alist)
 
1280
      (dolist (dict ispell-dicts-name2locale-equivs-alist)
1266
1281
        (if (assoc (car dict) ispell-hunspell-dict-paths-alist)
1267
1282
            (ispell-print-if-debug
1268
1283
             "-- ispell-fhd: Excluding %s alias. Standalone dict found.\n"
1269
1284
             (car dict))
1270
1285
          (add-to-list 'newlist dict)))
1271
 
      (setq ispell-hunspell-dictionary-equivs-alist newlist))
 
1286
      (setq ispell-dicts-name2locale-equivs-alist newlist))
1272
1287
    ;; Add known hunspell aliases
1273
 
    (dolist (dict-equiv ispell-hunspell-dictionary-equivs-alist)
 
1288
    (dolist (dict-equiv ispell-dicts-name2locale-equivs-alist)
1274
1289
      (let ((dict-equiv-key (car dict-equiv))
1275
1290
            (dict-equiv-value (cadr dict-equiv))
1276
1291
            (exclude-aliases (list   ;; Exclude TeX aliases
1367
1382
              (let* ((dict-name (nth 0 adict))
1368
1383
                     (dict-equiv
1369
1384
                      (cadr (assoc dict-name
1370
 
                                   ispell-hunspell-dictionary-equivs-alist)))
 
1385
                                   ispell-dicts-name2locale-equivs-alist)))
1371
1386
                     (ispell-args (nth 5 adict))
1372
1387
                     (ispell-args-has-d (member "-d" ispell-args))
1373
1388
                     skip-dict)