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>
This commit is contained in:
Nicolas Goaziou 2017-01-11 09:17:18 +01:00
parent a0409e56c3
commit 6a49de8862
1 changed files with 8 additions and 4 deletions

View File

@ -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