如何在 Emacs 中设置 reftex-view-crossref-extra ?
表达式 reftex-view-crossref-extra 为 reftex-view-crossref 函数设置附加模式。它由宏正则表达式、搜索正则表达式和突出显示组组成(如下图所示):
(宏观-RE 搜索-RE 亮点)。
MACRO-RE 与宏匹配。 SEARCH-RE 是正则表达式 用于搜索交叉引用。该正则表达式中的“%s”被替换 with 与 point 处的宏参数。 HIGHLIGHT 是一个整数 指示应突出显示匹配的哪个子组。
我正在尝试匹配以下模式(组织模式脚注):
[fn:author2000title:Optional text]
author2000title
是我想要匹配的 biblatex 标签。我如何编写MACRO-RE
和SEARCH-RE
,以便reftex-view-crossref
适用于这些类型的记录?
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 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许这会帮助您找到适合您的特殊设置的解决方案。为了测试这一点,我设置了一个小型组织测试文件,
将
reftex-view-crossref-extra
设置为是否将点放置在大括号内的
\oinc{mylabel}
处,然后按Cc &
,[fn...]
突出显示并标识为第一个且唯一的匹配项。编辑:将
"\\\\oinc"
替换为包含定义您使用的宏的标签的正则表达式,例如"\\\\mylabel\\|\\ \\oinc"
。您无法为标准命令\label
等定义引用匹配;它们的处理是硬编码的;但您可以定义一个新命令,为标准 1 别名,并使用它来定义标签,可以使用 reftex-view-crossref 设置此处显示的方式来搜索自定义引用。总结一下:
MACRO-RE
是一个与不带您感兴趣的参数的宏相匹配的正则表达式,SEARCH-RE
是一个与您所需的参考格式相匹配的正则表达式,并且您可以在其中使用应放置一个%s
,该%s
将被与MATCH-RE
匹配的宏的参数替换。如果您的SEARCH-RE
包含捕获括号,则可以通过将第三个列表元素HIGHLIGHT
提供为整数(通常引用捕获括号)来突出显示捕获匹配的部分对于正则表达式,即0
表示整个匹配,1
表示第一次捕获,2
表示第二次捕获,等等,其中左括号的顺序定义捕获的编号匹配。亲切的问候,
Tom
1:
\newcommand{\mylabel}[1]{\label{#1}}
注意:如果您只想在搜索/匹配时突出显示
mylabel
,更改它以注意列表中第二个元素 SEARCH-RE 中的匹配括号。
Maybe this will help you find a solution for your special setup. To test this, I setup a small org testfile
Setting
reftex-view-crossref-extra
toif I place point at
\oinc{mylabel}
, inside the braces, and pressC-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 usereftex-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 withMATCH-RE
. If yourSEARCH-RE
contains capturing parentheses, you can highlight the part of the capturing matches only, by providing the third list elementHIGHLIGHT
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 tonotice the matching parens in
SEARCH-RE
, the second element in the list.