auctex-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [AUCTeX-devel] Spell checking of macros


From: Arash Esbati
Subject: Re: [AUCTeX-devel] Spell checking of macros
Date: Mon, 11 Jul 2016 11:19:55 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.95

Hi Mosè,

Mosè Giordano <address@hidden> writes:

> 2016-07-08 19:11 GMT+02:00 Arash Esbati <address@hidden>:
>> Hi Mosè,
>>
>> Mosè Giordano <address@hidden> writes:
>>
>>> Thanks for your work!  Some questions:
>>>
>>> * why all those `eval-when-compile'?
>>
>> The final regexp which goes into byte-compiled file is built with:
>>
>> --8<---------------cut here---------------start------------->8---
>> (defvar TeX-ispell-skip-cmds-one-arg-regexp
>>   (eval-when-compile
>>     (concat "\\\\"
>>             (regexp-opt (TeX-ispell-sort-skip-cmds-list 1) t)))
>>   "Regexp of LaTeX commands with one argument to be skipped.")
>> --8<---------------cut here---------------end--------------->8---
>
> Ok, then why this regexp is built with `eval-when-compile'?

I wanted to implement a trick mentioned in regexp-opt.el:

;; Since this package was written to produce efficient regexps, not regexps
;; efficiently, it is probably not a good idea to in-line too many calls in
;; your code, unless you use the following trick with `eval-when-compile':
;;
;; (defvar definition-regexp
;;   (eval-when-compile
;;     (concat "^("
;;             (regexp-opt '("defun" "defsubst" "defmacro" "defalias"
;;                           "defvar" "defconst") t)
;;             "\\>")))
;;
;; The `byte-compile' code will be as if you had defined the variable thus:
;;
;; (defvar definition-regexp
;;   "^(\\(def\\(alias\\|const\\|macro\\|subst\\|un\\|var\\)\\)\\>")

Do you have any specific concern about using `eval-when-compile' here?

>>> * is is possible to skip the second
>>> argument of "\begin{}{}"?  For example. in the first example you
>>> showed us in this thread `ispell' still wants to check "llr".
>>
>> Yes it is.  It works for me for tabularx & tabulary with (already in
>> the last diff):
>>
>>   (TeX-ispell-skip-setcdr
>>     '(...
>>       ("tabular[xy]" ispell-tex-arg-end 2)))
>>
>> I see that I have missed \begin{tabular*} (since I never use it ;-),
>> should be easily fixed with:
>>
>>   (TeX-ispell-skip-setcdr
>>     '(...
>>       ("tabular[*xy]" ispell-tex-arg-end 2)))
>
> Maybe the regexp should be "tabular[*xy]?", right?

I think that would be wrong with this syntax:

    \begin{tabular}[<pos>]{<cols>} ...

    \begin{tabular*}{<width>}[<pos>]{<cols>} ...
    \begin{tabularx}{<width>}[<pos>]{<cols>} ...
    \begin{tabulary}{<width>}[<pos>]{<cols>} ...

"tabular" goes with ("tabular" ispell-tex-arg-end) and for the rest, it
should be ("tabular[*xy]" ispell-tex-arg-end 2).  But then,
`ispell-tex-arg-end' doesn't handle opt. arguements after mandatory
ones.  Here the definition from ispell.el:

    (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))))

For me, Ispell checks {llr} in this snippet:

    \begin{tabular*}{1.0\linewidth}[t]{llr}
      Onne & twwo & thre & fouur
    \end{tabular*}

I'm thinking about writing a function like this to catch this kind of
arguments:

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

and do ("tabular[*xy]" TeX-ispell-tex-arg-end).

Cheers, Arash




reply via email to

[Prev in Thread] Current Thread [Next in Thread]