capture protocol ¶激活 “capture” 处理器会在 Emacs 中弹出 ‘Capture’ 缓冲区,并使用捕获模板。
emacsclient "org-protocol://capture?template=X&url=URL&title=TITLE&body=BODY"
要使用该功能,新建名称任意的书签,例如 ‘Org: capture’ ,并在 ‘Location’ 中输入:
javascript:location.href='org-protocol://capture?' +
new URLSearchParams({
template: 'x', url: window.location.href,
title: document.title, body: window.getSelection()});
void(0);
你可能见过另一种写法:
javascript:location.href='org-protocol://capture?template=x'+
'&url='+encodeURIComponent(window.location.href)+
'&title='+encodeURIComponent(document.title)+
'&body='+encodeURIComponent(window.getSelection());void(0);
该写法比前一种稍显繁琐,但兼容 9.0–9.4 版本的旧版 Org。这些版本的 URI 解码器不支持将空格编码为 “+”。
要使用的捕获模板可在书签中指定(如上例中的 =X=)。若未指定,模板键由变量 org-protocol-default-template-key 设置。可用的模板占位符如下:
%:link 链接 URL %:description 网页标题 %:annotation 等价于 [[%:link][%:description]] %i 选中的文本