Subject: bug#72262: closed (Re: bug#72262: 31.0.50; [PATCH] Bug in `ispell-begin-tex-skip-regexp')

From: [email-masked] (GNU bug Tracking System)
Date: Sat, 17 Aug 2024 08:17:02 +0000

Your bug report

#72262: 31.0.50; [PATCH] Bug in `ispell-begin-tex-skip-regexp'

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
72262: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=72262
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#72262: 31.0.50; [PATCH] Bug in `ispell-begin-tex-skip-regexp'
From: Eli Zaretskii <[email-masked]>
To: Stefan Monnier <[email-masked]>
Cc: [email-masked], [email-masked]
Date: Sat, 17 Aug 2024 11:15:47 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

> From: Stefan Monnier <[email-masked]>
> Cc: Eli Zaretskii <[email-masked]>,  [email-masked]
> Date: Wed, 14 Aug 2024 08:11:45 -0400
> 
> >> The matching of whitespace there seems to be on purpose,
> >
> > In LaTeX2e, spaces in environment names are significant, so \begin{foo}
> > is not equivalent to \begin{foo } or \begin{ foo }, therefore I think
> > the current code is wrong.
> 
> Indeed, this is puzzling: I can't see why the code explicitly ignored
> whitespace there.  I've never seen environment names with leading or
> trailing whitespace, so it's probably not a big deal wither way, but
> your patch looks right to me.

Thanks, installed on master, and closing the bug.

Subject: 31.0.50; [PATCH] Bug in `ispell-begin-tex-skip-regexp'
From: Arash Esbati <[email-masked]>
To: "emacs-bugs" <[email-masked]>
Date: Tue, 23 Jul 2024 22:55:34 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi all,

please consider this .tex file which is valid LaTeX code:

--8<---------------cut here---------------start------------->8---
\documentclass{article}

\newenvironment{spacetest }{\itshape}{}
\newenvironment{spacetest}{\ttfamily}{}

\begin{document}

\begin{verbatim}
(setq ispell-tex-skip-alists
      '((("\\\\document\\(class\\|style\\)" . "\\\\begin[ \t\n]*{document}"))
        (("spacetest"    . "\\\\end[ \t]*{spacetest}")
         ("verbatim\\*?" . "\\\\end[ \t]*{verbatim\\*?}"))))
\end{verbatim}

\begin{spacetest }
Thiz iz nott to be ignorrd.
\end{spacetest }

\begin{spacetest}
  Thiz iz to be ignorrd.
\end{spacetest}

\end{document}
--8<---------------cut here---------------end--------------->8---

Eval the form in the verbatim environment and do 'M-x ispell RET'.  It
doesn't find any misspelled words at all and ignores both environments
'spacetest ' and 'spacetest' where it should only ignore the latter.

This is due to unnecessary matching of whitespaces in the function
`ispell-begin-tex-skip-regexp'.  The patch attached fixes the issue.
The patch is against the master branch, but should also apply to the
release branch.  I can update it once a number is assigned to the
report.

Best, Arash
>From 2dc603c32c106aa77cff23fc60a1500fdde4a5e1 Mon Sep 17 00:00:00 2001
From: Arash Esbati <[email-masked]>
Date: Tue, 23 Jul 2024 22:40:41 +0200
Subject: [PATCH] Delete matching of whitespaces in LaTeX env names

* lisp/textmodes/ispell.el (ispell-begin-tex-skip-regexp): Remove
matching of arbitrary whitespaces in LaTeX environment names when
wrapping them inside \begin{}.
---
 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 667da10d7a3..99f9e10a5a8 100644
--- a/lisp/textmodes/ispell.el
+++ b/lisp/textmodes/ispell.el
@@ -3320,9 +3320,7 @@ ispell-begin-tex-skip-regexp
    "\\|"
    ;; keys wrapped in begin{}
    (mapconcat (lambda (lst)
-                (concat "\\\\begin[ \t\n]*{[ \t\n]*"
-                        (car lst)
-                        "[ \t\n]*}"))
+                (concat "\\\\begin[ \t\n]*{" (car lst) "}"))
 	      (car (cdr ispell-tex-skip-alists))
 	      "\\|")))
 
-- 
2.45.2