Skip to content

The capture protocol

Activating the “capture” handler pops up a ‘Capture’ buffer in Emacs, using acapture template.

lisp
emacsclient "org-protocol://capture?template=X&url=URL&title=TITLE&body=BODY"

To use this feature, add a bookmark with an arbitrary name, e.g., ‘Org: capture’, and enter this as ‘Location’:

bash
javascript:location.href='org-protocol://capture?' +
      new URLSearchParams({
            template: 'x', url: window.location.href,
            title: document.title, body: window.getSelection()});

You might have seen another expression:

bash
javascript:location.href='org-protocol://capture?template=x'+
      '&url='+encodeURIComponent(window.location.href)+
      '&title='+encodeURIComponent(document.title)+
      '&body='+encodeURIComponent(window.getSelection());

It is a bit more cluttered than the former one, but it is compatible with previous Org versions 9.0-9.4. In these versions encoding of space as “+” character was not supported by URI decoder.

The capture template to be used can be specified in the bookmark (like ‘X’ above). If unspecified, the template key is set in the variable org-protocol-default-template-key. The following template placeholders are available:

bash
%:link          The URL
%:description   The webpage title
%:annotation    Equivalent to [[%:link][%:description]]
%i              The selected text