From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Arash Esbati Newsgroups: gmane.emacs.auctex.devel,gmane.emacs.bugs Subject: 27.0.50; Wrong parsing of key-val labels Date: Sat, 23 Feb 2019 14:17:54 +0100 Message-ID: <86pnrihce5.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="112397"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 Cc: auctex-devel To: bug-gnu-emacs@gnu.org Original-X-From: auctex-devel-bounces+gead-auctex-devel=m.gmane.org@gnu.org Sat Feb 23 14:19:46 2019 Return-path: Envelope-to: gead-auctex-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gxXDW-000T9V-Dm for gead-auctex-devel@m.gmane.org; Sat, 23 Feb 2019 14:19:46 +0100 Original-Received: from localhost ([127.0.0.1]:37803 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gxXDV-0005aE-9t for gead-auctex-devel@m.gmane.org; Sat, 23 Feb 2019 08:19:45 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:58944) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gxXDN-0005Zw-ME; Sat, 23 Feb 2019 08:19:38 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:49650) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gxXDL-0007gz-9C; Sat, 23 Feb 2019 08:19:36 -0500 Original-Received: from p5b32692e.dip0.t-ipconnect.de ([91.50.105.46]:51237 helo=MUTANT) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.82) (envelope-from ) id 1gxXDF-00085d-Cx; Sat, 23 Feb 2019 08:19:31 -0500 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: auctex-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Discussion list for AUCTeX developers List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: auctex-devel-bounces+gead-auctex-devel=m.gmane.org@gnu.org Original-Sender: "auctex-devel" Xref: news.gmane.org gmane.emacs.auctex.devel:5614 gmane.emacs.bugs:155688 Archived-At: --=-=-= Content-Type: text/plain Hi all, Please consider the following LaTeX code in a buffer where RefTeX is enabled: --8<---------------cut here---------------start------------->8--- \documentclass{article} \usepackage{listings} \begin{document} \begin{lstlisting}[ caption = Some caption , label = lst:1 % ] foo \end{lstlisting} \begin{lstlisting}[ caption = {[Short caption]Long caption}, label = lst:2 ] bar \end{lstlisting} \begin{lstlisting}[ language = {[LaTeX]TeX} , frame = single , caption = {[Short caption]\textit{L\textbf{o}ng} caption} , label = lst:3 ] foobar \end{lstlisting} \end{document} --8<---------------cut here---------------end--------------->8--- When hitting `C-u C-c )' in order to add a \ref, RefTeX fails to see the last 2 labels. For the first one, it inserts \ref{lst:1 % } The is due to the second regexp in `reftex-label-regexps'. Please find attached a patch fixing this issue. Any comments welcome. Best, Arash --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Improve-matching-of-key-val-labels.patch >From f6e3a84824f5597ab4f1641edf957b8af4b51564 Mon Sep 17 00:00:00 2001 From: Arash Esbati Date: Sat, 23 Feb 2019 14:02:05 +0100 Subject: [PATCH] Improve matching of key-val labels * lisp/textmodes/reftex-vars.el (reftex-label-regexps): Improve regexp for key-val labels in order to skip over content in braces. --- lisp/textmodes/reftex-vars.el | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/lisp/textmodes/reftex-vars.el b/lisp/textmodes/reftex-vars.el index 9147de6e01..eb1dfc50a3 100644 --- a/lisp/textmodes/reftex-vars.el +++ b/lisp/textmodes/reftex-vars.el @@ -891,11 +891,29 @@ reftex-derive-label-parameters ;; so this list mustn't get any more items. (defconst reftex-label-regexps '("\\\\label{\\([^}]*\\)}")) (defcustom reftex-label-regexps - '(;; Normal \\label{foo} labels + `(;; Normal \\label{foo} labels "\\\\label{\\(?1:[^}]*\\)}" ;; keyvals [..., label = {foo}, ...] forms used by ctable, ;; listings, minted, ... - "\\[[^][]\\{0,2000\\}\\