org-e-latex: Change syntax for images attributes
[org-mode.git] / lisp / org-publish.el
blob2baee32d73e87fc95a2afdbd7cf6050da1447e6a
1 ;;; org-publish.el --- publish related org-mode files as a website
2 ;; Copyright (C) 2006-2012 Free Software Foundation, Inc.
4 ;; Author: David O'Toole <dto@gnu.org>
5 ;; Maintainer: Carsten Dominik <carsten DOT dominik AT gmail DOT com>
6 ;; Keywords: hypermedia, outlines, wp
8 ;; This file is part of GNU Emacs.
9 ;;
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
23 ;;; Commentary:
25 ;; This program allow configurable publishing of related sets of
26 ;; Org-mode files as a complete website.
28 ;; org-publish.el can do the following:
30 ;; + Publish all one's org-files to HTML or PDF
31 ;; + Upload HTML, images, attachments and other files to a web server
32 ;; + Exclude selected private pages from publishing
33 ;; + Publish a clickable sitemap of pages
34 ;; + Manage local timestamps for publishing only changed files
35 ;; + Accept plugin functions to extend range of publishable content
37 ;; Documentation for publishing is in the manual.
39 ;;; Code:
42 (eval-when-compile
43 (require 'cl))
44 (require 'org)
45 (require 'org-exp)
46 (require 'format-spec)
48 (eval-and-compile
49 (unless (fboundp 'declare-function)
50 (defmacro declare-function (fn file &optional arglist fileonly))))
52 (defvar org-publish-initial-buffer nil
53 "The buffer `org-publish' has been called from.")
55 (defvar org-publish-temp-files nil
56 "Temporary list of files to be published.")
58 ;; Here, so you find the variable right before it's used the first time:
59 (defvar org-publish-cache nil
60 "This will cache timestamps and titles for files in publishing projects.
61 Blocks could hash sha1 values here.")
63 (defgroup org-publish nil
64 "Options for publishing a set of Org-mode and related files."
65 :tag "Org Publishing"
66 :group 'org)
68 (defcustom org-publish-project-alist nil
69 "Association list to control publishing behavior.
70 Each element of the alist is a publishing 'project.' The CAR of
71 each element is a string, uniquely identifying the project. The
72 CDR of each element is in one of the following forms:
74 1. A well-formed property list with an even number of elements, alternating
75 keys and values, specifying parameters for the publishing process.
77 (:property value :property value ... )
79 2. A meta-project definition, specifying of a list of sub-projects:
81 (:components (\"project-1\" \"project-2\" ...))
83 When the CDR of an element of org-publish-project-alist is in
84 this second form, the elements of the list after :components are
85 taken to be components of the project, which group together files
86 requiring different publishing options. When you publish such a
87 project with \\[org-publish], the components all publish.
89 When a property is given a value in org-publish-project-alist, its
90 setting overrides the value of the corresponding user variable
91 \(if any) during publishing. However, options set within a file
92 override everything.
94 Most properties are optional, but some should always be set:
96 :base-directory Directory containing publishing source files
97 :base-extension Extension (without the dot!) of source files.
98 This can be a regular expression. If not given,
99 \"org\" will be used as default extension.
100 :publishing-directory Directory (possibly remote) where output
101 files will be published
103 The :exclude property may be used to prevent certain files from
104 being published. Its value may be a string or regexp matching
105 file names you don't want to be published.
107 The :include property may be used to include extra files. Its
108 value may be a list of filenames to include. The filenames are
109 considered relative to the base directory.
111 When both :include and :exclude properties are given values, the
112 exclusion step happens first.
114 One special property controls which back-end function to use for
115 publishing files in the project. This can be used to extend the
116 set of file types publishable by org-publish, as well as the set
117 of output formats.
119 :publishing-function Function to publish file. The default is
120 `org-publish-org-to-html', but other
121 values are possible. May also be a
122 list of functions, in which case
123 each function in the list is invoked
124 in turn.
126 Another property allows you to insert code that prepares a
127 project for publishing. For example, you could call GNU Make on a
128 certain makefile, to ensure published files are built up to date.
130 :preparation-function Function to be called before publishing
131 this project. This may also be a list
132 of functions.
133 :completion-function Function to be called after publishing
134 this project. This may also be a list
135 of functions.
137 Some properties control details of the Org publishing process,
138 and are equivalent to the corresponding user variables listed in
139 the right column. See the documentation for those variables to
140 learn more about their use and default values.
142 :language `org-export-default-language'
143 :headline-levels `org-export-headline-levels'
144 :section-numbers `org-export-with-section-numbers'
145 :table-of-contents `org-export-with-toc'
146 :emphasize `org-export-with-emphasize'
147 :sub-superscript `org-export-with-sub-superscripts'
148 :TeX-macros `org-export-with-TeX-macros'
149 :fixed-width `org-export-with-fixed-width'
150 :tables `org-export-with-tables'
151 :table-auto-headline `org-export-highlight-first-table-line'
152 :style `org-export-html-style'
153 :convert-org-links `org-export-html-link-org-files-as-html'
154 :inline-images `org-export-html-inline-images'
155 :expand-quoted-html `org-export-html-expand'
156 :timestamp `org-export-html-with-timestamp'
157 :publishing-directory `org-export-publishing-directory'
158 :html-preamble `org-export-html-preamble'
159 :html-postamble `org-export-html-postamble'
160 :author `user-full-name'
161 :email `user-mail-address'
163 The following properties may be used to control publishing of a
164 sitemap of files or summary page for a given project.
166 :auto-sitemap Whether to publish a sitemap during
167 `org-publish-current-project' or `org-publish-all'.
168 :sitemap-filename Filename for output of sitemap. Defaults
169 to 'sitemap.org' (which becomes 'sitemap.html').
170 :sitemap-title Title of sitemap page. Defaults to name of file.
171 :sitemap-function Plugin function to use for generation of sitemap.
172 Defaults to `org-publish-org-sitemap', which
173 generates a plain list of links to all files
174 in the project.
175 :sitemap-style Can be `list' (sitemap is just an itemized list
176 of the titles of the files involved) or
177 `tree' (the directory structure of the source
178 files is reflected in the sitemap). Defaults to
179 `tree'.
180 :sitemap-sans-extension Remove extension from sitemap's
181 filenames. Useful to have cool
182 URIs (see
183 http://www.w3.org/Provider/Style/URI).
184 Defaults to nil.
186 If you create a sitemap file, adjust the sorting like this:
188 :sitemap-sort-folders Where folders should appear in the sitemap.
189 Set this to `first' (default) or `last' to
190 display folders first or last, respectively.
191 Any other value will mix files and folders.
192 :sitemap-sort-files The site map is normally sorted alphabetically.
193 You can change this behaviour setting this to
194 `chronologically', `anti-chronologically' or nil.
195 :sitemap-ignore-case Should sorting be case-sensitive? Default nil.
197 The following properties control the creation of a concept index.
199 :makeindex Create a concept index.
201 Other properties affecting publication.
203 :body-only Set this to 't' to publish only the body of the
204 documents, excluding everything outside and
205 including the <body> tags in HTML, or
206 \begin{document}..\end{document} in LaTeX."
207 :group 'org-publish
208 :type 'alist)
210 (defcustom org-publish-use-timestamps-flag t
211 "Non-nil means use timestamp checking to publish only changed files.
212 When nil, do no timestamp checking and always publish all files."
213 :group 'org-publish
214 :type 'boolean)
216 (defcustom org-publish-timestamp-directory (convert-standard-filename
217 "~/.org-timestamps/")
218 "Name of directory in which to store publishing timestamps."
219 :group 'org-publish
220 :type 'directory)
222 (defcustom org-publish-list-skipped-files t
223 "Non-nil means show message about files *not* published."
224 :group 'org-publish
225 :type 'boolean)
227 (defcustom org-publish-before-export-hook nil
228 "Hook run before export on the Org file.
229 The hook may modify the file in arbitrary ways before publishing happens.
230 The original version of the buffer will be restored after publishing."
231 :group 'org-publish
232 :type 'hook)
234 (defcustom org-publish-after-export-hook nil
235 "Hook run after export on the exported buffer.
236 Any changes made by this hook will be saved."
237 :group 'org-publish
238 :type 'hook)
240 (defcustom org-publish-sitemap-sort-files 'alphabetically
241 "How sitemaps files should be sorted by default?
242 Possible values are `alphabetically', `chronologically', `anti-chronologically' and nil.
243 If `alphabetically', files will be sorted alphabetically.
244 If `chronologically', files will be sorted with older modification time first.
245 If `anti-chronologically', files will be sorted with newer modification time first.
246 nil won't sort files.
248 You can overwrite this default per project in your
249 `org-publish-project-alist', using `:sitemap-sort-files'."
250 :group 'org-publish
251 :version "24.1"
252 :type 'symbol)
254 (defcustom org-publish-sitemap-sort-folders 'first
255 "A symbol, denoting if folders are sorted first in sitemaps.
256 Possible values are `first', `last', and nil.
257 If `first', folders will be sorted before files.
258 If `last', folders are sorted to the end after the files.
259 Any other value will not mix files and folders.
261 You can overwrite this default per project in your
262 `org-publish-project-alist', using `:sitemap-sort-folders'."
263 :group 'org-publish
264 :version "24.1"
265 :type 'symbol)
267 (defcustom org-publish-sitemap-sort-ignore-case nil
268 "Sort sitemaps case insensitively by default?
270 You can overwrite this default per project in your
271 `org-publish-project-alist', using `:sitemap-ignore-case'."
272 :group 'org-publish
273 :version "24.1"
274 :type 'boolean)
276 (defcustom org-publish-sitemap-date-format "%Y-%m-%d"
277 "Format for `format-time-string' which is used to print a date
278 in the sitemap."
279 :group 'org-publish
280 :version "24.1"
281 :type 'string)
283 (defcustom org-publish-sitemap-file-entry-format "%t"
284 "How a sitemap file entry is formatted.
285 You could use brackets to delimit on what part the link will be.
287 %t is the title.
288 %a is the author.
289 %d is the date formatted using `org-publish-sitemap-date-format'."
290 :group 'org-publish
291 :version "24.1"
292 :type 'string)
295 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
296 ;;; Sanitize-plist (FIXME why?)
298 (defun org-publish-sanitize-plist (plist)
299 ;; FIXME document
300 (mapcar (lambda (x)
301 (or (cdr (assq x '((:index-filename . :sitemap-filename)
302 (:index-title . :sitemap-title)
303 (:index-function . :sitemap-function)
304 (:index-style . :sitemap-style)
305 (:auto-index . :auto-sitemap))))
307 plist))
309 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
310 ;;; Timestamp-related functions
312 (defun org-publish-timestamp-filename (filename &optional pub-dir pub-func)
313 "Return path to timestamp file for filename FILENAME."
314 (setq filename (concat filename "::" (or pub-dir "") "::"
315 (format "%s" (or pub-func ""))))
316 (concat "X" (if (fboundp 'sha1) (sha1 filename) (md5 filename))))
318 (defun org-publish-needed-p (filename &optional pub-dir pub-func true-pub-dir base-dir)
319 "Return t if FILENAME should be published in PUB-DIR using PUB-FUNC.
320 TRUE-PUB-DIR is where the file will truly end up. Currently we are not using
321 this - maybe it can eventually be used to check if the file is present at
322 the target location, and how old it is. Right now we cannot do this, because
323 we do not know under what file name the file will be stored - the publishing
324 function can still decide about that independently."
325 (let ((rtn
326 (if org-publish-use-timestamps-flag
327 (org-publish-cache-file-needs-publishing
328 filename pub-dir pub-func base-dir)
329 ;; don't use timestamps, always return t
330 t)))
331 (if rtn
332 (message "Publishing file %s using `%s'" filename pub-func)
333 (when org-publish-list-skipped-files
334 (message "Skipping unmodified file %s" filename)))
335 rtn))
337 (defun org-publish-update-timestamp (filename &optional pub-dir pub-func base-dir)
338 "Update publishing timestamp for file FILENAME.
339 If there is no timestamp, create one."
340 (let ((key (org-publish-timestamp-filename filename pub-dir pub-func))
341 (stamp (org-publish-cache-ctime-of-src filename)))
342 (org-publish-cache-set key stamp)))
344 (defun org-publish-remove-all-timestamps ()
345 "Remove all files in the timestamp directory."
346 (let ((dir org-publish-timestamp-directory)
347 files)
348 (when (and (file-exists-p dir)
349 (file-directory-p dir))
350 (mapc 'delete-file (directory-files dir 'full "[^.]\\'"))
351 (org-publish-reset-cache))))
354 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
355 ;;; Compatibility aliases
357 ;; Delete-dups is not in Emacs <22
358 (if (fboundp 'delete-dups)
359 (defalias 'org-publish-delete-dups 'delete-dups)
360 (defun org-publish-delete-dups (list)
361 "Destructively remove `equal' duplicates from LIST.
362 Store the result in LIST and return it. LIST must be a proper list.
363 Of several `equal' occurrences of an element in LIST, the first
364 one is kept.
366 This is a compatibility function for Emacsen without `delete-dups'."
367 ;; Code from `subr.el' in Emacs 22:
368 (let ((tail list))
369 (while tail
370 (setcdr tail (delete (car tail) (cdr tail)))
371 (setq tail (cdr tail))))
372 list))
374 (declare-function org-publish-delete-dups "org-publish" (list))
375 (declare-function find-lisp-find-files "find-lisp" (directory regexp))
376 (declare-function org-pop-to-buffer-same-window
377 "org-compat" (&optional buffer-or-name norecord label))
379 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
380 ;;; Getting project information out of org-publish-project-alist
382 (defun org-publish-expand-projects (projects-alist)
383 "Expand projects in PROJECTS-ALIST.
384 This splices all the components into the list."
385 (let ((rest projects-alist) rtn p components)
386 (while (setq p (pop rest))
387 (if (setq components (plist-get (cdr p) :components))
388 (setq rest (append
389 (mapcar (lambda (x) (assoc x org-publish-project-alist))
390 components)
391 rest))
392 (push p rtn)))
393 (nreverse (org-publish-delete-dups (delq nil rtn)))))
395 (defvar org-sitemap-sort-files)
396 (defvar org-sitemap-sort-folders)
397 (defvar org-sitemap-ignore-case)
398 (defvar org-sitemap-requested)
399 (defvar org-sitemap-date-format)
400 (defvar org-sitemap-file-entry-format)
401 (defun org-publish-compare-directory-files (a b)
402 "Predicate for `sort', that sorts folders and files for sitemap."
403 (let ((retval t))
404 (when (or org-sitemap-sort-files org-sitemap-sort-folders)
405 ;; First we sort files:
406 (when org-sitemap-sort-files
407 (cond ((equal org-sitemap-sort-files 'alphabetically)
408 (let* ((adir (file-directory-p a))
409 (aorg (and (string-match "\\.org$" a) (not adir)))
410 (bdir (file-directory-p b))
411 (borg (and (string-match "\\.org$" b) (not bdir)))
412 (A (if aorg
413 (concat (file-name-directory a)
414 (org-publish-find-title a)) a))
415 (B (if borg
416 (concat (file-name-directory b)
417 (org-publish-find-title b)) b)))
418 (setq retval (if org-sitemap-ignore-case
419 (not (string-lessp (upcase B) (upcase A)))
420 (not (string-lessp B A))))))
421 ((or (equal org-sitemap-sort-files 'chronologically)
422 (equal org-sitemap-sort-files 'anti-chronologically))
423 (let* ((adate (org-publish-find-date a))
424 (bdate (org-publish-find-date b))
425 (A (+ (lsh (car adate) 16) (cadr adate)))
426 (B (+ (lsh (car bdate) 16) (cadr bdate))))
427 (setq retval (if (equal org-sitemap-sort-files 'chronologically)
428 (<= A B)
429 (>= A B)))))))
430 ;; Directory-wise wins:
431 (when org-sitemap-sort-folders
432 ;; a is directory, b not:
433 (cond
434 ((and (file-directory-p a) (not (file-directory-p b)))
435 (setq retval (equal org-sitemap-sort-folders 'first)))
436 ;; a is not a directory, but b is:
437 ((and (not (file-directory-p a)) (file-directory-p b))
438 (setq retval (equal org-sitemap-sort-folders 'last))))))
439 retval))
441 (defun org-publish-get-base-files-1 (base-dir &optional recurse match skip-file skip-dir)
442 "Set `org-publish-temp-files' with files from BASE-DIR directory.
443 If RECURSE is non-nil, check BASE-DIR recursively. If MATCH is
444 non-nil, restrict this list to the files matching the regexp
445 MATCH. If SKIP-FILE is non-nil, skip file matching the regexp
446 SKIP-FILE. If SKIP-DIR is non-nil, don't check directories
447 matching the regexp SKIP-DIR when recursing through BASE-DIR."
448 (mapc (lambda (f)
449 (let ((fd-p (file-directory-p f))
450 (fnd (file-name-nondirectory f)))
451 (if (and fd-p recurse
452 (not (string-match "^\\.+$" fnd))
453 (if skip-dir (not (string-match skip-dir fnd)) t))
454 (org-publish-get-base-files-1 f recurse match skip-file skip-dir)
455 (unless (or fd-p ;; this is a directory
456 (and skip-file (string-match skip-file fnd))
457 (not (file-exists-p (file-truename f)))
458 (not (string-match match fnd)))
460 (pushnew f org-publish-temp-files)))))
461 (if org-sitemap-requested
462 (sort (directory-files base-dir t (unless recurse match))
463 'org-publish-compare-directory-files)
464 (directory-files base-dir t (unless recurse match)))))
466 (defun org-publish-get-base-files (project &optional exclude-regexp)
467 "Return a list of all files in PROJECT.
468 If EXCLUDE-REGEXP is set, this will be used to filter out
469 matching filenames."
470 (let* ((project-plist (cdr project))
471 (base-dir (file-name-as-directory
472 (plist-get project-plist :base-directory)))
473 (include-list (plist-get project-plist :include))
474 (recurse (plist-get project-plist :recursive))
475 (extension (or (plist-get project-plist :base-extension) "org"))
476 ;; sitemap-... variables are dynamically scoped for
477 ;; org-publish-compare-directory-files:
478 (org-sitemap-requested
479 (plist-get project-plist :auto-sitemap))
480 (sitemap-filename
481 (or (plist-get project-plist :sitemap-filename)
482 "sitemap.org"))
483 (org-sitemap-sort-folders
484 (if (plist-member project-plist :sitemap-sort-folders)
485 (plist-get project-plist :sitemap-sort-folders)
486 org-publish-sitemap-sort-folders))
487 (org-sitemap-sort-files
488 (cond ((plist-member project-plist :sitemap-sort-files)
489 (plist-get project-plist :sitemap-sort-files))
490 ;; For backward compatibility:
491 ((plist-member project-plist :sitemap-alphabetically)
492 (if (plist-get project-plist :sitemap-alphabetically)
493 'alphabetically nil))
494 (t org-publish-sitemap-sort-files)))
495 (org-sitemap-ignore-case
496 (if (plist-member project-plist :sitemap-ignore-case)
497 (plist-get project-plist :sitemap-ignore-case)
498 org-publish-sitemap-sort-ignore-case))
499 (match (if (eq extension 'any)
500 "^[^\\.]"
501 (concat "^[^\\.].*\\.\\(" extension "\\)$"))))
502 ;; Make sure `org-sitemap-sort-folders' has an accepted value
503 (unless (memq org-sitemap-sort-folders '(first last))
504 (setq org-sitemap-sort-folders nil))
506 (setq org-publish-temp-files nil)
507 (if org-sitemap-requested
508 (pushnew (expand-file-name (concat base-dir sitemap-filename))
509 org-publish-temp-files))
510 (org-publish-get-base-files-1 base-dir recurse match
511 ;; FIXME distinguish exclude regexp
512 ;; for skip-file and skip-dir?
513 exclude-regexp exclude-regexp)
514 (mapc (lambda (f)
515 (pushnew
516 (expand-file-name (concat base-dir f))
517 org-publish-temp-files))
518 include-list)
519 org-publish-temp-files))
521 (defun org-publish-get-project-from-filename (filename &optional up)
522 "Return the project that FILENAME belongs to."
523 (let* ((filename (expand-file-name filename))
524 project-name)
526 (catch 'p-found
527 (dolist (prj org-publish-project-alist)
528 (unless (plist-get (cdr prj) :components)
529 ;; [[info:org:Selecting%20files]] shows how this is supposed to work:
530 (let* ((r (plist-get (cdr prj) :recursive))
531 (b (expand-file-name (file-name-as-directory
532 (plist-get (cdr prj) :base-directory))))
533 (x (or (plist-get (cdr prj) :base-extension) "org"))
534 (e (plist-get (cdr prj) :exclude))
535 (i (plist-get (cdr prj) :include))
536 (xm (concat "^" b (if r ".+" "[^/]+") "\\.\\(" x "\\)$")))
537 (when
539 (and
540 i (member filename
541 (mapcar
542 (lambda (file) (expand-file-name file b))
543 i)))
544 (and
545 (not (and e (string-match e filename)))
546 (string-match xm filename)))
547 (setq project-name (car prj))
548 (throw 'p-found project-name))))))
549 (when up
550 (dolist (prj org-publish-project-alist)
551 (if (member project-name (plist-get (cdr prj) :components))
552 (setq project-name (car prj)))))
553 (assoc project-name org-publish-project-alist)))
555 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
556 ;;; Pluggable publishing back-end functions
558 (defun org-publish-org-to (format plist filename pub-dir)
559 "Publish an org file to FORMAT.
560 PLIST is the property list for the given project.
561 FILENAME is the filename of the org file to be published.
562 PUB-DIR is the publishing directory."
563 (require 'org)
564 (unless (file-exists-p pub-dir)
565 (make-directory pub-dir t))
566 (let ((visiting (find-buffer-visiting filename)))
567 (save-excursion
568 (org-pop-to-buffer-same-window (or visiting (find-file filename)))
569 (let* ((plist (cons :buffer-will-be-killed (cons t plist)))
570 (init-buf (current-buffer))
571 (init-point (point))
572 (init-buf-string (buffer-string))
573 export-buf-or-file)
574 ;; run hooks before exporting
575 (run-hooks 'org-publish-before-export-hook)
576 ;; export the possibly modified buffer
577 (setq export-buf-or-file
578 (funcall (intern (concat "org-export-as-" format))
579 (plist-get plist :headline-levels)
580 nil plist nil
581 (plist-get plist :body-only)
582 pub-dir))
583 (when (and (bufferp export-buf-or-file)
584 (buffer-live-p export-buf-or-file))
585 (set-buffer export-buf-or-file)
586 ;; run hooks after export and save export
587 (progn (run-hooks 'org-publish-after-export-hook)
588 (if (buffer-modified-p) (save-buffer)))
589 (kill-buffer export-buf-or-file))
590 ;; maybe restore buffer's content
591 (set-buffer init-buf)
592 (when (buffer-modified-p init-buf)
593 (erase-buffer)
594 (insert init-buf-string)
595 (save-buffer)
596 (goto-char init-point))
597 (unless visiting
598 (kill-buffer init-buf))))))
600 (defmacro org-publish-with-aux-preprocess-maybe (&rest body)
601 "Execute BODY with a modified hook to preprocess for index."
602 `(let ((org-export-preprocess-after-headline-targets-hook
603 (if (plist-get project-plist :makeindex)
604 (cons 'org-publish-aux-preprocess
605 org-export-preprocess-after-headline-targets-hook)
606 org-export-preprocess-after-headline-targets-hook)))
607 ,@body))
608 (def-edebug-spec org-publish-with-aux-preprocess-maybe (body))
610 (defvar project-plist)
611 (defun org-publish-org-to-latex (plist filename pub-dir)
612 "Publish an org file to LaTeX.
613 See `org-publish-org-to' to the list of arguments."
614 (org-publish-with-aux-preprocess-maybe
615 (org-publish-org-to "latex" plist filename pub-dir)))
617 (defun org-publish-org-to-pdf (plist filename pub-dir)
618 "Publish an org file to PDF (via LaTeX).
619 See `org-publish-org-to' to the list of arguments."
620 (org-publish-with-aux-preprocess-maybe
621 (org-publish-org-to "pdf" plist filename pub-dir)))
623 (defun org-publish-org-to-html (plist filename pub-dir)
624 "Publish an org file to HTML.
625 See `org-publish-org-to' to the list of arguments."
626 (org-publish-with-aux-preprocess-maybe
627 (org-publish-org-to "html" plist filename pub-dir)))
629 (defun org-publish-org-to-org (plist filename pub-dir)
630 "Publish an org file to HTML.
631 See `org-publish-org-to' to the list of arguments."
632 (org-publish-org-to "org" plist filename pub-dir))
634 (defun org-publish-org-to-ascii (plist filename pub-dir)
635 "Publish an org file to ASCII.
636 See `org-publish-org-to' to the list of arguments."
637 (org-publish-with-aux-preprocess-maybe
638 (org-publish-org-to "ascii" plist filename pub-dir)))
640 (defun org-publish-org-to-latin1 (plist filename pub-dir)
641 "Publish an org file to Latin-1.
642 See `org-publish-org-to' to the list of arguments."
643 (org-publish-with-aux-preprocess-maybe
644 (org-publish-org-to "latin1" plist filename pub-dir)))
646 (defun org-publish-org-to-utf8 (plist filename pub-dir)
647 "Publish an org file to UTF-8.
648 See `org-publish-org-to' to the list of arguments."
649 (org-publish-with-aux-preprocess-maybe
650 (org-publish-org-to "utf8" plist filename pub-dir)))
652 (defun org-publish-org-to-taskjuggler (plist filename pub-dir)
653 "Publish an org file to TaskJuggler.
654 See `org-publish-org-to' to the list of arguments."
655 (org-publish-with-aux-preprocess-maybe
656 (org-publish-org-to "taskjuggler" plist filename pub-dir)))
658 (defun org-publish-attachment (plist filename pub-dir)
659 "Publish a file with no transformation of any kind.
660 See `org-publish-org-to' to the list of arguments."
661 ;; make sure eshell/cp code is loaded
662 (unless (file-directory-p pub-dir)
663 (make-directory pub-dir t))
664 (or (equal (expand-file-name (file-name-directory filename))
665 (file-name-as-directory (expand-file-name pub-dir)))
666 (copy-file filename
667 (expand-file-name (file-name-nondirectory filename) pub-dir)
668 t)))
670 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
671 ;;; Publishing files, sets of files, and indices
673 (defun org-publish-file (filename &optional project no-cache)
674 "Publish file FILENAME from PROJECT.
675 If NO-CACHE is not nil, do not initialize org-publish-cache and
676 write it to disk. This is needed, since this function is used to
677 publish single files, when entire projects are published.
678 See `org-publish-projects'."
679 (let* ((project
680 (or project
681 (or (org-publish-get-project-from-filename filename)
682 (error "File %s not part of any known project"
683 (abbreviate-file-name filename)))))
684 (project-plist (cdr project))
685 (ftname (expand-file-name filename))
686 (publishing-function
687 (or (plist-get project-plist :publishing-function)
688 'org-publish-org-to-html))
689 (base-dir
690 (file-name-as-directory
691 (expand-file-name
692 (or (plist-get project-plist :base-directory)
693 (error "Project %s does not have :base-directory defined"
694 (car project))))))
695 (pub-dir
696 (file-name-as-directory
697 (file-truename
698 (or (eval (plist-get project-plist :publishing-directory))
699 (error "Project %s does not have :publishing-directory defined"
700 (car project))))))
701 tmp-pub-dir)
703 (unless no-cache
704 (org-publish-initialize-cache (car project)))
706 (setq tmp-pub-dir
707 (file-name-directory
708 (concat pub-dir
709 (and (string-match (regexp-quote base-dir) ftname)
710 (substring ftname (match-end 0))))))
711 (if (listp publishing-function)
712 ;; allow chain of publishing functions
713 (mapc (lambda (f)
714 (when (org-publish-needed-p filename pub-dir f tmp-pub-dir base-dir)
715 (funcall f project-plist filename tmp-pub-dir)
716 (org-publish-update-timestamp filename pub-dir f base-dir)))
717 publishing-function)
718 (when (org-publish-needed-p filename pub-dir publishing-function tmp-pub-dir base-dir)
719 (funcall publishing-function project-plist filename tmp-pub-dir)
720 (org-publish-update-timestamp
721 filename pub-dir publishing-function base-dir)))
722 (unless no-cache (org-publish-write-cache-file))))
724 (defun org-publish-projects (projects)
725 "Publish all files belonging to the PROJECTS alist.
726 If :auto-sitemap is set, publish the sitemap too.
727 If :makeindex is set, also produce a file theindex.org."
728 (mapc
729 (lambda (project)
730 ;; Each project uses its own cache file:
731 (org-publish-initialize-cache (car project))
732 (let*
733 ((project-plist (cdr project))
734 (exclude-regexp (plist-get project-plist :exclude))
735 (sitemap-p (plist-get project-plist :auto-sitemap))
736 (sitemap-filename (or (plist-get project-plist :sitemap-filename)
737 "sitemap.org"))
738 (sitemap-function (or (plist-get project-plist :sitemap-function)
739 'org-publish-org-sitemap))
740 (org-sitemap-date-format (or (plist-get project-plist :sitemap-date-format)
741 org-publish-sitemap-date-format))
742 (org-sitemap-file-entry-format (or (plist-get project-plist :sitemap-file-entry-format)
743 org-publish-sitemap-file-entry-format))
744 (preparation-function (plist-get project-plist :preparation-function))
745 (completion-function (plist-get project-plist :completion-function))
746 (files (org-publish-get-base-files project exclude-regexp)) file)
747 (when preparation-function (run-hooks 'preparation-function))
748 (if sitemap-p (funcall sitemap-function project sitemap-filename))
749 (while (setq file (pop files))
750 (org-publish-file file project t))
751 (when (plist-get project-plist :makeindex)
752 (org-publish-index-generate-theindex
753 (plist-get project-plist :base-directory))
754 (org-publish-file (expand-file-name
755 "theindex.org"
756 (plist-get project-plist :base-directory))
757 project t))
758 (when completion-function (run-hooks 'completion-function))
759 (org-publish-write-cache-file)))
760 (org-publish-expand-projects projects)))
762 (defun org-publish-org-sitemap (project &optional sitemap-filename)
763 "Create a sitemap of pages in set defined by PROJECT.
764 Optionally set the filename of the sitemap with SITEMAP-FILENAME.
765 Default for SITEMAP-FILENAME is 'sitemap.org'."
766 (let* ((project-plist (cdr project))
767 (dir (file-name-as-directory
768 (plist-get project-plist :base-directory)))
769 (localdir (file-name-directory dir))
770 (indent-str (make-string 2 ?\ ))
771 (exclude-regexp (plist-get project-plist :exclude))
772 (files (nreverse (org-publish-get-base-files project exclude-regexp)))
773 (sitemap-filename (concat dir (or sitemap-filename "sitemap.org")))
774 (sitemap-title (or (plist-get project-plist :sitemap-title)
775 (concat "Sitemap for project " (car project))))
776 (sitemap-style (or (plist-get project-plist :sitemap-style)
777 'tree))
778 (sitemap-sans-extension (plist-get project-plist :sitemap-sans-extension))
779 (visiting (find-buffer-visiting sitemap-filename))
780 (ifn (file-name-nondirectory sitemap-filename))
781 file sitemap-buffer)
782 (with-current-buffer (setq sitemap-buffer
783 (or visiting (find-file sitemap-filename)))
784 (erase-buffer)
785 (insert (concat "#+TITLE: " sitemap-title "\n\n"))
786 (while (setq file (pop files))
787 (let ((fn (file-name-nondirectory file))
788 (link (file-relative-name file dir))
789 (oldlocal localdir))
790 (when sitemap-sans-extension
791 (setq link (file-name-sans-extension link)))
792 ;; sitemap shouldn't list itself
793 (unless (equal (file-truename sitemap-filename)
794 (file-truename file))
795 (if (eq sitemap-style 'list)
796 (message "Generating list-style sitemap for %s" sitemap-title)
797 (message "Generating tree-style sitemap for %s" sitemap-title)
798 (setq localdir (concat (file-name-as-directory dir)
799 (file-name-directory link)))
800 (unless (string= localdir oldlocal)
801 (if (string= localdir dir)
802 (setq indent-str (make-string 2 ?\ ))
803 (let ((subdirs
804 (split-string
805 (directory-file-name
806 (file-name-directory
807 (file-relative-name localdir dir))) "/"))
808 (subdir "")
809 (old-subdirs (split-string
810 (file-relative-name oldlocal dir) "/")))
811 (setq indent-str (make-string 2 ?\ ))
812 (while (string= (car old-subdirs) (car subdirs))
813 (setq indent-str (concat indent-str (make-string 2 ?\ )))
814 (pop old-subdirs)
815 (pop subdirs))
816 (dolist (d subdirs)
817 (setq subdir (concat subdir d "/"))
818 (insert (concat indent-str " + " d "\n"))
819 (setq indent-str (make-string
820 (+ (length indent-str) 2) ?\ )))))))
821 ;; This is common to 'flat and 'tree
822 (let ((entry
823 (org-publish-format-file-entry org-sitemap-file-entry-format
824 file project-plist))
825 (regexp "\\(.*\\)\\[\\([^][]+\\)\\]\\(.*\\)"))
826 (cond ((string-match-p regexp entry)
827 (string-match regexp entry)
828 (insert (concat indent-str " + " (match-string 1 entry)
829 "[[file:" link "]["
830 (match-string 2 entry)
831 "]]" (match-string 3 entry) "\n")))
833 (insert (concat indent-str " + [[file:" link "]["
834 entry
835 "]]\n"))))))))
836 (save-buffer))
837 (or visiting (kill-buffer sitemap-buffer))))
839 (defun org-publish-format-file-entry (fmt file project-plist)
840 (format-spec fmt
841 `((?t . ,(org-publish-find-title file t))
842 (?d . ,(format-time-string org-sitemap-date-format
843 (org-publish-find-date file)))
844 (?a . ,(or (plist-get project-plist :author) user-full-name)))))
846 (defun org-publish-find-title (file &optional reset)
847 "Find the title of FILE in project."
849 (and (not reset) (org-publish-cache-get-file-property file :title nil t))
850 (let* ((visiting (find-buffer-visiting file))
851 (buffer (or visiting (find-file-noselect file)))
852 title)
853 (with-current-buffer buffer
854 (let* ((opt-plist (org-combine-plists (org-default-export-plist)
855 (org-infile-export-plist))))
856 (setq title
857 (or (plist-get opt-plist :title)
858 (and (not
859 (plist-get opt-plist :skip-before-1st-heading))
860 (org-export-grab-title-from-buffer))
861 (file-name-nondirectory (file-name-sans-extension file))))))
862 (unless visiting
863 (kill-buffer buffer))
864 (org-publish-cache-set-file-property file :title title)
865 title)))
867 (defun org-publish-find-date (file)
868 "Find the date of FILE in project.
869 If FILE provides a #+date keyword use it else use the file
870 system's modification time.
872 It returns time in `current-time' format."
873 (let ((visiting (find-buffer-visiting file)))
874 (save-excursion
875 (org-pop-to-buffer-same-window (or visiting (find-file-noselect file nil t)))
876 (let* ((plist (org-infile-export-plist))
877 (date (plist-get plist :date)))
878 (unless visiting
879 (kill-buffer (current-buffer)))
880 (if date
881 (org-time-string-to-time date)
882 (when (file-exists-p file)
883 (nth 5 (file-attributes file))))))))
885 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
886 ;;; Interactive publishing functions
888 ;;;###autoload
889 (defalias 'org-publish-project 'org-publish)
891 ;;;###autoload
892 (defun org-publish (project &optional force)
893 "Publish PROJECT."
894 (interactive
895 (list
896 (assoc (org-icompleting-read
897 "Publish project: "
898 org-publish-project-alist nil t)
899 org-publish-project-alist)
900 current-prefix-arg))
901 (setq org-publish-initial-buffer (current-buffer))
902 (save-window-excursion
903 (let* ((org-publish-use-timestamps-flag
904 (if force nil org-publish-use-timestamps-flag)))
905 (org-publish-projects
906 (if (stringp project)
907 ;; If this function is called in batch mode,
908 ;; project is still a string here.
909 (list (assoc project org-publish-project-alist))
910 (list project))))))
912 ;;;###autoload
913 (defun org-publish-all (&optional force)
914 "Publish all projects.
915 With prefix argument, remove all files in the timestamp
916 directory and force publishing all files."
917 (interactive "P")
918 (when force
919 (org-publish-remove-all-timestamps))
920 (save-window-excursion
921 (let ((org-publish-use-timestamps-flag
922 (if force nil org-publish-use-timestamps-flag)))
923 (org-publish-projects org-publish-project-alist))))
925 ;;;###autoload
926 (defun org-publish-current-file (&optional force)
927 "Publish the current file.
928 With prefix argument, force publish the file."
929 (interactive "P")
930 (save-window-excursion
931 (let ((org-publish-use-timestamps-flag
932 (if force nil org-publish-use-timestamps-flag)))
933 (org-publish-file (buffer-file-name)))))
935 ;;;###autoload
936 (defun org-publish-current-project (&optional force)
937 "Publish the project associated with the current file.
938 With a prefix argument, force publishing of all files in
939 the project."
940 (interactive "P")
941 (save-window-excursion
942 (let ((project (org-publish-get-project-from-filename (buffer-file-name) 'up))
943 (org-publish-use-timestamps-flag
944 (if force nil org-publish-use-timestamps-flag)))
945 (if (not project)
946 (error "File %s is not part of any known project" (buffer-file-name)))
947 ;; FIXME: force is not used here?
948 (org-publish project))))
951 ;;; Index generation
953 (defun org-publish-aux-preprocess ()
954 "Find index entries and write them to an .orgx file."
955 (let ((case-fold-search t)
956 entry index target)
957 (goto-char (point-min))
958 (while
959 (and
960 (re-search-forward "^[ \t]*#\\+index:[ \t]*\\(.*?\\)[ \t]*$" nil t)
961 (> (match-end 1) (match-beginning 1)))
962 (setq entry (match-string 1))
963 (when (eq org-export-current-backend 'latex)
964 (replace-match (format "\\index{%s}" entry) t t))
965 (save-excursion
966 (ignore-errors (org-back-to-heading t))
967 (setq target (get-text-property (point) 'target))
968 (setq target (or (cdr (assoc target org-export-preferred-target-alist))
969 (cdr (assoc target org-export-id-target-alist))
970 target ""))
971 (push (cons entry target) index)))
972 (with-temp-file
973 (concat
974 (file-name-directory org-current-export-file) "."
975 (file-name-sans-extension
976 (file-name-nondirectory org-current-export-file)) ".orgx")
977 (dolist (entry (nreverse index))
978 (insert (format "INDEX: (%s) %s\n" (cdr entry) (car entry)))))))
980 (defun org-publish-index-generate-theindex (directory)
981 "Generate the index from all .orgx files in DIRECTORY."
982 (require 'find-lisp)
983 (let* ((fulldir (file-name-as-directory
984 (expand-file-name directory)))
985 (full-files (find-lisp-find-files directory "\\.orgx\\'"))
986 (re (concat "\\`" fulldir))
987 (files (mapcar (lambda (f) (if (string-match re f)
988 (substring f (match-end 0))
990 full-files))
991 (default-directory directory)
992 index origfile buf target entry ibuffer
993 main last-main letter last-letter file sub link tgext)
994 ;; `files' contains the list of relative file names
995 (dolist (file files)
996 (setq origfile
997 (concat (file-name-directory file)
998 (substring (file-name-nondirectory file) 1 -1)))
999 (setq buf (find-file-noselect file))
1000 (with-current-buffer buf
1001 (goto-char (point-min))
1002 (while (re-search-forward "^INDEX: (\\(.*?\\)) \\(.*\\)" nil t)
1003 (setq target (match-string 1)
1004 entry (match-string 2))
1005 (push (list entry origfile target) index)))
1006 (kill-buffer buf))
1007 (setq index (sort index (lambda (a b) (string< (downcase (car a))
1008 (downcase (car b))))))
1009 (setq ibuffer (find-file-noselect (expand-file-name "theindex.inc" directory)))
1010 (with-current-buffer ibuffer
1011 (erase-buffer)
1012 (insert "* Index\n")
1013 (setq last-letter nil)
1014 (dolist (idx index)
1015 (setq entry (car idx) file (nth 1 idx) target (nth 2 idx))
1016 (if (and (stringp target) (string-match "\\S-" target))
1017 (setq tgext (concat "::#" target))
1018 (setq tgext ""))
1019 (setq letter (upcase (substring entry 0 1)))
1020 (when (not (equal letter last-letter))
1021 (insert "** " letter "\n")
1022 (setq last-letter letter))
1023 (if (string-match "!" entry)
1024 (setq main (substring entry 0 (match-beginning 0))
1025 sub (substring entry (match-end 0)))
1026 (setq main nil sub nil last-main nil))
1027 (when (and main (not (equal main last-main)))
1028 (insert " - " main "\n")
1029 (setq last-main main))
1030 (setq link (concat "[[file:" file tgext "]"
1031 "[" (or sub entry) "]]"))
1032 (if (and main sub)
1033 (insert " - " link "\n")
1034 (insert " - " link "\n")))
1035 (save-buffer))
1036 (kill-buffer ibuffer)
1037 ;; Create theindex.org if it doesn't exist already
1038 (let ((index-file (expand-file-name "theindex.org" directory)))
1039 (unless (file-exists-p index-file)
1040 (setq ibuffer (find-file-noselect index-file))
1041 (with-current-buffer ibuffer
1042 (erase-buffer)
1043 (insert "\n\n#+INCLUDE: \"theindex.inc\"\n\n")
1044 (save-buffer))
1045 (kill-buffer ibuffer)))))
1047 ;; Caching functions:
1049 (defun org-publish-write-cache-file (&optional free-cache)
1050 "Write `org-publish-cache' to file.
1051 If FREE-CACHE, empty the cache."
1052 (or org-publish-cache
1053 (error "`org-publish-write-cache-file' called, but no cache present"))
1055 (let ((cache-file (org-publish-cache-get ":cache-file:")))
1056 (or cache-file
1057 (error "Cannot find cache-file name in `org-publish-write-cache-file'"))
1058 (with-temp-file cache-file
1059 (let ((print-level nil)
1060 (print-length nil))
1061 (insert "(setq org-publish-cache (make-hash-table :test 'equal :weakness nil :size 100))\n")
1062 (maphash (lambda (k v)
1063 (insert
1064 (format (concat "(puthash %S "
1065 (if (or (listp v) (symbolp v))
1066 "'" "")
1067 "%S org-publish-cache)\n") k v)))
1068 org-publish-cache)))
1069 (when free-cache (org-publish-reset-cache))))
1071 (defun org-publish-initialize-cache (project-name)
1072 "Initialize the projects cache if not initialized yet and return it."
1074 (or project-name
1075 (error "Cannot initialize `org-publish-cache' without projects name in `org-publish-initialize-cache'"))
1077 (unless (file-exists-p org-publish-timestamp-directory)
1078 (make-directory org-publish-timestamp-directory t))
1079 (if (not (file-directory-p org-publish-timestamp-directory))
1080 (error "Org publish timestamp: %s is not a directory"
1081 org-publish-timestamp-directory))
1083 (unless (and org-publish-cache
1084 (string= (org-publish-cache-get ":project:") project-name))
1085 (let* ((cache-file (concat
1086 (expand-file-name org-publish-timestamp-directory)
1087 project-name
1088 ".cache"))
1089 (cexists (file-exists-p cache-file)))
1091 (when org-publish-cache
1092 (org-publish-reset-cache))
1094 (if cexists
1095 (load-file cache-file)
1096 (setq org-publish-cache
1097 (make-hash-table :test 'equal :weakness nil :size 100))
1098 (org-publish-cache-set ":project:" project-name)
1099 (org-publish-cache-set ":cache-file:" cache-file))
1100 (unless cexists (org-publish-write-cache-file nil))))
1101 org-publish-cache)
1103 (defun org-publish-reset-cache ()
1104 "Empty org-publish-cache and reset it nil."
1105 (message "%s" "Resetting org-publish-cache")
1106 (if (hash-table-p org-publish-cache)
1107 (clrhash org-publish-cache))
1108 (setq org-publish-cache nil))
1110 (defun org-publish-cache-file-needs-publishing (filename &optional pub-dir pub-func base-dir)
1111 "Check the timestamp of the last publishing of FILENAME.
1112 Return `t', if the file needs publishing. The function also
1113 checks if any included files have been more recently published,
1114 so that the file including them will be republished as well."
1115 (or org-publish-cache
1116 (error "`org-publish-cache-file-needs-publishing' called, but no cache present"))
1117 (let* ((key (org-publish-timestamp-filename filename pub-dir pub-func))
1118 (pstamp (org-publish-cache-get key))
1119 (visiting (find-buffer-visiting filename))
1120 (case-fold-search t)
1121 included-files-ctime buf)
1123 (when (equal (file-name-extension filename) "org")
1124 (setq buf (find-file (expand-file-name filename)))
1125 (with-current-buffer buf
1126 (goto-char (point-min))
1127 (while (re-search-forward "^#\\+include:[ \t]+\"\\([^\t\n\r\"]*\\)\"[ \t]*.*$" nil t)
1128 (let* ((included-file (expand-file-name (match-string 1))))
1129 (add-to-list 'included-files-ctime
1130 (org-publish-cache-ctime-of-src included-file) t))))
1131 ;; FIXME don't kill current buffer
1132 (unless visiting (kill-buffer buf)))
1133 (if (null pstamp)
1135 (let ((ctime (org-publish-cache-ctime-of-src filename)))
1136 (or (< pstamp ctime)
1137 (when included-files-ctime
1138 (not (null (delq nil (mapcar (lambda(ct) (< ctime ct))
1139 included-files-ctime))))))))))
1141 (defun org-publish-cache-set-file-property (filename property value &optional project-name)
1142 "Set the VALUE for a PROPERTY of file FILENAME in publishing cache to VALUE.
1143 Use cache file of PROJECT-NAME. If the entry does not exist, it will be
1144 created. Return VALUE."
1145 ;; Evtl. load the requested cache file:
1146 (if project-name (org-publish-initialize-cache project-name))
1147 (let ((pl (org-publish-cache-get filename)))
1148 (if pl
1149 (progn
1150 (plist-put pl property value)
1151 value)
1152 (org-publish-cache-get-file-property
1153 filename property value nil project-name))))
1155 (defun org-publish-cache-get-file-property
1156 (filename property &optional default no-create project-name)
1157 "Return the value for a PROPERTY of file FILENAME in publishing cache.
1158 Use cache file of PROJECT-NAME. Return the value of that PROPERTY or
1159 DEFAULT, if the value does not yet exist.
1160 If the entry will be created, unless NO-CREATE is not nil."
1161 ;; Evtl. load the requested cache file:
1162 (if project-name (org-publish-initialize-cache project-name))
1163 (let ((pl (org-publish-cache-get filename))
1164 (retval nil))
1165 (if pl
1166 (if (plist-member pl property)
1167 (setq retval (plist-get pl property))
1168 (setq retval default))
1169 ;; no pl yet:
1170 (unless no-create
1171 (org-publish-cache-set filename (list property default)))
1172 (setq retval default))
1173 retval))
1175 (defun org-publish-cache-get (key)
1176 "Return the value stored in `org-publish-cache' for key KEY.
1177 Returns nil, if no value or nil is found, or the cache does not
1178 exist."
1179 (or org-publish-cache
1180 (error "`org-publish-cache-get' called, but no cache present"))
1181 (gethash key org-publish-cache))
1183 (defun org-publish-cache-set (key value)
1184 "Store KEY VALUE pair in `org-publish-cache'.
1185 Returns value on success, else nil."
1186 (or org-publish-cache
1187 (error "`org-publish-cache-set' called, but no cache present"))
1188 (puthash key value org-publish-cache))
1190 (defun org-publish-cache-ctime-of-src (file)
1191 "Get the ctime of filename F as an integer."
1192 (let ((attr (file-attributes
1193 (expand-file-name (or (file-symlink-p file) file)
1194 (file-name-directory file)))))
1195 (+ (lsh (car (nth 5 attr)) 16)
1196 (cadr (nth 5 attr)))))
1198 (provide 'org-publish)
1200 ;; Local variables:
1201 ;; generated-autoload-file: "org-loaddefs.el"
1202 ;; End:
1204 ;;; org-publish.el ends here