Start a new topic

Define templates in init.org

Hey there, was just wondering if anyone had any insight into how I might define my capture templates in my `init.org` file?


I see a variable in `library.org` called `item-templates`. It does not look like the capture templates I defined via the user interface are stored in this variable, as it returns nil in the REPL. Additionally, it says that it should store a list of pairs, with the first item being the template name and the second being the template definition, but I'm not sure what the structure of the "template definition" should be.


My ideal use case is to define these capture templates in the `init.org` file in case I move devices, and also so that I can eventually create functionality to translate my Emacs org-capture templates into beorg ones.


Let me know if there's any way to currently do this, and what the template definitions should look like. Thanks!


 Awesome, looks like this is working great!


Pasting what I'm using below for anyone else who is looking for the same effect:


 

(set! item-templates
      '(
        ;;; Quick TODO - schedule for today, don't prompt for notes
        ("QTODO"
         "s TODO f gtd.org sch 0 h Shortterm n \"Captured: [%now%]\"")

        ;;; Personal TODO - don't schedule but prompt for notes immediately
        ("Personal TODO"
         "s TODO f gtd.org h Personal n \"Captured: [%now%]\" e")

        ;;; Emacs TODO - like a personal TODO but filed under the Emacs subtree
        ("Emacs TODO"
         "s TODO f gtd.org h Emacs n \"Captured: [%now%]\" e")

        ;;; Book - quick capture a book recommendation
        ("Book"
         "s UPCOMING f lists.org h Books n \"Captured: [%now%]\nAuthor(s):\nGist:\nSource:\" e")

        ;;; Movie - quick capture a movie recommendation
        ("Movie"
         "s UPCOMING f lists.org h Movies n \"Captured: [%now%]\nGist:\nSource:\" e")

        ;;; Restaurant - quick capture a restaurant recommendation
        ("Restaurant"
         "s UPCOMING f lists.org h Restaurants n \"Captured: [%now%]\nRecommended Dishes:\nSource:\" e")

        ;;; TV Show - quick capture a tv show recommendation
        ("TV Show"
         "s UPCOMING f lists.org h \"TV Shows\" n \"Captured: [%now%]\nGist:\nSource:\" e")

        ;;; Game - quick capture a game recommendation
        ("Game"
         "s UPCOMING f lists.org h Games n \"Captured: [%now%]\nGist:\nSource:\" e")

        ;;; Web Link - capture a web page (used in conjunction with iOS shortcuts)
        ("Web Link"
         "s UPCOMING f lists.org h \"Internet Content\" t article")))

 Last question: is there a flag to specify what is the "favorite" template (i.e. the default template used when hitting the plus sign icon in the app)?


1 person likes this

I moved this into a different category.


I haven't documented this yet. Here is a brief summary of the template syntax (very similar to the search syntax).


You construct a template definition by specifying the properties of the template in a single string. Here are the properties which can be specified:


s STATE - the state to set the item to

p PRIORITY - the priority to use

f FILE - the file to add the item to

sch DATE - the scheduled date to set (using the date syntax describing the Users' Guide)

dead DATE - the deadline date

show DATE - the 'show on' date

t TAG - a tag to add (can include this property multiple times)

h SUBTREE - where to add this in the specified file (can include this property multiple times to define the hierarchy)

n NOTES - the notes to add

e - whether the notes should be automatically shown to the user

anything else is the headline


Here is an example:


s TODO p A f tasks sch 1 t Christmas t Shopping h 2019 h "To Buy"


This is a template which creates a new task with the state TODO, priority A, in the file tasks, with a scheduled date of tomorrow, the tags Christmas and Shopping, filed under 2019 > To Buy.


1 person likes this

Oh I just realized this is in the wrong section - I thought this was "How to use beorg" not "How you (I) use beorg".


Please move this if possible, or I can re-create in the correct category.

Login or Signup to post a comment