summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <n.goaziou@gmail.com>2013-02-17 01:19:09 +0100
committerNicolas Goaziou <n.goaziou@gmail.com>2013-02-17 01:30:44 +0100
commitfb039937f9665c2f1a2dfe94325adfe4c14c99c8 (patch)
tree8b88cfe26d0daa8a3737c743810a2a55147a2d0d
parent229d08e44eb9bb6f31f9d8eda9d1fb308b37fab1 (diff)
downloadorg-mode-fb039937f9665c2f1a2dfe94325adfe4c14c99c8.tar.gz
ox-publish: Create again theindex.inc
* lisp/ox-publish.el (org-publish-index-generate-theindex): Create again theindex.inc. See dd98619286f84c4ced735a052ff13e3fe343c980.
-rw-r--r--lisp/ox-publish.el19
1 files changed, 13 insertions, 6 deletions
diff --git a/lisp/ox-publish.el b/lisp/ox-publish.el
index 0dda649..eec44c0 100644
--- a/lisp/ox-publish.el
+++ b/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")))))))