Skip to content

Instantly share code, notes, and snippets.

@osamu2001
Created April 19, 2010 08:24
Show Gist options
  • Save osamu2001/370843 to your computer and use it in GitHub Desktop.
Save osamu2001/370843 to your computer and use it in GitHub Desktop.
;(setq org-archive-location "%s_archive::date-tree")
(defadvice org-archive-subtree
(around org-archive-subtree-to-data-tree activate)
"org-archive-subtree to date-tree"
(if
(string= "date-tree"
(org-extract-archive-heading
(org-get-local-archive-location)))
(let* ((dct (decode-time (org-current-time)))
(y (nth 5 dct))
(m (nth 4 dct))
(d (nth 3 dct))
(this-buffer (current-buffer))
(location (org-get-local-archive-location))
(afile (org-extract-archive-file location))
(org-archive-location
(format "%s::*** %04d-%02d-%02d %s" afile y m d
(format-time-string "%A" (encode-time 0 0 0 d m y)))))
(message "afile=%s" afile)
(unless afile
(error "Invalid `org-archive-location'"))
(save-excursion
(switch-to-buffer (find-file-noselect afile))
(org-datetree-find-year-create y)
(org-datetree-find-month-create y m)
(org-datetree-find-day-create y m d)
(widen)
(switch-to-buffer this-buffer)
)
ad-do-it)
ad-do-it))
@olberger
Copy link

I think this hack is obsolete now that there is the datetree/ option for org-archive-location - see: http://orgmode.org/worg/doc.html#org-archive-location

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment