summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2017-01-11 09:17:18 +0100
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2017-01-11 09:17:18 +0100
commit6a49de8862364bc15059d7c10a74ce4edf5e35e4 (patch)
treebdd61c92c807e4145b1a050207a86a6c97243c17
parenta0409e56c3e4e9e8746235f6c0841a701a2f57a2 (diff)
downloadorg-mode-6a49de8862364bc15059d7c10a74ce4edf5e35e4.tar.gz
org-capture: Improve error message for date/weektree capture
* lisp/org-capture.el (org-capture-set-target-location): Raise an error when target location is not an Org buffer. Reported-by: Simao <smm@imap.cc> <http://permalink.gmane.org/gmane.emacs.orgmode/111320>
-rw-r--r--lisp/org-capture.el12
1 files changed, 8 insertions, 4 deletions
diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index 7ab9121..b3b7f2f 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -890,14 +890,14 @@ Store them in the capture property list."
((eq (car target) 'file+headline)
(set-buffer (org-capture-target-buffer (nth 1 target)))
+ (unless (derived-mode-p 'org-mode)
+ (error
+ "Target buffer \"%s\" for file+headline should be in Org mode"
+ (current-buffer)))
(org-capture-put-target-region-and-position)
(widen)
(let ((hd (nth 2 target)))
(goto-char (point-min))
- (unless (derived-mode-p 'org-mode)
- (error
- "Target buffer \"%s\" for file+headline should be in Org mode"
- (current-buffer)))
(if (re-search-forward
(format org-complex-heading-regexp-format (regexp-quote hd))
nil t)
@@ -932,6 +932,10 @@ Store them in the capture property list."
((memq (car target) '(file+datetree file+datetree+prompt file+weektree file+weektree+prompt))
(require 'org-datetree)
(set-buffer (org-capture-target-buffer (nth 1 target)))
+ (unless (derived-mode-p 'org-mode)
+ (error "Target buffer \"%s\" for %s should be in Org mode"
+ (current-buffer)
+ (car target)))
(org-capture-put-target-region-and-position)
(widen)
;; Make a date/week tree entry, with the current date (or