From 8aacc708dd038fd0d351abbed04d49f813f8a7bf Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Thu, 16 Dec 2010 16:51:04 +0100 Subject: [PATCH] Capture: Better error message for invalid entry-type templates * lisp/org-capture.el (org-capture-place-entry): (org-capture-insert-template-here): Check tree for validity before pasting it. --- lisp/org-capture.el | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lisp/org-capture.el b/lisp/org-capture.el index 5c7b0386e..b85b011be 100644 --- a/lisp/org-capture.el +++ b/lisp/org-capture.el @@ -776,6 +776,7 @@ already gone. Any prefix argument will be passed to the refile comand." (or (bolp) (insert "\n"))))) (org-capture-empty-lines-before) (setq beg (point)) + (org-capture-verify-tree txt) (org-paste-subtree level txt 'for-yank) (org-capture-empty-lines-after 1) (org-capture-position-for-last-stored beg) @@ -1017,6 +1018,7 @@ Point will remain at the first line after the inserted text." (setq beg (point)) (cond ((and (eq type 'entry) (org-mode-p)) + (org-capture-verify-tree txt) (org-paste-subtree nil template t)) ((and (memq type '(item checkitem)) (org-mode-p) @@ -1084,6 +1086,11 @@ Use PREFIX as a prefix for the name of the indirect buffer." (error (make-indirect-buffer buffer bname))))) +(defun org-capture-verify-tree (tree) + "Throw error if TREE is not a valid tree" + (unless (org-kill-is-subtree-p tree) + (error "Template is not a valid Org entry or tree"))) + ;;; The template code (defun org-capture-select-template (&optional keys) -- 2.11.4.GIT