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

From: Markus Kohm <[email-masked]>
Date: Thu, 04 Apr 2019 09:17:47 +0200

Remember to cover the basics, that is, what you expected to happen and
what in fact did happen.

Be sure to consult the FAQ section in the manual before submitting
a bug report.  In addition check if the bug is reproducable with an
up-to-date version of AUCTeX.  So please upgrade to the version
available from http://www.gnu.org/software/auctex/ if your
installation is older than the one available from the web site.

If the bug is triggered by a specific (La)TeX file, you should try
to produce a minimal sample file showing the problem and include it
in your report.

Your report will be posted for the auctex package at the GNU bug
tracker.  Visit http://debbugs.gnu.org/cgi/pkgreport.cgi?pkg=auctex
to browse existing AUCTeX bugs.
------------------------------------------------------------------------

The LaTeX package doc, that is usually used via class ltxdoc for the
documentation part of dtx-files, declares ^^A as comment character.
But auctex's doctex mode fails scanning for balanced {...} pairs, if
} is immediately followed by ^^A. You can test it, with this example file:

--- test.dtx ---
% \begin{macro}{\test}^^A This is an official dtx-comment
% This does not work. Try to double-click to the closing brace before the
% comment and you will get: |Scan error: "Unbalanced parantheses", 22, 22|
% \end{macro}
%
% \begin{macro}{\test}%^^A This is a workaround for an official dtx-comment
% This does work, but the \% after the closing brace is not wanted.
% \end{macro}
% \endinput
% Local Variables:
% mode: doctex
% TeX-master: t
% End:
--- end of file ---

Emacs  : GNU Emacs 26.1 (build 1, x86_64-suse-linux-gnu, GTK+ Version 3.24.4)
Package: 12.1

current state:
==============
(setq
 AUCTeX-date "2017-12-10"
 window-system 'x
 LaTeX-version "2e"
 TeX-style-path '("/usr/share/emacs/site-lisp/auctex/auto"
		  "/usr/share/emacs/site-lisp/auctex/style"
		  "/home/mjk/.emacs.d/auctex/auto"
		  "/home/mjk/.emacs.d/auctex/style" "auto" "style")
 TeX-auto-save t
 TeX-parse-self t
 TeX-master t
 TeX-command-list '(("biber" "biber %s.bcf" TeX-run-BibTeX nil t)
		    ("TeX" "%(PDF)%(tex) %`%S%(PDFout)%(mode)%' %t"
		     TeX-run-TeX nil
		     (plain-tex-mode texinfo-mode ams-tex-mode) :help
		     "Run plain TeX")
		    ("LaTeX" "%`%l%(mode)%' %t" TeX-run-TeX nil
		     (latex-mode doctex-mode) :help "Run LaTeX")
		    ("Makeinfo" "makeinfo %t" TeX-run-compile nil
		     (texinfo-mode) :help "Run Makeinfo with Info output")
		    ("Makeinfo HTML" "makeinfo --html %t" TeX-run-compile
nil
		     (texinfo-mode) :help "Run Makeinfo with HTML output")
		    ("AmSTeX" "%(PDF)amstex %`%S%(PDFout)%(mode)%' %t"
		     TeX-run-TeX nil (ams-tex-mode) :help "Run AMSTeX")
		    ("ConTeXt" "texexec --once --texutil %(execopts)%t"
		     TeX-run-TeX nil (context-mode) :help "Run ConTeXt
once")
		    ("ConTeXt Full" "texexec %(execopts)%t" TeX-run-TeX
nil
		     (context-mode) :help "Run ConTeXt until completion")
		    ("BibTeX" "bibtex %s" TeX-run-BibTeX nil t :help
		     "Run BibTeX")
		    ("View" "%V" TeX-run-discard-or-function t t :help
		     "Run Viewer")
		    ("Print" "%p" TeX-run-command t t :help "Print the
file")
		    ("Queue" "%q" TeX-run-background nil t :help
		     "View the printer queue" :visible TeX-queue-command)
		    ("File" "%(o?)dvips %d -o %f " TeX-run-command t t
:help
		     "Generate PostScript file")
		    ("Index" "makeindex %s" TeX-run-command nil t :help
		     "Create index file")
		    ("Check" "lacheck %s" TeX-run-compile nil (latex-mode)
		     :help "Check LaTeX file for correctness")
		    ("Spell" "(TeX-ispell-document \"\")" TeX-run-function
nil
		     t :help "Spell-check the document")