all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Adding % to `ispell-tex-arg-end'
@ 2016-07-09  9:02 Arash Esbati
  2016-07-09  9:16 ` Eli Zaretskii
  0 siblings, 1 reply; 3+ messages in thread
From: Arash Esbati @ 2016-07-09  9:02 UTC (permalink / raw)
  To: emacs-devel

Hi all,

when I run Ispell over the following snippet, the second [htbp] is
matched by Ispell:

\begin{figure}
  [htbp]
  \caption{foo}
\end{figure}

\begin{figure}%
  [htbp] % <== matched by Ispell
  \caption{foo}
\end{figure}

It is due to the regexp in `ispell-tex-arg-end':

(defun ispell-tex-arg-end (&optional arg)
  "Skip across ARG number of braces."
  (condition-case nil
      (progn
	(while (looking-at "[ \t\n]*\\[") (forward-sexp))
	(forward-sexp (or arg 1)))
    (error
     (message "Error skipping s-expressions at point %d." (point))
     (beep)
     (sit-for 2))))

Would it be possible to add "%" to this function?

(defun ispell-tex-arg-end (&optional arg)
  "Skip across ARG number of braces."
  (condition-case nil
      (progn
	(while (looking-at "[ \t\n%]*\\[") (forward-sexp))
	(forward-sexp (or arg 1)))
    (error
     (message "Error skipping s-expressions at point %d." (point))
     (beep)
     (sit-for 2))))

I hope that nobody writes such LaTeX code, but Ispell should match valid
code here.

Best, Arash




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

* Re: Adding % to `ispell-tex-arg-end'
  2016-07-09  9:02 Adding % to `ispell-tex-arg-end' Arash Esbati
@ 2016-07-09  9:16 ` Eli Zaretskii
  2016-07-09  9:43   ` Arash Esbati
  0 siblings, 1 reply; 3+ messages in thread
From: Eli Zaretskii @ 2016-07-09  9:16 UTC (permalink / raw)
  To: Arash Esbati; +Cc: emacs-devel

> From: Arash Esbati <esbati@gmx.de>
> Date: Sat, 09 Jul 2016 11:02:27 +0200
> 
> when I run Ispell over the following snippet, the second [htbp] is
> matched by Ispell:
> 
> \begin{figure}
>   [htbp]
>   \caption{foo}
> \end{figure}
> 
> \begin{figure}%
>   [htbp] % <== matched by Ispell
>   \caption{foo}
> \end{figure}
> 
> It is due to the regexp in `ispell-tex-arg-end':
> 
> (defun ispell-tex-arg-end (&optional arg)
>   "Skip across ARG number of braces."
>   (condition-case nil
>       (progn
> 	(while (looking-at "[ \t\n]*\\[") (forward-sexp))
> 	(forward-sexp (or arg 1)))
>     (error
>      (message "Error skipping s-expressions at point %d." (point))
>      (beep)
>      (sit-for 2))))
> 
> Would it be possible to add "%" to this function?
> 
> (defun ispell-tex-arg-end (&optional arg)
>   "Skip across ARG number of braces."
>   (condition-case nil
>       (progn
> 	(while (looking-at "[ \t\n%]*\\[") (forward-sexp))
> 	(forward-sexp (or arg 1)))
>     (error
>      (message "Error skipping s-expressions at point %d." (point))
>      (beep)
>      (sit-for 2))))

Maybe I'm missing something, but this solution doesn't look right to
me, because if we do that, any mis-spelling in the comment after %
will be skipped.  E.g., imagine this text:

\begin{figure}% mysspelled word
  [htbp] % <== matched by Ispell
  \caption{foo}
\end{figure}

We do want the "mysspelled" part highlighted, right?  I think your
suggestion makes Ispell skip it.



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

* Re: Adding % to `ispell-tex-arg-end'
  2016-07-09  9:16 ` Eli Zaretskii
@ 2016-07-09  9:43   ` Arash Esbati
  0 siblings, 0 replies; 3+ messages in thread
From: Arash Esbati @ 2016-07-09  9:43 UTC (permalink / raw)
  To: emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Arash Esbati <esbati@gmx.de>
>> Date: Sat, 09 Jul 2016 11:02:27 +0200
>> 
>> when I run Ispell over the following snippet, the second [htbp] is
>> matched by Ispell:
>> 
>> \begin{figure}
>>   [htbp]
>>   \caption{foo}
>> \end{figure}
>> 
>> \begin{figure}%
>>   [htbp] % <== matched by Ispell
>>   \caption{foo}
>> \end{figure}
>> 
>> It is due to the regexp in `ispell-tex-arg-end':
>> 
>> (defun ispell-tex-arg-end (&optional arg)
>>   "Skip across ARG number of braces."
>>   (condition-case nil
>>       (progn
>> 	(while (looking-at "[ \t\n]*\\[") (forward-sexp))
>> 	(forward-sexp (or arg 1)))
>>     (error
>>      (message "Error skipping s-expressions at point %d." (point))
>>      (beep)
>>      (sit-for 2))))
>> 
>> Would it be possible to add "%" to this function?
>> 
>> (defun ispell-tex-arg-end (&optional arg)
>>   "Skip across ARG number of braces."
>>   (condition-case nil
>>       (progn
>> 	(while (looking-at "[ \t\n%]*\\[") (forward-sexp))
>> 	(forward-sexp (or arg 1)))
>>     (error
>>      (message "Error skipping s-expressions at point %d." (point))
>>      (beep)
>>      (sit-for 2))))
>
> Maybe I'm missing something, but this solution doesn't look right to
> me, because if we do that, any mis-spelling in the comment after %
> will be skipped.  E.g., imagine this text:
>
> \begin{figure}% mysspelled word
>   [htbp] % <== matched by Ispell
>   \caption{foo}
> \end{figure}
>
> We do want the "mysspelled" part highlighted, right?  I think your
> suggestion makes Ispell skip it.

Hmm, my Ispell (Hunspell 1.4.1, Emacs 25.0.95.1) does not check comments
at all with `ispell-check-comments' set to t, e.g.:

% mysspelled word

is not matched.  It does work when `ispell-check-comments' is set to
exclusive though.  Will play more with it and create a new case.

Best, Arash

PS: Also my congratulations to your new role!




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

end of thread, other threads:[~2016-07-09  9:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-09  9:02 Adding % to `ispell-tex-arg-end' Arash Esbati
2016-07-09  9:16 ` Eli Zaretskii
2016-07-09  9:43   ` Arash Esbati

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.