Browse Source

ox-org.el (org-org-publish-to-org): Kill buffers not visited at publication time

* ox-org.el (org-org-publish-to-org): Kill buffers not visited
at publication time.
Bastien Guerry 12 years ago
parent
commit
f5bf08c92c
1 changed files with 9 additions and 6 deletions
  1. 9 6
      lisp/ox-org.el

+ 9 - 6
lisp/ox-org.el

@@ -144,11 +144,13 @@ Return output file name."
   (when (plist-get plist :htmlized-source)
     (require 'htmlize)
     (require 'ox-html)
-    (or (find-buffer-visiting filename)
-	(find-file filename))
-    (font-lock-fontify-buffer)
-    (let* ((htmlize-output-type 'css)
-	   (newbuf (htmlize-buffer)))
+    (let* ((org-inhibit-startup t)
+	   (htmlize-output-type 'css)
+	   (visitingp (find-buffer-visiting filename))
+	   (work-buffer (or visitingp (find-file filename)))
+	   newbuf)
+      (font-lock-fontify-buffer)
+      (setq newbuf (htmlize-buffer))
       (with-current-buffer newbuf
 	(when org-org-htmlized-css-url
 	  (goto-char (point-min))
@@ -159,7 +161,8 @@ Return output file name."
 		 "<link rel=\"stylesheet\" type=\"text/css\" href=\"%s\">"
 		 org-org-htmlized-css-url) t t)))
 	(write-file (concat pub-dir (file-name-nondirectory filename) ".html")))
-      (kill-buffer newbuf))
+      (kill-buffer newbuf)
+      (unless visitingp (kill-buffer work-buffer)))
     (set-buffer-modified-p nil)))
 
 (provide 'ox-org)