From adc01ecf37905923727e4eba0a2603f0e9014c49 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Sun, 17 Feb 2013 01:40:53 +0100 Subject: [PATCH] ox-publish: Preserve order in files when building the index * lisp/ox-publish.el (org-publish-index-generate-theindex): Preserve order in file. --- lisp/ox-publish.el | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/lisp/ox-publish.el b/lisp/ox-publish.el index f2af098b8..5ba9a2c6b 100644 --- a/lisp/ox-publish.el +++ b/lisp/ox-publish.el @@ -947,17 +947,15 @@ publishing directory." (let ((all-files (org-publish-get-base-files project (plist-get (cdr project) :exclude))) full-index) - ;; Compile full index. - (mapc - (lambda (file) - (let ((index (org-publish-cache-get-file-property file :index))) - (dolist (term index) - (unless (member term full-index) (push term full-index))))) - all-files) - ;; Sort it alphabetically. - (setq full-index - (sort full-index (lambda (a b) (string< (downcase (car a)) - (downcase (car b)))))) + ;; Compile full index and sort it alphabetically. + (dolist (file all-files + (setq full-index + (sort (nreverse full-index) + (lambda (a b) (string< (downcase (car a)) + (downcase (car b))))))) + (let ((index (org-publish-cache-get-file-property file :index))) + (dolist (term index) + (unless (member term full-index) (push term full-index))))) ;; Write "theindex.inc" in DIRECTORY. (with-temp-file (expand-file-name "theindex.inc" directory) (insert "* Index\n")