diff options
Diffstat (limited to 'lisp/textmodes/reftex-vars.el')
-rw-r--r-- | lisp/textmodes/reftex-vars.el | 57 |
1 files changed, 48 insertions, 9 deletions
diff --git a/lisp/textmodes/reftex-vars.el b/lisp/textmodes/reftex-vars.el index 017f5a32126..88ad4478b06 100644 --- a/lisp/textmodes/reftex-vars.el +++ b/lisp/textmodes/reftex-vars.el @@ -891,21 +891,58 @@ DOWNCASE t: Downcase words before using them." ;; 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\\}\\<label[[:space:]]*=[[:space:]]*{?\\(?1:[^],}]+\\)}?") + ;; listings, breqn, ... + ,(concat + ;; Make sure we search only for optional arguments of + ;; environments/macros and don't match any other [. ctable + ;; provides a macro called \ctable, listings/breqn have + ;; environments. Start with a backslash and a group for names + "\\\\\\(?:" + ;; begin, optional spaces and opening brace + "begin[[:space:]]*{" + ;; Build a regexp for env names + (regexp-opt '("lstlisting" "dmath" "dseries" "dgroup" "darray")) + ;; closing brace, optional spaces + "}[[:space:]]*" + ;; Now for macros + "\\|" + ;; Build a regexp for macro names; currently only \ctable + (regexp-opt '("ctable")) + ;; Close the group for names + "\\)" + ;; Match the opening [ and the following chars + "\\[[^][]*" + ;; Allow nested levels of chars enclosed in braces + "\\(?:{[^}{]*" + "\\(?:{[^}{]*" + "\\(?:{[^}{]*}[^}{]*\\)*" + "}[^}{]*\\)*" + "}[^][]*\\)*" + ;; Match the label key + "\\<label[[:space:]]*=[[:space:]]*" + ;; Match the label value; braces around the value are + ;; optional. + "{?\\(?1:[^] ,}\r\n\t%]+\\)}?" + ;; We are done. Just search until the next closing bracket + "[^]]*\\]")) "List of regexps matching \\label definitions. The default value matches usual \\label{...} definitions and -keyval style [..., label = {...}, ...] label definitions. It is -assumed that the regexp group 1 matches the label text, so you -have to define it using \\(?1:...\\) when adding new regexps. +keyval style [..., label = {...}, ...] label definitions. The +regexp for keyval style explicitly looks for environments +provided by the packages \"listings\" (\"lstlisting\"), +\"breqn\" (\"dmath\", \"dseries\", \"dgroup\", \"darray\") and +the macro \"\\ctable\" provided by the package of the same name. + +It is assumed that the regexp group 1 matches the label text, so +you have to define it using \\(?1:...\\) when adding new regexps. When changed from Lisp, make sure to call `reftex-compile-variables' afterwards to make the change effective." - :version "25.1" + :version "27.1" :set (lambda (symbol value) (set symbol value) (when (fboundp 'reftex-compile-variables) @@ -1030,7 +1067,9 @@ This is used to string together whole reference sets, like ("Hyperref" "hyperref" (("\\autoref" ?a) ("\\autopageref" ?u))) ("Cleveref" "cleveref" - (("\\cref" ?c) ("\\Cref" ?C) ("\\cpageref" ?d) ("\\Cpageref" ?D)))) + (("\\cref" ?c) ("\\Cref" ?C) ("\\cpageref" ?d) ("\\Cpageref" ?D))) + ("AMSmath" "amsmath" + (("\\eqref" ?e)))) "Alist of reference styles. Each element is a list of the style name, the name of the LaTeX package associated with the style or t for any package, and an @@ -1040,7 +1079,7 @@ the macro type is being prompted for. (See also `reftex-ref-macro-prompt'.) The keys, represented as characters, have to be unique." :group 'reftex-referencing-labels - :version "24.3" + :version "27.1" :type '(alist :key-type (string :tag "Style name") :value-type (group (choice :tag "Package" (const :tag "Any package" t) |