all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Reuben Thomas via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 44318@debbugs.gnu.org, dinkonin <dinkonin@gmail.com>
Subject: bug#44318: 28.0.50; Problem with ispell/flyspell and ""enchant"" backend
Date: Mon, 2 Nov 2020 21:49:33 +0000	[thread overview]
Message-ID: <CAOnWdoh+zYWjYhtpS=6urzsUGt3B9v5Orw3uZk5_bN+3or2k1w@mail.gmail.com> (raw)
In-Reply-To: <83y2jjd9ix.fsf@gnu.org>


[-- Attachment #1.1: Type: text/plain, Size: 2123 bytes --]

On Mon, 2 Nov 2020 at 16:10, Eli Zaretskii <eliz@gnu.org> wrote:

> > From: Reuben Thomas <rrt@sc3d.org>
> > Date: Mon, 2 Nov 2020 15:49:19 +0000
> > Cc: dinkonin <dinkonin@gmail.com>, 44318@debbugs.gnu.org
> >
> > So I, as upstream maintainer, am telling you that indeed, it is not
> correct that Emacs should take
> > enchant-lsmod's stderr as part of its output! (As I said above, it would
> be possible to capture stderr
> > separately and display it to the user, though I don't recommend that
> currently, because the warnings are not
> > written for users. Other programs that use Enchant do not show these
> warnings, they simply omit providers
> > that do not load from the list of languages/spelling checkers that are
> available.)
>
> OK, I agree to this change, under protest.
>

Thanks Eli, I have installed it; of course, contact me if it causes any
problems. After installing that patch, I discovered that in
ispell--call-enchant-lsmod, it did need to use with-current-buffer, so I
have installed a patch that restores the use of with-current-buffer;
apologies for getting that wrong first time.

In fact, this change is not sufficient to fix the original problem, because
the enchant program outputs the same warning when a provider module cannot
be loaded. In this case, stderr is added to the list of suggested words.
Again, I believe Enchant is correct to output a warning, and again, I
believe Emacs is wrong to amalgamate stderr and stdout.

I attach three patches that do the following:

1. Simplify ispell-call-process{,-region} by factoring out the macro
ispell-with-safe-default-directory.

2. I also found that ispell-check-version can be simplified slightly:
aspell has accepted -vv since 2004, so use it always.
3. When spell-checking, collect only standard output. This leaves some
spell-checker-specific calls to ispell-call-process to collect stderr as
well, which as far as I can tell is needed in only one case,
ispell-find-hunspell-dictionaries; but it doesn't hurt to leave the rest
unchanged. I have tested this patch with all supported spellcheckers
(ispell, aspell, hunspell, enchant).

[-- Attachment #1.2: Type: text/html, Size: 4051 bytes --]

[-- Attachment #2: 0002-Factor-out-some-common-code-in-ispell.el.patch --]
[-- Type: text/x-patch, Size: 1982 bytes --]

From 1aa6c9f5e7ce89f9440a2a5b4c591e65c8b4e5a0 Mon Sep 17 00:00:00 2001
From: Reuben Thomas <rrt@sc3d.org>
Date: Mon, 2 Nov 2020 21:45:40 +0000
Subject: [PATCH 2/3] Factor out some common code in ispell.el

* lisp/textmodes/ispell.el (ispell-with-safe-default-directory): Add
  macro.
  (ispell-call-process, ispell-call-process-region): Use it.
---
 lisp/textmodes/ispell.el | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el
index 9e56923d60..49da3d1ed4 100644
--- a/lisp/textmodes/ispell.el
+++ b/lisp/textmodes/ispell.el
@@ -769,18 +769,23 @@ ispell-check-version
 	    (setq ispell-really-hunspell nil))))))
     result))
 
+(defmacro ispell-with-safe-default-directory (&rest body)
+  "Execute the forms in BODY with a reasonable
+`default-directory'."
+  (declare (indent 0) (debug t))
+  `(let ((default-directory default-directory))
+     (unless (file-accessible-directory-p default-directory)
+       (setq default-directory (expand-file-name "~/")))
+     ,@body))
+
 (defun ispell-call-process (&rest args)
-  "Like `call-process' but defend against bad `default-directory'."
-  (let ((default-directory default-directory))
-    (unless (file-accessible-directory-p default-directory)
-      (setq default-directory (expand-file-name "~/")))
+  "Like `call-process', but defend against bad `default-directory'."
+  (ispell-with-safe-default-directory
     (apply 'call-process args)))
 
 (defun ispell-call-process-region (&rest args)
-  "Like `call-process-region' but defend against bad `default-directory'."
-  (let ((default-directory default-directory))
-    (unless (file-accessible-directory-p default-directory)
-      (setq default-directory (expand-file-name "~/")))
+  "Like `call-process-region', but defend against bad `default-directory'."
+  (ispell-with-safe-default-directory
     (apply 'call-process-region args)))
 
 (defvar ispell-debug-buffer)
-- 
2.25.1


[-- Attachment #3: 0001-Simplify-ispell-check-version-s-use-of-vv-flag.patch --]
[-- Type: text/x-patch, Size: 1333 bytes --]

From c83ffcbe1ba950b9270bcde56d117c2c50e35112 Mon Sep 17 00:00:00 2001
From: Reuben Thomas <rrt@sc3d.org>
Date: Mon, 2 Nov 2020 21:41:05 +0000
Subject: [PATCH 1/3] =?UTF-8?q?Simplify=20ispell-check-version=E2=80=99s?=
 =?UTF-8?q?=20use=20of=20-vv=20flag?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* lisp/textmodes/ispell.el (ispell-check-version): All supported spell
checker programs accept -vv, including aspell for many years, so use
it.
---
 lisp/textmodes/ispell.el | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el
index da3c3f4d6f..9e56923d60 100644
--- a/lisp/textmodes/ispell.el
+++ b/lisp/textmodes/ispell.el
@@ -684,13 +684,11 @@ ispell-check-version
     (with-temp-buffer
       (setq status (ispell-call-process
 		    ispell-program-name nil t nil
-		    ;; aspell doesn't accept the -vv switch.
 		    (let ((case-fold-search
 			   (memq system-type '(ms-dos windows-nt)))
 			  (speller
 			   (file-name-nondirectory ispell-program-name)))
-		      ;; Assume anything that isn't `aspell' is Ispell.
-		      (if (string-match "\\`aspell" speller) "-v" "-vv"))))
+		      "-vv")))
       (goto-char (point-min))
       (if interactivep
 	  ;; Report version information of ispell
-- 
2.25.1


[-- Attachment #4: 0003-Prevent-ispell-being-confused-by-spellchecker-output.patch --]
[-- Type: text/x-patch, Size: 1471 bytes --]

From 5d772177536dcfed607159802eeadcd22eab1969 Mon Sep 17 00:00:00 2001
From: Reuben Thomas <rrt@sc3d.org>
Date: Mon, 2 Nov 2020 21:45:52 +0000
Subject: [PATCH 3/3] Prevent `ispell' being confused by spellchecker output on
 stderr

* lisp/textmodes/ispell.el (ispell-send-string, ispell-lookup-words):
Capture only stdout. This avoids warning messages, e.g. from Enchant,
from being interpreted as output from the spell-checker process.
---
 lisp/textmodes/ispell.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el
index 49da3d1ed4..8d90cab653 100644
--- a/lisp/textmodes/ispell.el
+++ b/lisp/textmodes/ispell.el
@@ -1861,7 +1861,7 @@ ispell-send-string
 		    (apply 'ispell-call-process-region
 			   (point-min) (point-max)
 			   ispell-program-name nil
-			   output-buf nil
+			   '(output-buf nil) nil
 			   "-a"
 			   ;; hunspell -m option means something different
 			   (if ispell-really-hunspell "" "-m")
@@ -2566,7 +2566,7 @@ ispell-lookup-words
         (while (search-backward "*" nil t) (insert "."))
         (setq word (buffer-string))
         (erase-buffer))
-      (setq status (apply 'ispell-call-process prog nil t nil
+      (setq status (apply 'ispell-call-process prog nil '(t nil) nil
                           (nconc (if (and args (> (length args) 0))
                                      (list args)
                                    (if look-p nil
-- 
2.25.1


  reply	other threads:[~2020-11-02 21:49 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-29 20:25 bug#44318: 28.0.50; Problem with ispell/flyspell and ""enchant"" backend dinkonin
2020-10-30  7:38 ` Eli Zaretskii
2020-10-30 22:56   ` Reuben Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-10-31  7:29     ` Eli Zaretskii
2020-10-31  7:32     ` dinkonin
2020-10-31  7:50       ` Eli Zaretskii
2020-10-31  8:37         ` dinkonin
2020-10-31  9:17           ` Eli Zaretskii
2020-11-01 22:23             ` Reuben Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-11-02  3:34               ` Eli Zaretskii
2020-11-02  8:14                 ` dinkonin
2020-11-02 15:41                   ` Eli Zaretskii
2020-11-02  8:35                 ` Reuben Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-11-02 15:41                   ` dinkonin
2020-11-02 15:43                   ` Eli Zaretskii
2020-11-02 15:49                     ` Reuben Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-11-02 16:10                       ` Eli Zaretskii
2020-11-02 21:49                         ` Reuben Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2020-11-03 16:45                           ` Eli Zaretskii
2020-11-03 17:06                             ` Reuben Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
     [not found]                             ` <CAOnWdohVdcVffjvptfJUjhRr1jdNn7H3PBzon0LvrR_cguPPow@mail.gmail.com>
     [not found]                               ` <835z6mcqyg.fsf@gnu.org>
2020-11-03 17:19                                 ` Reuben Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-11-03 17:31                                   ` Eli Zaretskii
2020-11-03 18:27                                     ` Reuben Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-11-03 18:50                                       ` Eli Zaretskii
2020-11-03 18:53                                         ` Reuben Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-11-03 19:39                                           ` Eli Zaretskii

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='CAOnWdoh+zYWjYhtpS=6urzsUGt3B9v5Orw3uZk5_bN+3or2k1w@mail.gmail.com' \
    --to=bug-gnu-emacs@gnu.org \
    --cc=44318@debbugs.gnu.org \
    --cc=dinkonin@gmail.com \
    --cc=eliz@gnu.org \
    --cc=rrt@sc3d.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.