瀏覽代碼

ox-publish: Create again theindex.inc

* lisp/ox-publish.el (org-publish-index-generate-theindex): Create
  again theindex.inc.  See dd98619286f84c4ced735a052ff13e3fe343c980.
Nicolas Goaziou 12 年之前
父節點
當前提交
fb039937f9
共有 1 個文件被更改,包括 13 次插入6 次删除
  1. 13 6
      lisp/ox-publish.el

+ 13 - 6
lisp/ox-publish.el

@@ -958,9 +958,9 @@ publishing directory."
     (setq full-index
 	  (sort full-index (lambda (a b) (string< (downcase (car a))
 					     (downcase (car b))))))
-    ;; Fill "theindex.org".
-    (with-temp-buffer
-      (insert "#+TITLE: Index\n#+OPTIONS: num:nil author:nil\n")
+    ;; Write "theindex.inc" in DIRECTORY.
+    (with-temp-file (expand-file-name "theindex.inc" directory)
+      (insert "* Index\n")
       (let ((current-letter nil) (last-entry nil))
 	(dolist (idx full-index)
 	  (let* ((entry (org-split-string (car idx) "!"))
@@ -972,7 +972,7 @@ publishing directory."
 			(plist-get (cdr project) :base-directory))))
 	    ;; Check if another letter has to be inserted.
 	    (unless (string= letter current-letter)
-	      (insert (format "* %s\n" letter)))
+	      (insert (format "** %s\n" letter)))
 	    ;; Compute the first difference between last entry and
 	    ;; current one: it tells the level at which new items
 	    ;; should be added.
@@ -1002,8 +1002,15 @@ publishing directory."
 		       (car (last entry)))))
 		  "\n"))))
 	    (setq current-letter letter last-entry entry))))
-      ;; Write index.
-      (write-file (expand-file-name "theindex.org" directory)))))
+      ;; Write "theindex.org" if it doesn't exist.  The combination
+      ;; "theindex.inc" and conditional "theindex.org" allows for
+      ;; a greater flexibility for the user, since he can provide its
+      ;; own "theindex.org", inserting "theindex.inc" wherever he
+      ;; wants.
+      (let ((index.org (expand-file-name "theindex.org" directory)))
+	(unless (file-exists-p index.org)
+	  (with-temp-file index.org
+	    (insert "\n\n#+INCLUDE: \"theindex.inc\"\n\n")))))))