unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#31344: 26.1; ispell enchant support generates invalid regexp for empty extra chars
@ 2018-05-02 20:05 Daniel Pittman
  2018-05-02 20:07 ` bug#31344: additional note: error triggers due to flyspell package using the extra chars regexp Daniel Pittman
  2018-10-19 13:56 ` bug#31344: resolved in master Daniel Pittman
  0 siblings, 2 replies; 3+ messages in thread
From: Daniel Pittman @ 2018-05-02 20:05 UTC (permalink / raw)
  To: 31344

[-- Attachment #1: Type: text/plain, Size: 1208 bytes --]

G'day.  With the new Enchant support in 26 I was motivated to try it out.
Turns out that some languages generate an empty "extra characters" report
for languages I use, which is turned into the (invalid, says `looking-at`)
regular expression "[]".

This triggers in this function in ispell.el:

(defun ispell--get-extra-word-characters (&optional lang)
   "Get the extra word characters for LANG as a character class.
If LANG is omitted, get the extra word characters for the default language."
   (concat "[" (string-trim-right (apply 'ispell--call-enchant-lsmod
                                         (append '("-word-chars") (if lang
`(,lang))))) "]"))

Obviously, when the result of that call is an empty string we get `[]`; in
my case:

] enchant-2-lsmod -word-chars en_US | xxd
00000000: 0a                                       .

...which causes that.  (Error is: `(invalid-regexp "Unmatched [ or [^")`)

I have attached a patch which correctly handles this case, though I feel
there must be a cleaner way to handle this modification of the return.

In any case, Google (and I personally) have papers on file with the FSF
covering this contribution, if it is non-trivial enough for that to matter.

[-- Attachment #2: emacs-ispell-enchant.patch --]
[-- Type: application/octet-stream, Size: 853 bytes --]

--- ispell.el.orig	2018-05-02 15:58:31.000000000 -0400
+++ ispell.el	2018-05-02 16:03:49.000000000 -0400
@@ -1206,8 +1206,12 @@
 (defun ispell--get-extra-word-characters (&optional lang)
   "Get the extra word characters for LANG as a character class.
 If LANG is omitted, get the extra word characters for the default language."
-  (concat "[" (string-trim-right (apply 'ispell--call-enchant-lsmod
-                                        (append '("-word-chars") (if lang `(,lang))))) "]"))
+  (let ((extra (string-trim-right
+                (apply 'ispell--call-enchant-lsmod
+                       (append '("-word-chars") (if lang `(,lang)))))))
+    (if (equal extra "")
+        ""
+      (concat "[" extra "]"))))
 
 (defun ispell-find-enchant-dictionaries ()
   "Find Enchant's dictionaries, and record in `ispell-enchant-dictionary-alist'."

^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#31344: additional note: error triggers due to flyspell package using the extra chars regexp
  2018-05-02 20:05 bug#31344: 26.1; ispell enchant support generates invalid regexp for empty extra chars Daniel Pittman
@ 2018-05-02 20:07 ` Daniel Pittman
  2018-10-19 13:56 ` bug#31344: resolved in master Daniel Pittman
  1 sibling, 0 replies; 3+ messages in thread
From: Daniel Pittman @ 2018-05-02 20:07 UTC (permalink / raw)
  To: 31344

Sorry, I forgot to mention in my original post that `flyspell-buffer` is
the trigger for this; it uses the extra character regular expression.  I
have not verified if it can be reproduced with only ispell.el commands,
though I assume it must be possible; it will trigger anywhere that regexp
is used.





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#31344: resolved in master
  2018-05-02 20:05 bug#31344: 26.1; ispell enchant support generates invalid regexp for empty extra chars Daniel Pittman
  2018-05-02 20:07 ` bug#31344: additional note: error triggers due to flyspell package using the extra chars regexp Daniel Pittman
@ 2018-10-19 13:56 ` Daniel Pittman
  1 sibling, 0 replies; 3+ messages in thread
From: Daniel Pittman @ 2018-10-19 13:56 UTC (permalink / raw)
  To: 31344-done

[-- Attachment #1: Type: text/plain, Size: 93 bytes --]

this issue has been resolved in the master branch, but the bug was not
closed.  cleaning up.

[-- Attachment #2: Type: text/html, Size: 116 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-10-19 13:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-02 20:05 bug#31344: 26.1; ispell enchant support generates invalid regexp for empty extra chars Daniel Pittman
2018-05-02 20:07 ` bug#31344: additional note: error triggers due to flyspell package using the extra chars regexp Daniel Pittman
2018-10-19 13:56 ` bug#31344: resolved in master Daniel Pittman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).