UP | HOME

Org API

Table of Contents

Org-Protocol API functions (org-protocol.el)

org-protocol-capture info

Process an org-protocol://capture:// style url.

The sub-protocol used to reach this function is set in org-protocol-protocol-alist.

This function detects an URL, title and optional text, separated by '/' The location for a browser's bookmark has to look like this:

javascript:location.href='org-protocol://capture://'+ \
      encodeURIComponent(location.href)+'/' \
      encodeURIComponent(document.title)+'/'+ \
      encodeURIComponent(window.getSelection())

By default, it uses the character org-protocol-default-template-key, which should be associated with a template in org-capture-templates. But you may prepend the encoded URL with a character and a slash like so:

javascript:location.href='org-protocol://capture://b/'+ ...

Now template ?b will be used.

org-protocol-check-filename-for-protocol fname restoffiles client

Detect if org-protocol-the-protocol and a known sub-protocol is used in fname. Sub-protocols are registered in org-protocol-protocol-alist and org-protocol-protocol-alist-default. This is, how the matching is done:

(string-match "protocol:/+sub-protocol:/+" ...)

protocol and sub-protocol are regexp-quoted.

If a matching protocol is found, the protocol is stripped from fname and the result is passed to the protocols function as the only parameter. If the function returns nil, the filename is removed from the list of filenames passed from emacsclient to the server. If the function returns a non nil value, that value is passed to the server as filename.

org-protocol-create &optional project-plist

Create a new org-protocol project interactively. An org-protocol project is an entry in org-protocol-project-alist which is used by org-protocol-open-source. Optionally use project-plist to initialize the defaults for this project. If project-plist is the CDR of an element in org-publish-project-alist, reuse :base-directory, :html-extension and :base-extension.

org-protocol-create-for-org

Create a org-protocol project for the current file's Org-mode project. This works, if the file visited is part of a publishing project in org-publish-project-alist. This function calls org-protocol-create to do most of the work.

org-protocol-do-capture info capture-func

Support org-capture and org-remember alike. capture-func is either the symbol org-remember or org-capture.

org-protocol-flatten l

Greedy handlers might receive a list like this from emacsclient:

'( ("/dir/org-protocol:/greedy:/~/path1" (23 . 12)) ("/dir/param")

where "dir" is the absolute path to emacsclients working directory. This function transforms it into a flat list.

org-protocol-flatten-greedy param-list &optional strip-path replacement

Greedy handlers might receive a list like this from emacsclient:

'(("/dir/org-protocol:/greedy:/~/path1" (23 . 12)) ("/dir/param")

where "dir" is the absolute path to emacsclients working directory. This function transforms it into a flat list using org-protocol-flatten and transforms the elements of that list as follows:

If strip-path is non-nil, remove the "dir" prefix from all members of param-list.

If replacement is string, replace the "dir" prefix with it.

The first parameter, the one that contains the protocols, is always changed. Everything up to the end of the protocols is stripped.

Note, that this function will always behave as if org-protocol-reverse-list-of-files was set to t and the returned list will reflect that. I.e. emacsclients first parameter will be the first one in the returned list.

org-protocol-open-source fname

Process an org-protocol://open-source:// style url.

Change a filename by mapping URLs to local filenames as set in org-protocol-project-alist.

The location for a browser's bookmark should look like this:

javascript:location.href='org-protocol://open-source://'+ \
      encodeURIComponent(location.href)

org-protocol-remember info

Process an org-protocol://remember:// style url.

The location for a browser's bookmark has to look like this:

javascript:location.href='org-protocol://remember://'+ \
      encodeURIComponent(location.href)+'/' \
      encodeURIComponent(document.title)+'/'+ \
      encodeURIComponent(window.getSelection())

See the docs for org-protocol-capture for more information.

org-protocol-sanitize-uri uri

emacsclient compresses double and triple slashes. Slashes are sanitized to double slashes here.

org-protocol-split-data data &optional unhexify separator

Split what an org-protocol handler function gets as only argument. data is that one argument. data is split at each occurrence of separator (regexp). If no separator is specified or separator is nil, assume "/+". The results of that splitting are returned as a list. If unhexify is non-nil, hex-decode each split part. If unhexify is a function, use that function to decode each split part.

org-protocol-store-link fname

Process an org-protocol://store-link:// style url. Additionally store a browser URL as an org link. Also pushes the link's URL to the kill-ring.

The location for a browser's bookmark has to look like this:

javascript:location.href='org-protocol://store-link://'+ \
      encodeURIComponent(location.href)
      encodeURIComponent(document.title)+'/'+ \

Don't use escape()! Use encodeURIComponent() instead. The title of the page could contain slashes and the location definitely will.

The sub-protocol used to reach this function is set in org-protocol-protocol-alist.

org-protocol-unhex-compound hex

Unhexify Unicode hex-chars. E.g. %C3%B6 is the German Umlaut ö. Note: this function also decodes single byte encodings like %E1 ("á") if not followed by another %[A-F0-9]{2} group.

org-protocol-unhex-single-byte-sequence hex

Unhexify hex-encoded single byte character sequences.

org-protocol-unhex-string str

Unhex hexified Unicode strings as returned from the JavaScript function encodeURIComponent. E.g. %C3%B6 is the german Umlaut ö.

Documentation from the http://orgmode.org/worg/ website (either in its HTML format or in its Org format) is licensed under the GNU Free Documentation License version 1.3 or later. The code examples and css stylesheets are licensed under the GNU General Public License v3 or later.