From ab351d442d7bb4d17cbb43638aaed1775d8c0344 Mon Sep 17 00:00:00 2001 From: Rasmus Date: Mon, 18 Sep 2017 12:01:12 +0200 Subject: Update Org to v9.1.1 Please see etc/ORG-NEWS for major changes. --- lisp/org/org-datetree.el | 53 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 18 deletions(-) (limited to 'lisp/org/org-datetree.el') diff --git a/lisp/org/org-datetree.el b/lisp/org/org-datetree.el index b7852baf10a..308f42ff6cf 100644 --- a/lisp/org/org-datetree.el +++ b/lisp/org/org-datetree.el @@ -54,16 +54,25 @@ Added time stamp is active unless value is `inactive'." "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 it is the sympol `subtree-at-point', then the tree +will be built under the headline at point." (setq-local org-datetree-base-level 1) - (or keep-restriction (widen)) (save-restriction - (let ((prop (org-find-property "DATE_TREE"))) - (when prop - (goto-char prop) - (setq-local org-datetree-base-level - (org-get-valid-level (org-current-level) 1)) - (org-narrow-to-subtree))) + (if (eq keep-restriction 'subtree-at-point) + (progn + (unless (org-at-heading-p) (error "Not at heading")) + (widen) + (org-narrow-to-subtree) + (setq-local org-datetree-base-level + (org-get-valid-level (org-current-level) 1))) + (unless keep-restriction (widen)) + ;; Support the old way of tree placement, using a property + (let ((prop (org-find-property "DATE_TREE"))) + (when prop + (goto-char prop) + (setq-local org-datetree-base-level + (org-get-valid-level (org-current-level) 1)) + (org-narrow-to-subtree)))) (goto-char (point-min)) (let ((year (calendar-extract-year d)) (month (calendar-extract-month d)) @@ -84,18 +93,26 @@ tree can be found." "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." +When it is nil, the buffer will be widened to make sure an existing date +tree can be found. If it is the sympol `subtree-at-point', then the tree +will be built under the headline at point." (setq-local org-datetree-base-level 1) - (or keep-restriction (widen)) (save-restriction - (let ((prop (org-find-property "WEEK_TREE"))) - (when prop - (goto-char prop) - (setq-local org-datetree-base-level - (org-get-valid-level (org-current-level) 1)) - (org-narrow-to-subtree))) + (if (eq keep-restriction 'subtree-at-point) + (progn + (unless (org-at-heading-p) (error "Not at heading")) + (widen) + (org-narrow-to-subtree) + (setq-local org-datetree-base-level + (org-get-valid-level (org-current-level) 1))) + (unless keep-restriction (widen)) + ;; Support the old way of tree placement, using a property + (let ((prop (org-find-property "WEEK_TREE"))) + (when prop + (goto-char prop) + (setq-local org-datetree-base-level + (org-get-valid-level (org-current-level) 1)) + (org-narrow-to-subtree)))) (goto-char (point-min)) (require 'cal-iso) (let* ((year (calendar-extract-year d)) -- cgit v1.2.3