org-capture: Fix datetree capture

* lisp/org-capture.el (org-capture-set-target-location): Fix
  file+datetree capture with non-nil `org-datetree-add-timestamp.

Reported-by: Gregor Zattler <telegraph@gmx.net>
<http://permalink.gmane.org/gmane.emacs.orgmode/100300>
This commit is contained in:
Nicolas Goaziou 2015-08-21 23:31:23 +02:00
parent 6d3c988561
commit a834a5939f
1 changed files with 6 additions and 1 deletions

View File

@ -929,7 +929,12 @@ Store them in the capture property list."
(time-to-days prompt-time)))
(t
;; current date, possibly corrected for late night workers
(org-today))))))
(org-today)))))
;; If `org-datetree-add-timestamp' is non-nil, point is not
;; located on a headline. However `file+datetree' expects
;; a node where to paste captured tree. Thus, we make sure to
;; move to day heading.
(org-back-to-heading t))
((eq (car target) 'file+function)
(set-buffer (org-capture-target-buffer (nth 1 target)))