From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bastien Subject: Re: Generating an org file actually including the #+INCLUDE files Date: Thu, 03 Feb 2011 19:04:37 +0100 Message-ID: <87pqr9ro3u.fsf@gnu.org> References: <827670.21979.qm@web29002.mail.ird.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from [140.186.70.92] (port=40130 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pl3Xr-0000R9-KB for emacs-orgmode@gnu.org; Thu, 03 Feb 2011 13:04:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pl3Xq-0000Uo-4Y for emacs-orgmode@gnu.org; Thu, 03 Feb 2011 13:04:39 -0500 Received: from mail-wy0-f169.google.com ([74.125.82.169]:49070) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pl3Xp-0000UX-RS for emacs-orgmode@gnu.org; Thu, 03 Feb 2011 13:04:38 -0500 Received: by wyj26 with SMTP id 26so1426714wyj.0 for ; Thu, 03 Feb 2011 10:04:36 -0800 (PST) In-Reply-To: <827670.21979.qm@web29002.mail.ird.yahoo.com> (Miguel Ruiz's message of "Wed, 8 Dec 2010 09:39:31 +0000 (GMT)") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Miguel Ruiz Cc: emacs-orgmode@gnu.org Miguel Ruiz 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