Subject: bug#35140: 12.1; Scan errors in doctex mode with ^^A-comments after braces

From: Arash Esbati <[email-masked]>
Date: Tue, 01 Mar 2022 12:52:39 +0100

Hi Keita,

Ikumi Keita <[email-masked]> writes:

> Thus I'm inclined to an idea just to fontify "^^A" type comments with
> normal comment face, not bothering with changing its syntax. Attached is
> a patch that implements this idea.
>
> What do others think about this?

I don't think AUCTeX suffers if the syntax after "^^A" isn't change so
we could do it.  One other idea would be to raise this issue also on
Emacs devel list since Emacs has the same issue as well or ping Stefan
M. to have a look at this thread before we make a final decision.  What
do you think?

> +(defun font-latex-doctex-match-^^A (limit)
> +  "In docTeX mode, match comment started by ^^A before LIMIT."
> +  (catch 'found
> +    (while (TeX-search-forward-unescaped "^^A" limit t)

While we're at it, can we change this to:

  (while (TeX-re-search-forward-unescaped "\\^\\^[AX]" limit t)

as well?  doc v3 also accepts ^^X as comment starter.

> +      (when (eq (char-after (line-beginning-position)) ?\%)
> +        (forward-line 1)
> +        ;; Adjust `font-latex--updated-region-end' if necessary.
> +        (let ((p (point)))
> +          (if (< font-latex--updated-region-end limit)
> +              (setq font-latex--updated-region-end limit))
> +          (when (< font-latex--updated-region-end p)
> +            (font-lock-unfontify-region
> +             font-latex--updated-region-end p)
> +            (setq font-latex--updated-region-end p))
> +          (set-match-data (list (match-beginning 0) p)))
> +        (throw 'found t)))))
>  
>  ;; Copy and adaptation of `doctex-font-lock-syntactic-face-function'
>  ;; in `tex-mode.el' of CVS Emacs (March 2004)

Best, Arash