Browse Source

Do not remove existing buffers during publishing.

Also, do not set a major mode for a buffer that will be killed anyway.
Carsten Dominik 16 years ago
parent
commit
3cbdda0e07
3 changed files with 16 additions and 7 deletions
  1. 7 0
      lisp/ChangeLog
  2. 3 2
      lisp/org-exp.el
  3. 6 5
      lisp/org-publish.el

+ 7 - 0
lisp/ChangeLog

@@ -1,5 +1,12 @@
 2008-09-07  Carsten Dominik  <dominik@science.uva.nl>
 2008-09-07  Carsten Dominik  <dominik@science.uva.nl>
 
 
+	* org-exp.el (org-export-as-html): Do not turn on the major mode
+	if the buffer will be killed anyway.
+
+	* org-publish.el (org-publish-org-to): Tell the exporter that this
+	buffer will be killed, so it is not necessary to do major mode
+	initialization.
+
 	* org-archive.el (org-archive-to-archive-sibling): Show empty
 	* org-archive.el (org-archive-to-archive-sibling): Show empty
 	lines after folding the archive sibling.
 	lines after folding the archive sibling.
 
 

+ 3 - 2
lisp/org-exp.el

@@ -3347,8 +3347,9 @@ lang=\"%s\" xml:lang=\"%s\">
 	(insert (or (plist-get opt-plist :postamble) ""))
 	(insert (or (plist-get opt-plist :postamble) ""))
 	(insert "</body>\n</html>\n"))
 	(insert "</body>\n</html>\n"))
 
 
-      (normal-mode)
-      (if (eq major-mode default-major-mode) (html-mode))
+      (unless (plist-get opt-plist :buffer-will-be-killed)
+	(normal-mode)
+	(if (eq major-mode default-major-mode) (html-mode)))
 
 
       ;; insert the table of contents
       ;; insert the table of contents
       (goto-char (point-min))
       (goto-char (point-min))

+ 6 - 5
lisp/org-publish.el

@@ -487,10 +487,11 @@ PUB-DIR is the publishing directory."
   (require 'org)
   (require 'org)
   (unless (file-exists-p pub-dir)
   (unless (file-exists-p pub-dir)
     (make-directory pub-dir t))
     (make-directory pub-dir t))
-  (find-file filename)
-  (let ((init-buf (current-buffer))
-	(init-point (point))
-	(init-buf-string (buffer-string)) export-buf)
+  (let* ((visiting (find-buffer-visiting))
+	 (plist (cons :buffer-will-be-killed (cons t plist)))
+	 (init-buf (or visiting (find-file filename)))
+	 (init-point (point))
+	 (init-buf-string (buffer-string)) export-buf)
     ;; run hooks before exporting
     ;; run hooks before exporting
     (run-hooks 'org-publish-before-export-hook)
     (run-hooks 'org-publish-before-export-hook)
     ;; export the possibly modified buffer
     ;; export the possibly modified buffer
@@ -510,7 +511,7 @@ PUB-DIR is the publishing directory."
       (insert init-buf-string)
       (insert init-buf-string)
       (save-buffer)
       (save-buffer)
       (goto-char init-point))
       (goto-char init-point))
-    (unless (eq init-buf org-publish-initial-buffer)
+    (unless visiting
       (kill-buffer init-buf))))
       (kill-buffer init-buf))))
 
 
 (defun org-publish-org-to-latex (plist filename pub-dir)
 (defun org-publish-org-to-latex (plist filename pub-dir)