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:
parent
a0409e56c3
commit
6a49de8862
|
@ -890,14 +890,14 @@ Store them in the capture property list."
|
||||||
|
|
||||||
((eq (car target) 'file+headline)
|
((eq (car target) 'file+headline)
|
||||||
(set-buffer (org-capture-target-buffer (nth 1 target)))
|
(set-buffer (org-capture-target-buffer (nth 1 target)))
|
||||||
(org-capture-put-target-region-and-position)
|
|
||||||
(widen)
|
|
||||||
(let ((hd (nth 2 target)))
|
|
||||||
(goto-char (point-min))
|
|
||||||
(unless (derived-mode-p 'org-mode)
|
(unless (derived-mode-p 'org-mode)
|
||||||
(error
|
(error
|
||||||
"Target buffer \"%s\" for file+headline should be in Org mode"
|
"Target buffer \"%s\" for file+headline should be in Org mode"
|
||||||
(current-buffer)))
|
(current-buffer)))
|
||||||
|
(org-capture-put-target-region-and-position)
|
||||||
|
(widen)
|
||||||
|
(let ((hd (nth 2 target)))
|
||||||
|
(goto-char (point-min))
|
||||||
(if (re-search-forward
|
(if (re-search-forward
|
||||||
(format org-complex-heading-regexp-format (regexp-quote hd))
|
(format org-complex-heading-regexp-format (regexp-quote hd))
|
||||||
nil t)
|
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))
|
((memq (car target) '(file+datetree file+datetree+prompt file+weektree file+weektree+prompt))
|
||||||
(require 'org-datetree)
|
(require 'org-datetree)
|
||||||
(set-buffer (org-capture-target-buffer (nth 1 target)))
|
(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)
|
(org-capture-put-target-region-and-position)
|
||||||
(widen)
|
(widen)
|
||||||
;; Make a date/week tree entry, with the current date (or
|
;; Make a date/week tree entry, with the current date (or
|
||||||
|
|
Loading…
Reference in New Issue