summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien <bzg@gnu.org>2020-02-11 14:45:19 +0100
committerBastien <bzg@gnu.org>2020-02-11 14:45:19 +0100
commit78ec8da52a3353117282e3dbf0d3d4f74a76f917 (patch)
tree6687d30a682691eb6161226bd2d8b36b336d3afc
parent20ab65482ac6564995fdb236e3754f1cb69f3e06 (diff)
downloadorg-mode-78ec8da52a3353117282e3dbf0d3d4f74a76f917.tar.gz
org-capture.el: Conditionally throw an error on missing annotation
* lisp/org-capture.el (org-capture-fill-template): Throw a user error when :immediate-finish is `t' and when the %a template could not be expanded. Thanks to Leo Gaspard for this idea.
-rw-r--r--lisp/org-capture.el8
1 files changed, 7 insertions, 1 deletions
diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index 84b0e4f..f053c7b 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -1565,7 +1565,13 @@ The template may still contain \"%?\" for cursor positioning."
(let ((a (or (plist-get org-store-link-plist :annotation)
annotation
(org-capture-get :annotation)
- "")))
+ ;; When immediately finishing and %a cannot be
+ ;; expanded, through a user error:
+ (if (org-capture-get :immediate-finish)
+ (user-error "Missing initial annotation in this template: %s"
+ (replace-regexp-in-string
+ "\n" " " (org-capture-get :template)))
+ ""))))
;; Is the link empty? Then we do not want it...
(if (equal a "[[]]") "" a)))
(l-re "\\[\\[\\(.*?\\)\\]\\(\\[.*?\\]\\)?\\]")