blob: d1b30cdeb3d9d2a6ca216d421a54d2f3df98bd28 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
(defun fcuny/org-new-datetree-at-point ()
(interactive)
(org-up-heading-safe)
(org-datetree-find-date-create
(calendar-gregorian-from-absolute (org-today))
'subtree-at-point))
(defun org-refile-to-datetree (&optional file)
"Refile a subtree to a datetree corresponding to it's timestamp.
The current time is used if the entry has no timestamp. If FILE
is nil, refile in the current file. A datetree within a subheading
is possible if the heading has a property of DATE_TREE."
(interactive "f")
(let* ((datetree-date (or (org-entry-get nil "TIMESTAMP" t)
(org-read-date t nil "now")))
(date (org-date-to-gregorian datetree-date))
)
(save-excursion
(with-current-buffer (current-buffer)
(org-cut-subtree)
(if file (find-file file))
(widen)
(org-datetree-find-date-create date)
(org-narrow-to-subtree)
(show-subtree)
(org-end-of-subtree t)
(newline)
(goto-char (point-max))
(org-paste-subtree (+ org-datetree-base-level 3))
(widen)
))))
(provide 'fcuny-org-custom)
|