aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArash Esbati2019-03-08 22:01:01 +0100
committerTassilo Horn2019-03-09 07:48:34 +0100
commiteed512814c45cd5859a1814bf07ad18ea3fa3b1a (patch)
treeb717dd906da62a71ffb87da7f483e228a2dbe49f
parent01b099bb3db740d53f3e79f3183767b071ddf6f9 (diff)
downloademacs-eed512814c45cd5859a1814bf07ad18ea3fa3b1a.tar.gz
emacs-eed512814c45cd5859a1814bf07ad18ea3fa3b1a.zip
; Improve matching of key-val labels yet more (bug#34629)
* lisp/textmodes/reftex-vars.el (reftex-label-regexps): Match explicitly for key-val labels in optional arguments of environments provided by "listings" and "breqn" packages and the macro "\ctable" from the package of the same name. Update docstring.
-rw-r--r--lisp/textmodes/reftex-vars.el33
1 files changed, 26 insertions, 7 deletions
diff --git a/lisp/textmodes/reftex-vars.el b/lisp/textmodes/reftex-vars.el
index eb1dfc50a35..88ad4478b06 100644
--- a/lisp/textmodes/reftex-vars.el
+++ b/lisp/textmodes/reftex-vars.el
@@ -894,11 +894,25 @@ DOWNCASE t: Downcase words before using them."
894 `(;; Normal \\label{foo} labels 894 `(;; Normal \\label{foo} labels
895 "\\\\label{\\(?1:[^}]*\\)}" 895 "\\\\label{\\(?1:[^}]*\\)}"
896 ;; keyvals [..., label = {foo}, ...] forms used by ctable, 896 ;; keyvals [..., label = {foo}, ...] forms used by ctable,
897 ;; listings, minted, ... 897 ;; listings, breqn, ...
898 ,(concat 898 ,(concat
899 ;; Make sure we search only for optional arguments of 899 ;; Make sure we search only for optional arguments of
900 ;; environments and don't match any other [ 900 ;; environments/macros and don't match any other [. ctable
901 "\\\\begin[[:space:]]*{\\(?:[^}]+\\)}[[:space:]]*" 901 ;; provides a macro called \ctable, listings/breqn have
902 ;; environments. Start with a backslash and a group for names
903 "\\\\\\(?:"
904 ;; begin, optional spaces and opening brace
905 "begin[[:space:]]*{"
906 ;; Build a regexp for env names
907 (regexp-opt '("lstlisting" "dmath" "dseries" "dgroup" "darray"))
908 ;; closing brace, optional spaces
909 "}[[:space:]]*"
910 ;; Now for macros
911 "\\|"
912 ;; Build a regexp for macro names; currently only \ctable
913 (regexp-opt '("ctable"))
914 ;; Close the group for names
915 "\\)"
902 ;; Match the opening [ and the following chars 916 ;; Match the opening [ and the following chars
903 "\\[[^][]*" 917 "\\[[^][]*"
904 ;; Allow nested levels of chars enclosed in braces 918 ;; Allow nested levels of chars enclosed in braces
@@ -912,13 +926,18 @@ DOWNCASE t: Downcase words before using them."
912 ;; Match the label value; braces around the value are 926 ;; Match the label value; braces around the value are
913 ;; optional. 927 ;; optional.
914 "{?\\(?1:[^] ,}\r\n\t%]+\\)}?" 928 "{?\\(?1:[^] ,}\r\n\t%]+\\)}?"
915 ;; We are done. Such search until the next closing bracket 929 ;; We are done. Just search until the next closing bracket
916 "[^]]*\\]")) 930 "[^]]*\\]"))
917 "List of regexps matching \\label definitions. 931 "List of regexps matching \\label definitions.
918The default value matches usual \\label{...} definitions and 932The default value matches usual \\label{...} definitions and
919keyval style [..., label = {...}, ...] label definitions. It is 933keyval style [..., label = {...}, ...] label definitions. The
920assumed that the regexp group 1 matches the label text, so you 934regexp for keyval style explicitly looks for environments
921have to define it using \\(?1:...\\) when adding new regexps. 935provided by the packages \"listings\" (\"lstlisting\"),
936\"breqn\" (\"dmath\", \"dseries\", \"dgroup\", \"darray\") and
937the macro \"\\ctable\" provided by the package of the same name.
938
939It is assumed that the regexp group 1 matches the label text, so
940you have to define it using \\(?1:...\\) when adding new regexps.
922 941
923When changed from Lisp, make sure to call 942When changed from Lisp, make sure to call
924`reftex-compile-variables' afterwards to make the change 943`reftex-compile-variables' afterwards to make the change