Browse Source

Don't keep buffers visited during index publishing.

The index generation of org-publish does briefly visit all files in
order to extract the correct page title.  Visiting is necessary,
because the title may be set by the first line in the buffer, by a
Before this patch, this would cause the generation of a large number
of buffers, one for each file mentioned in the index.  This patch
arranges for these buffers to be removed again.  However, buffers
which were already present will not be removed.

There is still one open problem:  The files to be published are
visited twice, one for publishing them, a second time for creating the
index.  Visiting causes some overhead, and we would like to limit this
overhead.  For now, however, this is not done.
Carsten Dominik 16 years ago
parent
commit
cb1bbaf244
2 changed files with 16 additions and 10 deletions
  1. 3 0
      lisp/ChangeLog
  2. 13 10
      lisp/org-publish.el

+ 3 - 0
lisp/ChangeLog

@@ -1,5 +1,8 @@
 2008-11-02  Carsten Dominik  <dominik@science.uva.nl>
 
+	* org-publish.el (org-publish-find-title): Remove buffers visited
+	only for extracting the title.
+
 	* org-exp.el (org-export-html-style)
 	(org-export-html-style-default): Mark style definitions as
 	unparsed CDATA.

+ 13 - 10
lisp/org-publish.el

@@ -673,16 +673,19 @@ Default for INDEX-FILENAME is 'index.org'."
 
 (defun org-publish-find-title (file)
   "Find the title of file in project."
-  (save-excursion
-    (set-buffer (find-file-noselect file))
-    (let* ((opt-plist (org-combine-plists (org-default-export-plist)
- 					  (org-infile-export-plist))))
-      (or (plist-get opt-plist :title)
- 	  (and (not
- 		(plist-get opt-plist :skip-before-1st-heading))
- 	       (org-export-grab-title-from-buffer))
-	  (file-name-nondirectory (file-name-sans-extension file))))))
-
+  (let* ((visiting (find-buffer-visiting file))
+	 (buffer (or visiting (find-file-noselect file))))
+    (save-excursion
+      (set-buffer buffer)
+      (let* ((opt-plist (org-combine-plists (org-default-export-plist)
+					    (org-infile-export-plist))))
+	(or (plist-get opt-plist :title)
+	    (and (not
+		  (plist-get opt-plist :skip-before-1st-heading))
+		 (org-export-grab-title-from-buffer))
+	    (file-name-nondirectory (file-name-sans-extension file)))))
+    (unless visiting
+      (kill-buffer buffer))))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Interactive publishing functions