GNU bug report logs - #32089
RefTeX: Regexp for parsing labels in optional arguments

Previous Next

Package: auctex;

Reported by: Arash Esbati <arash.esbati <at> gmail.com>

Date: Sat, 7 Jul 2018 21:25:02 UTC

Severity: normal

Done: Arash Esbati <arash <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Arash Esbati <arash.esbati <at> gmail.com>
To: 32089 <at> debbugs.gnu.org
Subject: bug#32089: RefTeX: Regexp for parsing labels in optional arguments
Date: Sat, 07 Jul 2018 23:11:26 +0200
Hi all,

please consider the following example:

--8<---------------cut here---------------start------------->8---
\documentclass{article}
\usepackage{listings}
\begin{document}

\begin{lstlisting}[
caption={Some caption},
label=lst:1]
Some code
\end{lstlisting}

\begin{lstlisting}[
caption={Some caption},
label=lst:2
]
Some code
\end{lstlisting}

\begin{lstlisting}[
caption = {Some caption},
label   = lst:3                   ]
Some code
\end{lstlisting}

\ref{lst:1}, \ref{lst:2
}, \ref{lst:3                   }

\ref{lst:1}, \ref{lst:2}, \ref{lst:3}

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

With RefTeX active, it fails to parse the labels defined in optional
arguments correctly (see the first set of \ref commands).  It is due to
the regex defined in `reftex-label-regexps' in `reftex-vars.el' which
expects one of ],} directly after the label.  With the following patch,
it parses the labels correctly:

--8<---------------cut here---------------start------------->8---
diff --git a/lisp/textmodes/reftex-vars.el b/lisp/textmodes/reftex-vars.el
index 11dbb8d..66d800d 100644
--- a/lisp/textmodes/reftex-vars.el
+++ b/lisp/textmodes/reftex-vars.el
@@ -895,7 +895,7 @@ DOWNCASE    t:   Downcase words before using them."
       "\\\\label{\\(?1:[^}]*\\)}"
       ;; keyvals [..., label = {foo}, ...] forms used by ctable,
       ;; listings, minted, ...
-      "\\[[^][]\\{0,2000\\}\\<label[[:space:]]*=[[:space:]]*{?\\(?1:[^],}]+\\)}?")
+      "\\[[^][]\\{0,2000\\}\\<label[[:space:]]*=[[:space:]]*{?\\(?1:[^], \t\n\r%}]+\\)}?")
     "List of regexps matching \\label definitions.
 The default value matches usual \\label{...} definitions and
 keyval style [..., label = {...}, ...] label definitions.  It is
 --8<---------------cut here---------------end--------------->8---

Any suggestion if I'm missing a character?  My next step would be to add
the same regexp to `LaTeX-auto-label-regexp-list' in order to make
AUCTeX also capable of this feature.  Any comments welcome.

Best, Arash




This bug report was last modified 6 years and 17 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.