GNU bug report logs - #38583
[PATCH] 27.0.50; Add unattended spell-checking to checkdoc

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Damien Cassou <damien@HIDDEN>; Keywords: patch; dated Thu, 12 Dec 2019 21:29:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 11 Jan 2020 12:26:28 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 11 07:26:28 2020
Received: from localhost ([127.0.0.1]:55512 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iqFqR-0001zv-Az
	for submit <at> debbugs.gnu.org; Sat, 11 Jan 2020 07:26:28 -0500
Received: from lists.gnu.org ([209.51.188.17]:40517)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1iqFqO-0001zo-I4
 for submit <at> debbugs.gnu.org; Sat, 11 Jan 2020 07:26:21 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:48064)
 by lists.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <eliz@HIDDEN>) id 1iqFqN-0001Ho-CX
 for bug-gnu-emacs@HIDDEN; Sat, 11 Jan 2020 07:26:20 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00,
 URIBL_BLOCKED autolearn=disabled version=3.3.2
Received: from fencepost.gnu.org ([2001:470:142:3::e]:47568)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <eliz@HIDDEN>)
 id 1iqFqM-0005Fj-9N; Sat, 11 Jan 2020 07:26:18 -0500
Received: from [176.228.60.248] (port=1189 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <eliz@HIDDEN>)
 id 1iqFqL-0000A9-0p; Sat, 11 Jan 2020 07:26:17 -0500
Date: Sat, 11 Jan 2020 14:26:16 +0200
Message-Id: <83sgkm6uxj.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Damien Cassou <damien@HIDDEN>
In-reply-to: <874kx28b7m.fsf@HIDDEN> (message from Damien Cassou on Sat, 11
 Jan 2020 12:49:17 +0100)
Subject: Re: [PATCH] 27.0.50; Add unattended spell-checking to checkdoc
References: <87immlw7zo.fsf@HIDDEN> <83blsc8ujl.fsf@HIDDEN>
 <871rt8gfy0.fsf@HIDDEN> <83mubw6lpb.fsf@HIDDEN>
 <87o8vu7zqp.fsf@HIDDEN> <83d0c9q2t3.fsf@HIDDEN>
 <87blrt7rso.fsf@HIDDEN> <874kx28b7m.fsf@HIDDEN>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: submit
Cc: alex.branham@HIDDEN, eggert@HIDDEN, k.stevens@HIDDEN,
 bug-gnu-emacs@HIDDEN, larsi@HIDDEN, zappo@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Damien Cassou <damien@HIDDEN>
> Cc: bug-gnu-emacs@HIDDEN, k.stevens@HIDDEN, zappo@HIDDEN,
>  alex.branham@HIDDEN, larsi@HIDDEN, eggert@HIDDEN
> Date: Sat, 11 Jan 2020 12:49:17 +0100
> 
> Damien Cassou <damien@HIDDEN> writes:
> 
> > Eli Zaretskii <eliz@HIDDEN> writes:
> >> You mean, this is in addition to the previous patches?  If so, I'd
> >> prefer a single patch.
> >
> > you want all the changes merged into a single patch? This seems much
> > harder to review but here it is.
> 
> any news?

Sorry, it fell through the cracks.

However, I was about to push it now, but compiling the modified
version generates warnings:

    ELC      emacs-lisp/checkdoc.elc

  In checkdoc-ispell-docstring-engine:
  emacs-lisp/checkdoc.el:2161:47:Warning: reference to free variable
      `ispell-format-word-function'
  emacs-lisp/checkdoc.el:2162:62:Warning: reference to free variable
      `ispell-program-name'
  emacs-lisp/checkdoc.el:2163:42:Warning: reference to free variable
      `ispell-current-dictionary'

  In end of data:
  emacs-lisp/checkdoc.el:2714:1:Warning: the following functions are not known
      to be defined: ispell-set-spellchecker-params,
      ispell-accept-buffer-local-defs, ispell-correct-p

Could you please augment the patch so that these warnings are avoided?

Also, please mention the bug number in the commit log message.

TIA




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#38583; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 11 Jan 2020 11:49:33 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 11 06:49:33 2020
Received: from localhost ([127.0.0.1]:55464 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iqFGm-00014e-V3
	for submit <at> debbugs.gnu.org; Sat, 11 Jan 2020 06:49:33 -0500
Received: from lists.gnu.org ([209.51.188.17]:53657)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <damien@HIDDEN>) id 1iqFGl-00014W-7a
 for submit <at> debbugs.gnu.org; Sat, 11 Jan 2020 06:49:31 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:36491)
 by lists.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <damien@HIDDEN>) id 1iqFGk-0003iA-2N
 for bug-gnu-emacs@HIDDEN; Sat, 11 Jan 2020 06:49:31 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,URIBL_BLOCKED
 autolearn=disabled version=3.3.2
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <damien@HIDDEN>) id 1iqFGi-0003ZK-W8
 for bug-gnu-emacs@HIDDEN; Sat, 11 Jan 2020 06:49:29 -0500
Received: from mail.choca.pics ([80.67.172.235]:49070)
 by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <damien@HIDDEN>)
 id 1iqFGi-0003DW-Pa; Sat, 11 Jan 2020 06:49:28 -0500
Received: from localhost (localhost.localdomain [IPv6:::1])
 by mail.choca.pics (Postfix) with ESMTP id 2CA51181A505B;
 Sat, 11 Jan 2020 12:49:20 +0100 (CET)
Received: from mail.choca.pics ([IPv6:::1])
 by localhost (mail.choca.pics [IPv6:::1]) (amavisd-new, port 10032)
 with ESMTP id STgI1ofEVakq; Sat, 11 Jan 2020 12:49:19 +0100 (CET)
Received: from localhost (localhost.localdomain [IPv6:::1])
 by mail.choca.pics (Postfix) with ESMTP id 7EE3B181A505C;
 Sat, 11 Jan 2020 12:49:19 +0100 (CET)
X-Virus-Scanned: amavisd-new at choca.pics
Received: from mail.choca.pics ([IPv6:::1])
 by localhost (mail.choca.pics [IPv6:::1]) (amavisd-new, port 10026)
 with ESMTP id q7CQNb5Nbd7f; Sat, 11 Jan 2020 12:49:19 +0100 (CET)
Received: from luz4 (57.139.120.78.rev.sfr.net [78.120.139.57])
 by mail.choca.pics (Postfix) with ESMTPSA id 15F16181A505B;
 Sat, 11 Jan 2020 12:49:19 +0100 (CET)
From: Damien Cassou <damien@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: [PATCH] 27.0.50; Add unattended spell-checking to checkdoc
In-Reply-To: <87blrt7rso.fsf@HIDDEN>
References: <87immlw7zo.fsf@HIDDEN> <83blsc8ujl.fsf@HIDDEN>
 <871rt8gfy0.fsf@HIDDEN> <83mubw6lpb.fsf@HIDDEN>
 <87o8vu7zqp.fsf@HIDDEN> <83d0c9q2t3.fsf@HIDDEN>
 <87blrt7rso.fsf@HIDDEN>
Date: Sat, 11 Jan 2020 12:49:17 +0100
Message-ID: <874kx28b7m.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
 [fuzzy]
X-Received-From: 80.67.172.235
X-Spam-Score: -1.4 (-)
X-Debbugs-Envelope-To: submit
Cc: alex.branham@HIDDEN, eggert@HIDDEN, k.stevens@HIDDEN,
 bug-gnu-emacs@HIDDEN, larsi@HIDDEN, zappo@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.4 (--)

Damien Cassou <damien@HIDDEN> writes:

> Eli Zaretskii <eliz@HIDDEN> writes:
>> You mean, this is in addition to the previous patches?  If so, I'd
>> prefer a single patch.
>
> you want all the changes merged into a single patch? This seems much
> harder to review but here it is.

any news?

-- 
Damien Cassou

"Success is the ability to go from one failure to another without
losing enthusiasm." --Winston Churchill




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#38583; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 27 Dec 2019 14:43:30 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Dec 27 09:43:30 2019
Received: from localhost ([127.0.0.1]:56677 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ikqpt-00038u-O0
	for submit <at> debbugs.gnu.org; Fri, 27 Dec 2019 09:43:30 -0500
Received: from lists.gnu.org ([209.51.188.17]:57906)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <damien@HIDDEN>) id 1ikqpr-00038l-Rr
 for submit <at> debbugs.gnu.org; Fri, 27 Dec 2019 09:43:28 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:40761)
 by lists.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <damien@HIDDEN>) id 1ikqpp-0004oN-OT
 for bug-gnu-emacs@HIDDEN; Fri, 27 Dec 2019 09:43:27 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,URIBL_BLOCKED
 autolearn=disabled version=3.3.2
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <damien@HIDDEN>) id 1ikqpn-0008H9-KG
 for bug-gnu-emacs@HIDDEN; Fri, 27 Dec 2019 09:43:25 -0500
Received: from mail.choca.pics ([80.67.172.235]:35330)
 by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <damien@HIDDEN>)
 id 1ikqpn-0008EJ-8f; Fri, 27 Dec 2019 09:43:23 -0500
Received: from localhost (localhost.localdomain [127.0.0.1])
 by mail.choca.pics (Postfix) with ESMTP id 61B4E18192DF2;
 Fri, 27 Dec 2019 15:43:21 +0100 (CET)
Received: from mail.choca.pics ([127.0.0.1])
 by localhost (mail.choca.pics [127.0.0.1]) (amavisd-new, port 10032)
 with ESMTP id UxS2saJAE5RM; Fri, 27 Dec 2019 15:43:20 +0100 (CET)
Received: from localhost (localhost.localdomain [127.0.0.1])
 by mail.choca.pics (Postfix) with ESMTP id 3B05818192B2A;
 Fri, 27 Dec 2019 15:43:20 +0100 (CET)
X-Virus-Scanned: amavisd-new at choca.pics
Received: from mail.choca.pics ([127.0.0.1])
 by localhost (mail.choca.pics [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id QqFJLNm7KTHa; Fri, 27 Dec 2019 15:43:20 +0100 (CET)
Received: from luz4 (87-231-56-147.rev.numericable.fr [87.231.56.147])
 by mail.choca.pics (Postfix) with ESMTPSA id CB01518192DF2;
 Fri, 27 Dec 2019 15:43:19 +0100 (CET)
From: Damien Cassou <damien@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: [PATCH] 27.0.50; Add unattended spell-checking to checkdoc
In-Reply-To: <83d0c9q2t3.fsf@HIDDEN>
References: <87immlw7zo.fsf@HIDDEN> <83blsc8ujl.fsf@HIDDEN>
 <871rt8gfy0.fsf@HIDDEN> <83mubw6lpb.fsf@HIDDEN>
 <87o8vu7zqp.fsf@HIDDEN> <83d0c9q2t3.fsf@HIDDEN>
Date: Fri, 27 Dec 2019 15:43:19 +0100
Message-ID: <87blrt7rso.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
 [fuzzy]
X-Received-From: 80.67.172.235
X-Spam-Score: -1.4 (-)
X-Debbugs-Envelope-To: submit
Cc: alex.branham@HIDDEN, eggert@HIDDEN, k.stevens@HIDDEN,
 bug-gnu-emacs@HIDDEN, larsi@HIDDEN, zappo@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.4 (--)

--=-=-=
Content-Type: text/plain

Eli Zaretskii <eliz@HIDDEN> writes:
> You mean, this is in addition to the previous patches?  If so, I'd
> prefer a single patch.

you want all the changes merged into a single patch? This seems much
harder to review but here it is.

-- 
Damien Cassou

"Success is the ability to go from one failure to another without
losing enthusiasm." --Winston Churchill

--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=0001-Add-unattended-spell-checking-to-checkdoc.patch

From 71bf337ce06411f4951ec3a6e3b2a7c7f5dca55b Mon Sep 17 00:00:00 2001
From: Damien Cassou <damien@HIDDEN>
Date: Fri, 27 Dec 2019 15:35:52 +0100
Subject: [PATCH] Add unattended spell-checking to checkdoc

This commit makes checkdoc capable of spell-checking even when the
user isn't using it interactively. When TAKE-NOTES is non-nil,
checkdoc will run spell-checking (with ispell) and report spelling
mistakes.

* lisp/textmodes/ispell.el (ispell-word): Extract part of it to
`ispell--run-on-word`.
(ispell--run-on-word): New function, extracted from `ispell-word`.
(ispell-correct-p): New function.  Use `ispell--run-on-word`.
* lisp/emacs-lisp/checkdoc.el (checkdoc-current-buffer): Pass
TAKE-NOTES to `checkdoc-start`.
(checkdoc-continue): Pass TAKE-NOTES to `checkdoc-this-string-valid`.
(checkdoc-this-string-valid): Add optional argument TAKE-NOTES and
pass it to `checkdoc-this-string-valid-engine`.
(checkdoc-this-string-valid-engine): Add optional argument TAKE-NOTES and
pass it to `checkdoc-ispell-docstring-engine`.
(checkdoc-ispell-init): Call `ispell-set-spellchecker-params` and
`ispell-accept-buffer-local-defs`.  These calls are required to
properly use ispell.  The problem went unnoticed until now because
checkdoc was only using ispell through the high-level command
`ispell-word` which takes care of all the initialization for the user.
(checkdoc-ispell-docstring-engine): Add optional argument TAKE-NOTES
to force reporting of spell-checking errors.  Throw error
when (checkdoc-ispell-init) fails configuring ispell.  Replace a
few (if cond nil body) with (unless cond body). Replace (let ((var
nil))) with (let (var)). Replace (if (not (eq checkdoc-autofix-flag
'never)) body) with just body because `checkdoc-autofix-flag` is
checked at the beginning of the function.
---
 lisp/emacs-lisp/checkdoc.el | 117 +++++++++++++++++++++---------------
 lisp/textmodes/ispell.el    |  46 ++++++++++----
 2 files changed, 101 insertions(+), 62 deletions(-)

diff --git a/lisp/emacs-lisp/checkdoc.el b/lisp/emacs-lisp/checkdoc.el
index 6c40bdf632..0269b89790 100644
--- a/lisp/emacs-lisp/checkdoc.el
+++ b/lisp/emacs-lisp/checkdoc.el
@@ -849,7 +849,7 @@ checkdoc-current-buffer
     ;; every test is responsible for returning the cursor.
     (or (and buffer-file-name ;; only check comments in a file
 	     (checkdoc-comments))
-	(checkdoc-start)
+	(checkdoc-start take-notes)
 	(checkdoc-message-text)
 	(checkdoc-rogue-spaces)
         (when checkdoc-package-keywords-flag
@@ -902,7 +902,7 @@ checkdoc-continue
       ;; the user is navigating down through the buffer.
       (while (and (not wrong) (checkdoc-next-docstring))
 	;; OK, let's look at the doc string.
-	(setq msg (checkdoc-this-string-valid))
+	(setq msg (checkdoc-this-string-valid take-notes))
 	(if msg (setq wrong (point)))))
     (if wrong
 	(progn
@@ -1284,12 +1284,15 @@ checkdoc-create-common-verbs-regexp
 
 ;;; Checking engines
 ;;
-(defun checkdoc-this-string-valid ()
+(defun checkdoc-this-string-valid (&optional take-notes)
   "Return a message string if the current doc string is invalid.
 Check for style only, such as the first line always being a complete
 sentence, whitespace restrictions, and making sure there are no
 hard-coded key-codes such as C-[char] or mouse-[number] in the comment.
-See the style guide in the Emacs Lisp manual for more details."
+See the style guide in the Emacs Lisp manual for more details.
+
+With a non-nil TAKE-NOTES, store all errors found in a warnings
+buffer, otherwise stop after the first error."
 
   ;; Jump over comments between the last object and the doc string
   (while (looking-at "[ \t\n]*;")
@@ -1366,13 +1369,16 @@ checkdoc-this-string-valid
 	      (point) (+ (point) 1) t)))))
     (if (and (not err) (= (following-char) ?\"))
         (with-syntax-table checkdoc-syntax-table
-          (checkdoc-this-string-valid-engine fp))
+          (checkdoc-this-string-valid-engine fp take-notes))
       err)))
 
-(defun checkdoc-this-string-valid-engine (fp)
+(defun checkdoc-this-string-valid-engine (fp &optional take-notes)
   "Return an error list or string if the current doc string is invalid.
 Depends on `checkdoc-this-string-valid' to reset the syntax table so that
-regexp short cuts work.  FP is the function defun information."
+regexp short cuts work.  FP is the function defun information.
+
+With a non-nil TAKE-NOTES, store all errors found in a warnings
+buffer, otherwise stop after the first error."
   (let ((case-fold-search nil)
 	;; Use a marker so if an early check modifies the text,
 	;; we won't accidentally lose our place.  This could cause
@@ -1864,7 +1870,7 @@ checkdoc-this-string-valid-engine
      ;; Make sure the doc string has correctly spelled English words
      ;; in it.  This function is extracted due to its complexity,
      ;; and reliance on the Ispell program.
-     (checkdoc-ispell-docstring-engine e)
+     (checkdoc-ispell-docstring-engine e take-notes)
      ;; User supplied checks
      (save-excursion (checkdoc-run-hooks 'checkdoc-style-functions fp e))
      ;; Done!
@@ -2100,58 +2106,69 @@ checkdoc-ispell-init
   (unless ispell-process
     (condition-case nil
 	(progn
-	  (ispell-buffer-local-words)
+          (ispell-set-spellchecker-params)    ; Initialize variables and dicts alists
+          (ispell-accept-buffer-local-defs)   ; use the correct dictionary
 	  ;; This code copied in part from ispell.el Emacs 19.34
 	  (dolist (w checkdoc-ispell-lisp-words)
 	    (process-send-string ispell-process (concat "@" w "\n"))))
       (error (setq checkdoc-spellcheck-documentation-flag nil)))))
 
-(defun checkdoc-ispell-docstring-engine (end)
+(defun checkdoc-ispell-docstring-engine (end &optional take-notes)
   "Run the Ispell tools on the doc string between point and END.
 Since Ispell isn't Lisp-smart, we must pre-process the doc string
-before using the Ispell engine on it."
-  (if (or (not checkdoc-spellcheck-documentation-flag)
-	  ;; If the user wants no questions or fixing, then we must
-	  ;; disable spell checking as not useful.
-	  (not checkdoc-autofix-flag)
-	  (eq checkdoc-autofix-flag 'never))
-      nil
+before using the Ispell engine on it.
+
+With a non-nil TAKE-NOTES, store all errors found in a warnings
+buffer, otherwise stop after the first error."
+  (when (and checkdoc-spellcheck-documentation-flag
+             ;; If the user wants no questions or fixing, then we must
+             ;; disable spell checking as not useful.
+             (or take-notes
+                 (and checkdoc-autofix-flag
+                      (not (eq checkdoc-autofix-flag 'never)))))
     (checkdoc-ispell-init)
+    (unless checkdoc-spellcheck-documentation-flag
+      ;; this happens when (checkdoc-ispell-init) can't start `ispell-program-name'
+      (user-error "No spellchecker installed: check the variable `ispell-program-name'."))
     (save-excursion
       (skip-chars-forward "^a-zA-Z")
-      (let ((word nil) (sym nil) (case-fold-search nil) (err nil))
-	(while (and (not err) (< (point) end))
-	  (if (save-excursion (forward-char -1) (looking-at "[('`]"))
-	      ;; Skip lists describing meta-syntax, or bound variables
-	      (forward-sexp 1)
-	    (setq word (buffer-substring-no-properties
-			(point) (progn
-				  (skip-chars-forward "a-zA-Z-")
-				  (point)))
-		  sym (intern-soft word))
-	    (if (and sym (or (boundp sym) (fboundp sym)))
-		;; This is probably repetitive in most cases, but not always.
-		nil
-	      ;; Find out how we spell-check this word.
-	      (if (or
-		   ;; All caps w/ option th, or s tacked on the end
-		   ;; for pluralization or number.
-		   (string-match "^[A-Z][A-Z]+\\(s\\|th\\)?$" word)
-		   (looking-at "}") ; a keymap expression
-		   )
-		  nil
-		(save-excursion
-		  (if (not (eq checkdoc-autofix-flag 'never))
-		      (let ((lk last-input-event))
-			(ispell-word nil t)
-			(if (not (equal last-input-event lk))
-			    (progn
-			      (sit-for 0)
-			      (message "Continuing..."))))
-		    ;; Nothing here.
-		    )))))
-	  (skip-chars-forward "^a-zA-Z"))
-	err))))
+      (let (word sym case-fold-search err word-beginning word-end)
+        (while (and (not err) (< (point) end))
+          (if (save-excursion (forward-char -1) (looking-at "[('`]"))
+              ;; Skip lists describing meta-syntax, or bound variables
+              (forward-sexp 1)
+            (setq word-beginning (point)
+                  word-end (progn
+                             (skip-chars-forward "a-zA-Z-")
+                             (point))
+                  word (buffer-substring-no-properties word-beginning word-end)
+                  sym (intern-soft word))
+            (unless (and sym (or (boundp sym) (fboundp sym)))
+              ;; Find out how we spell-check this word.
+              (unless (or
+                       ;; All caps w/ option th, or s tacked on the end
+                       ;; for pluralization or number.
+                       (string-match "^[A-Z][A-Z]+\\(s\\|th\\)?$" word)
+                       (looking-at "}") ; a keymap expression
+                       )
+                (save-excursion
+                  (let ((lk last-input-event))
+                    (if take-notes
+                        (progn
+                          (unless (ispell-correct-p)
+                            (checkdoc-create-error
+                             (format "Error checking word %s using %s with %s dictionary"
+		                     (funcall ispell-format-word-function word)
+		                     (file-name-nondirectory ispell-program-name)
+		                     (or ispell-current-dictionary "default"))
+                             word-beginning word-end)))
+                      (ispell-word nil t))
+                    (if (not (equal last-input-event lk))
+                        (progn
+                          (sit-for 0)
+                          (message "Continuing..."))))))))
+          (skip-chars-forward "^a-zA-Z"))
+        err))))
 
 ;;; Rogue space checking engine
 ;;
diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el
index dd1eeb4530..7ec445211d 100644
--- a/lisp/textmodes/ispell.el
+++ b/lisp/textmodes/ispell.el
@@ -1951,18 +1951,7 @@ ispell-word
       (or quietly
 	  (message "Checking spelling of %s..."
 		   (funcall ispell-format-word-function word)))
-      (ispell-send-string "%\n")	; put in verbose mode
-      (ispell-send-string (concat "^" word "\n"))
-      ;; wait until ispell has processed word
-      (while (progn
-	       (ispell-accept-output)
-	       (not (string= "" (car ispell-filter)))))
-      ;;(ispell-send-string "!\n") ;back to terse mode.
-      (setq ispell-filter (cdr ispell-filter)) ; remove extra \n
-      (if (and ispell-filter (listp ispell-filter))
-	  (if (> (length ispell-filter) 1)
-	      (error "Ispell and its process have different character maps")
-	    (setq poss (ispell-parse-output (car ispell-filter)))))
+      (setq poss (ispell--run-on-word))
       (cond ((eq poss t)
 	     (or quietly
 		 (message "%s is correct"
@@ -2024,6 +2013,39 @@ ispell-word
       (goto-char cursor-location)	; return to original location
       replace))))
 
+(defun ispell--run-on-word (word)
+  "Run ispell on WORD."
+  (ispell-send-string "%\n")	; put in verbose mode
+  (ispell-send-string (concat "^" word "\n"))
+  ;; wait until ispell has processed word
+  (while (progn
+           (ispell-accept-output)
+           (not (string= "" (car ispell-filter)))))
+  (setq ispell-filter (cdr ispell-filter))
+  (when (and ispell-filter (listp ispell-filter))
+    (if (> (length ispell-filter) 1)
+        (error "Ispell and its processs have different character maps: %s" ispell-filter)
+      (ispell-parse-output (car ispell-filter)))))
+
+(defun ispell-correct-p (&optional following)
+  "Return t if the word at point is correct. Nil otherwise.
+
+If optional argument FOLLOWING is non-nil then the following
+word (rather than preceding) is checked when the cursor is not
+over a word."
+  (save-excursion
+    ; reset ispell-filter so it only contains the result of
+    ; spell-checking the current-word:
+    (setq ispell-filter nil)
+    (let* ((word-and-boundaries (ispell-get-word following))
+           (poss (ispell--run-on-word (car word-and-boundaries))))
+      (unless poss
+        (error "Error checking word %s using %s with %s dictionary"
+               (funcall ispell-format-word-function word)
+               (file-name-nondirectory ispell-program-name)
+               (or ispell-current-dictionary "default")))
+      (or (eq poss t)
+          (stringp poss)))))
 
 (defun ispell-get-word (following &optional extra-otherchars)
   "Return the word for spell-checking according to ispell syntax.
-- 
2.24.1


--=-=-=--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#38583; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 27 Dec 2019 14:08:20 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Dec 27 09:08:20 2019
Received: from localhost ([127.0.0.1]:56644 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ikqHn-0002H8-Nw
	for submit <at> debbugs.gnu.org; Fri, 27 Dec 2019 09:08:20 -0500
Received: from lists.gnu.org ([209.51.188.17]:57970)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1ikqHl-0002H1-KA
 for submit <at> debbugs.gnu.org; Fri, 27 Dec 2019 09:08:13 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:34838)
 by lists.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <eliz@HIDDEN>) id 1ikqHj-0007qq-KY
 for bug-gnu-emacs@HIDDEN; Fri, 27 Dec 2019 09:08:13 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_20,
 URIBL_BLOCKED autolearn=disabled version=3.3.2
Received: from fencepost.gnu.org ([2001:470:142:3::e]:44966)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <eliz@HIDDEN>)
 id 1ikqHi-0007hj-94; Fri, 27 Dec 2019 09:08:10 -0500
Received: from [176.228.60.248] (port=2616 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <eliz@HIDDEN>)
 id 1ikqHh-0005wQ-Fs; Fri, 27 Dec 2019 09:08:10 -0500
Date: Fri, 27 Dec 2019 16:08:08 +0200
Message-Id: <83d0c9q2t3.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Damien Cassou <damien@HIDDEN>
In-reply-to: <87o8vu7zqp.fsf@HIDDEN> (message from Damien Cassou on Fri, 27
 Dec 2019 12:51:42 +0100)
Subject: Re: [PATCH] 27.0.50; Add unattended spell-checking to checkdoc
References: <87immlw7zo.fsf@HIDDEN> <83blsc8ujl.fsf@HIDDEN>
 <871rt8gfy0.fsf@HIDDEN> <83mubw6lpb.fsf@HIDDEN> <87o8vu7zqp.fsf@HIDDEN>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: submit
Cc: alex.branham@HIDDEN, eggert@HIDDEN, k.stevens@HIDDEN,
 bug-gnu-emacs@HIDDEN, larsi@HIDDEN, zappo@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Damien Cassou <damien@HIDDEN>
> Cc: bug-gnu-emacs@HIDDEN, k.stevens@HIDDEN, zappo@HIDDEN,
>  alex.branham@HIDDEN, larsi@HIDDEN, eggert@HIDDEN
> Date: Fri, 27 Dec 2019 12:51:42 +0100
> 
> > Can we check this up front, and display some user-friendly message to
> > the effect that spell-checking cannot be done?
> 
> Here is an additional patch for the series to answer your request.

You mean, this is in addition to the previous patches?  If so, I'd
prefer a single patch.

Thanks.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#38583; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 27 Dec 2019 11:52:02 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Dec 27 06:52:02 2019
Received: from localhost ([127.0.0.1]:56594 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iko9y-0003dA-Ge
	for submit <at> debbugs.gnu.org; Fri, 27 Dec 2019 06:52:02 -0500
Received: from lists.gnu.org ([209.51.188.17]:60773)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <damien@HIDDEN>) id 1iko9v-0003ck-RS
 for submit <at> debbugs.gnu.org; Fri, 27 Dec 2019 06:52:00 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:38088)
 by lists.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <damien@HIDDEN>) id 1iko9s-0002fW-Mf
 for bug-gnu-emacs@HIDDEN; Fri, 27 Dec 2019 06:51:58 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,URIBL_BLOCKED
 autolearn=disabled version=3.3.2
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <damien@HIDDEN>) id 1iko9q-00013c-S5
 for bug-gnu-emacs@HIDDEN; Fri, 27 Dec 2019 06:51:56 -0500
Received: from mail.choca.pics ([80.67.172.235]:60488)
 by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <damien@HIDDEN>)
 id 1iko9p-0000qu-So; Fri, 27 Dec 2019 06:51:54 -0500
Received: from localhost (localhost.localdomain [127.0.0.1])
 by mail.choca.pics (Postfix) with ESMTP id 0A16C18192DF2;
 Fri, 27 Dec 2019 12:51:45 +0100 (CET)
Received: from mail.choca.pics ([127.0.0.1])
 by localhost (mail.choca.pics [127.0.0.1]) (amavisd-new, port 10032)
 with ESMTP id zkZmmYgNyD9O; Fri, 27 Dec 2019 12:51:44 +0100 (CET)
Received: from localhost (localhost.localdomain [127.0.0.1])
 by mail.choca.pics (Postfix) with ESMTP id 5D81718192B2B;
 Fri, 27 Dec 2019 12:51:44 +0100 (CET)
X-Virus-Scanned: amavisd-new at choca.pics
Received: from mail.choca.pics ([127.0.0.1])
 by localhost (mail.choca.pics [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id VCiGJsgyW_s8; Fri, 27 Dec 2019 12:51:44 +0100 (CET)
Received: from luz4 (87-231-56-147.rev.numericable.fr [87.231.56.147])
 by mail.choca.pics (Postfix) with ESMTPSA id E775F18192DF2;
 Fri, 27 Dec 2019 12:51:43 +0100 (CET)
From: Damien Cassou <damien@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: [PATCH] 27.0.50; Add unattended spell-checking to checkdoc
In-Reply-To: <83mubw6lpb.fsf@HIDDEN>
References: <87immlw7zo.fsf@HIDDEN> <83blsc8ujl.fsf@HIDDEN>
 <871rt8gfy0.fsf@HIDDEN> <83mubw6lpb.fsf@HIDDEN>
Date: Fri, 27 Dec 2019 12:51:42 +0100
Message-ID: <87o8vu7zqp.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
 [fuzzy]
X-Received-From: 80.67.172.235
X-Spam-Score: -1.4 (-)
X-Debbugs-Envelope-To: submit
Cc: alex.branham@HIDDEN, eggert@HIDDEN, k.stevens@HIDDEN,
 bug-gnu-emacs@HIDDEN, larsi@HIDDEN, zappo@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.4 (--)

--=-=-=
Content-Type: text/plain

Hi Eli,

Eli Zaretskii <eliz@HIDDEN> writes:
>> Eli Zaretskii <eliz@HIDDEN> writes:
>> > What happens if none of the spellers supported by ispell.el is
>> > installed on the user's system?
>> 
>> Starting new Ispell process ispell with default dictionary... \ 
>> Buffer xxx has no process
>> 
>> Emacs exit status is 255 in this case.
>
> Can we check this up front, and display some user-friendly message to
> the effect that spell-checking cannot be done?

Here is an additional patch for the series to answer your request.

If you believe the patch series is too large to be reviewed, I can split
it in several smaller ones.

-- 
Damien Cassou

"Success is the ability to go from one failure to another without
losing enthusiasm." --Winston Churchill

--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=0006-Improve-error-message-when-no-spellchecker-can-be-fo.patch

From 754a6ed8e9bbe7dd46e0d4595d8e46b76dc5b606 Mon Sep 17 00:00:00 2001
From: Damien Cassou <damien@HIDDEN>
Date: Fri, 27 Dec 2019 12:48:55 +0100
Subject: [PATCH] Improve error message when no spellchecker can be found

* lisp/emacs-lisp/checkdoc.el: Throw error when (checkdoc-ispell-init)
fails configuring ispell.
---
 lisp/emacs-lisp/checkdoc.el | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lisp/emacs-lisp/checkdoc.el b/lisp/emacs-lisp/checkdoc.el
index 3e6542bc80..0269b89790 100644
--- a/lisp/emacs-lisp/checkdoc.el
+++ b/lisp/emacs-lisp/checkdoc.el
@@ -2127,6 +2127,9 @@ checkdoc-ispell-docstring-engine
                  (and checkdoc-autofix-flag
                       (not (eq checkdoc-autofix-flag 'never)))))
     (checkdoc-ispell-init)
+    (unless checkdoc-spellcheck-documentation-flag
+      ;; this happens when (checkdoc-ispell-init) can't start `ispell-program-name'
+      (user-error "No spellchecker installed: check the variable `ispell-program-name'."))
     (save-excursion
       (skip-chars-forward "^a-zA-Z")
       (let (word sym case-fold-search err word-beginning word-end)
-- 
2.24.1


--=-=-=--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#38583; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 13 Dec 2019 19:59:43 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Dec 13 14:59:43 2019
Received: from localhost ([127.0.0.1]:34668 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ifr6A-0002Ml-Ua
	for submit <at> debbugs.gnu.org; Fri, 13 Dec 2019 14:59:43 -0500
Received: from lists.gnu.org ([209.51.188.17]:37426)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1ifr68-0002Md-Vl
 for submit <at> debbugs.gnu.org; Fri, 13 Dec 2019 14:59:37 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:41549)
 by lists.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <eliz@HIDDEN>) id 1ifr67-0001v7-8C
 for bug-gnu-emacs@HIDDEN; Fri, 13 Dec 2019 14:59:36 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00,
 URIBL_BLOCKED autolearn=disabled version=3.3.2
Received: from fencepost.gnu.org ([2001:470:142:3::e]:46635)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <eliz@HIDDEN>)
 id 1ifr65-0001gK-HN; Fri, 13 Dec 2019 14:59:33 -0500
Received: from [176.228.60.248] (port=4002 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <eliz@HIDDEN>)
 id 1ifr64-0004OV-8X; Fri, 13 Dec 2019 14:59:33 -0500
Date: Fri, 13 Dec 2019 21:59:28 +0200
Message-Id: <83mubw6lpb.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Damien Cassou <damien@HIDDEN>
In-reply-to: <871rt8gfy0.fsf@HIDDEN> (message from Damien Cassou on Fri, 13
 Dec 2019 20:53:43 +0100)
Subject: Re: [PATCH] 27.0.50; Add unattended spell-checking to checkdoc
References: <87immlw7zo.fsf@HIDDEN> <83blsc8ujl.fsf@HIDDEN>
 <871rt8gfy0.fsf@HIDDEN>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: submit
Cc: alex.branham@HIDDEN, eggert@HIDDEN, k.stevens@HIDDEN,
 bug-gnu-emacs@HIDDEN, larsi@HIDDEN, zappo@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

> From: Damien Cassou <damien@HIDDEN>
> Cc: bug-gnu-emacs@HIDDEN, k.stevens@HIDDEN, zappo@HIDDEN, alex.branham@HIDDEN, larsi@HIDDEN, eggert@HIDDEN
> Date: Fri, 13 Dec 2019 20:53:43 +0100
> 
> Eli Zaretskii <eliz@HIDDEN> writes:
> > What happens if none of the spellers supported by ispell.el is
> > installed on the user's system?
> 
> Starting new Ispell process ispell with default dictionary... \ 
> Buffer xxx has no process
> 
> Emacs exit status is 255 in this case.

Can we check this up front, and display some user-friendly message to
the effect that spell-checking cannot be done?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#38583; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 13 Dec 2019 19:53:54 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Dec 13 14:53:54 2019
Received: from localhost ([127.0.0.1]:34652 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ifr0c-0002DN-A2
	for submit <at> debbugs.gnu.org; Fri, 13 Dec 2019 14:53:54 -0500
Received: from lists.gnu.org ([209.51.188.17]:45107)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <damien@HIDDEN>) id 1ifr0Z-0002DF-PE
 for submit <at> debbugs.gnu.org; Fri, 13 Dec 2019 14:53:52 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:37474)
 by lists.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <damien@HIDDEN>) id 1ifr0Y-0007vv-N2
 for bug-gnu-emacs@HIDDEN; Fri, 13 Dec 2019 14:53:51 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,URIBL_BLOCKED
 autolearn=disabled version=3.3.2
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <damien@HIDDEN>) id 1ifr0X-0004Hj-NZ
 for bug-gnu-emacs@HIDDEN; Fri, 13 Dec 2019 14:53:50 -0500
Received: from mail.choca.pics ([62.210.108.126]:52682)
 by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <damien@HIDDEN>)
 id 1ifr0X-0004BF-Gt; Fri, 13 Dec 2019 14:53:49 -0500
Received: from localhost (localhost.localdomain [IPv6:::1])
 by mail.choca.pics (Postfix) with ESMTP id 0BAB6F09985;
 Fri, 13 Dec 2019 20:53:47 +0100 (CET)
Received: from mail.choca.pics ([IPv6:::1])
 by localhost (mail.choca.pics [IPv6:::1]) (amavisd-new, port 10032)
 with ESMTP id xhugKA8AFpkt; Fri, 13 Dec 2019 20:53:46 +0100 (CET)
Received: from localhost (localhost.localdomain [IPv6:::1])
 by mail.choca.pics (Postfix) with ESMTP id 151A9F09986;
 Fri, 13 Dec 2019 20:53:46 +0100 (CET)
X-Virus-Scanned: amavisd-new at choca.pics
Received: from mail.choca.pics ([IPv6:::1])
 by localhost (mail.choca.pics [IPv6:::1]) (amavisd-new, port 10026)
 with ESMTP id 30LKHLjejDCr; Fri, 13 Dec 2019 20:53:45 +0100 (CET)
Received: from luz4 (254.116.5.93.rev.sfr.net [93.5.116.254])
 by mail.choca.pics (Postfix) with ESMTPSA id 9B4C9F09985;
 Fri, 13 Dec 2019 20:53:45 +0100 (CET)
From: Damien Cassou <damien@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: [PATCH] 27.0.50; Add unattended spell-checking to checkdoc
In-Reply-To: <83blsc8ujl.fsf@HIDDEN>
References: <87immlw7zo.fsf@HIDDEN> <83blsc8ujl.fsf@HIDDEN>
Date: Fri, 13 Dec 2019 20:53:43 +0100
Message-ID: <871rt8gfy0.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
 [fuzzy]
X-Received-From: 62.210.108.126
X-Spam-Score: -1.4 (-)
X-Debbugs-Envelope-To: submit
Cc: alex.branham@HIDDEN, eggert@HIDDEN, k.stevens@HIDDEN,
 bug-gnu-emacs@HIDDEN, larsi@HIDDEN, zappo@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.4 (--)

Eli Zaretskii <eliz@HIDDEN> writes:
> What happens if none of the spellers supported by ispell.el is
> installed on the user's system?

Starting new Ispell process ispell with default dictionary... \ 
Buffer xxx has no process

Emacs exit status is 255 in this case.


-- 
Damien Cassou

"Success is the ability to go from one failure to another without
losing enthusiasm." --Winston Churchill




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#38583; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 13 Dec 2019 09:05:49 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Dec 13 04:05:49 2019
Received: from localhost ([127.0.0.1]:33001 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ifgtM-0004vu-M9
	for submit <at> debbugs.gnu.org; Fri, 13 Dec 2019 04:05:49 -0500
Received: from lists.gnu.org ([209.51.188.17]:46959)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1ifgtK-0004vm-TL
 for submit <at> debbugs.gnu.org; Fri, 13 Dec 2019 04:05:43 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:35424)
 by lists.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <eliz@HIDDEN>) id 1ifgtJ-0003N7-R8
 for bug-gnu-emacs@HIDDEN; Fri, 13 Dec 2019 04:05:42 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_40,
 URIBL_BLOCKED autolearn=disabled version=3.3.2
Received: from fencepost.gnu.org ([2001:470:142:3::e]:51938)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <eliz@HIDDEN>)
 id 1ifgtI-0005vk-GG; Fri, 13 Dec 2019 04:05:40 -0500
Received: from [176.228.60.248] (port=3881 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <eliz@HIDDEN>)
 id 1ifgtH-0006KX-Pg; Fri, 13 Dec 2019 04:05:40 -0500
Date: Fri, 13 Dec 2019 11:05:34 +0200
Message-Id: <83blsc8ujl.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Damien Cassou <damien@HIDDEN>
In-reply-to: <87immlw7zo.fsf@HIDDEN> (message from Damien Cassou on Thu, 12
 Dec 2019 22:26:35 +0100)
Subject: Re: [PATCH] 27.0.50; Add unattended spell-checking to checkdoc
References: <87immlw7zo.fsf@HIDDEN>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: submit
Cc: alex.branham@HIDDEN, eggert@HIDDEN, k.stevens@HIDDEN,
 bug-gnu-emacs@HIDDEN, larsi@HIDDEN, zappo@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

> From: Damien Cassou <damien@HIDDEN>
> Cc: "Ken Stevens" <k.stevens@HIDDEN>, "Eric M. Ludlam" <zappo@HIDDEN>,
>  "Alex Branham" <alex.branham@HIDDEN>, "Lars Ingebrigtsen"
>  <larsi@HIDDEN>, "Paul Eggert" <eggert@HIDDEN>, "Eli Zaretskii"
>  <eliz@HIDDEN>
> Date: Thu, 12 Dec 2019 22:26:35 +0100
> 
> This series of patches makes checkdoc capable of spell-checking even
> when the user isn't using it interactively. When TAKE-NOTES is non-nil,
> checkdoc will run spell-checking (with ispell) and report spelling
> mistakes.

Thanks.

What happens if none of the spellers supported by ispell.el is
installed on the user's system?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#38583; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 12 Dec 2019 21:28:29 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Dec 12 16:28:29 2019
Received: from localhost ([127.0.0.1]:60974 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ifW0a-0004uN-MY
	for submit <at> debbugs.gnu.org; Thu, 12 Dec 2019 16:28:29 -0500
Received: from lists.gnu.org ([209.51.188.17]:43641)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <damien@HIDDEN>) id 1ifW0Y-0004uF-Ho
 for submit <at> debbugs.gnu.org; Thu, 12 Dec 2019 16:28:27 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:39630)
 by lists.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <damien@HIDDEN>) id 1ifW0V-0002lc-Ud
 for bug-gnu-emacs@HIDDEN; Thu, 12 Dec 2019 16:28:26 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,URIBL_BLOCKED
 autolearn=disabled version=3.3.2
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <damien@HIDDEN>) id 1ifW0T-0007FA-94
 for bug-gnu-emacs@HIDDEN; Thu, 12 Dec 2019 16:28:23 -0500
Received: from mail.choca.pics ([62.210.108.126]:36768)
 by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <damien@HIDDEN>)
 id 1ifW0S-00051q-LD; Thu, 12 Dec 2019 16:28:21 -0500
Received: from localhost (localhost.localdomain [IPv6:::1])
 by mail.choca.pics (Postfix) with ESMTP id 7196EF098BE;
 Thu, 12 Dec 2019 22:26:41 +0100 (CET)
Received: from mail.choca.pics ([IPv6:::1])
 by localhost (mail.choca.pics [IPv6:::1]) (amavisd-new, port 10032)
 with ESMTP id h4uSll4qgGjk; Thu, 12 Dec 2019 22:26:38 +0100 (CET)
Received: from localhost (localhost.localdomain [IPv6:::1])
 by mail.choca.pics (Postfix) with ESMTP id 36762F098BF;
 Thu, 12 Dec 2019 22:26:38 +0100 (CET)
X-Virus-Scanned: amavisd-new at choca.pics
Received: from mail.choca.pics ([IPv6:::1])
 by localhost (mail.choca.pics [IPv6:::1]) (amavisd-new, port 10026)
 with ESMTP id BQ6SdTeQd2BE; Thu, 12 Dec 2019 22:26:37 +0100 (CET)
Received: from luz4 (254.116.5.93.rev.sfr.net [93.5.116.254])
 by mail.choca.pics (Postfix) with ESMTPSA id 770FCF098BE;
 Thu, 12 Dec 2019 22:26:37 +0100 (CET)
From: Damien Cassou <damien@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: [PATCH] 27.0.50; Add unattended spell-checking to checkdoc
Date: Thu, 12 Dec 2019 22:26:35 +0100
Message-ID: <87immlw7zo.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
 [fuzzy]
X-Received-From: 62.210.108.126
X-Spam-Score: -1.4 (-)
X-Debbugs-Envelope-To: submit
Cc: Alex Branham <alex.branham@HIDDEN>, Paul Eggert <eggert@HIDDEN>,
 Ken Stevens <k.stevens@HIDDEN>, Lars Ingebrigtsen <larsi@HIDDEN>,
 "Eric M. Ludlam" <zappo@HIDDEN>, Eli Zaretskii <eliz@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.4 (--)

--=-=-=
Content-Type: text/plain

This series of patches makes checkdoc capable of spell-checking even
when the user isn't using it interactively. When TAKE-NOTES is non-nil,
checkdoc will run spell-checking (with ispell) and report spelling
mistakes.

Damien Cassou (5):
  Add function `ispell-correct-p`
  Fix indentation of `checkdoc-ispell-docstring-engine`
  Cleanup of `checkdoc-ispell-docstring-engine`
  Properly initialize ispell in checkdoc
  Add unattended spell-checking to checkdoc

 lisp/emacs-lisp/checkdoc.el | 114 ++++++++++++++++++++----------------
 lisp/textmodes/ispell.el    |  46 +++++++++++----
 2 files changed, 98 insertions(+), 62 deletions(-)

-- 
Damien Cassou

"Success is the ability to go from one failure to another without
losing enthusiasm." --Winston Churchill

--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=0001-Add-function-ispell-correct-p.patch

From aca6b5bc1571018efa3f05e972882738ddb3a271 Mon Sep 17 00:00:00 2001
From: Damien Cassou <damien@HIDDEN>
Date: Sat, 7 Dec 2019 16:01:13 +0100
Subject: [PATCH 1/5] Add function `ispell-correct-p`

* lisp/textmodes/ispell.el (ispell-word): Extract part of it to
`ispell--run-on-word`.
(ispell--run-on-word): New function, extracted from `ispell-word`.
(ispell-correct-p): New function. Use `ispell--run-on-word`.
---
 lisp/textmodes/ispell.el | 46 +++++++++++++++++++++++++++++-----------
 1 file changed, 34 insertions(+), 12 deletions(-)

diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el
index dd1eeb4530..7ec445211d 100644
--- a/lisp/textmodes/ispell.el
+++ b/lisp/textmodes/ispell.el
@@ -1951,18 +1951,7 @@ ispell-word
       (or quietly
 	  (message "Checking spelling of %s..."
 		   (funcall ispell-format-word-function word)))
-      (ispell-send-string "%\n")	; put in verbose mode
-      (ispell-send-string (concat "^" word "\n"))
-      ;; wait until ispell has processed word
-      (while (progn
-	       (ispell-accept-output)
-	       (not (string= "" (car ispell-filter)))))
-      ;;(ispell-send-string "!\n") ;back to terse mode.
-      (setq ispell-filter (cdr ispell-filter)) ; remove extra \n
-      (if (and ispell-filter (listp ispell-filter))
-	  (if (> (length ispell-filter) 1)
-	      (error "Ispell and its process have different character maps")
-	    (setq poss (ispell-parse-output (car ispell-filter)))))
+      (setq poss (ispell--run-on-word))
       (cond ((eq poss t)
 	     (or quietly
 		 (message "%s is correct"
@@ -2024,6 +2013,39 @@ ispell-word
       (goto-char cursor-location)	; return to original location
       replace))))
 
+(defun ispell--run-on-word (word)
+  "Run ispell on WORD."
+  (ispell-send-string "%\n")	; put in verbose mode
+  (ispell-send-string (concat "^" word "\n"))
+  ;; wait until ispell has processed word
+  (while (progn
+           (ispell-accept-output)
+           (not (string= "" (car ispell-filter)))))
+  (setq ispell-filter (cdr ispell-filter))
+  (when (and ispell-filter (listp ispell-filter))
+    (if (> (length ispell-filter) 1)
+        (error "Ispell and its processs have different character maps: %s" ispell-filter)
+      (ispell-parse-output (car ispell-filter)))))
+
+(defun ispell-correct-p (&optional following)
+  "Return t if the word at point is correct. Nil otherwise.
+
+If optional argument FOLLOWING is non-nil then the following
+word (rather than preceding) is checked when the cursor is not
+over a word."
+  (save-excursion
+    ; reset ispell-filter so it only contains the result of
+    ; spell-checking the current-word:
+    (setq ispell-filter nil)
+    (let* ((word-and-boundaries (ispell-get-word following))
+           (poss (ispell--run-on-word (car word-and-boundaries))))
+      (unless poss
+        (error "Error checking word %s using %s with %s dictionary"
+               (funcall ispell-format-word-function word)
+               (file-name-nondirectory ispell-program-name)
+               (or ispell-current-dictionary "default")))
+      (or (eq poss t)
+          (stringp poss)))))
 
 (defun ispell-get-word (following &optional extra-otherchars)
   "Return the word for spell-checking according to ispell syntax.
-- 
2.23.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=0002-Fix-indentation-of-checkdoc-ispell-docstring-engine.patch

From 2e78244d3da3796dbf960ce5acbea82ba476bd12 Mon Sep 17 00:00:00 2001
From: Damien Cassou <damien@HIDDEN>
Date: Sat, 7 Dec 2019 17:37:46 +0100
Subject: [PATCH 2/5] Fix indentation of `checkdoc-ispell-docstring-engine`

* lisp/emacs-lisp/checkdoc.el (checkdoc-ispell-docstring-engine):
Replace tabs with white spaces.
---
 lisp/emacs-lisp/checkdoc.el | 72 ++++++++++++++++++-------------------
 1 file changed, 36 insertions(+), 36 deletions(-)

diff --git a/lisp/emacs-lisp/checkdoc.el b/lisp/emacs-lisp/checkdoc.el
index 6c40bdf632..b4c20778bf 100644
--- a/lisp/emacs-lisp/checkdoc.el
+++ b/lisp/emacs-lisp/checkdoc.el
@@ -2111,47 +2111,47 @@ checkdoc-ispell-docstring-engine
 Since Ispell isn't Lisp-smart, we must pre-process the doc string
 before using the Ispell engine on it."
   (if (or (not checkdoc-spellcheck-documentation-flag)
-	  ;; If the user wants no questions or fixing, then we must
-	  ;; disable spell checking as not useful.
-	  (not checkdoc-autofix-flag)
-	  (eq checkdoc-autofix-flag 'never))
+          ;; If the user wants no questions or fixing, then we must
+          ;; disable spell checking as not useful.
+          (not checkdoc-autofix-flag)
+          (eq checkdoc-autofix-flag 'never))
       nil
     (checkdoc-ispell-init)
     (save-excursion
       (skip-chars-forward "^a-zA-Z")
       (let ((word nil) (sym nil) (case-fold-search nil) (err nil))
-	(while (and (not err) (< (point) end))
-	  (if (save-excursion (forward-char -1) (looking-at "[('`]"))
-	      ;; Skip lists describing meta-syntax, or bound variables
-	      (forward-sexp 1)
-	    (setq word (buffer-substring-no-properties
-			(point) (progn
-				  (skip-chars-forward "a-zA-Z-")
-				  (point)))
-		  sym (intern-soft word))
-	    (if (and sym (or (boundp sym) (fboundp sym)))
-		;; This is probably repetitive in most cases, but not always.
-		nil
-	      ;; Find out how we spell-check this word.
-	      (if (or
-		   ;; All caps w/ option th, or s tacked on the end
-		   ;; for pluralization or number.
-		   (string-match "^[A-Z][A-Z]+\\(s\\|th\\)?$" word)
-		   (looking-at "}") ; a keymap expression
-		   )
-		  nil
-		(save-excursion
-		  (if (not (eq checkdoc-autofix-flag 'never))
-		      (let ((lk last-input-event))
-			(ispell-word nil t)
-			(if (not (equal last-input-event lk))
-			    (progn
-			      (sit-for 0)
-			      (message "Continuing..."))))
-		    ;; Nothing here.
-		    )))))
-	  (skip-chars-forward "^a-zA-Z"))
-	err))))
+        (while (and (not err) (< (point) end))
+          (if (save-excursion (forward-char -1) (looking-at "[('`]"))
+              ;; Skip lists describing meta-syntax, or bound variables
+              (forward-sexp 1)
+            (setq word (buffer-substring-no-properties
+                        (point) (progn
+                                  (skip-chars-forward "a-zA-Z-")
+                                  (point)))
+                  sym (intern-soft word))
+            (if (and sym (or (boundp sym) (fboundp sym)))
+                ;; This is probably repetitive in most cases, but not always.
+                nil
+              ;; Find out how we spell-check this word.
+              (if (or
+                   ;; All caps w/ option th, or s tacked on the end
+                   ;; for pluralization or number.
+                   (string-match "^[A-Z][A-Z]+\\(s\\|th\\)?$" word)
+                   (looking-at "}") ; a keymap expression
+                   )
+                  nil
+                (save-excursion
+                  (if (not (eq checkdoc-autofix-flag 'never))
+                      (let ((lk last-input-event))
+                        (ispell-word nil t)
+                        (if (not (equal last-input-event lk))
+                            (progn
+                              (sit-for 0)
+                              (message "Continuing..."))))
+                    ;; Nothing here.
+                    )))))
+          (skip-chars-forward "^a-zA-Z"))
+        err))))
 
 ;;; Rogue space checking engine
 ;;
-- 
2.23.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=0003-Cleanup-of-checkdoc-ispell-docstring-engine.patch

From b3044d5068fa17d1626a2345ffaadf81e6b4e86b Mon Sep 17 00:00:00 2001
From: Damien Cassou <damien@HIDDEN>
Date: Sat, 7 Dec 2019 17:40:35 +0100
Subject: [PATCH 3/5] Cleanup of `checkdoc-ispell-docstring-engine`

* lisp/emacs-lisp/checkdoc.el (checkdoc-ispell-docstring-engine):
Cleanup.  Replace a few (if cond nil body) with (unless cond
body). Replace (let ((var nil)))
with (let (var)). Replace (if (not (eq checkdoc-autofix-flag 'never))
body) with just body because `checkdoc-autofix-flag` is checked at the
beginning of the function.
---
 lisp/emacs-lisp/checkdoc.el | 45 ++++++++++++++++---------------------
 1 file changed, 19 insertions(+), 26 deletions(-)

diff --git a/lisp/emacs-lisp/checkdoc.el b/lisp/emacs-lisp/checkdoc.el
index b4c20778bf..a28bf414bd 100644
--- a/lisp/emacs-lisp/checkdoc.el
+++ b/lisp/emacs-lisp/checkdoc.el
@@ -2110,16 +2110,15 @@ checkdoc-ispell-docstring-engine
   "Run the Ispell tools on the doc string between point and END.
 Since Ispell isn't Lisp-smart, we must pre-process the doc string
 before using the Ispell engine on it."
-  (if (or (not checkdoc-spellcheck-documentation-flag)
-          ;; If the user wants no questions or fixing, then we must
-          ;; disable spell checking as not useful.
-          (not checkdoc-autofix-flag)
-          (eq checkdoc-autofix-flag 'never))
-      nil
+  (when (and checkdoc-spellcheck-documentation-flag
+             ;; If the user wants no questions or fixing, then we must
+             ;; disable spell checking as not useful.
+             checkdoc-autofix-flag
+             (not (eq checkdoc-autofix-flag 'never)))
     (checkdoc-ispell-init)
     (save-excursion
       (skip-chars-forward "^a-zA-Z")
-      (let ((word nil) (sym nil) (case-fold-search nil) (err nil))
+      (let (word sym case-fold-search err)
         (while (and (not err) (< (point) end))
           (if (save-excursion (forward-char -1) (looking-at "[('`]"))
               ;; Skip lists describing meta-syntax, or bound variables
@@ -2129,27 +2128,21 @@ checkdoc-ispell-docstring-engine
                                   (skip-chars-forward "a-zA-Z-")
                                   (point)))
                   sym (intern-soft word))
-            (if (and sym (or (boundp sym) (fboundp sym)))
-                ;; This is probably repetitive in most cases, but not always.
-                nil
+            (unless (and sym (or (boundp sym) (fboundp sym)))
               ;; Find out how we spell-check this word.
-              (if (or
-                   ;; All caps w/ option th, or s tacked on the end
-                   ;; for pluralization or number.
-                   (string-match "^[A-Z][A-Z]+\\(s\\|th\\)?$" word)
-                   (looking-at "}") ; a keymap expression
-                   )
-                  nil
+              (unless (or
+                       ;; All caps w/ option th, or s tacked on the end
+                       ;; for pluralization or number.
+                       (string-match "^[A-Z][A-Z]+\\(s\\|th\\)?$" word)
+                       (looking-at "}") ; a keymap expression
+                       )
                 (save-excursion
-                  (if (not (eq checkdoc-autofix-flag 'never))
-                      (let ((lk last-input-event))
-                        (ispell-word nil t)
-                        (if (not (equal last-input-event lk))
-                            (progn
-                              (sit-for 0)
-                              (message "Continuing..."))))
-                    ;; Nothing here.
-                    )))))
+                  (let ((lk last-input-event))
+                    (ispell-word nil t)
+                    (if (not (equal last-input-event lk))
+                        (progn
+                          (sit-for 0)
+                          (message "Continuing..."))))))))
           (skip-chars-forward "^a-zA-Z"))
         err))))
 
-- 
2.23.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=0004-Properly-initialize-ispell-in-checkdoc.patch

From 58eff3a38959479691ede0d42b841d6696d64a29 Mon Sep 17 00:00:00 2001
From: Damien Cassou <damien@HIDDEN>
Date: Thu, 12 Dec 2019 21:38:08 +0100
Subject: [PATCH 4/5] Properly initialize ispell in checkdoc

* lisp/emacs-lisp/checkdoc.el (checkdoc-ispell-init): Call
`ispell-set-spellchecker-params` and
`ispell-accept-buffer-local-defs`. These calls are required to
properly use ispell. The problem went unnoticed until now because
checkdoc was only using ispell through the high-level command
`ispell-word` which takes care of all the initialization for the user.
---
 lisp/emacs-lisp/checkdoc.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/emacs-lisp/checkdoc.el b/lisp/emacs-lisp/checkdoc.el
index a28bf414bd..075817a252 100644
--- a/lisp/emacs-lisp/checkdoc.el
+++ b/lisp/emacs-lisp/checkdoc.el
@@ -2100,7 +2100,8 @@ checkdoc-ispell-init
   (unless ispell-process
     (condition-case nil
 	(progn
-	  (ispell-buffer-local-words)
+          (ispell-set-spellchecker-params)    ; Initialize variables and dicts alists
+          (ispell-accept-buffer-local-defs)   ; use the correct dictionary
 	  ;; This code copied in part from ispell.el Emacs 19.34
 	  (dolist (w checkdoc-ispell-lisp-words)
 	    (process-send-string ispell-process (concat "@" w "\n"))))
-- 
2.23.0


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=0005-Add-unattended-spell-checking-to-checkdoc.patch

From a3ee18626be6ac564eef34128d50a006073aa130 Mon Sep 17 00:00:00 2001
From: Damien Cassou <damien@HIDDEN>
Date: Thu, 12 Dec 2019 20:27:05 +0100
Subject: [PATCH 5/5] Add unattended spell-checking to checkdoc

This commit makes checkdoc capable of spell-checking even when the
user isn't using it interactively. When TAKE-NOTES is non-nil,
checkdoc will run spell-checking (with ispell) and report spelling
mistakes.

* lisp/emacs-lisp/checkdoc.el (checkdoc-current-buffer): Pass
TAKE-NOTES to `checkdoc-start`.
(checkdoc-continue): Pass TAKE-NOTES to `checkdoc-this-string-valid`.
(checkdoc-this-string-valid): Add optional argument TAKE-NOTES and
pass it to `checkdoc-this-string-valid-engine`.
(checkdoc-this-string-valid-engine): Add optional argument TAKE-NOTES and
pass it to `checkdoc-ispell-docstring-engine`.
(checkdoc-ispell-docstring-engine): Add optional argument TAKE-NOTES
to force reporting of spell-checking errors.
---
 lisp/emacs-lisp/checkdoc.el | 56 +++++++++++++++++++++++++------------
 1 file changed, 38 insertions(+), 18 deletions(-)

diff --git a/lisp/emacs-lisp/checkdoc.el b/lisp/emacs-lisp/checkdoc.el
index 075817a252..3e6542bc80 100644
--- a/lisp/emacs-lisp/checkdoc.el
+++ b/lisp/emacs-lisp/checkdoc.el
@@ -849,7 +849,7 @@ checkdoc-current-buffer
     ;; every test is responsible for returning the cursor.
     (or (and buffer-file-name ;; only check comments in a file
 	     (checkdoc-comments))
-	(checkdoc-start)
+	(checkdoc-start take-notes)
 	(checkdoc-message-text)
 	(checkdoc-rogue-spaces)
         (when checkdoc-package-keywords-flag
@@ -902,7 +902,7 @@ checkdoc-continue
       ;; the user is navigating down through the buffer.
       (while (and (not wrong) (checkdoc-next-docstring))
 	;; OK, let's look at the doc string.
-	(setq msg (checkdoc-this-string-valid))
+	(setq msg (checkdoc-this-string-valid take-notes))
 	(if msg (setq wrong (point)))))
     (if wrong
 	(progn
@@ -1284,12 +1284,15 @@ checkdoc-create-common-verbs-regexp
 
 ;;; Checking engines
 ;;
-(defun checkdoc-this-string-valid ()
+(defun checkdoc-this-string-valid (&optional take-notes)
   "Return a message string if the current doc string is invalid.
 Check for style only, such as the first line always being a complete
 sentence, whitespace restrictions, and making sure there are no
 hard-coded key-codes such as C-[char] or mouse-[number] in the comment.
-See the style guide in the Emacs Lisp manual for more details."
+See the style guide in the Emacs Lisp manual for more details.
+
+With a non-nil TAKE-NOTES, store all errors found in a warnings
+buffer, otherwise stop after the first error."
 
   ;; Jump over comments between the last object and the doc string
   (while (looking-at "[ \t\n]*;")
@@ -1366,13 +1369,16 @@ checkdoc-this-string-valid
 	      (point) (+ (point) 1) t)))))
     (if (and (not err) (= (following-char) ?\"))
         (with-syntax-table checkdoc-syntax-table
-          (checkdoc-this-string-valid-engine fp))
+          (checkdoc-this-string-valid-engine fp take-notes))
       err)))
 
-(defun checkdoc-this-string-valid-engine (fp)
+(defun checkdoc-this-string-valid-engine (fp &optional take-notes)
   "Return an error list or string if the current doc string is invalid.
 Depends on `checkdoc-this-string-valid' to reset the syntax table so that
-regexp short cuts work.  FP is the function defun information."
+regexp short cuts work.  FP is the function defun information.
+
+With a non-nil TAKE-NOTES, store all errors found in a warnings
+buffer, otherwise stop after the first error."
   (let ((case-fold-search nil)
 	;; Use a marker so if an early check modifies the text,
 	;; we won't accidentally lose our place.  This could cause
@@ -1864,7 +1870,7 @@ checkdoc-this-string-valid-engine
      ;; Make sure the doc string has correctly spelled English words
      ;; in it.  This function is extracted due to its complexity,
      ;; and reliance on the Ispell program.
-     (checkdoc-ispell-docstring-engine e)
+     (checkdoc-ispell-docstring-engine e take-notes)
      ;; User supplied checks
      (save-excursion (checkdoc-run-hooks 'checkdoc-style-functions fp e))
      ;; Done!
@@ -2107,27 +2113,32 @@ checkdoc-ispell-init
 	    (process-send-string ispell-process (concat "@" w "\n"))))
       (error (setq checkdoc-spellcheck-documentation-flag nil)))))
 
-(defun checkdoc-ispell-docstring-engine (end)
+(defun checkdoc-ispell-docstring-engine (end &optional take-notes)
   "Run the Ispell tools on the doc string between point and END.
 Since Ispell isn't Lisp-smart, we must pre-process the doc string
-before using the Ispell engine on it."
+before using the Ispell engine on it.
+
+With a non-nil TAKE-NOTES, store all errors found in a warnings
+buffer, otherwise stop after the first error."
   (when (and checkdoc-spellcheck-documentation-flag
              ;; If the user wants no questions or fixing, then we must
              ;; disable spell checking as not useful.
-             checkdoc-autofix-flag
-             (not (eq checkdoc-autofix-flag 'never)))
+             (or take-notes
+                 (and checkdoc-autofix-flag
+                      (not (eq checkdoc-autofix-flag 'never)))))
     (checkdoc-ispell-init)
     (save-excursion
       (skip-chars-forward "^a-zA-Z")
-      (let (word sym case-fold-search err)
+      (let (word sym case-fold-search err word-beginning word-end)
         (while (and (not err) (< (point) end))
           (if (save-excursion (forward-char -1) (looking-at "[('`]"))
               ;; Skip lists describing meta-syntax, or bound variables
               (forward-sexp 1)
-            (setq word (buffer-substring-no-properties
-                        (point) (progn
-                                  (skip-chars-forward "a-zA-Z-")
-                                  (point)))
+            (setq word-beginning (point)
+                  word-end (progn
+                             (skip-chars-forward "a-zA-Z-")
+                             (point))
+                  word (buffer-substring-no-properties word-beginning word-end)
                   sym (intern-soft word))
             (unless (and sym (or (boundp sym) (fboundp sym)))
               ;; Find out how we spell-check this word.
@@ -2139,7 +2150,16 @@ checkdoc-ispell-docstring-engine
                        )
                 (save-excursion
                   (let ((lk last-input-event))
-                    (ispell-word nil t)
+                    (if take-notes
+                        (progn
+                          (unless (ispell-correct-p)
+                            (checkdoc-create-error
+                             (format "Error checking word %s using %s with %s dictionary"
+		                     (funcall ispell-format-word-function word)
+		                     (file-name-nondirectory ispell-program-name)
+		                     (or ispell-current-dictionary "default"))
+                             word-beginning word-end)))
+                      (ispell-word nil t))
                     (if (not (equal last-input-event lk))
                         (progn
                           (sit-for 0)
-- 
2.23.0


--=-=-=--




Acknowledgement sent to Damien Cassou <damien@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#38583; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sat, 11 Jan 2020 12:30:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.