Browse Source

ox-publish.el: Set `org-inhibit-startup' to t when visiting files for publication

* ox-publish.el (org-publish-org-to)
(org-publish-org-sitemap, org-publish-find-title)
(org-publish-find-date)
(org-publish-cache-file-needs-publishing): Set
`org-inhibit-startup' to t when visiting files for
publication.

Thanks to Samuel Wales for this idea.
Bastien Guerry 12 years ago
parent
commit
b9974192a1
1 changed files with 13 additions and 7 deletions
  1. 13 7
      lisp/ox-publish.el

+ 13 - 7
lisp/ox-publish.el

@@ -558,7 +558,8 @@ directory.
 Return output file name."
   (unless (or (not pub-dir) (file-exists-p pub-dir)) (make-directory pub-dir t))
   ;; Check if a buffer visiting FILENAME is already open.
-  (let* ((visitingp (find-buffer-visiting filename))
+  (let* ((org-inhibit-startup t)
+	 (visitingp (find-buffer-visiting filename))
 	 (work-buffer (or visitingp (find-file-noselect filename))))
     (prog1 (with-current-buffer work-buffer
 	     (let ((output-file
@@ -723,8 +724,10 @@ Default for SITEMAP-FILENAME is 'sitemap.org'."
 	 (visiting (find-buffer-visiting sitemap-filename))
 	 (ifn (file-name-nondirectory sitemap-filename))
 	 file sitemap-buffer)
-    (with-current-buffer (setq sitemap-buffer
-			       (or visiting (find-file sitemap-filename)))
+    (with-current-buffer
+	(let ((org-inhibit-startup t))
+	  (setq sitemap-buffer
+		(or visiting (find-file sitemap-filename))))
       (erase-buffer)
       (insert (concat "#+TITLE: " sitemap-title "\n\n"))
       (while (setq file (pop files))
@@ -791,7 +794,8 @@ Default for SITEMAP-FILENAME is 'sitemap.org'."
   "Find the title of FILE in project."
   (or
    (and (not reset) (org-publish-cache-get-file-property file :title nil t))
-   (let* ((visiting (find-buffer-visiting file))
+   (let* ((org-inhibit-startup t)
+	  (visiting (find-buffer-visiting file))
 	  (buffer (or visiting (find-file-noselect file)))
 	  title)
      (with-current-buffer buffer
@@ -810,7 +814,8 @@ If FILE provides a #+date keyword use it else use the file
 system's modification time.
 
 It returns time in `current-time' format."
-  (let* ((visiting (find-buffer-visiting file))
+  (let* ((org-inhibit-startup t)
+	 (visiting (find-buffer-visiting file))
 	 (file-buf (or visiting (find-file-noselect file nil)))
 	 (date (plist-get
 		(with-current-buffer file-buf
@@ -1122,8 +1127,8 @@ If FREE-CACHE, empty the cache."
 (defun org-publish-cache-file-needs-publishing
   (filename &optional pub-dir pub-func base-dir)
   "Check the timestamp of the last publishing of FILENAME.
-Non-nil if the file needs publishing.  The function also checks
-if any included files have been more recently published, so that
+Return non-nil if the file needs publishing.  Also check if
+any included files have been more recently published, so that
 the file including them will be republished as well."
   (unless org-publish-cache
     (error
@@ -1131,6 +1136,7 @@ the file including them will be republished as well."
   (let* ((case-fold-search t)
 	 (key (org-publish-timestamp-filename filename pub-dir pub-func))
 	 (pstamp (org-publish-cache-get key))
+	 (org-inhibit-startup t)
 	 (visiting (find-buffer-visiting filename))
 	 included-files-ctime buf)