Ulf Stegemann wrote: >I'm wondering what's the best way to export a single org file to a >/single/ LaTeX file but also to /multiple/ HTML files. Think of lengthy >manuals and things like that where such a strategy may be sensible. What >came to my mind were include commands or publishing functions that >post-process the export but this seems all rather cumbersome. Has anyone >a better idea? The function below could be a starting point of a more general functionality: It takes a file and splits copys all headlines with a certain level to a separate output file. The more general functionality I am thinking of would be: Create multiple output files for one or more input files that contain headlines that match a certain criteria. E.g.: Create output file "TODO.org" with all headlines with todo keyword TODO or put all files with the tag "tag" into a output file "tag.org" etc. Things to consider: - escape sequences for output file names ("%number" -> counter, "%tag" -> tag etc.) - functions to move headline from here to there (copy, cut, cut and insert link) - maybe provide template for the output file's in file options (e.g. #+TITLE etc.) For the splitting-by-level there is one caveat: The numbering of the headlines is lost. Definitively something that should be cooked up a little more. ,---- | (defun org-split-file (file level outfmt) | "Split FILE into multiple files. | FILE is Org file to split. | LEVEL is outline level of headlines. | OUTFMT is a template for output files." | (let ((visiting (find-buffer-visiting file)) | (cnt 1) | cand hl out) | (with-current-buffer (or visiting (find-file-noselect file)) | (save-excursion | (save-restriction | (setq cand (org-map-entries 'point | (format "LEVEL=%s" level) | 'file)) | (while (setq hl (pop cand)) | (goto-char hl) | (setq out (concat | (org-replace-escapes outfmt | `(("%n" . ,(format "%s" cnt)))) | ".org")) | (org-copy-subtree) | (with-current-buffer (find-file-noselect out) | (erase-buffer) | (org-paste-subtree level) | (save-buffer)) | (kill-buffer (find-buffer-visiting out)) | (setq cnt (1+ cnt)) | (print out))))))) `---- HTH -- David -- OpenPGP... 0x99ADB83B5A4478E6 Jabber.... dmjena@jabber.org Email..... dmaus@ictsoc.de