emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] Exporting a given file (not buffer)


From: Sebastien Vauban
Subject: Re: [O] Exporting a given file (not buffer)
Date: Fri, 13 Feb 2015 23:20:57 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (windows-nt)

Marcin Borkowski wrote:
> I need a function, which – given an org file's name – opens it silently,
> exports to a file, and closes.
>
> I can write it myself, but maybe such a function already exists?  It
> seems that `org-export-to-file' exports the current buffer, so I could
> make a new buffer, `insert-file-contents' the given file to it, turn on
> `org-mode', do my export and close the buffer (probably using
> `with-temp-buffer' in the first place) – but is it really necessary to
> code it, or is it ready somewhere in Org?

This is the core part of the code which would do that:

--8<---------------cut here---------------start------------->8---
  (with-temp-buffer
    (insert-file-contents orgfile)
    (setq htmlcontents (org-export-as 'html))
    (delete-region (point-min) (point-max))
    (insert htmlcontents)
    (buffer-string))
--8<---------------cut here---------------end--------------->8---

Best regards,
  Seb

-- 
Sebastien Vauban




reply via email to

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