From cbf97141d08e53c0b5076a40bdf863e3b282f1de Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Thu, 22 Apr 2010 09:23:56 +0200 Subject: [PATCH] Index: Allow index entries before the first headline Requested by Stefan Vollmar. --- lisp/ChangeLog | 5 +++++ lisp/org-publish.el | 11 +++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 6f8ae35bd..4d59a067a 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -9,6 +9,11 @@ (org-publish-find-title): Use the file title cache. (org-publish-find-title): Build the file title cache. (org-publish-get-base-files-1): Sort files. + (org-publish-aux-preprocess): Do not throw an error when before + the first headline. Allow an empty target, meaning to link just + to the file. + (org-publish-index-generate-theindex.inc): Check if there is + actually a target and only then add it to the link. * org-html.el (org-export-as-html): Treat verse as open/close paragraph. diff --git a/lisp/org-publish.el b/lisp/org-publish.el index dace606ae..496f4d1e9 100644 --- a/lisp/org-publish.el +++ b/lisp/org-publish.el @@ -801,11 +801,11 @@ the project." (when (eq backend 'latex) (replace-match (format "\\index{%s}" entry) t t)) (save-excursion - (org-back-to-heading t) + (ignore-errors (org-back-to-heading t)) (setq target (get-text-property (point) 'target)) (setq target (or (cdr (assoc target org-export-preferred-target-alist)) (cdr (assoc target org-export-id-target-alist)) - target)) + target "")) (push (cons entry target) index))) (with-temp-file (concat (file-name-sans-extension org-current-export-file) ".orgx") @@ -825,7 +825,7 @@ the project." full-files)) (default-directory directory) index origfile buf target entry ibuffer - main last-main letter last-letter file sub link) + main last-main letter last-letter file sub link tgext) ;; `files' contains the list of relative file names (dolist (file files) (setq origfile (substring file 0 -1)) @@ -846,6 +846,9 @@ the project." (setq last-letter nil) (dolist (idx index) (setq entry (car idx) file (nth 1 idx) target (nth 2 idx)) + (if (and (stringp target) (string-match "\\S-" target)) + (setq tgext (concat "::#" target)) + (setq tgext "")) (setq letter (upcase (substring entry 0 1))) (when (not (equal letter last-letter)) (insert "** " letter "\n") @@ -857,7 +860,7 @@ the project." (when (and main (not (equal main last-main))) (insert " - " main "\n") (setq last-main main)) - (setq link (concat "[[file:" file "::#" target "]" + (setq link (concat "[[file:" file tgext "]" "[" (or sub entry) "]]")) (if (and main sub) (insert " - " link "\n") -- 2.11.4.GIT