Next: , Previous: , Up: Capture templates   [Contents][Index] Template expansion

In the template itself, special %-escapes89 allow dynamic insertion of content. The templates are expanded in the order given here:

%[file]     Insert the contents of the file given by file.
%(sexp)     Evaluate Elisp sexp and replace with the result.
                  For convenience, %:keyword (see below) placeholders
                  within the expression will be expanded prior to this.
                  The sexp must return a string.
%<...>      The result of format-time-string on the ... format specification.
%t          Timestamp, date only.
%T          Timestamp, with date and time.
%u, %U      Like the above, but inactive timestamps.
%i          Initial content, the region when capture is called while the
            region is active.
            The entire text will be indented like %i itself.
%a          Annotation, normally the link created with org-store-link.
%A          Like %a, but prompt for the description part.
%l          Like %a, but only insert the literal link.
%c          Current kill ring head.
%x          Content of the X clipboard.
%k          Title of the currently clocked task.
%K          Link to the currently clocked task.
%n          User name (taken from user-full-name).
%f          File visited by current buffer when org-capture was called.
%F          Full path of the file or directory visited by current buffer.
%:keyword   Specific information for certain link types, see below.
%^g         Prompt for tags, with completion on tags in target file.
%^G         Prompt for tags, with completion all tags in all agenda files.
%^t         Like %t, but prompt for date.  Similarly %^T, %^u, %^U.
            You may define a prompt like %^{Birthday}t.
%^C         Interactive selection of which kill or clip to use.
%^L         Like %^C, but insert as link.
%^{prop}p   Prompt the user for a value for property prop.
%^{prompt}  prompt the user for a string and replace this sequence with it.
            You may specify a default value and a completion table with
            The arrow keys access a prompt-specific history.
%\1 … %\N Insert the text entered at the Nth %^{prompt}, where N is
            a number, starting from 1.(90)
%?          After completing the template, position cursor here.

For specific link types, the following keywords will be defined91:

Link type                        |  Available keywords
bbdb                             |  %:name %:company
irc                              |  %:server %:port %:nick
vm, vm-imap, wl, mh, mew, rmail, |  %:type %:subject %:message-id
gnus, notmuch                    |  %:from %:fromname %:fromaddress
                                 |  %:to   %:toname   %:toaddress
                                 |  %:date (message date header field)
                                 |  %:date-timestamp (date as active timestamp)
                                 |  %:date-timestamp-inactive (date as inactive timestamp)
                                 |  %:fromto (either "to NAME" or "from NAME")(92)
gnus                             |  %:group, for messages also all email fields
eww, w3, w3m                     |  %:url
info                             |  %:file %:node
calendar                         |  %:date
org-protocol                     |  %:link %:description %:annotation

To place the cursor after template expansion use:

%?          After completing the template, position cursor here.



If you need one of these sequences literally, escape the % with a backslash.


As required in Emacs Lisp, it is necessary to escape any backslash character in a string with another backslash. So, in order to use ‘%\1’ placeholder, you need to write ‘%\\1’ in the template.


If you define your own link types (see Adding hyperlink types), any property you store with org-store-link-props can be accessed in capture templates in a similar way.


This will always be the other, not the user. See the variable org-from-is-user-regexp.

Next: , Previous: , Up: Capture templates   [Contents][Index]