aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorReuben Thomas2017-08-07 21:59:06 +0100
committerReuben Thomas2017-08-07 21:59:06 +0100
commite6fa08363dc950e48d72d41fd0f65444d2755ce3 (patch)
treec021cd02e533631e4bc7bad90472997e4622e76b
parent89187e93d220ac5e2177c7c769ae6a0e9966d0f5 (diff)
downloademacs-e6fa08363dc950e48d72d41fd0f65444d2755ce3.tar.gz
emacs-e6fa08363dc950e48d72d41fd0f65444d2755ce3.zip
Revert "Add Enchant support to ispell.el (Bug#17742)"
This reverts commit 7136e6723d87b51ae3089f5ceef6b14621bfaf87.
-rw-r--r--lisp/textmodes/ispell.el79
1 files changed, 14 insertions, 65 deletions
diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el
index 9ca43895581..773023a34a6 100644
--- a/lisp/textmodes/ispell.el
+++ b/lisp/textmodes/ispell.el
@@ -208,10 +208,6 @@ Must be greater than 1."
208 :type 'integer 208 :type 'integer
209 :group 'ispell) 209 :group 'ispell)
210 210
211;; XXX Add enchant to this list once enchant >= 1.6.1 is widespread.
212;; Before that, adding it is useless, as if it is found, it will just
213;; cause an error; and one of the other spelling engines below is
214;; almost certainly installed in any case, for enchant to use.
215(defcustom ispell-program-name 211(defcustom ispell-program-name
216 (or (executable-find "aspell") 212 (or (executable-find "aspell")
217 (executable-find "ispell") 213 (executable-find "ispell")
@@ -609,8 +605,6 @@ english.aff). Aspell and Hunspell don't have this limitation.")
609 "Non-nil if we can use Aspell extensions.") 605 "Non-nil if we can use Aspell extensions.")
610(defvar ispell-really-hunspell nil 606(defvar ispell-really-hunspell nil
611 "Non-nil if we can use Hunspell extensions.") 607 "Non-nil if we can use Hunspell extensions.")
612(defvar ispell-really-enchant nil
613 "Non-nil if we can use Enchant extensions.")
614(defvar ispell-encoding8-command nil 608(defvar ispell-encoding8-command nil
615 "Command line option prefix to select encoding if supported, nil otherwise. 609 "Command line option prefix to select encoding if supported, nil otherwise.
616If setting the encoding is supported by spellchecker and is selectable from 610If setting the encoding is supported by spellchecker and is selectable from
@@ -745,26 +739,17 @@ Otherwise returns the library directory name, if that is defined."
745 (and (search-forward-regexp 739 (and (search-forward-regexp
746 "(but really Hunspell \\([0-9]+\\.[0-9\\.-]+\\)?)" 740 "(but really Hunspell \\([0-9]+\\.[0-9\\.-]+\\)?)"
747 nil t) 741 nil t)
748 (match-string 1)))
749 (setq ispell-really-enchant
750 (and (search-forward-regexp
751 "(but really Enchant \\([0-9]+\\.[0-9\\.-]+\\)?)"
752 nil t)
753 (match-string 1))))) 742 (match-string 1)))))
754 743
755 (let* ((aspell8-minver "0.60") 744 (let* ((aspell8-minver "0.60")
756 (ispell-minver "3.1.12") 745 (ispell-minver "3.1.12")
757 (hunspell8-minver "1.1.6") 746 (hunspell8-minver "1.1.6")
758 (enchant-minver "1.6.1")
759 (minver (cond 747 (minver (cond
760 ((not (version<= ispell-minver ispell-program-version)) 748 ((not (version<= ispell-minver ispell-program-version))
761 ispell-minver) 749 ispell-minver)
762 ((and ispell-really-aspell 750 ((and ispell-really-aspell
763 (not (version<= aspell8-minver ispell-really-aspell))) 751 (not (version<= aspell8-minver ispell-really-aspell)))
764 aspell8-minver) 752 aspell8-minver))))
765 ((and ispell-really-enchant
766 (not (version<= enchant-minver ispell-really-enchant)))
767 enchant-minver))))
768 753
769 (if minver 754 (if minver
770 (error "%s release %s or greater is required" 755 (error "%s release %s or greater is required"
@@ -1198,36 +1183,6 @@ dictionary from that list was found."
1198 (list dict)) 1183 (list dict))
1199 ispell-hunspell-dictionary-alist :test #'equal)))) 1184 ispell-hunspell-dictionary-alist :test #'equal))))
1200 1185
1201;; Make ispell.el work better with enchant.
1202
1203(defvar ispell-enchant-dictionary-alist nil
1204 "An alist of parsed Enchant dicts and associated parameters.
1205Internal use.")
1206
1207(defun ispell-find-enchant-dictionaries ()
1208 "Find Enchant's dictionaries, and record in `ispell-enchant-dictionary-alist'."
1209 (let* ((dictionaries
1210 (split-string
1211 (with-temp-buffer
1212 (ispell-call-process
1213 (concat ispell-program-name "-lsmod") nil t nil "-list-dicts")
1214 (buffer-string))
1215 " ([^)]+)\n"))
1216 (found
1217 (mapcar #'(lambda (lang)
1218 `(,lang "[[:alpha:]]" "[^[:alpha:]]" "['.’-]" t nil nil utf-8))
1219 dictionaries)))
1220 ;; Merge into FOUND any elements from the standard ispell-dictionary-base-alist
1221 ;; which have no element in FOUND at all.
1222 (dolist (dict ispell-dictionary-base-alist)
1223 (unless (assoc (car dict) found)
1224 (setq found (nconc found (list dict)))))
1225 (setq ispell-enchant-dictionary-alist found)
1226 ;; Add a default entry
1227 (let ((default-dict
1228 '(nil "[[:alpha:]]" "[^[:alpha:]]" "['.’-]" t nil nil utf-8)))
1229 (push default-dict ispell-enchant-dictionary-alist))))
1230
1231;; Set params according to the selected spellchecker 1186;; Set params according to the selected spellchecker
1232 1187
1233(defvar ispell-last-program-name nil 1188(defvar ispell-last-program-name nil
@@ -1253,7 +1208,7 @@ aspell is used along with Emacs).")
1253 (setq ispell-library-directory (ispell-check-version)) 1208 (setq ispell-library-directory (ispell-check-version))
1254 t) 1209 t)
1255 (error nil)) 1210 (error nil))
1256 (or ispell-encoding8-command ispell-really-enchant)) 1211 ispell-encoding8-command)
1257 ;; auto-detection will only be used if spellchecker is not 1212 ;; auto-detection will only be used if spellchecker is not
1258 ;; ispell and supports a way to set communication to UTF-8. 1213 ;; ispell and supports a way to set communication to UTF-8.
1259 (if ispell-really-aspell 1214 (if ispell-really-aspell
@@ -1261,14 +1216,11 @@ aspell is used along with Emacs).")
1261 (ispell-find-aspell-dictionaries)) 1216 (ispell-find-aspell-dictionaries))
1262 (if ispell-really-hunspell 1217 (if ispell-really-hunspell
1263 (or ispell-hunspell-dictionary-alist 1218 (or ispell-hunspell-dictionary-alist
1264 (ispell-find-hunspell-dictionaries)) 1219 (ispell-find-hunspell-dictionaries)))))
1265 (if ispell-really-enchant
1266 (or ispell-enchant-dictionary-alist
1267 (ispell-find-enchant-dictionaries))))))
1268 1220
1269 ;; Substitute ispell-dictionary-alist with the list of 1221 ;; Substitute ispell-dictionary-alist with the list of
1270 ;; dictionaries corresponding to the given spellchecker. 1222 ;; dictionaries corresponding to the given spellchecker.
1271 ;; With programs that support it, use the list of really 1223 ;; If a recent aspell or hunspell, use the list of really
1272 ;; installed dictionaries and add to it elements of the original 1224 ;; installed dictionaries and add to it elements of the original
1273 ;; list that are not present there. Allow distro info. 1225 ;; list that are not present there. Allow distro info.
1274 (let ((found-dicts-alist 1226 (let ((found-dicts-alist
@@ -1277,19 +1229,17 @@ aspell is used along with Emacs).")
1277 ispell-aspell-dictionary-alist 1229 ispell-aspell-dictionary-alist
1278 (if ispell-really-hunspell 1230 (if ispell-really-hunspell
1279 ispell-hunspell-dictionary-alist)) 1231 ispell-hunspell-dictionary-alist))
1280 (if ispell-really-enchant 1232 nil))
1281 ispell-enchant-dictionary-alist
1282 nil)))
1283 (ispell-dictionary-base-alist ispell-dictionary-base-alist) 1233 (ispell-dictionary-base-alist ispell-dictionary-base-alist)
1284 ispell-base-dicts-override-alist ; Override only base-dicts-alist 1234 ispell-base-dicts-override-alist ; Override only base-dicts-alist
1285 all-dicts-alist) 1235 all-dicts-alist)
1286 1236
1287 ;; While ispell and aspell (through aliases) use the traditional 1237 ;; While ispell and aspell (through aliases) use the traditional
1288 ;; dict naming originally expected by ispell.el, hunspell & Enchant 1238 ;; dict naming originally expected by ispell.el, hunspell
1289 ;; use locale-based names with no alias. We need to map 1239 ;; uses locale based names with no alias. We need to map
1290 ;; standard names to locale based names to make default dict 1240 ;; standard names to locale based names to make default dict
1291 ;; definitions available to these programs. 1241 ;; definitions available for hunspell.
1292 (if (or ispell-really-hunspell ispell-really-enchant) 1242 (if ispell-really-hunspell
1293 (let (tmp-dicts-alist) 1243 (let (tmp-dicts-alist)
1294 (dolist (adict ispell-dictionary-base-alist) 1244 (dolist (adict ispell-dictionary-base-alist)
1295 (let* ((dict-name (nth 0 adict)) 1245 (let* ((dict-name (nth 0 adict))
@@ -1314,7 +1264,7 @@ aspell is used along with Emacs).")
1314 (setq ispell-args 1264 (setq ispell-args
1315 (nconc ispell-args (list "-d" dict-equiv))) 1265 (nconc ispell-args (list "-d" dict-equiv)))
1316 (message 1266 (message
1317 "ispell-set-spellchecker-params: Missing equivalent for \"%s\". Skipping." 1267 "ispell-set-spellchecker-params: Missing Hunspell equiv for \"%s\". Skipping."
1318 dict-name) 1268 dict-name)
1319 (setq skip-dict t))) 1269 (setq skip-dict t)))
1320 1270
@@ -1356,7 +1306,7 @@ aspell is used along with Emacs).")
1356 (nth 4 adict) ; many-otherchars-p 1306 (nth 4 adict) ; many-otherchars-p
1357 (nth 5 adict) ; ispell-args 1307 (nth 5 adict) ; ispell-args
1358 (nth 6 adict) ; extended-character-mode 1308 (nth 6 adict) ; extended-character-mode
1359 (if (or ispell-encoding8-command ispell-really-enchant) 1309 (if ispell-encoding8-command
1360 'utf-8 1310 'utf-8
1361 (nth 7 adict))) 1311 (nth 7 adict)))
1362 adict) 1312 adict)
@@ -1792,10 +1742,9 @@ and pass it the output of the last Ispell invocation."
1792 (erase-buffer))))))) 1742 (erase-buffer)))))))
1793 1743
1794(defun ispell-send-replacement (misspelled replacement) 1744(defun ispell-send-replacement (misspelled replacement)
1795 "Notify spell checker that MISSPELLED should be spelled REPLACEMENT. 1745 "Notify Aspell that MISSPELLED should be spelled REPLACEMENT.
1796This allows improving the suggestion list based on actual misspellings. 1746This allows improving the suggestion list based on actual misspellings."
1797Only works for Aspell and Enchant." 1747 (and ispell-really-aspell
1798 (and (or ispell-really-aspell ispell-really-enchant)
1799 (ispell-send-string (concat "$$ra " misspelled "," replacement "\n")))) 1748 (ispell-send-string (concat "$$ra " misspelled "," replacement "\n"))))
1800 1749
1801 1750