Guest User

Untitled

a guest
Jul 23rd, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. (defadvice org-archive-subtree
  2. (around org-archive-subtree-to-data-tree activate)
  3. "org-archive-subtree to date-tree"
  4. (if (org-entry-is-done-p)
  5. (let* ((dct (decode-time
  6. (org-time-string-to-time
  7. (cdar (org-entry-properties nil 'special "CLOSED")))))
  8. (y (nth 5 dct))
  9. (m (nth 4 dct))
  10. (d (nth 3 dct))
  11. (this-buffer (current-buffer))
  12. (location (org-get-local-archive-location))
  13. (afile (org-extract-archive-file location))
  14. (org-archive-location
  15. (format "%s::%s %04d-%02d-%02d %s" afile
  16. (make-string (org-get-valid-level 0 2) ?*) y m d
  17. (format-time-string "%A" (encode-time 0 0 0 d m y)))))
  18. (message "afile=%s" afile)
  19. (message "archive-loc=%s" org-archive-location)
  20. (unless afile
  21. (error "Invalid `org-archive-location'"))
  22. (save-excursion
  23. (switch-to-buffer (find-file-noselect afile))
  24. (org-datetree-find-year-create y)
  25. (org-datetree-find-month-create y m)
  26. (org-datetree-find-day-create y m d)
  27. (widen)
  28. (switch-to-buffer this-buffer))
  29. ad-do-it)
  30. ad-do-it))
  31.  
  32. ;; Execute the following in the file which you want to archive
  33. (org-map-entries 'org-archive-subtree
  34. (mapconcat
  35. '(lambda (x) (format "TODO=\"%s\"" x))
  36. org-done-keywords "|"))
Add Comment
Please, Sign In to add comment