













| author | Arash Esbati <arash@gnu.org> | 2026-08-14 15:48:43 +0200 |
|---|---|---|
| committer | Arash Esbati <arash@gnu.org> | 2026-08-14 15:48:43 +0200 |
| commit | 3ad2a0a8e7349641685cdd0e81c3d11d56eedf65 (patch) | |
| tree | dd84f15d7a9b06ab0b84ddb2106e49de98f436e3 | |
| parent | 5c3af8120cbd8612a3eebcb8422eb6fbe6967615 (diff) | |
* latex.el (LaTeX-keyval-caption-reftex-context-function): Deal also with LaTeX macros and not only with environments. Use `search-backward' since the search string is fixed.
| -rw-r--r-- | latex.el | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/latex.el b/latex.el
index 0c652ad3457..460bf936c0d 100644
--- a/latex.el
+++ b/latex.el
@@ -9653,18 +9653,24 @@ wrapped in \\(?:...\\)? then."
;; We are done. Just search until the next closing bracket
"[^]]*\\]"))
-(defun LaTeX-keyval-caption-reftex-context-function (env)
- "Extract and return a key=val caption context string for RefTeX in ENV.
-ENV is the name of current environment 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* ((envstart (save-excursion
- (re-search-backward (concat "\\\\begin{" env "}")
- nil t)))
+(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%]*"
- envstart t)))
+ start t)))
capt-start capt-end)
(if capt-key
(save-excursion
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。