Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Archive all past calendar items in Org-mode?

I'm becoming addicted to Org-mode, particularly the way that calendar items (aka timestamped items) and TODOs are both equal-class citizens in a project tree. As time goes on, many of those calendar items slip into the past.

I'd love a single keybind that would automatically archive any timestamped/calendar item (n.b.: not a scheduled item or a deadlined item, and preferably only things without TODO types) that has already happened.

Is there something like this already available in Org-mode? Can anybody point me in the direction of how to write something like org-archive-past-items-in-buffer? (My elisp skills are weak.) Thanks!

(EDIT: I should note that I mean archive in the sense of archive files C-c $, not archive in the sense of archive tags/siblings C-c C-x a or C-c C-x A.)

like image 476
Charles Pence Avatar asked May 01 '12 02:05

Charles Pence


1 Answers

I would create a new agenda custom entry like this:

(setq org-agenda-custom-commands
  '(("P" ((tags "TIMESTAMP<=\"<now>\"")))))

Then C-c a P % . RET $ will archive all items in the resulting agenda view (assuming C-c a is bound to `org-agenda'.)

Related and complementary, C-c / b RET will create a sparse tree with scheduled and deadline items before today (or a date you interactively enter.) You can then navigate the buffer with C-c C-n (or just n at the beginning of the line if `org-use-speed-commands' is non-nil) and archive the entries.

like image 76
bzg Avatar answered Oct 04 '22 21:10

bzg