;; export headlines to separate files ;; http://emacs.stackexchange.com/questions/2259/how-to-export-top-level-headings-of-org-mode-buffer-to-separate-files (defun org-export-headlines-to-txt () "Export all subtrees that are *not* tagged with :noexport: to separate files. Subtrees that do not have the :EXPORT_FILE_NAME: property set are exported to a filename derived from the headline text." (interactive) (save-buffer) (let ((modifiedp (buffer-modified-p))) (save-excursion (goto-char (point-min)) (goto-char (re-search-forward "^*")) (set-mark (line-beginning-position)) (goto-char (point-max)) (org-map-entries (lambda () (let ((export-file (org-entry-get (point) "EXPORT_FILE_NAME"))) ;; I'm assuming 'export-file' is an on-the-fly var; ;; org-entry-get is part of the property API and finds the heading that has that property (unless export-file (org-set-property "EXPORT_FILE_NAME" (replace-regexp-in-string " " "_" (nth 4 (org-heading-components))))) (deactivate-mark) (org-org-export-to-org nil t) ;; will have to learn a tiny bit of lisp (unless export-file (org-delete-property "EXPORT_FILE_NAME")) (set-buffer-modified-p modifiedp))) "-noexport" 'region-start-level))))