From 223f37f07e7990804199bf6d6cdb5d522f5f42e5 Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Wed, 9 Jul 2008 09:55:00 -0700 Subject: [PATCH] New option :index-style for publishing. Patch from Manuel Hermenegildo. --- lisp/ChangeLog | 1 + lisp/org-publish.el | 50 ++++++++++++++++++++++++++++++++------------------ 2 files changed, 33 insertions(+), 18 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 2c77da8de..39d5a9729 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,6 +1,7 @@ 2008-07-09 Carsten Dominik * org-publish.el (org-publish-find-title): Bug fix. + (org-publish-org-index): Implement new :index-style option. 2008-07-07 Carsten Dominik diff --git a/lisp/org-publish.el b/lisp/org-publish.el index 5e98b94ed..4cb86df6f 100644 --- a/lisp/org-publish.el +++ b/lisp/org-publish.el @@ -263,7 +263,12 @@ index of files or summary page for a given project. :index-function Plugin function to use for generation of index. Defaults to `org-publish-org-index', which generates a plain list of links to all files - in the project." + in the project. + :index-style Can be `list' (index is just an itemized list + of the titles of the files involved) or + `tree' (the directory structure of the source + files is reflected in the index). Defaults to + `tree'." :group 'org-publish :type 'alist) @@ -607,6 +612,8 @@ Default for INDEX-FILENAME is 'index.org'." (index-filename (concat dir (or index-filename "index.org"))) (index-title (or (plist-get project-plist :index-title) (concat "Index for project " (car project)))) + (index-style (or (plist-get project-plist :index-style) + 'tree)) (index-buffer (find-buffer-visiting index-filename)) (ifn (file-name-nondirectory index-filename)) file) @@ -621,25 +628,32 @@ Default for INDEX-FILENAME is 'index.org'." (oldlocal localdir)) ;; index shouldn't index itself (unless (string= fn ifn) - (setq localdir (concat (file-name-as-directory dir) - (file-name-directory link))) - (unless (string= localdir oldlocal) - (if (string= localdir dir) - (setq indent-str (make-string 2 ?\ )) - (let ((subdirs - (split-string - (directory-file-name - (file-name-directory - (file-relative-name localdir dir))) "/")) - (subdir "")) - (setq indent-str (make-string 2 ?\ )) - (dolist (d subdirs) - (setq subdir (concat subdir d "/")) - (insert (concat indent-str " + [[file:" subdir "][" d "/]]\n")) - (setq indent-str (make-string (+ (length indent-str) 2) ?\ )))))) + (if (eq index-style 'list) + (message "Generating list-style index for %s" index-title) + (message "Generating tree-style index for %s" index-title) + (setq localdir (concat (file-name-as-directory dir) + (file-name-directory link))) + (unless (string= localdir oldlocal) + (if (string= localdir dir) + (setq indent-str (make-string 2 ?\ )) + (let ((subdirs + (split-string + (directory-file-name + (file-name-directory + (file-relative-name localdir dir))) "/")) + (subdir "")) + (setq indent-str (make-string 2 ?\ )) + (dolist (d subdirs) + (setq subdir (concat subdir d "/")) + (insert (concat indent-str " + [[file:" + subdir "][" d "/]]\n")) + (setq indent-str (make-string + (+ (length indent-str) 2) ?\ ))))))) + ;; This is common to 'flat and 'tree (insert (concat indent-str " + [[file:" link "][" (org-publish-find-title file) - "]]\n"))))) + "]]\n")) + ))) (write-file index-filename) (kill-buffer (current-buffer))))) -- 2.11.4.GIT