diff --git a/lisp/org-publish.el b/lisp/org-publish.el index 496f4d1..866133d 100644 --- a/lisp/org-publish.el +++ b/lisp/org-publish.el @@ -384,23 +384,32 @@ eventually alphabetically." (when (or sitemap-alphabetically sitemap-sort-folders) ;; First we sort alphabetically: (when sitemap-alphabetically - (let ((aorg (and (string-match "\\.org$" a) (not (file-directory-p a)))) - (borg (and (string-match "\\.org$" b) (not (file-directory-p b))))) + (let* ((adir (file-directory-p a)) + (aorg (and (string-match "\\.org$" a) (not adir))) + (bdir (file-directory-p b)) + (borg (and (string-match "\\.org$" b) (not bdir))) + (A (if aorg (org-publish-find-title a) a)) + (B (if borg (org-publish-find-title b) b))) + ;; If we have a directory and an Org file, we need to combine + ;; directory and title as filename of the Org file: + (when (and adir borg) + (setq B (concat (file-name-directory b) B))) + (when (and bdir aorg) + (setq A (concat (file-name-directory a) A))) + ;; (setq retval (if sitemap-ignore-case - (string-lessp (if borg (upcase (org-publish-find-title a)) (upcase a)) - (if aorg (upcase (org-publish-find-title b)) (upcase b))) - (string-lessp (if borg (org-publish-find-title a) a) - (if aorg (org-publish-find-title b) b)))))) + (string-lessp (upcase A) (upcase B)) + (string-lessp A B))))) ;; Directory-wise wins: (when sitemap-sort-folders ;; a is directory, b not: (cond ((and (file-directory-p a) (not (file-directory-p b))) - (setq retval (eq sitemap-sort-folders 'first))) + (setq retval (equal sitemap-sort-folders 'first))) ;; a is not a directory, but b is: ((and (not (file-directory-p a)) (file-directory-p b)) - (setq retval (eq sitemap-sort-folders 'last)))))) + (setq retval (equal sitemap-sort-folders 'last)))))) retval)) (defun org-publish-get-base-files-1 (base-dir &optional recurse match skip-file skip-dir) @@ -618,9 +627,9 @@ If :makeindex is set, also produce a file theindex.org." (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) - (when (and (not (stringp sitemap-sort-folders)) - (not (string= sitemap-sort-folders "first")) - (not (string= sitemap-sort-folders "last"))) + (when (and (not (null sitemap-sort-folders)) + (not (equal sitemap-sort-folders 'first)) + (not (equal sitemap-sort-folders 'last))) (setq sitemap-sort-folders nil)) (when preparation-function (run-hooks 'preparation-function)) (if sitemap-p (funcall sitemap-function project sitemap-filename))