在 org-mode 模板中使用 %\n 时遇到问题
Trouble using %\n in org-mode templates
org 文档描述了捕获模板中的各种 %-escape 代码。我很难让 %\n 工作。文档的相关部分说:
%\n Insert the text entered at the nth %^{prompt}, where n is a
number, starting from 1.
以下是我使用特定转义码的捕获模板的片段:
("i" "Interrupts")
(
"io" ; key
"Other" ; description
entry ; type
(file+headline "~/git/org/agenda/refile.org" "Interrupts") ; target
"* IRQ from %^{Name}: %^{Subject} :%:\n\n%?" ; template
:prepend t ; properties
:clock-in t ; properties
:clock-resume t ;
:empty-lines 1 ; properties
)
我对该模板生成的条目 header 的期望,如果我为两个提示输入 "Fred" 和 "SomeSubject",是这样的:
- 来自 Fred 的 IRQ:SomeSubject :Fred:
但是,%\1 没有正确扩展,而是我得到:
- 来自 Fred 的 IRQ:SomeSubject :^A:
为了检查问题是否是我将 %\1 放在标签内,我也试过这样:
- 来自 Fred 的 IRQ:SomeSubject Name 是 %\1
但它仍然没有用,并且给出:
- 来自 Fred 的 IRQ:SomeSubject Name 是 ^A
知道我做错了什么吗?
谢谢。
您需要像正则表达式一样对反斜杠进行转义。试试 %\\1.
org 文档描述了捕获模板中的各种 %-escape 代码。我很难让 %\n 工作。文档的相关部分说:
%\n Insert the text entered at the nth %^{prompt}, where n is a number, starting from 1.
以下是我使用特定转义码的捕获模板的片段:
("i" "Interrupts")
(
"io" ; key
"Other" ; description
entry ; type
(file+headline "~/git/org/agenda/refile.org" "Interrupts") ; target
"* IRQ from %^{Name}: %^{Subject} :%:\n\n%?" ; template
:prepend t ; properties
:clock-in t ; properties
:clock-resume t ;
:empty-lines 1 ; properties
)
我对该模板生成的条目 header 的期望,如果我为两个提示输入 "Fred" 和 "SomeSubject",是这样的:
- 来自 Fred 的 IRQ:SomeSubject :Fred:
但是,%\1 没有正确扩展,而是我得到:
- 来自 Fred 的 IRQ:SomeSubject :^A:
为了检查问题是否是我将 %\1 放在标签内,我也试过这样:
- 来自 Fred 的 IRQ:SomeSubject Name 是 %\1
但它仍然没有用,并且给出:
- 来自 Fred 的 IRQ:SomeSubject Name 是 ^A
知道我做错了什么吗?
谢谢。
您需要像正则表达式一样对反斜杠进行转义。试试 %\\1.