Changes in master Modified doc/org.texi diff --git a/doc/org.texi b/doc/org.texi index f68ef6e..d59976d 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -7253,6 +7253,11 @@ separator line. @item :kill-buffer If the target file was not yet visited when capture was invoked, kill the buffer again after capture is completed. + +@item :tree-property +If the target is in a date or week tree, this property will be used instead +of DATE_TREE or WEEK_TREE to identify the org entry under which the tree +should be built. @end table @end table Modified lisp/org-capture.el diff --git a/lisp/org-capture.el b/lisp/org-capture.el index a8b9879..1202664 100644 --- a/lisp/org-capture.el +++ b/lisp/org-capture.el @@ -227,6 +227,10 @@ properties are: capture was invoked, kill the buffer again after capture is finalized. + :tree-property The property that identifies the entry where the date or + iso-week tree should be placed. When given, overrules + the default DATE_TREE or WEEK_TREE properties. + The template defines the text to be inserted. Often this is an Org mode entry (so the first line should start with a star) that will be filed as a child of the target headline. It can also be @@ -379,7 +383,8 @@ you can escape ambiguous cases with a backward slash, e.g., \\%i." ((const :format "%v " :clock-resume) (const t)) ((const :format "%v " :unnarrowed) (const t)) ((const :format "%v " :table-line-pos) (const t)) - ((const :format "%v " :kill-buffer) (const t))))))))) + ((const :format "%v " :kill-buffer) (const t)) + ((const :format "%v " :tree-property) (string ""))))))))) (defcustom org-capture-before-finalize-hook nil "Hook that is run right before a capture process is finalized. @@ -974,7 +979,8 @@ Store them in the capture property list." (t ;; Current date, possibly corrected for late night ;; workers. - (org-today)))))) + (org-today)))) + nil (org-capture-get :tree-property))) (`(file+function ,path ,function) (set-buffer (org-capture-target-buffer path)) (org-capture-put-target-region-and-position) Modified lisp/org-datetree.el diff --git a/lisp/org-datetree.el b/lisp/org-datetree.el index 540753d..d9aa665 100644 --- a/lisp/org-datetree.el +++ b/lisp/org-datetree.el @@ -50,15 +50,18 @@ Added time stamp is active unless value is `inactive'." (const :tag "Add an active time stamp" active))) ;;;###autoload -(defun org-datetree-find-date-create (d &optional keep-restriction) +(defun org-datetree-find-date-create (d &optional keep-restriction + tree-property) "Find or create an entry for date D. If KEEP-RESTRICTION is non-nil, do not widen the buffer. When it is nil, the buffer will be widened to make sure an existing date -tree can be found." +tree can be found. +If TREE-PROPERTY is given, place the tree under an entry that has this +property, instead of the default DATE_TREE property." (setq-local org-datetree-base-level 1) (or keep-restriction (widen)) (save-restriction - (let ((prop (org-find-property "DATE_TREE"))) + (let ((prop (org-find-property (or tree-property "DATE_TREE")))) (when prop (goto-char prop) (setq-local org-datetree-base-level @@ -80,17 +83,20 @@ tree can be found." year month day)))) ;;;###autoload -(defun org-datetree-find-iso-week-create (d &optional keep-restriction) +(defun org-datetree-find-iso-week-create (d &optional keep-restriction + tree-property) "Find or create an ISO week entry for date D. Compared to `org-datetree-find-date-create' this function creates entries ordered by week instead of months. If KEEP-RESTRICTION is non-nil, do not widen the buffer. When it is nil, the buffer will be widened to make sure an existing date -tree can be found." +tree can be found. +If TREE-PROPERTY is given, place the tree under an entry that has this +property, instead of the default DATE_TREE property." (setq-local org-datetree-base-level 1) (or keep-restriction (widen)) (save-restriction - (let ((prop (org-find-property "WEEK_TREE"))) + (let ((prop (org-find-property (or tree-property "WEEK_TREE")))) (when prop (goto-char prop) (setq-local org-datetree-base-level