annotate lisp/org/org-publish.el @ 101954:a7b2ac5493bd

(rmail-show-message-verbose-min): New option. (rmail-show-message): Conditionally show start and finish in echo area.
author Richard M. Stallman <rms@gnu.org>
date Thu, 12 Feb 2009 04:01:02 +0000
parents 6d71fc980cde
children ac1a55cc2c38
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1 ;;; org-publish.el --- publish related org-mode files as a website
100908
a9dc0e7c3f2b Add 2009 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 100605
diff changeset
2 ;; Copyright (C) 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4 ;; Author: David O'Toole <dto@gnu.org>
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5 ;; Maintainer: Bastien Guerry <bzg AT altern DOT org>
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6 ;; Keywords: hypermedia, outlines, wp
101757
6d71fc980cde 2009-02-02 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101702
diff changeset
7 ;; Version: 6.21b
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10 ;;
94676
ba3167bc4143 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94414
diff changeset
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
94676
ba3167bc4143 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94414
diff changeset
13 ;; the Free Software Foundation, either version 3 of the License, or
ba3167bc4143 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94414
diff changeset
14 ;; (at your option) any later version.
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
15
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
19 ;; GNU General Public License for more details.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
20
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
94676
ba3167bc4143 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94414
diff changeset
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
23
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
24 ;;; Commentary:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
25
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
26 ;; This program allow configurable publishing of related sets of
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
27 ;; Org-mode files as a complete website.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
28 ;;
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
29 ;; org-publish.el can do the following:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
30 ;;
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
31 ;; + Publish all one's org-files to HTML or LaTeX
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
32 ;; + Upload HTML, images, attachments and other files to a web server
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
33 ;; + Exclude selected private pages from publishing
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
34 ;; + Publish a clickable index of pages
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
35 ;; + Manage local timestamps for publishing only changed files
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
36 ;; + Accept plugin functions to extend range of publishable content
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
37 ;;
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
38 ;; Special thanks to the org-mode maintainer Carsten Dominik for his
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
39 ;; ideas, enthusiasm, and cooperation.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
40
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
41 ;;; Installation:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
42
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
43 ;; Put org-publish.el in your load path, byte-compile it, and then add
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
44 ;; the following lines to your emacs initialization file:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
45
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
46 ;; (autoload 'org-publish "org-publish" nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
47 ;; (autoload 'org-publish "org-publish-all" nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
48 ;; (autoload 'org-publish "org-publish-current-file" nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
49 ;; (autoload 'org-publish "org-publish-current-project" nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
50
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
51 ;; NOTE: When org-publish.el is included with org.el, those forms are
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
52 ;; already in the file org-install.el, and hence don't need to be put
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
53 ;; in your emacs initialization file in this case.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
54
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
55 ;;; Usage:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
56 ;;
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
57 ;; The program's main configuration variable is
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
58 ;; `org-publish-project-alist'. See below for example configurations
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
59 ;; with commentary.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
60
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
61 ;; The main interactive functions are:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
62 ;;
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
63 ;; M-x org-publish
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
64 ;; M-x org-publish-all
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
65 ;; M-x org-publish-current-file
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
66 ;; M-x org-publish-current-project
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
67
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
68 ;;;; Simple example configuration:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
69
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
70 ;; (setq org-publish-project-alist
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
71 ;; (list
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
72 ;; '("org" . (:base-directory "~/org/"
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
73 ;; :base-extension "org"
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
74 ;; :publishing-directory "~/public_html"
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
75 ;; :with-section-numbers nil
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
76 ;; :table-of-contents nil
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
77 ;; :recursive t
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
78 ;; :style "<link rel="stylesheet" href=\"../other/mystyle.css\" type=\"text/css\">")))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
79
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
80 ;;;; More complex example configuration:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
81
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
82 ;; Imagine your *.org files are kept in ~/org, your images in
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
83 ;; ~/images, and stylesheets in ~/other. Now imagine you want to
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
84 ;; publish the files through an ssh connection to a remote host, via
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
85 ;; Tramp-mode. To maintain relative links from *.org files to /images
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
86 ;; and /other, we should replicate the same directory structure in
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
87 ;; your web server account's designated html root (in this case,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
88 ;; assumed to be ~/html)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
89
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
90 ;; Once you've done created the proper directories, you can adapt the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
91 ;; following example configuration to your specific paths, run M-x
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
92 ;; org-publish-all, and it should publish the files to the correct
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
93 ;; directories on the web server, transforming the *.org files into
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
94 ;; HTML, and leaving other files alone.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
95
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
96 ;; (setq org-publish-project-alist
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
97 ;; (list
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
98 ;; '("orgfiles" :base-directory "~/org/"
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
99 ;; :base-extension "org"
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
100 ;; :publishing-directory "/ssh:user@host:~/html/notebook/"
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
101 ;; :publishing-function org-publish-org-to-html
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
102 ;; :exclude "PrivatePage.org" ;; regexp
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
103 ;; :headline-levels 3
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
104 ;; :with-section-numbers nil
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
105 ;; :table-of-contents nil
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
106 ;; :style "<link rel="stylesheet" href=\"../other/mystyle.css\" type=\"text/css\">"
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
107 ;; :auto-preamble t
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
108 ;; :auto-postamble nil)
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
109 ;; ("images" :base-directory "~/images/"
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
110 ;; :base-extension "jpg\\|gif\\|png"
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
111 ;; :publishing-directory "/ssh:user@host:~/html/images/"
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
112 ;; :publishing-function org-publish-attachment)
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
113 ;; ("other" :base-directory "~/other/"
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
114 ;; :base-extension "css"
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
115 ;; :publishing-directory "/ssh:user@host:~/html/other/"
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
116 ;; :publishing-function org-publish-attachment)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
117 ;; ("website" :components ("orgfiles" "images" "other"))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
118
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
119 ;; For more information, see the documentation for the variable
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
120 ;; `org-publish-project-alist'.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
121
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
122 ;; Of course, you don't have to publish to remote directories from
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
123 ;; within emacs. You can always just publish to local folders, and
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
124 ;; then use the synchronization/upload tool of your choice.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
125
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
126 ;;; List of user-visible changes since version 1.27
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
127
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
128 ;; 1.78: Allow list-valued :publishing-function
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
129 ;; 1.77: Added :preparation-function, this allows you to use GNU Make etc.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
130 ;; 1.65: Remove old "composite projects". They're redundant.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
131 ;; 1.64: Allow meta-projects with :components
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
132 ;; 1.57: Timestamps flag is now called "org-publish-use-timestamps-flag"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
133 ;; 1.52: Properly set default for :index-filename
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
134 ;; 1.48: Composite projects allowed.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
135 ;; :include keyword allowed.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
136 ;; 1.43: Index no longer includes itself in the index.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
137 ;; 1.42: Fix "function definition is void" error
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
138 ;; when :publishing-function not set in org-publish-current-file.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
139 ;; 1.41: Fixed bug where index isn't published on first try.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
140 ;; 1.37: Added interactive function "org-publish". Prompts for particular
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
141 ;; project name to publish.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
142 ;; 1.34: Added force-publish option to all interactive functions.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
143 ;; 1.32: Fixed "index.org has changed on disk" error during index publishing.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
144 ;; 1.30: Fixed startup error caused by (require 'em-unix)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
145
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
146 ;;; Code:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
147
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
148 (eval-when-compile
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
149 (require 'cl))
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94773
diff changeset
150 (require 'org)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94773
diff changeset
151 (require 'org-exp)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
152
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
153 (eval-and-compile
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
154 (unless (fboundp 'declare-function)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
155 (defmacro declare-function (fn file &optional arglist fileonly))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
156
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
157 (defgroup org-publish nil
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94773
diff changeset
158 "Options for publishing a set of Org-mode and related files."
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94773
diff changeset
159 :tag "Org Publishing"
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94773
diff changeset
160 :group 'org)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
161
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
162 (defcustom org-publish-project-alist nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
163 "Association list to control publishing behavior.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
164 Each element of the alist is a publishing 'project.' The CAR of
94773
817e282b0cc9 (org-publish-project-alist): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 94676
diff changeset
165 each element is a string, uniquely identifying the project. The
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
166 CDR of each element is in one of the following forms:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
167
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
168 (:property value :property value ... )
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
169
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
170 OR,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
171
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
172 (:components (\"project-1\" \"project-2\" ...))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
173
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
174 When the CDR of an element of org-publish-project-alist is in
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
175 this second form, the elements of the list after :components are
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
176 taken to be components of the project, which group together files
94773
817e282b0cc9 (org-publish-project-alist): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 94676
diff changeset
177 requiring different publishing options. When you publish such a
817e282b0cc9 (org-publish-project-alist): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 94676
diff changeset
178 project with \\[org-publish], the components all publish.
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
179
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
180 When a property is given a value in org-publish-project-alist, its
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
181 setting overrides the value of the corresponding user variable
94773
817e282b0cc9 (org-publish-project-alist): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 94676
diff changeset
182 \(if any) during publishing. However, options set within a file
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
183 override everything.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
184
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
185 Most properties are optional, but some should always be set:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
186
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
187 :base-directory Directory containing publishing source files
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
188 :base-extension Extension (without the dot!) of source files.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
189 This can be a regular expression.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
190 :publishing-directory Directory (possibly remote) where output
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
191 files will be published
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
192
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
193 The :exclude property may be used to prevent certain files from
94773
817e282b0cc9 (org-publish-project-alist): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 94676
diff changeset
194 being published. Its value may be a string or regexp matching
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
195 file names you don't want to be published.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
196
94773
817e282b0cc9 (org-publish-project-alist): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 94676
diff changeset
197 The :include property may be used to include extra files. Its
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94773
diff changeset
198 value may be a list of filenames to include. The filenames are
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94773
diff changeset
199 considered relative to the base directory.
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
200
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
201 When both :include and :exclude properties are given values, the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
202 exclusion step happens first.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
203
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
204 One special property controls which back-end function to use for
94773
817e282b0cc9 (org-publish-project-alist): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 94676
diff changeset
205 publishing files in the project. This can be used to extend the
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
206 set of file types publishable by org-publish, as well as the set
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
207 of output formats.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
208
94773
817e282b0cc9 (org-publish-project-alist): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 94676
diff changeset
209 :publishing-function Function to publish file. The default is
817e282b0cc9 (org-publish-project-alist): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 94676
diff changeset
210 `org-publish-org-to-html', but other
817e282b0cc9 (org-publish-project-alist): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 94676
diff changeset
211 values are possible. May also be a
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
212 list of functions, in which case
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
213 each function in the list is invoked
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
214 in turn.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
215
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
216 Another property allows you to insert code that prepares a
94773
817e282b0cc9 (org-publish-project-alist): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 94676
diff changeset
217 project for publishing. For example, you could call GNU Make on a
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
218 certain makefile, to ensure published files are built up to date.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
219
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
220 :preparation-function Function to be called before publishing
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
221 this project.
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94773
diff changeset
222 :completion-function Function to be called after publishing
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94773
diff changeset
223 this project.
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
224
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
225 Some properties control details of the Org publishing process,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
226 and are equivalent to the corresponding user variables listed in
94773
817e282b0cc9 (org-publish-project-alist): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 94676
diff changeset
227 the right column. See the documentation for those variables to
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
228 learn more about their use and default values.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
229
94773
817e282b0cc9 (org-publish-project-alist): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 94676
diff changeset
230 :language `org-export-default-language'
817e282b0cc9 (org-publish-project-alist): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 94676
diff changeset
231 :headline-levels `org-export-headline-levels'
817e282b0cc9 (org-publish-project-alist): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 94676
diff changeset
232 :section-numbers `org-export-with-section-numbers'
817e282b0cc9 (org-publish-project-alist): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 94676
diff changeset
233 :table-of-contents `org-export-with-toc'
817e282b0cc9 (org-publish-project-alist): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 94676
diff changeset
234 :emphasize `org-export-with-emphasize'
817e282b0cc9 (org-publish-project-alist): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 94676
diff changeset
235 :sub-superscript `org-export-with-sub-superscripts'
817e282b0cc9 (org-publish-project-alist): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 94676
diff changeset
236 :TeX-macros `org-export-with-TeX-macros'
817e282b0cc9 (org-publish-project-alist): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 94676
diff changeset
237 :fixed-width `org-export-with-fixed-width'
817e282b0cc9 (org-publish-project-alist): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 94676
diff changeset
238 :tables `org-export-with-tables'
817e282b0cc9 (org-publish-project-alist): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 94676
diff changeset
239 :table-auto-headline `org-export-highlight-first-table-line'
817e282b0cc9 (org-publish-project-alist): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 94676
diff changeset
240 :style `org-export-html-style'
817e282b0cc9 (org-publish-project-alist): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 94676
diff changeset
241 :convert-org-links `org-export-html-link-org-files-as-html'
817e282b0cc9 (org-publish-project-alist): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 94676
diff changeset
242 :inline-images `org-export-html-inline-images'
817e282b0cc9 (org-publish-project-alist): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 94676
diff changeset
243 :expand-quoted-html `org-export-html-expand'
817e282b0cc9 (org-publish-project-alist): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 94676
diff changeset
244 :timestamp `org-export-html-with-timestamp'
817e282b0cc9 (org-publish-project-alist): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 94676
diff changeset
245 :publishing-directory `org-export-publishing-directory'
817e282b0cc9 (org-publish-project-alist): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 94676
diff changeset
246 :preamble `org-export-html-preamble'
817e282b0cc9 (org-publish-project-alist): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 94676
diff changeset
247 :postamble `org-export-html-postamble'
817e282b0cc9 (org-publish-project-alist): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 94676
diff changeset
248 :auto-preamble `org-export-html-auto-preamble'
817e282b0cc9 (org-publish-project-alist): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 94676
diff changeset
249 :auto-postamble `org-export-html-auto-postamble'
817e282b0cc9 (org-publish-project-alist): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 94676
diff changeset
250 :author `user-full-name'
817e282b0cc9 (org-publish-project-alist): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 94676
diff changeset
251 :email `user-mail-address'
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
252
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
253 The following properties may be used to control publishing of an
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
254 index of files or summary page for a given project.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
255
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
256 :auto-index Whether to publish an index during
94773
817e282b0cc9 (org-publish-project-alist): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 94676
diff changeset
257 `org-publish-current-project' or `org-publish-all'.
817e282b0cc9 (org-publish-project-alist): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 94676
diff changeset
258 :index-filename Filename for output of index. Defaults
817e282b0cc9 (org-publish-project-alist): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 94676
diff changeset
259 to 'index.org' (which becomes 'index.html').
817e282b0cc9 (org-publish-project-alist): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 94676
diff changeset
260 :index-title Title of index page. Defaults to name of file.
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
261 :index-function Plugin function to use for generation of index.
94773
817e282b0cc9 (org-publish-project-alist): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 94676
diff changeset
262 Defaults to `org-publish-org-index', which
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
263 generates a plain list of links to all files
96975
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96044
diff changeset
264 in the project.
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96044
diff changeset
265 :index-style Can be `list' (index is just an itemized list
100267
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
266 of the titles of the files involved) or
96975
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96044
diff changeset
267 `tree' (the directory structure of the source
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96044
diff changeset
268 files is reflected in the index). Defaults to
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96044
diff changeset
269 `tree'."
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
270 :group 'org-publish
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
271 :type 'alist)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
272
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
273 (defcustom org-publish-use-timestamps-flag t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
274 "When non-nil, use timestamp checking to publish only changed files.
94773
817e282b0cc9 (org-publish-project-alist): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 94676
diff changeset
275 When nil, do no timestamp checking and always publish all files."
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
276 :group 'org-publish
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
277 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
278
100267
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
279 (defcustom org-publish-timestamp-directory (convert-standard-filename
99139
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98872
diff changeset
280 "~/.org-timestamps/")
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
281 "Name of directory in which to store publishing timestamps."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
282 :group 'org-publish
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
283 :type 'directory)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
284
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
285 (defcustom org-publish-before-export-hook nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
286 "Hook run before export on the Org file.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
287 If the functions in this hook modify the original Org buffer, the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
288 modified buffer will be used for export, but the buffer will be
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
289 restored and saved back to its initial state after export."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
290 :group 'org-publish
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
291 :type 'hook)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
292
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
293 (defcustom org-publish-after-export-hook nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
294 "Hook run after export on the exported buffer.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
295 If functions in this hook modify the buffer, it will be saved."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
296 :group 'org-publish
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
297 :type 'hook)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
298
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
299 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
300 ;;; Timestamp-related functions
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
301
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
302 (defun org-publish-timestamp-filename (filename)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
303 "Return path to timestamp file for filename FILENAME."
96975
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96044
diff changeset
304 (concat (file-name-as-directory org-publish-timestamp-directory)
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
305 "X" (if (fboundp 'sha1) (sha1 filename) (md5 filename))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
306
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
307 (defun org-publish-needed-p (filename)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
308 "Return `t' if FILENAME should be published."
96975
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96044
diff changeset
309 (let ((rtn
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96044
diff changeset
310 (if org-publish-use-timestamps-flag
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96044
diff changeset
311 (if (file-exists-p org-publish-timestamp-directory)
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96044
diff changeset
312 ;; first handle possible wrong timestamp directory
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96044
diff changeset
313 (if (not (file-directory-p org-publish-timestamp-directory))
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96044
diff changeset
314 (error "Org publish timestamp: %s is not a directory"
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96044
diff changeset
315 org-publish-timestamp-directory)
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96044
diff changeset
316 ;; there is a timestamp, check if FILENAME is newer
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96044
diff changeset
317 (file-newer-than-file-p
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96044
diff changeset
318 filename (org-publish-timestamp-filename filename)))
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96044
diff changeset
319 (make-directory org-publish-timestamp-directory)
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96044
diff changeset
320 t)
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96044
diff changeset
321 ;; don't use timestamps, always return t
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96044
diff changeset
322 t)))
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96044
diff changeset
323 (if rtn
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96044
diff changeset
324 (message "Publishing file %s" filename)
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96044
diff changeset
325 (message "Skipping unmodified file %s" filename))
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96044
diff changeset
326 rtn))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
327
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
328 (defun org-publish-update-timestamp (filename)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
329 "Update publishing timestamp for file FILENAME.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
330 If there is no timestamp, create one."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
331 (let ((timestamp-file (org-publish-timestamp-filename filename))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
332 newly-created-timestamp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
333 (if (not (file-exists-p timestamp-file))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
334 ;; create timestamp file if needed
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
335 (with-temp-buffer
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
336 (make-directory (file-name-directory timestamp-file) t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
337 (write-file timestamp-file)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
338 (setq newly-created-timestamp t)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
339 ;; Emacs 21 doesn't have `set-file-times'
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
340 (if (and (fboundp 'set-file-times)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
341 (not newly-created-timestamp))
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
342 (set-file-times timestamp-file)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
343 (call-process "touch" nil 0 nil timestamp-file))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
344
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
345 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
346 ;;; Mapping files to project names
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
347
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
348 (defvar org-publish-files-alist nil
94773
817e282b0cc9 (org-publish-project-alist): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 94676
diff changeset
349 "Alist of files and their parent projects.
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
350 Each element of this alist is of the form:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
351
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
352 (file-name . project-name)")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
353
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
354 (defvar org-publish-initial-buffer nil
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
355 "The buffer `org-publish' has been called from.")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
356 (defvar org-publish-temp-files nil
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
357 "Temporary list of files to be published.")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
358
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
359 (defun org-publish-initialize-files-alist (&optional refresh)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
360 "Set `org-publish-files-alist' if it is not set.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
361 Also set it if the optional argument REFRESH is non-nil."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
362 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
363 (when (or refresh (not org-publish-files-alist))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
364 (setq org-publish-files-alist
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
365 (org-publish-get-files org-publish-project-alist))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
366
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99415
diff changeset
367 (defun org-publish-validate-link (link &optional directory)
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99415
diff changeset
368 "Check if LINK points to a file in the current project."
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99415
diff changeset
369 (assoc (expand-file-name link directory) org-publish-files-alist))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99415
diff changeset
370
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
371 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
372 ;;; Compatibility aliases
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
373
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
374 ;; Delete-dups is not in Emacs <22
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
375 (if (fboundp 'delete-dups)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
376 (defalias 'org-publish-delete-dups 'delete-dups)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
377 (defun org-publish-delete-dups (list)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
378 "Destructively remove `equal' duplicates from LIST.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
379 Store the result in LIST and return it. LIST must be a proper list.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
380 Of several `equal' occurrences of an element in LIST, the first
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
381 one is kept.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
382
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
383 This is a compatibility function for Emacsen without `delete-dups'."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
384 ;; Code from `subr.el' in Emacs 22:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
385 (let ((tail list))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
386 (while tail
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
387 (setcdr tail (delete (car tail) (cdr tail)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
388 (setq tail (cdr tail))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
389 list))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
390
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
391 (declare-function org-publish-delete-dups "org-publish" (list))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
392
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
393 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
394 ;;; Getting project information out of org-publish-project-alist
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
395
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
396 (defun org-publish-get-files (projects-alist &optional no-exclusion)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
397 "Return the list of all publishable files for PROJECTS-ALIST.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
398 If NO-EXCLUSION is non-nil, don't exclude files."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
399 (let (all-files)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
400 ;; add all projects
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
401 (mapc
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
402 (lambda(p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
403 (let* ((exclude (plist-get (cdr p) :exclude))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
404 (files (and p (org-publish-get-base-files p exclude))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
405 ;; add all files from this project
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
406 (mapc (lambda(f)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
407 (add-to-list 'all-files
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
408 (cons (expand-file-name f) (car p))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
409 files)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
410 (org-publish-expand-projects projects-alist))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
411 all-files))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
412
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
413 (defun org-publish-expand-projects (projects-alist)
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97027
diff changeset
414 "Expand projects in PROJECTS-ALIST.
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97027
diff changeset
415 This splices all the components into the list."
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97027
diff changeset
416 (let ((rest projects-alist) rtn p components)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97027
diff changeset
417 (while (setq p (pop rest))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97027
diff changeset
418 (if (setq components (plist-get (cdr p) :components))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97027
diff changeset
419 (setq rest (append
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97027
diff changeset
420 (mapcar (lambda (x) (assoc x org-publish-project-alist))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97027
diff changeset
421 components)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97027
diff changeset
422 rest))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97027
diff changeset
423 (push p rtn)))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97027
diff changeset
424 (nreverse (org-publish-delete-dups (delq nil rtn)))))
100267
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
425
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
426 (defun org-publish-get-base-files-1 (base-dir &optional recurse match skip-file skip-dir)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
427 "Set `org-publish-temp-files' with files from BASE-DIR directory.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
428 If RECURSE is non-nil, check BASE-DIR recursively. If MATCH is
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
429 non-nil, restrict this list to the files matching the regexp
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
430 MATCH. If SKIP-FILE is non-nil, skip file matching the regexp
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
431 SKIP-FILE. If SKIP-DIR is non-nil, don't check directories
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
432 matching the regexp SKIP-DIR when recursing through BASE-DIR."
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
433 (mapc (lambda (f)
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99415
diff changeset
434 (let ((fd-p (file-directory-p f))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
435 (fnd (file-name-nondirectory f)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
436 (if (and fd-p recurse
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
437 (not (string-match "^\\.+$" fnd))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
438 (if skip-dir (not (string-match skip-dir fnd)) t))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
439 (org-publish-get-base-files-1 f recurse match skip-file skip-dir)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
440 (unless (or fd-p ;; this is a directory
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
441 (and skip-file (string-match skip-file fnd))
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99415
diff changeset
442 (not (file-exists-p (file-truename f)))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
443 (not (string-match match fnd)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
444 (pushnew f org-publish-temp-files)))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
445 (directory-files base-dir t (unless recurse match))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
446
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
447 (defun org-publish-get-base-files (project &optional exclude-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
448 "Return a list of all files in PROJECT.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
449 If EXCLUDE-REGEXP is set, this will be used to filter out
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
450 matching filenames."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
451 (let* ((project-plist (cdr project))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
452 (base-dir (file-name-as-directory
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
453 (plist-get project-plist :base-directory)))
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
454 (include-list (plist-get project-plist :include))
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
455 (recurse (plist-get project-plist :recursive))
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
456 (extension (or (plist-get project-plist :base-extension) "org"))
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
457 (match (concat "^[^\\.].*\\.\\(" extension "\\)$")))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
458 (setq org-publish-temp-files nil)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
459 (org-publish-get-base-files-1 base-dir recurse match
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
460 ;; FIXME distinguish exclude regexp
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
461 ;; for skip-file and skip-dir?
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
462 exclude-regexp exclude-regexp)
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94773
diff changeset
463 (mapc (lambda (f)
100267
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
464 (pushnew
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94773
diff changeset
465 (expand-file-name (concat base-dir f))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94773
diff changeset
466 org-publish-temp-files))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94773
diff changeset
467 include-list)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
468 org-publish-temp-files))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
469
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
470 (defun org-publish-get-project-from-filename (filename)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
471 "Return the project FILENAME belongs."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
472 (let* ((project-name (cdr (assoc (expand-file-name filename)
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
473 org-publish-files-alist))))
100267
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
474 (dolist (prj org-publish-project-alist)
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
475 (if (member project-name (plist-get (cdr prj) :components))
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
476 (setq project-name (car prj))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
477 (assoc project-name org-publish-project-alist)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
478
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
479 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
480 ;;; Pluggable publishing back-end functions
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
481
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
482 (defun org-publish-org-to (format plist filename pub-dir)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
483 "Publish an org file to FORMAT.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
484 PLIST is the property list for the given project.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
485 FILENAME is the filename of the org file to be published.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
486 PUB-DIR is the publishing directory."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
487 (require 'org)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
488 (unless (file-exists-p pub-dir)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
489 (make-directory pub-dir t))
99139
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98872
diff changeset
490 (let ((visiting (find-buffer-visiting filename)))
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98872
diff changeset
491 (save-excursion
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98872
diff changeset
492 (switch-to-buffer (or visiting (find-file filename)))
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98872
diff changeset
493 (let* ((plist (cons :buffer-will-be-killed (cons t plist)))
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98872
diff changeset
494 (init-buf (current-buffer))
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98872
diff changeset
495 (init-point (point))
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98872
diff changeset
496 (init-buf-string (buffer-string))
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98872
diff changeset
497 export-buf-or-file)
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98872
diff changeset
498 ;; run hooks before exporting
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98872
diff changeset
499 (run-hooks 'org-publish-before-export-hook)
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98872
diff changeset
500 ;; export the possibly modified buffer
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98872
diff changeset
501 (setq export-buf-or-file
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98872
diff changeset
502 (funcall (intern (concat "org-export-as-" format))
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98872
diff changeset
503 (plist-get plist :headline-levels)
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98872
diff changeset
504 nil plist nil nil pub-dir))
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98872
diff changeset
505 (when (and (bufferp export-buf-or-file)
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98872
diff changeset
506 (buffer-live-p export-buf-or-file))
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98872
diff changeset
507 (set-buffer export-buf-or-file)
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98872
diff changeset
508 ;; run hooks after export and save export
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98872
diff changeset
509 (and (run-hooks 'org-publish-after-export-hook)
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98872
diff changeset
510 (if (buffer-modified-p) (save-buffer)))
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98872
diff changeset
511 (kill-buffer export-buf-or-file))
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98872
diff changeset
512 ;; maybe restore buffer's content
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98872
diff changeset
513 (set-buffer init-buf)
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98872
diff changeset
514 (when (buffer-modified-p init-buf)
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98872
diff changeset
515 (erase-buffer)
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98872
diff changeset
516 (insert init-buf-string)
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98872
diff changeset
517 (save-buffer)
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98872
diff changeset
518 (goto-char init-point))
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98872
diff changeset
519 (unless visiting
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98872
diff changeset
520 (kill-buffer init-buf))))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
521
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
522 (defun org-publish-org-to-latex (plist filename pub-dir)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
523 "Publish an org file to LaTeX.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
524 See `org-publish-org-to' to the list of arguments."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
525 (org-publish-org-to "latex" plist filename pub-dir))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
526
99139
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98872
diff changeset
527 (defun org-publish-org-to-pdf (plist filename pub-dir)
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98872
diff changeset
528 "Publish an org file to PDF (via LaTeX).
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98872
diff changeset
529 See `org-publish-org-to' to the list of arguments."
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98872
diff changeset
530 (org-publish-org-to "pdf" plist filename pub-dir))
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98872
diff changeset
531
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
532 (defun org-publish-org-to-html (plist filename pub-dir)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
533 "Publish an org file to HTML.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
534 See `org-publish-org-to' to the list of arguments."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
535 (org-publish-org-to "html" plist filename pub-dir))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
536
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
537 (defun org-publish-attachment (plist filename pub-dir)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
538 "Publish a file with no transformation of any kind.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
539 See `org-publish-org-to' to the list of arguments."
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99415
diff changeset
540 ;; make sure eshell/cp code is loaded
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94773
diff changeset
541 (unless (file-directory-p pub-dir)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94773
diff changeset
542 (make-directory pub-dir t))
99566
4114af8bda08 * org-publish.el (org-publish-attachment): Alow copy-file to
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
543 (copy-file filename pub-dir t))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
544
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
545 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
546 ;;; Publishing files, sets of files, and indices
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
547
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
548 (defun org-publish-file (filename &optional project)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
549 "Publish file FILENAME from PROJECT."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
550 (when (org-publish-needed-p filename)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
551 (let* ((project
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
552 (or project
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
553 (or (org-publish-get-project-from-filename filename)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
554 (if (y-or-n-p
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
555 (format "%s is not in a project. Re-read the list of projects files? "
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
556 (abbreviate-file-name filename)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
557 ;; If requested, re-initialize the list of projects files
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
558 (progn (org-publish-initialize-files-alist t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
559 (or (org-publish-get-project-from-filename filename)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
560 (error "File %s not part of any known project"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
561 (abbreviate-file-name filename))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
562 (error "Can't publish file outside of a project")))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
563 (project-plist (cdr project))
97027
adc2dffbdfc3 2008-07-25 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96975
diff changeset
564 (ftname (file-truename filename))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
565 (publishing-function
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
566 (or (plist-get project-plist :publishing-function)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
567 'org-publish-org-to-html))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
568 (base-dir (file-name-as-directory
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
569 (file-truename (plist-get project-plist :base-directory))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
570 (pub-dir (file-name-as-directory
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
571 (file-truename (plist-get project-plist :publishing-directory))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
572 tmp-pub-dir)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
573 (setq tmp-pub-dir
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
574 (file-name-directory
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
575 (concat pub-dir
97027
adc2dffbdfc3 2008-07-25 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96975
diff changeset
576 (and (string-match (regexp-quote base-dir) ftname)
adc2dffbdfc3 2008-07-25 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96975
diff changeset
577 (substring ftname (match-end 0))))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
578 (if (listp publishing-function)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
579 ;; allow chain of publishing functions
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
580 (mapc (lambda (f)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
581 (funcall f project-plist filename tmp-pub-dir))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
582 publishing-function)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
583 (funcall publishing-function project-plist filename tmp-pub-dir)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
584 (org-publish-update-timestamp filename)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
585
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
586 (defun org-publish-projects (projects)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
587 "Publish all files belonging to the PROJECTS alist.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
588 If :auto-index is set, publish the index too."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
589 (mapc
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
590 (lambda (project)
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94773
diff changeset
591 (let*
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94773
diff changeset
592 ((project-plist (cdr project))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94773
diff changeset
593 (exclude-regexp (plist-get project-plist :exclude))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94773
diff changeset
594 (index-p (plist-get project-plist :auto-index))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94773
diff changeset
595 (index-filename (or (plist-get project-plist :index-filename)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94773
diff changeset
596 "index.org"))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94773
diff changeset
597 (index-function (or (plist-get project-plist :index-function)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94773
diff changeset
598 'org-publish-org-index))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94773
diff changeset
599 (preparation-function (plist-get project-plist :preparation-function))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94773
diff changeset
600 (completion-function (plist-get project-plist :completion-function))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94773
diff changeset
601 (files (org-publish-get-base-files project exclude-regexp)) file)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
602 (when preparation-function (funcall preparation-function))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
603 (if index-p (funcall index-function project index-filename))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
604 (while (setq file (pop files))
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94773
diff changeset
605 (org-publish-file file project))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94773
diff changeset
606 (when completion-function (funcall completion-function))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
607 (org-publish-expand-projects projects)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
608
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
609 (defun org-publish-org-index (project &optional index-filename)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
610 "Create an index of pages in set defined by PROJECT.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
611 Optionally set the filename of the index with INDEX-FILENAME.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
612 Default for INDEX-FILENAME is 'index.org'."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
613 (let* ((project-plist (cdr project))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
614 (dir (file-name-as-directory
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
615 (plist-get project-plist :base-directory)))
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94773
diff changeset
616 (localdir (file-name-directory dir))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94773
diff changeset
617 (indent-str (make-string 2 ?\ ))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
618 (exclude-regexp (plist-get project-plist :exclude))
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94773
diff changeset
619 (files (nreverse (org-publish-get-base-files project exclude-regexp)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
620 (index-filename (concat dir (or index-filename "index.org")))
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94773
diff changeset
621 (index-title (or (plist-get project-plist :index-title)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94773
diff changeset
622 (concat "Index for project " (car project))))
96975
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96044
diff changeset
623 (index-style (or (plist-get project-plist :index-style)
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96044
diff changeset
624 'tree))
100267
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
625 (visiting (find-buffer-visiting index-filename))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
626 (ifn (file-name-nondirectory index-filename))
100267
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
627 file index-buffer)
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
628 (with-current-buffer (setq index-buffer
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
629 (or visiting (find-file index-filename)))
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
630 (erase-buffer)
99849
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99566
diff changeset
631 (insert (concat "#+TITLE: " index-title "\n\n"))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
632 (while (setq file (pop files))
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94773
diff changeset
633 (let ((fn (file-name-nondirectory file))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94773
diff changeset
634 (link (file-relative-name file dir))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94773
diff changeset
635 (oldlocal localdir))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
636 ;; index shouldn't index itself
100267
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
637 (unless (equal (file-truename index-filename)
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
638 (file-truename file))
96975
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96044
diff changeset
639 (if (eq index-style 'list)
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96044
diff changeset
640 (message "Generating list-style index for %s" index-title)
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96044
diff changeset
641 (message "Generating tree-style index for %s" index-title)
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96044
diff changeset
642 (setq localdir (concat (file-name-as-directory dir)
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96044
diff changeset
643 (file-name-directory link)))
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96044
diff changeset
644 (unless (string= localdir oldlocal)
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96044
diff changeset
645 (if (string= localdir dir)
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96044
diff changeset
646 (setq indent-str (make-string 2 ?\ ))
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96044
diff changeset
647 (let ((subdirs
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96044
diff changeset
648 (split-string
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96044
diff changeset
649 (directory-file-name
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96044
diff changeset
650 (file-name-directory
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96044
diff changeset
651 (file-relative-name localdir dir))) "/"))
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99415
diff changeset
652 (subdir "")
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99415
diff changeset
653 (old-subdirs (split-string
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99415
diff changeset
654 (file-relative-name oldlocal dir) "/")))
96975
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96044
diff changeset
655 (setq indent-str (make-string 2 ?\ ))
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99415
diff changeset
656 (while (string= (car old-subdirs) (car subdirs))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99415
diff changeset
657 (setq indent-str (concat indent-str (make-string 2 ?\ )))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99415
diff changeset
658 (pop old-subdirs)
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99415
diff changeset
659 (pop subdirs))
96975
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96044
diff changeset
660 (dolist (d subdirs)
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96044
diff changeset
661 (setq subdir (concat subdir d "/"))
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99415
diff changeset
662 (insert (concat indent-str " + " d "\n"))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99415
diff changeset
663 (setq indent-str (make-string
96975
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96044
diff changeset
664 (+ (length indent-str) 2) ?\ )))))))
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96044
diff changeset
665 ;; This is common to 'flat and 'tree
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94773
diff changeset
666 (insert (concat indent-str " + [[file:" link "]["
96975
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96044
diff changeset
667 (org-publish-find-title file)
100267
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
668 "]]\n")))))
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
669 (save-buffer))
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
670 (or visiting (kill-buffer index-buffer))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
671
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94773
diff changeset
672 (defun org-publish-find-title (file)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94773
diff changeset
673 "Find the title of file in project."
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99415
diff changeset
674 (let* ((visiting (find-buffer-visiting file))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99415
diff changeset
675 (buffer (or visiting (find-file-noselect file)))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99415
diff changeset
676 title)
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99415
diff changeset
677 (save-excursion
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99415
diff changeset
678 (set-buffer buffer)
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99415
diff changeset
679 (let* ((opt-plist (org-combine-plists (org-default-export-plist)
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99415
diff changeset
680 (org-infile-export-plist))))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99415
diff changeset
681 (setq title
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99415
diff changeset
682 (or (plist-get opt-plist :title)
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99415
diff changeset
683 (and (not
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99415
diff changeset
684 (plist-get opt-plist :skip-before-1st-heading))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99415
diff changeset
685 (org-export-grab-title-from-buffer))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99415
diff changeset
686 (file-name-nondirectory (file-name-sans-extension file))))))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99415
diff changeset
687 (unless visiting
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99415
diff changeset
688 (kill-buffer buffer))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99415
diff changeset
689 title))
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94773
diff changeset
690
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
691 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
692 ;;; Interactive publishing functions
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
693
99139
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98872
diff changeset
694 ;;;###autoload
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
695 (defalias 'org-publish-project 'org-publish)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
696
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
697 ;;;###autoload
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
698 (defun org-publish (project &optional force)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
699 "Publish PROJECT."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
700 (interactive "P")
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
701 (setq org-publish-initial-buffer (current-buffer))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
702 (save-window-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
703 (let* ((force current-prefix-arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
704 (org-publish-use-timestamps-flag
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
705 (if force nil org-publish-use-timestamps-flag)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
706 (org-publish-projects
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
707 (list (or project
99849
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99566
diff changeset
708 (assoc (org-ido-completing-read
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
709 "Publish project: "
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
710 org-publish-project-alist nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
711 org-publish-project-alist)))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
712
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
713 ;;;###autoload
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
714 (defun org-publish-all (&optional force)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
715 "Publish all projects.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
716 With prefix argument, force publish all files."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
717 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
718 (org-publish-initialize-files-alist)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
719 (save-window-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
720 (let ((org-publish-use-timestamps-flag
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
721 (if force nil org-publish-use-timestamps-flag)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
722 (org-publish-projects org-publish-project-alist))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
723
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
724 ;;;###autoload
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
725 (defun org-publish-current-file (&optional force)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
726 "Publish the current file.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
727 With prefix argument, force publish the file."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
728 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
729 (org-publish-initialize-files-alist)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
730 (save-window-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
731 (let ((org-publish-use-timestamps-flag
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
732 (if force nil org-publish-use-timestamps-flag)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
733 (org-publish-file (buffer-file-name)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
734
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
735 ;;;###autoload
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
736 (defun org-publish-current-project (&optional force)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
737 "Publish the project associated with the current file.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
738 With a prefix argument, force publishing of all files in
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
739 the project."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
740 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
741 (org-publish-initialize-files-alist)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
742 (save-window-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
743 (let ((project (org-publish-get-project-from-filename (buffer-file-name)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
744 (org-publish-use-timestamps-flag
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
745 (if force nil org-publish-use-timestamps-flag)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
746 (if (not project)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
747 (error "File %s is not part of any known project" (buffer-file-name)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
748 (org-publish project))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
749
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
750 (provide 'org-publish)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
751
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
752
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
753 ;; arch-tag: 72807f3c-8af0-4a6b-8dca-c3376eb25adb
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94773
diff changeset
754
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
755 ;;; org-publish.el ends here