{"id":14176,"date":"2026-10-25T10:39:20","date_gmt":"2026-10-25T14:39:20","guid":{"rendered":"https:\/\/irreal.org\/blog\/?p=14176"},"modified":"2026-10-25T10:39:20","modified_gmt":"2026-10-25T14:39:20","slug":"variables-in-org-capture","status":"publish","type":"post","link":"https:\/\/irreal.org\/blog\/?p=14176","title":{"rendered":"Variables In Org Capture"},"content":{"rendered":"<p>\nMartin Schell has an excellent post on <a href=\"https:\/\/martinschell.eu\/blog\/create_subtree_org_capture_dynamic\/\">building and using Org capture templates<\/a>. What&rsquo;s interesting about his approach is that his template prompts for certain information\u2014customer ID and site location in his example\u2014captures that information in some local variables, and uses those variables to customize the capture for the particular customer.\n<\/p>\n<p>\nHis two main tools for doing this are:\n<\/p>\n<ol class=\"org-ol\">\n<li>The <code>%^{PROMPT|A|B|...}<\/code> placeholder to prompt for data.<\/li>\n<li>The <code>%(EXP)<\/code> placeholder to execute the Elisp expression EXP.<\/li>\n<\/ol>\n<p>\nHe wrote some helper functions to deal with setting and accessing local variables. The first, <code>ms\/set-var<\/code>, prompts the user for the value of a variable, creates the variable, sets its value, and returns the value. This is different from the <code>%^{...}<\/code> placeholder in that it captures the value of the user&rsquo;s answer for later use. The other helper functions make use of the captured variables.\n<\/p>\n<p>\nTake a look at Schell&rsquo;s post to see the functions and how the whole thing hangs together. His needs may be more complicated than normal but the ideas he uses to solve them are handy and applicable to many\u2014even simpler\u2014situations.\n<\/p>\n<p>\nI&rsquo;ve used all the placeholders that uses in my own templates but the idea of capturing a variable for later reuse in the template is new to me. It&rsquo;s a neat idea and definitely worth knowing.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Martin Schell has an excellent post on building and using Org capture templates. What&rsquo;s interesting about his approach is that his template prompts for certain information\u2014customer ID and site location in his example\u2014captures that information in some local variables, and &hellip; <a href=\"https:\/\/irreal.org\/blog\/?p=14176\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[18,4],"class_list":["post-14176","post","type-post","status-publish","format-standard","hentry","category-general","tag-emacs","tag-org-mode"],"_links":{"self":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/14176","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=14176"}],"version-history":[{"count":1,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/14176\/revisions"}],"predecessor-version":[{"id":14177,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/14176\/revisions\/14177"}],"wp:attachment":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=14176"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=14176"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=14176"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}