Table of Contents

Next: , Previous: Setting up Remember for Org, Up: Remember


9.1.2 Remember templates

In combination with Org, you can use templates to generate different types of Remember notes. For example, if you would like to use one template to create general TODO entries, another one for journal entries, and a third one for collecting random ideas, you could use:

     (setq org-remember-templates
      '(("Todo" ?t "* TODO %?\n  %i\n  %a" "~/org/TODO.org" "Tasks")
        ("Journal" ?j "* %U %?\n\n  %i\n  %a" "~/org/JOURNAL.org")
        ("Idea" ?i "* %^{Title}\n  %i\n  %a" "~/org/JOURNAL.org" "New Ideas")))

In these entries, the first string is just a name, and the character specifies how to select the template. It is useful if the character is also the first letter of the name. The next string specifies the template. Two more (optional) strings give the file in which, and the headline under which, the new note should be stored. The file (if not present or nil) defaults to org-default-notes-file, the heading to org-remember-default-headline. If the file name is not an absolute path, it will be interpreted relative to org-directory.

The heading can also be the symbols top or bottom to send notes as level 1 entries to the beginning or end of the file, respectively. It may also be the symbol date-tree. Then, a tree with year on level 1, month on level 2 and day on level three will be build in the file, and the entry will be filed into the tree under the current date1

An optional sixth element specifies the contexts in which the user can select the template. This element can be a list of major modes or a function. org-remember will first check whether the function returns t or if we are in any of the listed major modes, and exclude templates for which this condition is not fulfilled. Templates that do not specify this element at all, or that use nil or t as a value will always be selectable.

So for example:

     (setq org-remember-templates
      '(("Bug" ?b "* BUG %?\n  %i\n  %a" "~/org/BUGS.org" "Bugs" (emacs-lisp-mode))
        ("Journal" ?j "* %U %?\n\n  %i\n  %a" "~/org/JOURNAL.org" "X" my-check)
        ("Idea" ?i "* %^{Title}\n  %i\n  %a" "~/org/JOURNAL.org" "New Ideas")))

The first template will only be available when invoking org-remember from an buffer in emacs-lisp-mode. The second template will only be available when the function my-check returns t. The third template will be proposed in any context.

When you call M-x org-remember (or M-x remember) to remember something, Org will prompt for a key to select the template (if you have more than one template) and then prepare the buffer like

     * TODO
       [[file:link to where you called remember]]

During expansion of the template, special %-escapes2 allow dynamic insertion of content:

     %^{prompt}  prompt the user for a string and replace this sequence with it.
                 You may specify a default value and a completion table with
                 %^{prompt|default|completion2|completion3...}
                 The arrow keys access a prompt-specific history.
     %a          annotation, normally the link created with org-store-link
     %A          like %a, but prompt for the description part
     %i          initial content, the region when remember is called with C-u.
                 The entire text will be indented like %i itself.
     %t          timestamp, date only
     %T          timestamp with date and time
     %u, %U      like the above, but inactive timestamps
     %^t         like %t, but prompt for date.  Similarly %^T, %^u, %^U
                 You may define a prompt like %^{Birthday}t
     %n          user name (taken from user-full-name)
     %c          Current kill ring head.
     %x          Content of the X clipboard.
     %^C         Interactive selection of which kill or clip to use.
     %^L         Like %^C, but insert as link.
     %^g         prompt for tags, with completion on tags in target file.
     %k          title of currently clocked task
     %K          link to currently clocked task
     %^G         prompt for tags, with completion all tags in all agenda files.
     %^{prop}p   Prompt the user for a value for property prop
     %:keyword   specific information for certain link types, see below
     %[file]     insert the contents of the file given by file
     %(sexp)     evaluate Elisp sexp and replace with the result
     %!          immediately store note after completing the template
                 (skipping the C-c C-c that normally triggers storing)
     %&          jump to target location immediately after storing note

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

     Link type          |  Available keywords
     -------------------+----------------------------------------------
     bbdb               |  %:name %:company
     bbdb               |  %::server %:port %:nick
     vm, wl, mh, rmail  |  %:type %:subject %:message-id
                        |  %:from %:fromname %:fromaddress
                        |  %:to   %:toname   %:toaddress
                        |  %:fromto (either "to NAME" or "from NAME")4
     gnus               |  %:group, for messages also all email fields
     w3, w3m            |  %:url
     info               |  %:file %:node
     calendar           |  %:date"

To place the cursor after template expansion use:

     %?          After completing the template, position cursor here.

If you change your mind about which template to use, call org-remember in the remember buffer. You may then select a new template that will be filled with the previous context information.


Footnotes

[1] If the file contains an entry with a DATE_TREE property, the entire date tree will be build under that entry.

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

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

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