emacs.d

My Emacs configuration files.
git clone git://soucy.cc/emacs.d.git
Log | Files | Refs | README

commit 1e54f878d202049ace5f98763453224a4a1e6d8e
parent 603294119f06f133b251900e3c85f625bb36d339
Author: Hugo Soucy <hugo@soucy.cc>
Date:   Sat, 27 Jun 2020 14:25:34 -0400

Add a function

Diffstat:
Adefuns/org-export-headlines-to-html.el | 30++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+), 0 deletions(-)

diff --git a/defuns/org-export-headlines-to-html.el b/defuns/org-export-headlines-to-html.el @@ -0,0 +1,30 @@ +;; 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-html () + "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"))) + (unless export-file + (org-set-property + "EXPORT_FILE_NAME" + (replace-regexp-in-string " " "-" (nth 4 (org-heading-components))))) + (deactivate-mark) + (org-latex-export-to-html nil t) + (unless export-file (org-delete-property "EXPORT_FILE_NAME")) + (set-buffer-modified-p modifiedp))) + "-noexport" 'region-start-level)))) + +;;; org-export-headlines-to-html.el ends here