diff --git a/lisp/org-capture.el b/lisp/org-capture.el index afb56ba..eb05c7a 100644 --- a/lisp/org-capture.el +++ b/lisp/org-capture.el @@ -982,6 +982,18 @@ Point will remain at the first line after the inserted text." (org-capture-put :key (car entry) :description (nth 1 entry) :target (nth 3 entry)) (let ((txt (nth 4 entry)) (type (or (nth 2 entry) 'entry))) + + ;; Special case: + ;; The template consists of exactly one element out of "%[FILE]" or "%(SEXP)". + ;; In this case, insert the contents/reulsts to allow full fledged templates. + (cond + ;; %[] Insert contents of a file: + ((string-match "^%\\[\\(.+\\)\\]$" txt) + (setq txt (org-file-contents (expand-file-name (match-string 1 txt))))) + ;; %() Insert contents of a sexp: + ((string-match "^%\\((.+)\\)$" txt) + (setq txt (eval (read (match-string 1 txt)))))) + (when (or (not txt) (and (stringp txt) (not (string-match "\\S-" txt)))) ;; The template may be empty or omitted for special types. ;; Here we insert the default templates for such cases.