From: Reuben Thomas <rrt@sc3d.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 17742@debbugs.gnu.org
Subject: bug#17742: Acknowledgement (Support for enchant?)
Date: Tue, 13 Dec 2016 21:30:04 +0000 [thread overview]
Message-ID: <CAOnWdohqUsxde96JTuGKBqWu25+Mg1J8D3GvdYR9m5DcHryfsQ@mail.gmail.com> (raw)
In-Reply-To: <CAOnWdojx6SXSQTd73a64mPuRWWOps=xN4uVtc4ZxbRA6BDMa9Q@mail.gmail.com>
[-- Attachment #1.1: Type: text/plain, Size: 380 bytes --]
This updates the first patch to use enchant-lsmod to list the dictionaries
in ispell-find-enchant-dictionaries, rather than the (now retracted) patch
I previously made to enchant, not realising that the functionality existed
in enchant-lsmod.
Of course, this dictionary-scanning functionality is still disabled
currently by default for Enchant in Emacs.
--
http://rrt.sc3d.org
[-- Attachment #1.2: Type: text/html, Size: 788 bytes --]
[-- Attachment #2: 0001-Add-Enchant-support-to-ispell.el-Bug-17742.patch --]
[-- Type: text/x-patch, Size: 8648 bytes --]
From ea6115153585c777ecb626470c2e7b5426d906f9 Mon Sep 17 00:00:00 2001
From: Reuben Thomas <rrt@sc3d.org>
Date: Sun, 4 Dec 2016 22:39:27 +0000
Subject: [PATCH 1/3] Add Enchant support to ispell.el (Bug#17742)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* lisp/textmodes/ispell.el (ispell-program-name): Add “enchant”.
(ispell-really-enchant): Add variable.
(ispell-check-version): If using Enchant, check it’s new enough (at
least 1.6.1). (Like the ispell check, this is absolute: cannot work
without.)
(ispell-enchant-dictionary-alist): Add variable.
(ispell-find-enchant-dictionaries): Add function, based on
ispell-find-aspell-dictionaries.
(ispell-set-spellchecker-params): Allow dictionary auto-detection for
Enchant, and call ispell-find-enchant-dictionaries to find them. Use
old ispell name to locale mapping code for Enchant too.
(ispell-send-replacement): Make it work with Enchant.
---
lisp/textmodes/ispell.el | 79 +++++++++++++++++++++++++++++++++++++++---------
1 file changed, 65 insertions(+), 14 deletions(-)
diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el
index 37a6ffc..bc25945 100644
--- a/lisp/textmodes/ispell.el
+++ b/lisp/textmodes/ispell.el
@@ -208,6 +208,10 @@ ispell-choices-win-default-height
:type 'integer
:group 'ispell)
+;; XXX Add enchant to this list once enchant >= 1.6.1 is widespread.
+;; Before that, adding it is useless, as if it is found, it will just
+;; cause an error; and one of the other spelling engines below is
+;; almost certainly installed in any case, for enchant to use.
(defcustom ispell-program-name
(or (executable-find "aspell")
(executable-find "ispell")
@@ -605,6 +609,8 @@ ispell-really-aspell
"Non-nil if we can use Aspell extensions.")
(defvar ispell-really-hunspell nil
"Non-nil if we can use Hunspell extensions.")
+(defvar ispell-really-enchant nil
+ "Non-nil if we can use Enchant extensions.")
(defvar ispell-encoding8-command nil
"Command line option prefix to select encoding if supported, nil otherwise.
If setting the encoding is supported by spellchecker and is selectable from
@@ -739,17 +745,26 @@ ispell-check-version
(and (search-forward-regexp
"(but really Hunspell \\([0-9]+\\.[0-9\\.-]+\\)?)"
nil t)
+ (match-string 1)))
+ (setq ispell-really-enchant
+ (and (search-forward-regexp
+ "(but really Enchant \\([0-9]+\\.[0-9\\.-]+\\)?)"
+ nil t)
(match-string 1)))))
(let* ((aspell8-minver "0.60")
(ispell-minver "3.1.12")
(hunspell8-minver "1.1.6")
+ (enchant-minver "1.6.1")
(minver (cond
((not (version<= ispell-minver ispell-program-version))
ispell-minver)
((and ispell-really-aspell
(not (version<= aspell8-minver ispell-really-aspell)))
- aspell8-minver))))
+ aspell8-minver)
+ ((and ispell-really-enchant
+ (not (version<= enchant-minver ispell-really-enchant)))
+ enchant-minver))))
(if minver
(error "%s release %s or greater is required"
@@ -1173,6 +1188,36 @@ ispell-find-hunspell-dictionaries
(list dict))
ispell-hunspell-dictionary-alist :test #'equal))))
+;; Make ispell.el work better with enchant.
+
+(defvar ispell-enchant-dictionary-alist nil
+ "An alist of parsed Enchant dicts and associated parameters.
+Internal use.")
+
+(defun ispell-find-enchant-dictionaries ()
+ "Find Enchant's dictionaries, and record in `ispell-enchant-dictionary-alist'."
+ (let* ((dictionaries
+ (split-string
+ (with-temp-buffer
+ (ispell-call-process
+ (concat ispell-program-name "-lsmod") nil t nil "-list-dicts")
+ (buffer-string))
+ " ([^)]+)\n"))
+ (found
+ (mapcar #'(lambda (lang)
+ `(,lang "[[:alpha:]]" "[^[:alpha:]]" "['.’-]" t nil nil utf-8))
+ dictionaries)))
+ ;; Merge into FOUND any elements from the standard ispell-dictionary-base-alist
+ ;; which have no element in FOUND at all.
+ (dolist (dict ispell-dictionary-base-alist)
+ (unless (assoc (car dict) found)
+ (setq found (nconc found (list dict)))))
+ (setq ispell-enchant-dictionary-alist found)
+ ;; Add a default entry
+ (let ((default-dict
+ '(nil "[[:alpha:]]" "[^[:alpha:]]" "['.’-]" t nil nil utf-8)))
+ (push default-dict ispell-enchant-dictionary-alist))))
+
;; Set params according to the selected spellchecker
(defvar ispell-last-program-name nil
@@ -1198,7 +1243,7 @@ ispell-set-spellchecker-params
(setq ispell-library-directory (ispell-check-version))
t)
(error nil))
- ispell-encoding8-command)
+ (or ispell-encoding8-command ispell-really-enchant))
;; auto-detection will only be used if spellchecker is not
;; ispell and supports a way to set communication to UTF-8.
(if ispell-really-aspell
@@ -1206,11 +1251,14 @@ ispell-set-spellchecker-params
(ispell-find-aspell-dictionaries))
(if ispell-really-hunspell
(or ispell-hunspell-dictionary-alist
- (ispell-find-hunspell-dictionaries)))))
+ (ispell-find-hunspell-dictionaries))
+ (if ispell-really-enchant
+ (or ispell-enchant-dictionary-alist
+ (ispell-find-enchant-dictionaries))))))
;; Substitute ispell-dictionary-alist with the list of
;; dictionaries corresponding to the given spellchecker.
- ;; If a recent aspell or hunspell, use the list of really
+ ;; With programs that support it, use the list of really
;; installed dictionaries and add to it elements of the original
;; list that are not present there. Allow distro info.
(let ((found-dicts-alist
@@ -1219,17 +1267,19 @@ ispell-set-spellchecker-params
ispell-aspell-dictionary-alist
(if ispell-really-hunspell
ispell-hunspell-dictionary-alist))
- nil))
+ (if ispell-really-enchant
+ ispell-enchant-dictionary-alist
+ nil)))
(ispell-dictionary-base-alist ispell-dictionary-base-alist)
ispell-base-dicts-override-alist ; Override only base-dicts-alist
all-dicts-alist)
;; While ispell and aspell (through aliases) use the traditional
- ;; dict naming originally expected by ispell.el, hunspell
- ;; uses locale based names with no alias. We need to map
+ ;; dict naming originally expected by ispell.el, hunspell & Enchant
+ ;; use locale-based names with no alias. We need to map
;; standard names to locale based names to make default dict
- ;; definitions available for hunspell.
- (if ispell-really-hunspell
+ ;; definitions available to these programs.
+ (if (or ispell-really-hunspell ispell-really-enchant)
(let (tmp-dicts-alist)
(dolist (adict ispell-dictionary-base-alist)
(let* ((dict-name (nth 0 adict))
@@ -1254,7 +1304,7 @@ ispell-set-spellchecker-params
(setq ispell-args
(nconc ispell-args (list "-d" dict-equiv)))
(message
- "ispell-set-spellchecker-params: Missing Hunspell equiv for \"%s\". Skipping."
+ "ispell-set-spellchecker-params: Missing equivalent for \"%s\". Skipping."
dict-name)
(setq skip-dict t)))
@@ -1296,7 +1346,7 @@ ispell-set-spellchecker-params
(nth 4 adict) ; many-otherchars-p
(nth 5 adict) ; ispell-args
(nth 6 adict) ; extended-character-mode
- (if ispell-encoding8-command
+ (if (or ispell-encoding8-command ispell-really-enchant)
'utf-8
(nth 7 adict)))
adict)
@@ -1732,9 +1782,10 @@ ispell-accept-output
(erase-buffer)))))))
(defun ispell-send-replacement (misspelled replacement)
- "Notify Aspell that MISSPELLED should be spelled REPLACEMENT.
-This allows improving the suggestion list based on actual misspellings."
- (and ispell-really-aspell
+ "Notify spell checker that MISSPELLED should be spelled REPLACEMENT.
+This allows improving the suggestion list based on actual misspellings.
+Only works for Aspell and Enchant."
+ (and (or ispell-really-aspell ispell-really-enchant)
(ispell-send-string (concat "$$ra " misspelled "," replacement "\n"))))
--
2.7.4
[-- Attachment #3: 0002-Disable-auto-scanning-of-Enchant-dictionaries.patch --]
[-- Type: text/x-patch, Size: 1905 bytes --]
From f4252552d7670e25160cc3e77d2c95e64f831332 Mon Sep 17 00:00:00 2001
From: Reuben Thomas <rrt@sc3d.org>
Date: Tue, 13 Dec 2016 21:12:13 +0000
Subject: [PATCH 2/3] Disable auto-scanning of Enchant dictionaries
lisp/textmodes/ispell.el (ispell-set-spellchecker-params): Do not call
ispell-find-enchant-dictionaries. Add a comment noting that it is
disabled until it is possible to set good CASECHARS and NOT-CASECHARS
values. (Bug#17742; see also
https://github.com/AbiWord/enchant/issues/17 )
---
lisp/textmodes/ispell.el | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el
index bc25945..43eb672 100644
--- a/lisp/textmodes/ispell.el
+++ b/lisp/textmodes/ispell.el
@@ -1194,6 +1194,8 @@ ispell-enchant-dictionary-alist
"An alist of parsed Enchant dicts and associated parameters.
Internal use.")
+;; XXX Not used: needs to be fixed to generate good CASECHARS and
+;; NOT-CASECHARS values.
(defun ispell-find-enchant-dictionaries ()
"Find Enchant's dictionaries, and record in `ispell-enchant-dictionary-alist'."
(let* ((dictionaries
@@ -1252,9 +1254,12 @@ ispell-set-spellchecker-params
(if ispell-really-hunspell
(or ispell-hunspell-dictionary-alist
(ispell-find-hunspell-dictionaries))
- (if ispell-really-enchant
- (or ispell-enchant-dictionary-alist
- (ispell-find-enchant-dictionaries))))))
+ ;; XXX Disable until ispell-find-enchant-dictionaries can
+ ;; generate good CASECHARS and NOT-CASECHARS values.
+ ;; (if ispell-really-enchant
+ ;; (or ispell-enchant-dictionary-alist
+ ;; (ispell-find-enchant-dictionaries)))
+ )))
;; Substitute ispell-dictionary-alist with the list of
;; dictionaries corresponding to the given spellchecker.
--
2.7.4
next prev parent reply other threads:[~2016-12-13 21:30 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-10 0:01 bug#17742: Support for enchant? Reuben Thomas
2014-09-15 11:06 ` bug#17742: Limitations of enchant Reuben Thomas
2016-12-02 0:15 ` Reuben Thomas
[not found] ` <handler.17742.B.140235850213377.ack@debbugs.gnu.org>
2016-12-05 21:41 ` bug#17742: Acknowledgement (Support for enchant?) Reuben Thomas
2016-12-06 15:55 ` Eli Zaretskii
2016-12-06 15:56 ` Reuben Thomas
2016-12-13 0:53 ` Reuben Thomas
2016-12-13 16:37 ` Eli Zaretskii
2016-12-13 18:26 ` Reuben Thomas
2016-12-13 18:54 ` Eli Zaretskii
2016-12-13 21:17 ` Reuben Thomas
2016-12-13 21:30 ` Reuben Thomas [this message]
2016-12-14 15:42 ` Eli Zaretskii
2016-12-15 12:36 ` Reuben Thomas
2016-12-18 23:39 ` Reuben Thomas
2016-12-19 1:02 ` Reuben Thomas
2016-12-19 12:41 ` Reuben Thomas
2016-12-19 16:01 ` Eli Zaretskii
2016-12-19 17:37 ` Agustin Martin
2016-12-19 18:09 ` Eli Zaretskii
2016-12-19 21:21 ` Reuben Thomas
2016-12-19 21:27 ` Reuben Thomas
2016-12-20 15:38 ` Eli Zaretskii
2016-12-19 21:47 ` Reuben Thomas
2016-12-19 22:04 ` Reuben Thomas
2016-12-20 15:40 ` Eli Zaretskii
2016-12-20 15:40 ` Eli Zaretskii
2016-12-20 21:43 ` Reuben Thomas
2016-12-21 17:13 ` Eli Zaretskii
2016-12-21 17:32 ` Reuben Thomas
2017-08-09 11:35 ` Reuben Thomas
2017-08-18 8:54 ` Eli Zaretskii
2017-08-20 13:02 ` Reuben Thomas
2017-08-20 14:42 ` Eli Zaretskii
2017-08-20 14:50 ` Reuben Thomas
2017-08-20 19:34 ` Eli Zaretskii
2017-08-20 20:36 ` Reuben Thomas
2017-08-20 14:50 ` bug#17742: Reuben Thomas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAOnWdohqUsxde96JTuGKBqWu25+Mg1J8D3GvdYR9m5DcHryfsQ@mail.gmail.com \
--to=rrt@sc3d.org \
--cc=17742@debbugs.gnu.org \
--cc=eliz@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.