Skip to content

Instantly share code, notes, and snippets.

@natfarleydev
Created July 29, 2013 16:25
Show Gist options
  • Save natfarleydev/6105561 to your computer and use it in GitHub Desktop.
Save natfarleydev/6105561 to your computer and use it in GitHub Desktop.
Little function to clean org mode files that have no more TODO items in them from the org-agenda-file
;; Function for cleaning org mode agenda
(defun clean-org-mode-agenda (tmp-org-agenda)
"Clean up all the org mode files that no longer have TODO items in"
(while tmp-org-agenda
(set-buffer (find-file-noselect (car tmp-org-agenda)))
(goto-char (point-min))
(if (re-search-forward "^\*+ TODO" nil t 1)
()
(org-remove-file (car tmp-org-agenda))
)
(setq tmp-org-agenda (cdr tmp-org-agenda))
)
)
(defun really-clean-org-mode-agenda ()
(interactive)
(clean-org-mode-agenda (org-agenda-files))
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment