|
|
|
@ -259,7 +259,7 @@ direct children of this heading."
|
|
|
|
|
(if (local-variable-p 'org-odd-levels-only (current-buffer))
|
|
|
|
|
org-odd-levels-only
|
|
|
|
|
tr-org-odd-levels-only))
|
|
|
|
|
level datetree-date datetree-subheading-p
|
|
|
|
|
level datetree-date datetree-subheading-p match-outline-path
|
|
|
|
|
;; Suppress on-the-fly headline updates.
|
|
|
|
|
(org-element--cache-avoid-synchronous-headline-re-parsing t))
|
|
|
|
|
(when (string-match "\\`datetree/\\(\\**\\)" heading)
|
|
|
|
@ -273,10 +273,14 @@ direct children of this heading."
|
|
|
|
|
(setq datetree-subheading-p (> nsub 0)))
|
|
|
|
|
(setq datetree-date (org-date-to-gregorian
|
|
|
|
|
(or (org-entry-get nil "CLOSED" t) time))))
|
|
|
|
|
(if (and (> (length heading) 0)
|
|
|
|
|
(string-match "^\\*+" heading))
|
|
|
|
|
(setq level (match-end 0))
|
|
|
|
|
(setq heading nil level 0))
|
|
|
|
|
(if (string-match "\\match-outline" heading)
|
|
|
|
|
(setq match-outline-path (org-get-outline-path)
|
|
|
|
|
level (1+ (length match-outline-path))
|
|
|
|
|
heading nil)
|
|
|
|
|
(if (and (> (length heading) 0)
|
|
|
|
|
(string-match "^\\*+" heading))
|
|
|
|
|
(setq level (match-end 0))
|
|
|
|
|
(setq heading nil level 0)))
|
|
|
|
|
(save-excursion
|
|
|
|
|
(org-back-to-heading t)
|
|
|
|
|
;; Get context information that will be lost by moving the
|
|
|
|
@ -319,6 +323,9 @@ direct children of this heading."
|
|
|
|
|
(require 'org-datetree)
|
|
|
|
|
(org-datetree-find-date-create datetree-date)
|
|
|
|
|
(org-narrow-to-subtree))
|
|
|
|
|
(when match-outline-path
|
|
|
|
|
(goto-char (org-find-or-create-olp match-outline-path t))
|
|
|
|
|
(org-narrow-to-subtree))
|
|
|
|
|
;; Force the TODO keywords of the original buffer
|
|
|
|
|
(let ((org-todo-line-regexp tr-org-todo-line-regexp)
|
|
|
|
|
(org-todo-keywords-1 tr-org-todo-keywords-1)
|
|
|
|
@ -339,7 +346,8 @@ direct children of this heading."
|
|
|
|
|
(goto-char (point-max))
|
|
|
|
|
(or (bolp) (insert "\n"))
|
|
|
|
|
;; datetrees don't need too much spacing
|
|
|
|
|
(insert (if datetree-date "" "\n") heading "\n")
|
|
|
|
|
(unless match-outline-path
|
|
|
|
|
(insert (if datetree-date "" "\n") heading "\n"))
|
|
|
|
|
(end-of-line 0))
|
|
|
|
|
;; Make the subtree visible
|
|
|
|
|
(org-fold-show-subtree)
|
|
|
|
@ -364,7 +372,7 @@ direct children of this heading."
|
|
|
|
|
;; To prevent this, make sure visible part of buffer
|
|
|
|
|
;; always terminates on a new line, while limiting
|
|
|
|
|
;; number of blank lines in a date tree.
|
|
|
|
|
(unless (and datetree-date (bolp)) (insert "\n"))))
|
|
|
|
|
(unless (and (or datetree-date match-outline-path) (bolp)) (insert "\n"))))
|
|
|
|
|
;; Paste
|
|
|
|
|
(org-paste-subtree (org-get-valid-level level (and heading 1)))
|
|
|
|
|
;; Shall we append inherited tags?
|
|
|
|
|