Function: LaTeX-extract-key-value-label
LaTeX-extract-key-value-label is a byte-compiled function defined in
latex.el.
Signature
(LaTeX-extract-key-value-label &optional KEY NUM)
Documentation
Return a regexp string to match a label in an optional argument.
The optional KEY is a string which is the name of the key in the
key=value, default is "label". NUM is an integer for an
explicitly numbered group construct, useful when adding items to
reftex-label-regexps.
As an extra feature, the key can be the symbol none where the
entire matching for the key=value is skipped. The regexp then is
useful for skipping complex optional arguments. It should be
wrapped in \(?:...\)? then.
Source Code
;; Defined in ~/.emacs.d/elpa/auctex-14.1.2/latex.el
(defun LaTeX-extract-key-value-label (&optional key num)
"Return a regexp string to match a label in an optional argument.
The optional KEY is a string which is the name of the key in the
key=value, default is \"label\". NUM is an integer for an
explicitly numbered group construct, useful when adding items to
`reftex-label-regexps'.
As an extra feature, the key can be the symbol `none' where the
entire matching for the key=value is skipped. The regexp then is
useful for skipping complex optional arguments. It should be
wrapped in \\(?:...\\)? then."
;; The regexp produced here is ideally in sync with the complex one
;; in `reftex-label-regexps'.
(concat
;; Match the opening [ and the following chars
"\\[[^][]*"
;; Allow nested levels of chars enclosed in braces
"\\(?:{[^}{]*"
"\\(?:{[^}{]*"
"\\(?:{[^}{]*}[^}{]*\\)*"
"}[^}{]*\\)*"
"}[^][]*\\)*"
;; If KEY is the symbol none, don't look for any key=val:
(unless (eq key 'none)
(concat "\\<"
;; Match the key, default is label
(or key "label")
;; Optional spaces
"[[:space:]]*=[[:space:]]*"
;; Match the value; braces around the value are optional
"{?\\("
;; Cater for NUM which sets the regexp group
(when (and num (integerp num))
(concat "?" (number-to-string num) ":"))
;; One of these chars terminates the value
"[^] ,}\r\n\t%]+"
;; Close the group
"\\)}?"))
;; We are done. Just search until the next closing bracket
"[^]]*\\]"))