annotate lisp/textmodes/org-publish.el @ 82861:8eced8e0e14f

Remove the PS versions of the refcards.
author Michaël Cadilhac <michael.cadilhac@lrde.org>
date Sun, 26 Aug 2007 20:31:40 +0000
parents 54b437841f58
children bee1c9ad195a 27d11c1d4e46
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
81170
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1 ;;; org-publish.el --- publish related org-mode files as a website
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3 ;; Copyright (C) 2006, 2007 Free Software Foundation, Inc.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5 ;; Author: David O'Toole <dto@gnu.org>
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6 ;; Keywords: hypermedia, outlines
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7 ;; Version: 1.80
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8
82784
54b437841f58 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 82757
diff changeset
9 ;; $Id: org-publish.el,v 1.5 2007/08/22 11:49:23 cdominik Exp $
82757
00bb6352b55a * textmodes/org-publish.el (org-publish-org-to-latex): New
Carsten Dominik <dominik@science.uva.nl>
parents: 82162
diff changeset
10
81170
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11 ;; This file is free software; you can redistribute it and/or modify
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
82757
00bb6352b55a * textmodes/org-publish.el (org-publish-org-to-latex): New
Carsten Dominik <dominik@science.uva.nl>
parents: 82162
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
81170
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14 ;; any later version.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
15
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
16 ;; This file is distributed in the hope that it will be useful,
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
19 ;; GNU General Public License for more details.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
20
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
23 ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
24 ;; Boston, MA 02110-1301, USA.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
25
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
26 ;; This file is part of GNU Emacs.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
27
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
28 ;;; Commentary:
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
29
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
30 ;; Requires at least version 4.27 of org.el
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
31 ;;
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
32 ;; The official org-mode website:
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
33 ;; http://staff.science.uva.nl/~dominik/Tools/org/
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
34 ;;
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
35 ;; Home page for org-publish.el:
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
36 ;; http://dto.freeshell.org/notebook/OrgMode.html
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
37
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
38 ;; This program extends the HTML publishing support of Emacs Org-mode
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
39 ;; to allow configurable publishing of related sets of files as a
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
40 ;; complete website.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
41 ;;
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
42 ;; org-publish.el can do the following:
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
43 ;;
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
44 ;; + Publish all one's org-files to html
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
45 ;; + Upload html, images, attachments and other files to a web server
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
46 ;; + Exclude selected private pages from publishing
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
47 ;; + Publish a clickable index of pages
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
48 ;; + Manage local timestamps, for publishing only changed files
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
49 ;; + Accept plugin functions to extend range of publishable content
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
50 ;;
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
51 ;; Special thanks to the org-mode maintainer Carsten Dominik for his
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
52 ;; ideas, enthusiasm, and cooperation.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
53
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
54 ;;; Installation:
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
55
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
56 ;; Put org-publish.el in your load path, byte-compile it, and then add
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
57 ;; the following lines to your emacs initialization file:
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
58
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
59 ;; (autoload 'org-publish "org-publish" nil t)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
60 ;; (autoload 'org-publish "org-publish-all" nil t)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
61 ;; (autoload 'org-publish "org-publish-current-file" nil t)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
62 ;; (autoload 'org-publish "org-publish-current-project" nil t)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
63
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
64 ;; NOTE: When org-publish.el is included with org.el, those forms are
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
65 ;; already in the file org-install.el, and hence don't need to be put
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
66 ;; in your emacs initialization file in this case.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
67
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
68 ;;; Usage:
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
69 ;;
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
70 ;; The program's main configuration variable is
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
71 ;; `org-publish-project-alist'. See below for example configurations
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
72 ;; with commentary.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
73
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
74 ;; The main interactive functions are:
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
75 ;;
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
76 ;; M-x org-publish
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
77 ;; M-x org-publish-all
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
78 ;; M-x org-publish-current-file
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
79 ;; M-x org-publish-current-project
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
80
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
81 ;;;; Simple example configuration:
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
82
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
83 ;; (setq org-publish-project-alist
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
84 ;; (list
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
85 ;; '("org" . (:base-directory "~/org/"
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
86 ;; :base-extension "org"
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
87 ;; :publishing-directory "~/public_html"
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
88 ;; :with-section-numbers nil
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
89 ;; :table-of-contents nil
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
90 ;; :style "<link rel=stylesheet href=\"../other/mystyle.css\" type=\"text/css\">")))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
91
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
92 ;;;; More complex example configuration:
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
93
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
94 ;; Imagine your *.org files are kept in ~/org, your images in
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
95 ;; ~/images, and stylesheets in ~/other. Now imagine you want to
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
96 ;; publish the files through an ssh connection to a remote host, via
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
97 ;; Tramp-mode. To maintain relative links from *.org files to /images
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
98 ;; and /other, we should replicate the same directory structure in
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
99 ;; your web server account's designated html root (in this case,
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
100 ;; assumed to be ~/html)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
101
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
102 ;; Once you've done created the proper directories, you can adapt the
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
103 ;; following example configuration to your specific paths, run M-x
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
104 ;; org-publish-all, and it should publish the files to the correct
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
105 ;; directories on the web server, transforming the *.org files into
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
106 ;; HTML, and leaving other files alone.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
107
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
108 ;; (setq org-publish-project-alist
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
109 ;; (list
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
110 ;; '("orgfiles" :base-directory "~/org/"
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
111 ;; :base-extension "org"
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
112 ;; :publishing-directory "/ssh:user@host:~/html/notebook/"
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
113 ;; :publishing-function org-publish-org-to-html
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
114 ;; :exclude "PrivatePage.org" ;; regexp
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
115 ;; :headline-levels 3
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
116 ;; :with-section-numbers nil
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
117 ;; :table-of-contents nil
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
118 ;; :style "<link rel=stylesheet href=\"../other/mystyle.css\" type=\"text/css\">"
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
119 ;; :auto-preamble t
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
120 ;; :auto-postamble nil)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
121 ;;
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
122 ;; ("images" :base-directory "~/images/"
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
123 ;; :base-extension "jpg\\|gif\\|png"
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
124 ;; :publishing-directory "/ssh:user@host:~/html/images/"
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
125 ;; :publishing-function org-publish-attachment)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
126 ;;
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
127 ;; ("other" :base-directory "~/other/"
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
128 ;; :base-extension "css"
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
129 ;; :publishing-directory "/ssh:user@host:~/html/other/"
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
130 ;; :publishing-function org-publish-attachment)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
131 ;; ("website" :components ("orgfiles" "images" "other"))))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
132
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
133 ;; For more information, see the documentation for the variable
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
134 ;; `org-publish-project-alist'.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
135
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
136 ;; Of course, you don't have to publish to remote directories from
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
137 ;; within emacs. You can always just publish to local folders, and
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
138 ;; then use the synchronization/upload tool of your choice.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
139
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
140
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
141 ;;; List of user-visible changes since version 1.27
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
142
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
143 ;; 1.78: Allow list-valued :publishing-function
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
144 ;; 1.77: Added :preparation-function, this allows you to use GNU Make etc.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
145 ;; 1.65: Remove old "composite projects". They're redundant.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
146 ;; 1.64: Allow meta-projects with :components
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
147 ;; 1.57: Timestamps flag is now called "org-publish-use-timestamps-flag"
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
148 ;; 1.52: Properly set default for :index-filename
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
149 ;; 1.48: Composite projects allowed.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
150 ;; :include keyword allowed.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
151 ;; 1.43: Index no longer includes itself in the index.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
152 ;; 1.42: Fix "function definition is void" error
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
153 ;; when :publishing-function not set in org-publish-current-file.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
154 ;; 1.41: Fixed bug where index isn't published on first try.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
155 ;; 1.37: Added interactive function "org-publish". Prompts for particular
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
156 ;; project name to publish.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
157 ;; 1.34: Added force-publish option to all interactive functions.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
158 ;; 1.32: Fixed "index.org has changed on disk" error during index publishing.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
159 ;; 1.30: Fixed startup error caused by (require 'em-unix)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
160
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
161 ;;; Code:
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
162
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
163
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
164 (eval-when-compile
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
165 (require 'cl))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
166
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
167
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
168 (defgroup org-publish nil
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
169 "Options for publishing a set of Org-mode and related files."
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
170 :tag "Org Publishing"
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
171 :group 'org)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
172
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
173
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
174 (defcustom org-publish-project-alist nil
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
175 "Association list to control publishing behavior.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
176 Each element of the alist is a publishing 'project.' The CAR of
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
177 each element is a string, uniquely identifying the project. The
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
178 CDR of each element is in one of the following forms:
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
179
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
180 (:property value :property value ... )
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
181
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
182 OR,
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
183
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
184 (:components (\"project-1\" \"project-2\" ...))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
185
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
186 When the CDR of an element of org-publish-project-alist is in
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
187 this second form, the elements of the list after :components are
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
188 taken to be components of the project, which group together files
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
189 requiring different publishing options. When you publish such a
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
190 project with M-x org-publish, the components all publish.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
191
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
192 When a property is given a value in org-publish-project-alist, its
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
193 setting overrides the value of the corresponding user variable
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
194 (if any) during publishing. However, options set within a file
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
195 override everything.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
196
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
197 Most properties are optional, but some should always be set:
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
198
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
199 :base-directory Directory containing publishing source files
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
200 :base-extension Extension (without the dot!) of source files.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
201 This can be a regular expression.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
202 :publishing-directory Directory (possibly remote) where output
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
203 files will be published
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
204
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
205 The :exclude property may be used to prevent certain files from
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
206 being published. Its value may be a string or regexp matching
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
207 file names you don't want to be published.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
208
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
209 The :include property may be used to include extra files. Its
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
210 value may be a list of filenames to include. The filenames are
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
211 considered relative to the publishing directory.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
212
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
213 When both :include and :exclude properties are given values, the
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
214 exclusion step happens first.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
215
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
216 One special property controls which back-end function to use for
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
217 publishing files in the project. This can be used to extend the
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
218 set of file types publishable by org-publish, as well as the set
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
219 of output formats.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
220
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
221 :publishing-function Function to publish file. The default is
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
222 org-publish-org-to-html, but other
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
223 values are possible. May also be a
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
224 list of functions, in which case
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
225 each function in the list is invoked
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
226 in turn.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
227
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
228 Another property allows you to insert code that prepares a
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
229 project for publishing. For example, you could call GNU Make on a
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
230 certain makefile, to ensure published files are built up to date.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
231
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
232 :preparation-function Function to be called before publishing
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
233 this project.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
234
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
235 Some properties control details of the Org publishing process,
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
236 and are equivalent to the corresponding user variables listed in
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
237 the right column. See the documentation for those variables to
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
238 learn more about their use and default values.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
239
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
240 :language org-export-default-language
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
241 :headline-levels org-export-headline-levels
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
242 :section-numbers org-export-with-section-numbers
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
243 :table-of-contents org-export-with-toc
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
244 :emphasize org-export-with-emphasize
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
245 :sub-superscript org-export-with-sub-superscripts
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
246 :TeX-macros org-export-with-TeX-macros
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
247 :fixed-width org-export-with-fixed-width
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
248 :tables org-export-with-tables
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
249 :table-auto-headline org-export-highlight-first-table-line
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
250 :style org-export-html-style
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
251 :convert-org-links org-export-html-link-org-files-as-html
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
252 :inline-images org-export-html-inline-images
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
253 :expand-quoted-html org-export-html-expand
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
254 :timestamp org-export-html-with-timestamp
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
255 :publishing-directory org-export-publishing-directory
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
256 :preamble org-export-html-preamble
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
257 :postamble org-export-html-postamble
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
258 :auto-preamble org-export-html-auto-preamble
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
259 :auto-postamble org-export-html-auto-postamble
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
260 :author user-full-name
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
261 :email user-mail-address
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
262
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
263 The following properties may be used to control publishing of an
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
264 index of files or summary page for a given project.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
265
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
266 :auto-index Whether to publish an index during
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
267 org-publish-current-project or org-publish-all.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
268 :index-filename Filename for output of index. Defaults
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
269 to 'index.org' (which becomes 'index.html')
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
270 :index-title Title of index page. Defaults to name of file.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
271 :index-function Plugin function to use for generation of index.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
272 Defaults to 'org-publish-org-index', which
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
273 generates a plain list of links to all files
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
274 in the project.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
275 "
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
276 :group 'org-publish
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
277 :type 'alist)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
278
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
279
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
280 (defcustom org-publish-use-timestamps-flag t
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
281 "When non-nil, use timestamp checking to publish only changed files.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
282 When nil, do no timestamp checking and always publish all
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
283 files."
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
284 :group 'org-publish
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
285 :type 'boolean)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
286
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
287
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
288 (defcustom org-publish-timestamp-directory "~/.org-timestamps/"
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
289 "Name of directory in which to store publishing timestamps."
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
290 :group 'org-publish
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
291 :type 'string)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
292
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
293
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
294 ;;;; Timestamp-related functions
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
295
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
296
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
297 (defun org-publish-timestamp-filename (filename)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
298 "Return path to timestamp file for filename FILENAME."
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
299 (while (string-match "~\\|/" filename)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
300 (setq filename (replace-match "_" nil t filename)))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
301 (concat org-publish-timestamp-directory filename ".timestamp"))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
302
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
303
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
304 (defun org-publish-needed-p (filename)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
305 "Check whether file should be published.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
306 If org-publish-use-timestamps-flag is set to nil, this function always
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
307 returns t. Otherwise, check the timestamps folder to determine
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
308 whether file should be published."
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
309 (if org-publish-use-timestamps-flag
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
310 (progn
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
311 ;;
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
312 ;; create folder if needed
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
313 (if (not (file-exists-p org-publish-timestamp-directory))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
314 (make-directory org-publish-timestamp-directory)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
315 (if (not (file-directory-p org-publish-timestamp-directory))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
316 (error "org-publish-timestamp-directory must be a directory.")))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
317 ;;
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
318 ;; check timestamp. ok if timestamp file doesn't exist
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
319 (let* ((timestamp (org-publish-timestamp-filename filename))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
320 (rtn (file-newer-than-file-p filename timestamp)))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
321 (if rtn
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
322 ;; handle new timestamps
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
323 (if (not (file-exists-p timestamp))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
324 ;; create file
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
325 (with-temp-buffer
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
326 (make-directory (file-name-directory timestamp) :parents)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
327 (write-file timestamp)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
328 (kill-buffer (current-buffer)))))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
329 rtn))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
330 t))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
331
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
332
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
333 (defun org-publish-update-timestamp (filename)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
334 "Update publishing timestamp for file FILENAME."
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
335 (let ((timestamp (org-publish-timestamp-filename filename)))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
336 ;; Emacs 21 doesn't have set-file-times
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
337 (if (fboundp 'set-file-times)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
338 (set-file-times timestamp)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
339 (call-process "touch" nil 0 nil timestamp))))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
340
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
341
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
342 ;;;; A hash mapping files to project names
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
343
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
344
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
345 (defvar org-publish-files (make-hash-table :test 'equal) "Hash
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
346 table mapping file names to project names.")
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
347
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
348
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
349 ;;;; Checking filenames against this hash
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
350
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
351
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
352 (defun org-publish-validate-link (link &optional directory)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
353 (gethash (file-truename (expand-file-name link directory))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
354 org-publish-files))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
355
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
356
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
357 ;;;; Getting project information out of org-publish-project-alist
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
358
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
359
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
360 (defun org-publish-get-plists (&optional project-name)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
361 "Return a list of property lists for project PROJECT-NAME.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
362 When argument is not given, return all property lists for all projects."
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
363 (let ((alist (if project-name
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
364 (list (assoc project-name org-publish-project-alist))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
365 org-publish-project-alist))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
366 (project nil)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
367 (plists nil)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
368 (single nil)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
369 (components nil))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
370
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
371 ;;
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
372 ;;
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
373 (while (setq project (pop alist))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
374 ;; what kind of project is it?
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
375 (if (setq components (plist-get (cdr project) :components))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
376 ;; meta project. annotate each plist with name of enclosing project
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
377 (setq single
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
378 (apply 'append
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
379 (mapcar 'org-publish-get-plists components)))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
380 ;; normal project
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
381 (setq single (list (cdr project))))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
382 ;;
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
383 (setq plists (append plists single))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
384 (dolist (p single)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
385 (let* ((exclude (plist-get p :exclude))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
386 (files (org-publish-get-base-files p exclude)))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
387 (dolist (f files)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
388 (puthash (file-truename f) (car project) org-publish-files)))))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
389 plists))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
390
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
391
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
392
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
393 (defun org-publish-get-base-files (plist &optional exclude-regexp)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
394 "Return a list of all files in project defined by PLIST.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
395 If EXCLUDE-REGEXP is set, this will be used to filter out
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
396 matching filenames."
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
397 (let* ((dir (file-name-as-directory (plist-get plist :base-directory)))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
398 (include-list (plist-get plist :include))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
399 (extension (or (plist-get plist :base-extension) "org"))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
400 (regexp (concat "^[^\\.].*\\.\\(" extension "\\)$"))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
401 (allfiles (directory-files dir t regexp)))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
402 ;;
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
403 ;; exclude files
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
404 (setq allfiles
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
405 (if (not exclude-regexp)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
406 allfiles
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
407 (delq nil
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
408 (mapcar (lambda (x)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
409 (if (string-match exclude-regexp x) nil x))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
410 allfiles))))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
411 ;;
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
412 ;; include extra files
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
413 (let ((inc nil))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
414 (while (setq inc (pop include-list))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
415 (setq allfiles (cons (expand-file-name inc dir) allfiles))))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
416
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
417 allfiles))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
418
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
419
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
420 (defun org-publish-get-project-from-filename (filename)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
421 "Figure out which project a given FILENAME belongs to, if any.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
422 Filename should contain full path. Returns name of project, or
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
423 nil if not found."
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
424 (org-publish-get-plists)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
425 (gethash (file-truename filename) org-publish-files))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
426
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
427
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
428 (defun org-publish-get-plist-from-filename (filename)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
429 "Return publishing configuration plist for file FILENAME."
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
430 (let ((found nil))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
431 (mapcar
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
432 (lambda (plist)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
433 (let ((files (org-publish-get-base-files plist)))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
434 (if (member (expand-file-name filename) files)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
435 (setq found plist))))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
436 (org-publish-get-plists))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
437 found))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
438
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
439
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
440
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
441 ;;;; Pluggable publishing back-end functions
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
442
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
443
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
444 (defun org-publish-org-to-html (plist filename)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
445 "Publish an org file to HTML.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
446 PLIST is the property list for the given project.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
447 FILENAME is the filename of the org file to be published."
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
448 (require 'org)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
449 (let* ((arg (plist-get plist :headline-levels)))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
450 (progn
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
451 (find-file filename)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
452 (org-export-as-html arg nil plist)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
453 ;; get rid of HTML buffer
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
454 (kill-buffer (current-buffer)))))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
455
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
456
82757
00bb6352b55a * textmodes/org-publish.el (org-publish-org-to-latex): New
Carsten Dominik <dominik@science.uva.nl>
parents: 82162
diff changeset
457 (defun org-publish-org-to-latex (plist filename)
00bb6352b55a * textmodes/org-publish.el (org-publish-org-to-latex): New
Carsten Dominik <dominik@science.uva.nl>
parents: 82162
diff changeset
458 "Publish an org file to LaTeX."
00bb6352b55a * textmodes/org-publish.el (org-publish-org-to-latex): New
Carsten Dominik <dominik@science.uva.nl>
parents: 82162
diff changeset
459 (org-publish-org-to "latex" plist filename))
00bb6352b55a * textmodes/org-publish.el (org-publish-org-to-latex): New
Carsten Dominik <dominik@science.uva.nl>
parents: 82162
diff changeset
460
00bb6352b55a * textmodes/org-publish.el (org-publish-org-to-latex): New
Carsten Dominik <dominik@science.uva.nl>
parents: 82162
diff changeset
461 (defun org-publish-org-to-html (plist filename)
00bb6352b55a * textmodes/org-publish.el (org-publish-org-to-latex): New
Carsten Dominik <dominik@science.uva.nl>
parents: 82162
diff changeset
462 "Publish an org file to HTML."
00bb6352b55a * textmodes/org-publish.el (org-publish-org-to-latex): New
Carsten Dominik <dominik@science.uva.nl>
parents: 82162
diff changeset
463 (org-publish-org-to "html" plist filename))
00bb6352b55a * textmodes/org-publish.el (org-publish-org-to-latex): New
Carsten Dominik <dominik@science.uva.nl>
parents: 82162
diff changeset
464
00bb6352b55a * textmodes/org-publish.el (org-publish-org-to-latex): New
Carsten Dominik <dominik@science.uva.nl>
parents: 82162
diff changeset
465 (defun org-publish-org-to (format plist filename)
00bb6352b55a * textmodes/org-publish.el (org-publish-org-to-latex): New
Carsten Dominik <dominik@science.uva.nl>
parents: 82162
diff changeset
466 "Publish an org file to FORMAT.
00bb6352b55a * textmodes/org-publish.el (org-publish-org-to-latex): New
Carsten Dominik <dominik@science.uva.nl>
parents: 82162
diff changeset
467 PLIST is the property list for the given project.
00bb6352b55a * textmodes/org-publish.el (org-publish-org-to-latex): New
Carsten Dominik <dominik@science.uva.nl>
parents: 82162
diff changeset
468 FILENAME is the filename of the org file to be published."
00bb6352b55a * textmodes/org-publish.el (org-publish-org-to-latex): New
Carsten Dominik <dominik@science.uva.nl>
parents: 82162
diff changeset
469 (require 'org)
00bb6352b55a * textmodes/org-publish.el (org-publish-org-to-latex): New
Carsten Dominik <dominik@science.uva.nl>
parents: 82162
diff changeset
470 (let* ((arg (plist-get plist :headline-levels)))
00bb6352b55a * textmodes/org-publish.el (org-publish-org-to-latex): New
Carsten Dominik <dominik@science.uva.nl>
parents: 82162
diff changeset
471 (progn
00bb6352b55a * textmodes/org-publish.el (org-publish-org-to-latex): New
Carsten Dominik <dominik@science.uva.nl>
parents: 82162
diff changeset
472 (find-file filename)
00bb6352b55a * textmodes/org-publish.el (org-publish-org-to-latex): New
Carsten Dominik <dominik@science.uva.nl>
parents: 82162
diff changeset
473 (funcall (intern (concat "org-export-as-" format))
00bb6352b55a * textmodes/org-publish.el (org-publish-org-to-latex): New
Carsten Dominik <dominik@science.uva.nl>
parents: 82162
diff changeset
474 arg nil plist)
00bb6352b55a * textmodes/org-publish.el (org-publish-org-to-latex): New
Carsten Dominik <dominik@science.uva.nl>
parents: 82162
diff changeset
475 (kill-buffer (current-buffer)))))
00bb6352b55a * textmodes/org-publish.el (org-publish-org-to-latex): New
Carsten Dominik <dominik@science.uva.nl>
parents: 82162
diff changeset
476
00bb6352b55a * textmodes/org-publish.el (org-publish-org-to-latex): New
Carsten Dominik <dominik@science.uva.nl>
parents: 82162
diff changeset
477
81170
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
478 (defun org-publish-attachment (plist filename)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
479 "Publish a file with no transformation of any kind.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
480 PLIST is the property list for the given project.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
481 FILENAME is the filename of the file to be published."
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
482 ;; make sure eshell/cp code is loaded
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
483 (require 'eshell)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
484 (require 'esh-maint)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
485 (require 'em-unix)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
486 (let ((destination (file-name-as-directory (plist-get plist :publishing-directory))))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
487 (eshell/cp filename destination)))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
488
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
489
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
490 ;;;; Publishing files, sets of files, and indices
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
491
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
492
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
493 (defun org-publish-file (filename)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
494 "Publish file FILENAME."
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
495 (let* ((project-name (org-publish-get-project-from-filename filename))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
496 (plist (org-publish-get-plist-from-filename filename))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
497 (publishing-function (or (plist-get plist :publishing-function) 'org-publish-org-to-html)))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
498 (if (not project-name)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
499 (error (format "File %s is not part of any known project." filename)))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
500 (when (org-publish-needed-p filename)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
501 (if (listp publishing-function)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
502 ;; allow chain of publishing functions
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
503 (mapc (lambda (f)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
504 (funcall f plist filename))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
505 publishing-function)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
506 (funcall publishing-function plist filename))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
507 (org-publish-update-timestamp filename))))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
508
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
509
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
510 (defun org-publish-plist (plist)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
511 "Publish all files in set defined by PLIST.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
512 If :auto-index is set, publish the index too."
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
513 (let* ((exclude-regexp (plist-get plist :exclude))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
514 (publishing-function (or (plist-get plist :publishing-function) 'org-publish-org-to-html))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
515 (index-p (plist-get plist :auto-index))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
516 (index-filename (or (plist-get plist :index-filename) "index.org"))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
517 (index-function (or (plist-get plist :index-function) 'org-publish-org-index))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
518 (preparation-function (plist-get plist :preparation-function))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
519 (f nil))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
520 ;;
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
521 (when preparation-function
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
522 (funcall preparation-function))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
523 (if index-p
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
524 (funcall index-function plist index-filename))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
525 (let ((files (org-publish-get-base-files plist exclude-regexp)))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
526 (while (setq f (pop files))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
527 ;; check timestamps
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
528 (when (org-publish-needed-p f)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
529 (if (listp publishing-function)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
530 ;; allow chain of publishing functions
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
531 (mapc (lambda (func)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
532 (funcall func plist f))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
533 publishing-function)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
534 (funcall publishing-function plist f))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
535 (org-publish-update-timestamp f))))))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
536
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
537
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
538 (defun org-publish-org-index (plist &optional index-filename)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
539 "Create an index of pages in set defined by PLIST.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
540 Optionally set the filename of the index with INDEX-FILENAME;
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
541 default is 'index.org'."
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
542 (let* ((dir (file-name-as-directory (plist-get plist :base-directory)))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
543 (exclude-regexp (plist-get plist :exclude))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
544 (files (org-publish-get-base-files plist exclude-regexp))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
545 (index-filename (concat dir (or index-filename "index.org")))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
546 (index-buffer (find-buffer-visiting index-filename))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
547 (ifn (file-name-nondirectory index-filename))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
548 (f nil))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
549 ;;
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
550 ;; if buffer is already open, kill it to prevent error message
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
551 (if index-buffer
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
552 (kill-buffer index-buffer))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
553 (with-temp-buffer
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
554 (while (setq f (pop files))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
555 (let ((fn (file-name-nondirectory f)))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
556 (unless (string= fn ifn) ;; index shouldn't index itself
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
557 (insert (concat " + [[file:" fn "]["
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
558 (file-name-sans-extension fn)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
559 "]]\n")))))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
560 (write-file index-filename)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
561 (kill-buffer (current-buffer)))))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
562
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
563
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
564 ;(defun org-publish-meta-index (meta-plist &optional index-filename)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
565 ; "Create an index for a metaproject."
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
566 ; (let* ((plists (
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
567
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
568
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
569 ;;;; Interactive publishing functions
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
570
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
571
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
572 ;;;###autoload
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
573 (defun org-publish (project-name &optional force)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
574 "Publish the project PROJECT-NAME."
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
575 (interactive (list (completing-read "Project name: " org-publish-project-alist
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
576 nil t)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
577 current-prefix-arg))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
578 (save-window-excursion
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
579 (let ((org-publish-use-timestamps-flag (if force nil t))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
580 (plists (org-publish-get-plists project-name)))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
581 (mapcar 'org-publish-plist plists))))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
582
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
583
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
584 ;;;###autoload
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
585 (defun org-publish-current-project (&optional force)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
586 "Publish the project associated with the current file.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
587 With prefix argument, force publishing all files in project."
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
588 (interactive "P")
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
589 (save-window-excursion
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
590 (let* ((project-name (org-publish-get-project-from-filename (buffer-file-name)))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
591 (org-publish-use-timestamps-flag (if force nil t)))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
592 (if (not project-name)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
593 (error (format "File %s is not part of any known project." (buffer-file-name))))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
594 (org-publish project-name))))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
595
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
596
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
597 ;;;###autoload
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
598 (defun org-publish-current-file (&optional force)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
599 "Publish the current file.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
600 With prefix argument, force publish the file."
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
601 (interactive "P")
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
602 (save-window-excursion
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
603 (let ((org-publish-use-timestamps-flag
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
604 (if force nil t)))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
605 (org-publish-file (buffer-file-name)))))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
606
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
607
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
608 ;;;###autoload
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
609 (defun org-publish-all (&optional force)
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
610 "Publish all projects.
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
611 With prefix argument, force publish all files."
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
612 (interactive "P")
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
613 (save-window-excursion
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
614 (let ((org-publish-use-timestamps-flag
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
615 (if force nil t))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
616 (plists (org-publish-get-plists)))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
617 (mapcar 'org-publish-plist plists))))
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
618
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
619
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
620
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
621 (provide 'org-publish)
82784
54b437841f58 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 82757
diff changeset
622
54b437841f58 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 82757
diff changeset
623 ;; arch-tag: 72807f3c-8af0-4a6b-8dca-c3376eb25adb
81170
8b347979875b New file.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
624 ;;; org-publish.el ends here