Browse Source

ox-publish: Publish "theindex.org" last

* lisp/ox-publish.el (org-publish-projects): Publish "theindex.org"
  last, so that "theindex.inc" can be completed.
Nicolas Goaziou 6 years ago
parent
commit
5c61a34e5b
1 changed files with 13 additions and 6 deletions
  1. 13 6
      lisp/ox-publish.el

+ 13 - 6
lisp/ox-publish.el

@@ -675,17 +675,24 @@ If `:auto-sitemap' is set, publish the sitemap too.  If
 	    (preparation-function
 	     (plist-get project-plist :preparation-function))
 	    (completion-function (plist-get project-plist :completion-function))
-	    (files (org-publish-get-base-files project exclude-regexp)) file)
+	    (files (org-publish-get-base-files project exclude-regexp))
+	    (theindex
+	     (expand-file-name "theindex.org"
+			       (plist-get project-plist :base-directory))))
        (when preparation-function (run-hooks 'preparation-function))
        (if sitemap-p (funcall sitemap-function project sitemap-filename))
-       (dolist (file files) (org-publish-file file project t))
+       ;; Publish all files from PROJECT excepted "theindex.org".  Its
+       ;; publishing will be deferred until "theindex.inc" is
+       ;; populated.
+       (dolist (file files)
+	 (unless (equal file theindex)
+	   (org-publish-file file project t)))
+       ;; Populate "theindex.inc", if needed, and publish
+       ;; "theindex.org".
        (when (plist-get project-plist :makeindex)
 	 (org-publish-index-generate-theindex
 	  project (plist-get project-plist :base-directory))
-	 (org-publish-file
-	  (expand-file-name
-	   "theindex.org" (plist-get project-plist :base-directory))
-	  project t))
+	 (org-publish-file theindex project t))
        (when completion-function (run-hooks 'completion-function))
        (org-publish-write-cache-file)))
    (org-publish-expand-projects projects)))