unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Daniel Pittman <slippycheeze@google.com>
To: 31344@debbugs.gnu.org
Subject: bug#31344: 26.1; ispell enchant support generates invalid regexp for empty extra chars
Date: Wed, 02 May 2018 20:05:02 +0000	[thread overview]
Message-ID: <CAC45yQsmtptJE8h=z6oSH1cFEPpd-Q_qX3JxWBKQEydNShkN_A@mail.gmail.com> (raw)

[-- 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'."

             reply	other threads:[~2018-05-02 20:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-02 20:05 Daniel Pittman [this message]
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

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAC45yQsmtptJE8h=z6oSH1cFEPpd-Q_qX3JxWBKQEydNShkN_A@mail.gmail.com' \
    --to=slippycheeze@google.com \
    --cc=31344@debbugs.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 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).