From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sebastien Vauban Subject: Re: Exporting a given file (not buffer) Date: Fri, 13 Feb 2015 23:20:57 +0100 Message-ID: <868ug1jvw6.fsf@example.com> References: <87wq3lwjck.fsf@wmi.amu.edu.pl> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org-mXXj517/zsQ@public.gmane.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org-mXXj517/zsQ@public.gmane.org To: emacs-orgmode-mXXj517/zsQ@public.gmane.org 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