diff options
| author | Arash Esbati <arash@gnu.org> | 2019-02-23 14:02:05 +0100 | 
|---|---|---|
| committer | Tassilo Horn <tsdh@gnu.org> | 2019-02-27 18:22:08 +0100 | 
| commit | b18cecf89bbb9d2d057f86e8fa1a1f1417d887b6 (patch) | |
| tree | 2a2ca48133c65e4606477ca9e0a70e13ed068091 | |
| parent | d07f3aae48242ad70e874c2d10fc15b7e1efa4d6 (diff) | |
| download | emacs-b18cecf89bbb9d2d057f86e8fa1a1f1417d887b6.tar.gz | |
Improve matching of key-val labels (bug#34629)
* lisp/textmodes/reftex-vars.el (reftex-label-regexps): Improve
regexp for key-val labels in order to skip over content in braces.
| -rw-r--r-- | lisp/textmodes/reftex-vars.el | 24 | 
1 files changed, 21 insertions, 3 deletions
| diff --git a/lisp/textmodes/reftex-vars.el b/lisp/textmodes/reftex-vars.el index 9147de6e01e..eb1dfc50a35 100644 --- a/lisp/textmodes/reftex-vars.el +++ b/lisp/textmodes/reftex-vars.el @@ -891,11 +891,29 @@ 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:[^],}]+\\)}?") +      ,(concat +        ;; Make sure we search only for optional arguments of +        ;; environments and don't match any other [ +        "\\\\begin[[:space:]]*{\\(?:[^}]+\\)}[[:space:]]*" +        ;; 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.  Such 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 @@ -905,7 +923,7 @@ 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) | 
