Function: LaTeX-keyval-caption-reftex-context-function
LaTeX-keyval-caption-reftex-context-function is a byte-compiled
function defined in latex.el.
Signature
(LaTeX-keyval-caption-reftex-context-function ENV-OR-MAC)
Documentation
Return a key=val caption context string for RefTeX in ENV-OR-MAC.
ENV-OR-MAC is the name of current environment or macro passed to this
function by RefTeX. The context string is the value given to the
caption key. If no caption key is found, an error is issued. See also
the docstring of reftex-label-alist and its description for
CONTEXT-METHOD.
Source Code
;; Defined in ~/.emacs.d/elpa/auctex-14.2.0/latex.el
(defun LaTeX-keyval-caption-reftex-context-function (env-or-mac)
"Return a key=val caption context string for RefTeX in ENV-OR-MAC.
ENV-OR-MAC is the name of current environment or macro passed to this
function by RefTeX. The context string is the value given to the
caption key. If no caption key is found, an error is issued. See also
the docstring of `reftex-label-alist' and its description for
CONTEXT-METHOD."
(let* ((start (save-excursion
(search-backward
;; ENV-OR-MAC is a macro if it starts with `TeX-esc':
(if (string-match-p (concat "\\`" (regexp-quote TeX-esc))
env-or-mac)
env-or-mac
(concat "\\begin{" env-or-mac "}"))
nil t)))
(capt-key (save-excursion
(re-search-backward "\\<caption[ \t\n\r%]*=[ \t\n\r%]*"
start t)))
capt-start capt-end)
(if capt-key
(save-excursion
(goto-char (match-end 0))
(cond ((looking-at-p (regexp-quote (concat TeX-grop LaTeX-optop)))
;; Short caption inside [] is available, extract it only
(forward-char)
(setq capt-start (1+ (point)))
(setq capt-end (1- (progn (forward-sexp) (point)))))
;; Extract the entire caption which is enclosed in braces
((looking-at-p TeX-grop)
(setq capt-start (1+ (point)))
(setq capt-end (1- (progn (forward-sexp) (point)))))
;; Extract everything to next comma ,
(t
(setq capt-start (point))
(setq capt-end (progn (skip-chars-forward "^,") (point)))))
;; Return the extracted string
(buffer-substring-no-properties capt-start capt-end))
(error "%s" "No caption found"))))