emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Orgmode] Generating an org file actually including the #+INCLUDE fi


From: Bastien
Subject: Re: [Orgmode] Generating an org file actually including the #+INCLUDE files
Date: Thu, 03 Feb 2011 19:04:37 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

Miguel Ruiz <address@hidden> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]