Skip to content

Commit 0e7033e

Browse files
committed
org-capture: Expand sexps in template with Org mode being active
* lisp/org-capture.el (org-capture-fill-template): Enable `org-mode' in the temporary template expansion buffer. Update docstring accordingly. (org-capture-templates): Clarify that %(sexp) expansion happens in a temporary Org mode buffer. Fixes https://orgmode.org/list/CABUh-776V-_+_JAZwcKQm9ATcs0WUV9SmGwjooGFbt=CtwQj8g@mail.gmail.com
1 parent 4487acc commit 0e7033e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lisp/org-capture.el

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,8 @@ be replaced with content and expanded:
309309
introduced with %[pathname] are expanded this way.
310310
Since this happens after expanding non-interactive
311311
%-escapes, those can be used to fill the expression.
312+
The evaluation happens with Org mode set as major mode
313+
in a temporary buffer.
312314
%<...> The result of `format-time-string' on the ... format
313315
specification.
314316
%t Time stamp, date only. The time stamp is the current
@@ -1572,7 +1574,9 @@ Lisp programs can force the template by setting KEYS to a string."
15721574
"Fill a TEMPLATE and return the filled template as a string.
15731575
The template may still contain \"%?\" for cursor positioning.
15741576
INITIAL content and/or ANNOTATION may be specified, but will be overridden
1575-
by their respective `org-store-link-plist' properties if present."
1577+
by their respective `org-store-link-plist' properties if present.
1578+
1579+
Expansion occurs in a temporary Org mode buffer."
15761580
(let* ((template (or template (org-capture-get :template)))
15771581
(buffer (org-capture-get :buffer))
15781582
(file (buffer-file-name (or (buffer-base-buffer buffer) buffer)))
@@ -1645,6 +1649,7 @@ by their respective `org-store-link-plist' properties if present."
16451649
(setq buffer-file-name nil)
16461650
(setq mark-active nil)
16471651
(insert template)
1652+
(org-mode)
16481653
(goto-char (point-min))
16491654
;; %[] insert contents of a file.
16501655
(save-excursion

0 commit comments

Comments
 (0)