我使用的是Windows的emacs-24.3,尤其是Org-Mode,这太棒了。我正在尝试为工作中遇到的缺陷设置新的捕获模板,并希望该模板输出如下内容:
例如
我遇到的问题是URL与此http://www.jira.com/browse/COM-19112类似,我希望将其输出为COM-19112。要在emacs中正常执行此操作,我将执行以下操作:
[[http://www.jira.com/browse/COM-19112][COM-19112]]
Run Code Online (Sandbox Code Playgroud)
但是,当尝试设置组织捕获模板时,我只需要键入一次COM-19112,并在两个地方都填写一次。这是到目前为止我能得到的最好的-它给了我想要的东西,但是我必须在提示符下两次键入“ COM-19112”:
(setq org-capture-templates
'(("d" "Defects" entry (file+headline "C:/EmacsOrg/Defects.org" "Tasks")
"* TODO %? [[http://www.jira.com/browse/%^{Defect}][%^{Defect}]]")))
Run Code Online (Sandbox Code Playgroud)
我在http://orgmode.org/manual/Template-expansion.html#fn-2上看不到任何内容,该内容说明了如何创建可在多个地方使用的变量,但是我敢肯定有一种方法这个。
如果有人能指出正确的方向,我将不胜感激。
问候
比伯歌
模板扩展页面上确实包含有关如何重新插入现有变量的信息。
%\n Insert the text entered at the nth %^{prompt}, where n is
a number, starting from 1.
Run Code Online (Sandbox Code Playgroud)
假设您的模板如上所述:
%\n Insert the text entered at the nth %^{prompt}, where n is
a number, starting from 1.
Run Code Online (Sandbox Code Playgroud)
您可以将其替换为
(setq org-capture-templates
'(("d" "Defects" entry (file+headline "C:/EmacsOrg/Defects.org" "Tasks")
"* TODO %? [[http://www.jira.com/browse/%^{Defect}][%^{Defect}]]")))
Run Code Online (Sandbox Code Playgroud)
您可能需要%\\1根据定义的其他变量来更改。(由于\是转义字符,因此确实需要双反斜杠才能起作用)