Miguel Ruiz <rbeni...@yahoo.es> writes:

> I am working on a document split in several chunks. I need to generate the
> full document in order to do different sorting processes before exporting.
>
> It would be nice if that generation could be recursive ... you know, one
> master file, one included file with another included file.

Crude hack to produce file_include.org based on file.org with some
#+INCLUDE directives:

(defun org-new-file-with-include ()
  "Create a new org file honoring #+INCLUDE directives."
  (interactive)
  (let* ((bfile (buffer-file-name))
         (bfilenoext (file-name-sans-extension bfile)))
    (find-file-other-window (concat bfilenoext "_include.org"))
    (insert-file bfile)
    (goto-char (point-min))
    (while (re-search-forward "^[ \t]*#\\+INCLUDE:[ \t]*\\(.+\\)[ \t]*$" nil t)
      (let ((ifile (match-string 1)))
        (save-match-data (replace-match ""))
        (insert-file (expand-file-name ifile))))))

Careful: it does not prevent errors when #+INCLUDE directives are
circular...  just a hack.

HTH,

-- 
 Bastien

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

Reply via email to