aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArash Esbati2019-02-23 14:02:05 +0100
committerTassilo Horn2019-02-27 18:22:08 +0100
commitb18cecf89bbb9d2d057f86e8fa1a1f1417d887b6 (patch)
tree2a2ca48133c65e4606477ca9e0a70e13ed068091
parentd07f3aae48242ad70e874c2d10fc15b7e1efa4d6 (diff)
downloademacs-b18cecf89bbb9d2d057f86e8fa1a1f1417d887b6.tar.gz
emacs-b18cecf89bbb9d2d057f86e8fa1a1f1417d887b6.zip
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.el24
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."
891 ;; so this list mustn't get any more items. 891 ;; so this list mustn't get any more items.
892 (defconst reftex-label-regexps '("\\\\label{\\([^}]*\\)}")) 892 (defconst reftex-label-regexps '("\\\\label{\\([^}]*\\)}"))
893 (defcustom reftex-label-regexps 893 (defcustom reftex-label-regexps
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, minted, ...
898 "\\[[^][]\\{0,2000\\}\\<label[[:space:]]*=[[:space:]]*{?\\(?1:[^],}]+\\)}?") 898 ,(concat
899 ;; Make sure we search only for optional arguments of
900 ;; environments and don't match any other [
901 "\\\\begin[[:space:]]*{\\(?:[^}]+\\)}[[:space:]]*"
902 ;; Match the opening [ and the following chars
903 "\\[[^][]*"
904 ;; Allow nested levels of chars enclosed in braces
905 "\\(?:{[^}{]*"
906 "\\(?:{[^}{]*"
907 "\\(?:{[^}{]*}[^}{]*\\)*"
908 "}[^}{]*\\)*"
909 "}[^][]*\\)*"
910 ;; Match the label key
911 "\\<label[[:space:]]*=[[:space:]]*"
912 ;; Match the label value; braces around the value are
913 ;; optional.
914 "{?\\(?1:[^] ,}\r\n\t%]+\\)}?"
915 ;; We are done. Such search until the next closing bracket
916 "[^]]*\\]"))
899 "List of regexps matching \\label definitions. 917 "List of regexps matching \\label definitions.
900The default value matches usual \\label{...} definitions and 918The default value matches usual \\label{...} definitions and
901keyval style [..., label = {...}, ...] label definitions. It is 919keyval style [..., label = {...}, ...] label definitions. It is
@@ -905,7 +923,7 @@ have to define it using \\(?1:...\\) when adding new regexps.
905When changed from Lisp, make sure to call 923When changed from Lisp, make sure to call
906`reftex-compile-variables' afterwards to make the change 924`reftex-compile-variables' afterwards to make the change
907effective." 925effective."
908 :version "25.1" 926 :version "27.1"
909 :set (lambda (symbol value) 927 :set (lambda (symbol value)
910 (set symbol value) 928 (set symbol value)
911 (when (fboundp 'reftex-compile-variables) 929 (when (fboundp 'reftex-compile-variables)