How to set up reftex-view-crossref-extra in Emacs ?
The expression reftex-view-crossref-extra
sets additional patterns for reftex-view-crossref
function. It consists of Macro Regexp, Search Regexp and Highlight Group(as illustrated below):
(MACRO-RE SEARCH-RE HIGHLIGHT).
MACRO-RE is matched against the macro. SEARCH-RE is the regexp used to search for cross references. `%s' in this regexp is replaced with with the macro argument at point. HIGHLIGHT is an integer indicating which subgroup of the开发者_StackOverflow社区 match should be highlighted.
I'm trying to match the following pattern (org-mode footnotes):
[fn:author2000title:Optional text]
author2000title
is the biblatex label that i want to have a match for. How can i write MACRO-RE
and SEARCH-RE
, such that reftex-view-crossref
works on these kind of records?
Maybe this will help you find a solution for your special setup. To test this, I setup a small org testfile
* Heading 1
\oinc{mylabel}
stuff
* Heading 2
otherstuff [fn:mylabel:Display text]
Setting reftex-view-crossref-extra
to
(setq reftex-view-crossref-extra '(("\\\\oinc" "\\[fn:%s:[^]]*?\\]" 0)))
if I place point at \oinc{mylabel}
, inside the braces, and press C-c &
, [fn...]
gets highlighted and identified as first and only match.
Edit: Replace "\\\\oinc"
with a regex holding the label defining macros you use, e.g. "\\\\mylabel\\|\\\\oinc"
. You can't define reference matches for the standard commands \label
, etc.; their handling is hardcoded; but you can define a new command aliasing the standard¹, and using this to define your labels can use reftex-view-crossref
setup the way shown here to search for your custom references.
To summarize: MACRO-RE
is a regexp matching the macros without parameters you are interested in, SEARCH-RE
is a regexp that matches your desired reference format, and in which you should place a %s
that will be replaced by the argument to the macro matched with MATCH-RE
. If your SEARCH-RE
contains capturing parentheses, you can highlight the part of the capturing matches only, by providing the third list element HIGHLIGHT
as integer referring to the capturing parens as ususal for regex, i.e. 0
for the whole match, 1
for the first capture, 2
for the second etc., where the order of opening parens defines the numbering of the captured matches.
kind regards, Tom
1: \newcommand{\mylabel}[1]{\label{#1}}
Nota Bene: If you want only mylabel
to be highlighted on search/matching, change that to
(setq reftex-view-crossref-extra '(("\\oinc" "\\[fn:\\(%s\\):[^]]*?\\]" 1)))
notice the matching parens in SEARCH-RE
, the second element in the list.
精彩评论