emacs-orgmode
[Top][All Lists]
Advanced

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

[O] [ANN] Convert Org-mode file to Source-code file


From: Thorsten Jolitz
Subject: [O] [ANN] Convert Org-mode file to Source-code file
Date: Thu, 20 Jun 2013 02:19:15 +0200
User-agent: Gnus/5.130002 (Ma Gnus v0.2) Emacs/24.3 (gnu/linux)

Hi List, 

it is now possible to convert existing Org-mode files with source-blocks into
machine-executable source-code files, using the following function from
`outorg.el':

#+begin_src emacs-lisp
(defun outorg-convert-org-file-to-source-code
  (&optional mode infile outfile BATCH)
  "Convert an existing Org-mode file into an Outshine buffer.

If MODE is non-nil, the Outshine buffer will be put in this
major-mode, otherwise the major-mode of the language of the first
source-code block in the Org-mode buffer will be used.

If INFILE is non-nil, the specified Org-mode file will be visited
and its buffer converted, otherwise the current buffer will be
converted.

If OUTFILE is non-nil, the converted Outshine buffer will be saved in this
file. Its the user's responsability to make sure that OUTFILE's
file-extension is suited for the major-mode of the Outshine buffer to be
saved. When in doubt, consult variable  `auto-mode-alist' for associations
between file-extensions and major-modes.

If BATCH is non-nil (and OUTFILE is non-nil, otherwise it makes
no sense), the new Outshine file is saved and its buffer
deleted."...)
#+end_src

Usage example:

,----------------------------------------------------------------
| (outorg-convert-org-file-to-source-code
|    "emacs-lisp-mode" "~/junk/test.org" "~/junk/test.el" 'BATCH)
`----------------------------------------------------------------

I'm not sure about the general use case for this, but I do have my uses for
it, so I announce it here because it might serve others too.

PS 
This is *not* about tangling, try it out to see the (big) difference.

-- 
cheers,
Thorsten




reply via email to

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