Re: [O] Emacs lisp code export difference between `org-export-region-as-html' and `org-export-as-html'
In case anyone might be interested in this, here is what I think is a minimal example. As I said, I am fine with it for my purposes, but since the behaviour seems inconsistent (from my possibly limited perspective) I thought I ought to at least specify as clearly as possible what is going on: First, with emacs -Q, and with a file called ~/tmp/foo.org It's contents are only this: #+BEGIN_SRC emacs-lisp :exports results :results html #+END_SRC Now, slightly reformatted for clarity, M-x ielm -- *** Welcome to IELM *** Type (describe-mode) for help. ELISP (defun render-with-find-file (file) (save-excursion (let ((buffer (set-buffer (find-file file (setq rtn (org-export-as-html nil nil nil 'string t)) (kill-buffer buffer) rtn))) == render-with-find-file ELISP (defun render-with-temp-buffer (file) (with-temp-buffer (insert-file file) (org-mode) ; doesn't actually seem to have any effect (org-export-as-html nil nil nil 'string t))) == render-with-temp-buffer ELISP (render-with-find-file ~/tmp/foo.org) == #(\n\n 0 2 (org-native-text t original-indentation 0 org-protected t fontified nil) 2 3 (fontified nil) 3 4 (fontified nil)) ELISP (render-with-temp-buffer ~/tmp/foo.org) == #(pre class=\example\\nlt;gt;\n/pre\n\n\n 0 40 (fontified nil))
Re: [O] Emacs lisp code export difference between `org-export-region-as-html' and `org-export-as-html'
On Mon, Sep 24, 2012 at 3:53 PM, thorne ego...@gmail.com wrote: (defun render-one (file) (with-temp-buffer (insert-file file) (org-export-as-html nil nil nil 'string t))) Well, I still don't know why it behaves the way I've described, but it works the way I want if instead of the above function, I use: (defun render-one (file) (save-excursion (let ((buffer (set-buffer (find-file file (setq rtn (org-export-as-html nil nil nil 'string t)) (kill-buffer buffer) rtn))) -- using find-file and messing with the buffer stuff by hand, instead of using `with-temp-buffer' and `insert-file', which later strikes me as neater, and possibly faster (I am using it in batch to process multiple files) but the other way works, so that's fine. Thanks.
Re: [O] Emacs lisp code export difference between `org-export-region-as-html' and `org-export-as-html'
Actually I think I have a simpler version of this question now. I have this function: (defun render-one (file) (with-temp-buffer (insert-file file) (org-export-as-html nil nil nil 'string t))) With the last line being the important bit. If I open a file, foo.org, that has the #+BEING_SRC bit that I want to export, and put this line in the buffer and evaluate it: (org-export-as-html nil nil nil 'string t) then the result I get is correct -- the html that I want is embedded in the resulting string. But if instead I evaluate (render-one ~/foo.org) using the function above which should (I assume) do the same thing, it does not work. Instead, the html code I want is wrapped in pre tags and angle brackets changed to html entities. So, it seems that something about running the export function in my code above makes it ignore my :results html setting in the code block. Is this a security thing? Is there a variable that I need to let-bind in my function or something? Thanks for any help.