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


9.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.

An optional sixth element specifies the contexts in which the user can select the template. This element can be either 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 mode, and select the template accordingly.

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" 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 remember (or M-x org-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 %-escapes 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.
     %t          time stamp, date only
     %T          time stamp with date and time
     %u, %U      like the above, but inactive time stamps
     %^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)
     %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.
     %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.
     %^G         prompt for tags, with completion all tags in all agenda files.
     %:keyword   specific information for certain link types, see below
     %[pathname] insert the contents of the file given by pathname
     %(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)

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

     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")2
     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 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.

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