diff options
author | oleh <wave@mail.ua> | 2013-09-01 18:27:01 +0200 |
---|---|---|
committer | Carsten Dominik <carsten.dominik@gmail.com> | 2013-09-01 19:47:37 +0200 |
commit | 1871bf69331b110122d7f7615dfbb2a0f3f09c02 (patch) | |
tree | 2da02ae4c54532cc927bc698b098597e02a7997e | |
parent | cdb8d78b00ccd27bed7adf42b7f6bff77625a469 (diff) | |
download | org-mode-1871bf69331b110122d7f7615dfbb2a0f3f09c02.tar.gz |
Allow nil as return of sexp in capture templates
* lisp/org-capture.el (org-capture-expand-embedded-elisp): Throw error if
result is not a string and not nil. If the result is nil, treat it as
if it was the empty string.
-rw-r--r-- | lisp/org-capture.el | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lisp/org-capture.el b/lisp/org-capture.el index bc0a21f..0a6e4e4 100644 --- a/lisp/org-capture.el +++ b/lisp/org-capture.el @@ -1737,11 +1737,15 @@ The template may still contain \"%?\" for cursor positioning." (goto-char (match-beginning 0)) (let ((template-start (point))) (forward-char 1) - (let ((result (org-eval - (org-capture--expand-keyword-in-embedded-elisp - (read (current-buffer)))))) + (let* ((sexp (read (current-buffer))) + (result (org-eval + (org-capture--expand-keyword-in-embedded-elisp sexp)))) (delete-region template-start (point)) - (insert result)))))) + (when result + (if (stringp result) + (insert result) + (error "Capture template sexp `%s' must evaluate to string or nil" + sexp)))))))) (defun org-capture--expand-keyword-in-embedded-elisp (attr) "Recursively replace capture link keywords in ATTR sexp. |