Merge branch 'maint'
[org-mode.git] / lisp / ox-publish.el
blobcfa7967435e6ee62dca24e1f13d15aa0b191e58c
1 ;;; ox-publish.el --- Publish Related Org Mode Files as a Website
2 ;; Copyright (C) 2006-2013 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 ;; ox-publish.el can do the following:
30 ;; + Publish all one's Org files to a given export back-end
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:
41 (eval-when-compile (require 'cl))
42 (require 'format-spec)
43 (require 'ox)
47 ;;; Variables
49 (defvar org-publish-temp-files nil
50 "Temporary list of files to be published.")
52 ;; Here, so you find the variable right before it's used the first time:
53 (defvar org-publish-cache nil
54 "This will cache timestamps and titles for files in publishing projects.
55 Blocks could hash sha1 values here.")
57 (defgroup org-publish nil
58 "Options for publishing a set of Org-mode and related files."
59 :tag "Org Publishing"
60 :group 'org)
62 (defcustom org-publish-project-alist nil
63 "Association list to control publishing behavior.
64 Each element of the alist is a publishing 'project.' The CAR of
65 each element is a string, uniquely identifying the project. The
66 CDR of each element is in one of the following forms:
68 1. A well-formed property list with an even number of elements,
69 alternating keys and values, specifying parameters for the
70 publishing process.
72 \(:property value :property value ... )
74 2. A meta-project definition, specifying of a list of
75 sub-projects:
77 \(:components (\"project-1\" \"project-2\" ...))
79 When the CDR of an element of org-publish-project-alist is in
80 this second form, the elements of the list after `:components'
81 are taken to be components of the project, which group together
82 files requiring different publishing options. When you publish
83 such a project with \\[org-publish], the components all publish.
85 When a property is given a value in `org-publish-project-alist',
86 its setting overrides the value of the corresponding user
87 variable (if any) during publishing. However, options set within
88 a file override everything.
90 Most properties are optional, but some should always be set:
92 `:base-directory'
94 Directory containing publishing source files.
96 `:base-extension'
98 Extension (without the dot!) of source files. This can be
99 a regular expression. If not given, \"org\" will be used as
100 default extension.
102 `:publishing-directory'
104 Directory (possibly remote) where output files will be
105 published.
107 The `:exclude' property may be used to prevent certain files from
108 being published. Its value may be a string or regexp matching
109 file names you don't want to be published.
111 The `:include' property may be used to include extra files. Its
112 value may be a list of filenames to include. The filenames are
113 considered relative to the base directory.
115 When both `:include' and `:exclude' properties are given values,
116 the exclusion step happens first.
118 One special property controls which back-end function to use for
119 publishing files in the project. This can be used to extend the
120 set of file types publishable by `org-publish', as well as the
121 set of output formats.
123 `:publishing-function'
125 Function to publish file. Each back-end may define its
126 own (i.e. `org-latex-publish-to-pdf',
127 `org-html-publish-to-html'). May be a list of functions, in
128 which case each function in the list is invoked in turn.
130 Another property allows you to insert code that prepares
131 a project for publishing. For example, you could call GNU Make
132 on a certain makefile, to ensure published files are built up to
133 date.
135 `:preparation-function'
137 Function to be called before publishing this project. This
138 may also be a list of functions.
140 `:completion-function'
142 Function to be called after publishing this project. This
143 may also be a list of functions.
145 Some properties control details of the Org publishing process,
146 and are equivalent to the corresponding user variables listed in
147 the right column. Back-end specific properties may also be
148 included. See the back-end documentation for more information.
150 :author `user-full-name'
151 :creator `org-export-creator-string'
152 :email `user-mail-address'
153 :exclude-tags `org-export-exclude-tags'
154 :headline-levels `org-export-headline-levels'
155 :language `org-export-default-language'
156 :preserve-breaks `org-export-preserve-breaks'
157 :section-numbers `org-export-with-section-numbers'
158 :select-tags `org-export-select-tags'
159 :time-stamp-file `org-export-time-stamp-file'
160 :with-archived-trees `org-export-with-archived-trees'
161 :with-author `org-export-with-author'
162 :with-creator `org-export-with-creator'
163 :with-date `org-export-with-date'
164 :with-drawers `org-export-with-drawers'
165 :with-email `org-export-with-email'
166 :with-emphasize `org-export-with-emphasize'
167 :with-entities `org-export-with-entities'
168 :with-fixed-width `org-export-with-fixed-width'
169 :with-footnotes `org-export-with-footnotes'
170 :with-inlinetasks `org-export-with-inlinetasks'
171 :with-latex `org-export-with-latex'
172 :with-priority `org-export-with-priority'
173 :with-properties `org-export-with-properties'
174 :with-smart-quotes `org-export-with-smart-quotes'
175 :with-special-strings `org-export-with-special-strings'
176 :with-statistics-cookies' `org-export-with-statistics-cookies'
177 :with-sub-superscript `org-export-with-sub-superscripts'
178 :with-toc `org-export-with-toc'
179 :with-tables `org-export-with-tables'
180 :with-tags `org-export-with-tags'
181 :with-tasks `org-export-with-tasks'
182 :with-timestamps `org-export-with-timestamps'
183 :with-planning `org-export-with-planning'
184 :with-todo-keywords `org-export-with-todo-keywords'
186 The following properties may be used to control publishing of
187 a site-map of files or summary page for a given project.
189 `:auto-sitemap'
191 Whether to publish a site-map during
192 `org-publish-current-project' or `org-publish-all'.
194 `:sitemap-filename'
196 Filename for output of sitemap. Defaults to \"sitemap.org\".
198 `:sitemap-title'
200 Title of site-map page. Defaults to name of file.
202 `:sitemap-function'
204 Plugin function to use for generation of site-map. Defaults
205 to `org-publish-org-sitemap', which generates a plain list of
206 links to all files in the project.
208 `:sitemap-style'
210 Can be `list' (site-map is just an itemized list of the
211 titles of the files involved) or `tree' (the directory
212 structure of the source files is reflected in the site-map).
213 Defaults to `tree'.
215 `:sitemap-sans-extension'
217 Remove extension from site-map's file-names. Useful to have
218 cool URIs (see http://www.w3.org/Provider/Style/URI).
219 Defaults to nil.
221 If you create a site-map file, adjust the sorting like this:
223 `:sitemap-sort-folders'
225 Where folders should appear in the site-map. Set this to
226 `first' (default) or `last' to display folders first or last,
227 respectively. Any other value will mix files and folders.
229 `:sitemap-sort-files'
231 The site map is normally sorted alphabetically. You can
232 change this behaviour setting this to `anti-chronologically',
233 `chronologically', or nil.
235 `:sitemap-ignore-case'
237 Should sorting be case-sensitive? Default nil.
239 The following property control the creation of a concept index.
241 `:makeindex'
243 Create a concept index. The file containing the index has to
244 be called \"theindex.org\". If it doesn't exist in the
245 project, it will be generated. Contents of the index are
246 stored in the file \"theindex.inc\", which can be included in
247 \"theindex.org\".
249 Other properties affecting publication.
251 `:body-only'
253 Set this to t to publish only the body of the documents."
254 :group 'org-export-publish
255 :type 'alist)
257 (defcustom org-publish-use-timestamps-flag t
258 "Non-nil means use timestamp checking to publish only changed files.
259 When nil, do no timestamp checking and always publish all files."
260 :group 'org-export-publish
261 :type 'boolean)
263 (defcustom org-publish-timestamp-directory
264 (convert-standard-filename "~/.org-timestamps/")
265 "Name of directory in which to store publishing timestamps."
266 :group 'org-export-publish
267 :type 'directory)
269 (defcustom org-publish-list-skipped-files t
270 "Non-nil means show message about files *not* published."
271 :group 'org-export-publish
272 :type 'boolean)
274 (defcustom org-publish-sitemap-sort-files 'alphabetically
275 "Method to sort files in site-maps.
276 Possible values are `alphabetically', `chronologically',
277 `anti-chronologically' and nil.
279 If `alphabetically', files will be sorted alphabetically. If
280 `chronologically', files will be sorted with older modification
281 time first. If `anti-chronologically', files will be sorted with
282 newer modification time first. nil won't sort files.
284 You can overwrite this default per project in your
285 `org-publish-project-alist', using `:sitemap-sort-files'."
286 :group 'org-export-publish
287 :type 'symbol)
289 (defcustom org-publish-sitemap-sort-folders 'first
290 "A symbol, denoting if folders are sorted first in sitemaps.
291 Possible values are `first', `last', and nil.
292 If `first', folders will be sorted before files.
293 If `last', folders are sorted to the end after the files.
294 Any other value will not mix files and folders.
296 You can overwrite this default per project in your
297 `org-publish-project-alist', using `:sitemap-sort-folders'."
298 :group 'org-export-publish
299 :type 'symbol)
301 (defcustom org-publish-sitemap-sort-ignore-case nil
302 "Non-nil when site-map sorting should ignore case.
304 You can overwrite this default per project in your
305 `org-publish-project-alist', using `:sitemap-ignore-case'."
306 :group 'org-export-publish
307 :type 'boolean)
309 (defcustom org-publish-sitemap-date-format "%Y-%m-%d"
310 "Format for printing a date in the sitemap.
311 See `format-time-string' for allowed formatters."
312 :group 'org-export-publish
313 :type 'string)
315 (defcustom org-publish-sitemap-file-entry-format "%t"
316 "Format string for site-map file entry.
317 You could use brackets to delimit on what part the link will be.
319 %t is the title.
320 %a is the author.
321 %d is the date formatted using `org-publish-sitemap-date-format'."
322 :group 'org-export-publish
323 :type 'string)
327 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
328 ;;; Timestamp-related functions
330 (defun org-publish-timestamp-filename (filename &optional pub-dir pub-func)
331 "Return path to timestamp file for filename FILENAME."
332 (setq filename (concat filename "::" (or pub-dir "") "::"
333 (format "%s" (or pub-func ""))))
334 (concat "X" (if (fboundp 'sha1) (sha1 filename) (md5 filename))))
336 (defun org-publish-needed-p
337 (filename &optional pub-dir pub-func true-pub-dir base-dir)
338 "Non-nil if FILENAME should be published in PUB-DIR using PUB-FUNC.
339 TRUE-PUB-DIR is where the file will truly end up. Currently we
340 are not using this - maybe it can eventually be used to check if
341 the file is present at the target location, and how old it is.
342 Right now we cannot do this, because we do not know under what
343 file name the file will be stored - the publishing function can
344 still decide about that independently."
345 (let ((rtn (if (not org-publish-use-timestamps-flag) t
346 (org-publish-cache-file-needs-publishing
347 filename pub-dir pub-func base-dir))))
348 (if rtn (message "Publishing file %s using `%s'" filename pub-func)
349 (when org-publish-list-skipped-files
350 (message "Skipping unmodified file %s" filename)))
351 rtn))
353 (defun org-publish-update-timestamp
354 (filename &optional pub-dir pub-func base-dir)
355 "Update publishing timestamp for file FILENAME.
356 If there is no timestamp, create one."
357 (let ((key (org-publish-timestamp-filename filename pub-dir pub-func))
358 (stamp (org-publish-cache-ctime-of-src filename)))
359 (org-publish-cache-set key stamp)))
361 (defun org-publish-remove-all-timestamps ()
362 "Remove all files in the timestamp directory."
363 (let ((dir org-publish-timestamp-directory)
364 files)
365 (when (and (file-exists-p dir) (file-directory-p dir))
366 (mapc 'delete-file (directory-files dir 'full "[^.]\\'"))
367 (org-publish-reset-cache))))
371 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
372 ;;; Getting project information out of `org-publish-project-alist'
374 (defun org-publish-expand-projects (projects-alist)
375 "Expand projects in PROJECTS-ALIST.
376 This splices all the components into the list."
377 (let ((rest projects-alist) rtn p components)
378 (while (setq p (pop rest))
379 (if (setq components (plist-get (cdr p) :components))
380 (setq rest (append
381 (mapcar (lambda (x) (assoc x org-publish-project-alist))
382 components)
383 rest))
384 (push p rtn)))
385 (nreverse (delete-dups (delq nil rtn)))))
387 (defvar org-publish-sitemap-sort-files)
388 (defvar org-publish-sitemap-sort-folders)
389 (defvar org-publish-sitemap-ignore-case)
390 (defvar org-publish-sitemap-requested)
391 (defvar org-publish-sitemap-date-format)
392 (defvar org-publish-sitemap-file-entry-format)
393 (defun org-publish-compare-directory-files (a b)
394 "Predicate for `sort', that sorts folders and files for sitemap."
395 (let ((retval t))
396 (when (or org-publish-sitemap-sort-files org-publish-sitemap-sort-folders)
397 ;; First we sort files:
398 (when org-publish-sitemap-sort-files
399 (case org-publish-sitemap-sort-files
400 (alphabetically
401 (let* ((adir (file-directory-p a))
402 (aorg (and (string-match "\\.org$" a) (not adir)))
403 (bdir (file-directory-p b))
404 (borg (and (string-match "\\.org$" b) (not bdir)))
405 (A (if aorg (concat (file-name-directory a)
406 (org-publish-find-title a)) a))
407 (B (if borg (concat (file-name-directory b)
408 (org-publish-find-title b)) b)))
409 (setq retval (if org-publish-sitemap-ignore-case
410 (not (string-lessp (upcase B) (upcase A)))
411 (not (string-lessp B A))))))
412 ((anti-chronologically chronologically)
413 (let* ((adate (org-publish-find-date a))
414 (bdate (org-publish-find-date b))
415 (A (+ (lsh (car adate) 16) (cadr adate)))
416 (B (+ (lsh (car bdate) 16) (cadr bdate))))
417 (setq retval
418 (if (eq org-publish-sitemap-sort-files 'chronologically) (<= A B)
419 (>= A B)))))))
420 ;; Directory-wise wins:
421 (when org-publish-sitemap-sort-folders
422 ;; a is directory, b not:
423 (cond
424 ((and (file-directory-p a) (not (file-directory-p b)))
425 (setq retval (equal org-publish-sitemap-sort-folders 'first)))
426 ;; a is not a directory, but b is:
427 ((and (not (file-directory-p a)) (file-directory-p b))
428 (setq retval (equal org-publish-sitemap-sort-folders 'last))))))
429 retval))
431 (defun org-publish-get-base-files-1
432 (base-dir &optional recurse match skip-file skip-dir)
433 "Set `org-publish-temp-files' with files from BASE-DIR directory.
434 If RECURSE is non-nil, check BASE-DIR recursively. If MATCH is
435 non-nil, restrict this list to the files matching the regexp
436 MATCH. If SKIP-FILE is non-nil, skip file matching the regexp
437 SKIP-FILE. If SKIP-DIR is non-nil, don't check directories
438 matching the regexp SKIP-DIR when recursing through BASE-DIR."
439 (mapc (lambda (f)
440 (let ((fd-p (file-directory-p f))
441 (fnd (file-name-nondirectory f)))
442 (if (and fd-p recurse
443 (not (string-match "^\\.+$" fnd))
444 (if skip-dir (not (string-match skip-dir fnd)) t))
445 (org-publish-get-base-files-1
446 f recurse match skip-file skip-dir)
447 (unless (or fd-p ;; this is a directory
448 (and skip-file (string-match skip-file fnd))
449 (not (file-exists-p (file-truename f)))
450 (not (string-match match fnd)))
452 (pushnew f org-publish-temp-files)))))
453 (let ((all-files (if (not recurse) (directory-files base-dir t match)
454 ;; If RECURSE is non-nil, we want all files
455 ;; matching MATCH and sub-directories.
456 (org-remove-if-not
457 (lambda (file)
458 (or (file-directory-p file)
459 (and match (string-match match file))))
460 (directory-files base-dir t)))))
461 (if (not org-publish-sitemap-requested) all-files
462 (sort all-files 'org-publish-compare-directory-files)))))
464 (defun org-publish-get-base-files (project &optional exclude-regexp)
465 "Return a list of all files in PROJECT.
466 If EXCLUDE-REGEXP is set, this will be used to filter out
467 matching filenames."
468 (let* ((project-plist (cdr project))
469 (base-dir (file-name-as-directory
470 (plist-get project-plist :base-directory)))
471 (include-list (plist-get project-plist :include))
472 (recurse (plist-get project-plist :recursive))
473 (extension (or (plist-get project-plist :base-extension) "org"))
474 ;; sitemap-... variables are dynamically scoped for
475 ;; org-publish-compare-directory-files:
476 (org-publish-sitemap-requested
477 (plist-get project-plist :auto-sitemap))
478 (sitemap-filename
479 (or (plist-get project-plist :sitemap-filename) "sitemap.org"))
480 (org-publish-sitemap-sort-folders
481 (if (plist-member project-plist :sitemap-sort-folders)
482 (plist-get project-plist :sitemap-sort-folders)
483 org-publish-sitemap-sort-folders))
484 (org-publish-sitemap-sort-files
485 (cond ((plist-member project-plist :sitemap-sort-files)
486 (plist-get project-plist :sitemap-sort-files))
487 ;; For backward compatibility:
488 ((plist-member project-plist :sitemap-alphabetically)
489 (if (plist-get project-plist :sitemap-alphabetically)
490 'alphabetically nil))
491 (t org-publish-sitemap-sort-files)))
492 (org-publish-sitemap-ignore-case
493 (if (plist-member project-plist :sitemap-ignore-case)
494 (plist-get project-plist :sitemap-ignore-case)
495 org-publish-sitemap-sort-ignore-case))
496 (match (if (eq extension 'any) "^[^\\.]"
497 (concat "^[^\\.].*\\.\\(" extension "\\)$"))))
498 ;; Make sure `org-publish-sitemap-sort-folders' has an accepted
499 ;; value.
500 (unless (memq org-publish-sitemap-sort-folders '(first last))
501 (setq org-publish-sitemap-sort-folders nil))
503 (setq org-publish-temp-files nil)
504 (if org-publish-sitemap-requested
505 (pushnew (expand-file-name (concat base-dir sitemap-filename))
506 org-publish-temp-files))
507 (org-publish-get-base-files-1 base-dir recurse match
508 ;; FIXME distinguish exclude regexp
509 ;; for skip-file and skip-dir?
510 exclude-regexp exclude-regexp)
511 (mapc (lambda (f)
512 (pushnew
513 (expand-file-name (concat base-dir f))
514 org-publish-temp-files))
515 include-list)
516 org-publish-temp-files))
518 (defun org-publish-get-project-from-filename (filename &optional up)
519 "Return the project that FILENAME belongs to."
520 (let* ((filename (expand-file-name filename))
521 project-name)
523 (catch 'p-found
524 (dolist (prj org-publish-project-alist)
525 (unless (plist-get (cdr prj) :components)
526 ;; [[info:org:Selecting%20files]] shows how this is supposed to work:
527 (let* ((r (plist-get (cdr prj) :recursive))
528 (b (expand-file-name (file-name-as-directory
529 (plist-get (cdr prj) :base-directory))))
530 (x (or (plist-get (cdr prj) :base-extension) "org"))
531 (e (plist-get (cdr prj) :exclude))
532 (i (plist-get (cdr prj) :include))
533 (xm (concat "^" b (if r ".+" "[^/]+") "\\.\\(" x "\\)$")))
534 (when
535 (or (and i
536 (member filename
537 (mapcar (lambda (file)
538 (expand-file-name file b))
539 i)))
540 (and (not (and e (string-match e filename)))
541 (string-match xm filename)))
542 (setq project-name (car prj))
543 (throw 'p-found project-name))))))
544 (when up
545 (dolist (prj org-publish-project-alist)
546 (if (member project-name (plist-get (cdr prj) :components))
547 (setq project-name (car prj)))))
548 (assoc project-name org-publish-project-alist)))
552 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
553 ;;; Tools for publishing functions in back-ends
555 (defun org-publish-org-to (backend filename extension plist &optional pub-dir)
556 "Publish an Org file to a specified back-end.
558 BACKEND is a symbol representing the back-end used for
559 transcoding. FILENAME is the filename of the Org file to be
560 published. EXTENSION is the extension used for the output
561 string, with the leading dot. PLIST is the property list for the
562 given project.
564 Optional argument PUB-DIR, when non-nil is the publishing
565 directory.
567 Return output file name."
568 (unless (or (not pub-dir) (file-exists-p pub-dir)) (make-directory pub-dir t))
569 ;; Check if a buffer visiting FILENAME is already open.
570 (let* ((org-inhibit-startup t)
571 (visitingp (find-buffer-visiting filename))
572 (work-buffer (or visitingp (find-file-noselect filename))))
573 (prog1 (with-current-buffer work-buffer
574 (let ((output-file
575 (org-export-output-file-name extension nil pub-dir))
576 (body-p (plist-get plist :body-only)))
577 (org-export-to-file backend output-file
578 nil nil nil body-p
579 ;; Add `org-publish-collect-numbering' and
580 ;; `org-publish-collect-index' to final output
581 ;; filters. The latter isn't dependent on
582 ;; `:makeindex', since we want to keep it up-to-date
583 ;; in cache anyway.
584 (org-combine-plists
585 plist
586 `(:filter-final-output
587 ,(cons 'org-publish-collect-numbering
588 (cons 'org-publish-collect-index
589 (plist-get plist :filter-final-output))))))))
590 ;; Remove opened buffer in the process.
591 (unless visitingp (kill-buffer work-buffer)))))
593 (defun org-publish-attachment (plist filename pub-dir)
594 "Publish a file with no transformation of any kind.
596 FILENAME is the filename of the Org file to be published. PLIST
597 is the property list for the given project. PUB-DIR is the
598 publishing directory.
600 Return output file name."
601 (unless (file-directory-p pub-dir)
602 (make-directory pub-dir t))
603 (or (equal (expand-file-name (file-name-directory filename))
604 (file-name-as-directory (expand-file-name pub-dir)))
605 (copy-file filename
606 (expand-file-name (file-name-nondirectory filename) pub-dir)
607 t)))
611 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
612 ;;; Publishing files, sets of files, and indices
614 (defun org-publish-file (filename &optional project no-cache)
615 "Publish file FILENAME from PROJECT.
616 If NO-CACHE is not nil, do not initialize org-publish-cache and
617 write it to disk. This is needed, since this function is used to
618 publish single files, when entire projects are published.
619 See `org-publish-projects'."
620 (let* ((project
621 (or project
622 (or (org-publish-get-project-from-filename filename)
623 (error "File %s not part of any known project"
624 (abbreviate-file-name filename)))))
625 (project-plist (cdr project))
626 (ftname (expand-file-name filename))
627 (publishing-function
628 (or (plist-get project-plist :publishing-function)
629 (error "No publishing function chosen")))
630 (base-dir
631 (file-name-as-directory
632 (expand-file-name
633 (or (plist-get project-plist :base-directory)
634 (error "Project %s does not have :base-directory defined"
635 (car project))))))
636 (pub-dir
637 (file-name-as-directory
638 (file-truename
639 (or (eval (plist-get project-plist :publishing-directory))
640 (error "Project %s does not have :publishing-directory defined"
641 (car project))))))
642 tmp-pub-dir)
644 (unless no-cache (org-publish-initialize-cache (car project)))
646 (setq tmp-pub-dir
647 (file-name-directory
648 (concat pub-dir
649 (and (string-match (regexp-quote base-dir) ftname)
650 (substring ftname (match-end 0))))))
651 (if (listp publishing-function)
652 ;; allow chain of publishing functions
653 (mapc (lambda (f)
654 (when (org-publish-needed-p
655 filename pub-dir f tmp-pub-dir base-dir)
656 (funcall f project-plist filename tmp-pub-dir)
657 (org-publish-update-timestamp filename pub-dir f base-dir)))
658 publishing-function)
659 (when (org-publish-needed-p
660 filename pub-dir publishing-function tmp-pub-dir base-dir)
661 (funcall publishing-function project-plist filename tmp-pub-dir)
662 (org-publish-update-timestamp
663 filename pub-dir publishing-function base-dir)))
664 (unless no-cache (org-publish-write-cache-file))))
666 (defun org-publish-projects (projects)
667 "Publish all files belonging to the PROJECTS alist.
668 If `:auto-sitemap' is set, publish the sitemap too. If
669 `:makeindex' is set, also produce a file theindex.org."
670 (mapc
671 (lambda (project)
672 ;; Each project uses its own cache file:
673 (org-publish-initialize-cache (car project))
674 (let* ((project-plist (cdr project))
675 (exclude-regexp (plist-get project-plist :exclude))
676 (sitemap-p (plist-get project-plist :auto-sitemap))
677 (sitemap-filename (or (plist-get project-plist :sitemap-filename)
678 "sitemap.org"))
679 (sitemap-function (or (plist-get project-plist :sitemap-function)
680 'org-publish-org-sitemap))
681 (org-publish-sitemap-date-format
682 (or (plist-get project-plist :sitemap-date-format)
683 org-publish-sitemap-date-format))
684 (org-publish-sitemap-file-entry-format
685 (or (plist-get project-plist :sitemap-file-entry-format)
686 org-publish-sitemap-file-entry-format))
687 (preparation-function
688 (plist-get project-plist :preparation-function))
689 (completion-function (plist-get project-plist :completion-function))
690 (files (org-publish-get-base-files project exclude-regexp))
691 (theindex
692 (expand-file-name "theindex.org"
693 (plist-get project-plist :base-directory))))
694 (when preparation-function (run-hooks 'preparation-function))
695 (if sitemap-p (funcall sitemap-function project sitemap-filename))
696 ;; Publish all files from PROJECT excepted "theindex.org". Its
697 ;; publishing will be deferred until "theindex.inc" is
698 ;; populated.
699 (dolist (file files)
700 (unless (equal file theindex)
701 (org-publish-file file project t)))
702 ;; Populate "theindex.inc", if needed, and publish
703 ;; "theindex.org".
704 (when (plist-get project-plist :makeindex)
705 (org-publish-index-generate-theindex
706 project (plist-get project-plist :base-directory))
707 (org-publish-file theindex project t))
708 (when completion-function (run-hooks 'completion-function))
709 (org-publish-write-cache-file)))
710 (org-publish-expand-projects projects)))
712 (defun org-publish-org-sitemap (project &optional sitemap-filename)
713 "Create a sitemap of pages in set defined by PROJECT.
714 Optionally set the filename of the sitemap with SITEMAP-FILENAME.
715 Default for SITEMAP-FILENAME is 'sitemap.org'."
716 (let* ((project-plist (cdr project))
717 (dir (file-name-as-directory
718 (plist-get project-plist :base-directory)))
719 (localdir (file-name-directory dir))
720 (indent-str (make-string 2 ?\ ))
721 (exclude-regexp (plist-get project-plist :exclude))
722 (files (nreverse
723 (org-publish-get-base-files project exclude-regexp)))
724 (sitemap-filename (concat dir (or sitemap-filename "sitemap.org")))
725 (sitemap-title (or (plist-get project-plist :sitemap-title)
726 (concat "Sitemap for project " (car project))))
727 (sitemap-style (or (plist-get project-plist :sitemap-style)
728 'tree))
729 (sitemap-sans-extension
730 (plist-get project-plist :sitemap-sans-extension))
731 (visiting (find-buffer-visiting sitemap-filename))
732 (ifn (file-name-nondirectory sitemap-filename))
733 file sitemap-buffer)
734 (with-current-buffer
735 (let ((org-inhibit-startup t))
736 (setq sitemap-buffer
737 (or visiting (find-file sitemap-filename))))
738 (erase-buffer)
739 (insert (concat "#+TITLE: " sitemap-title "\n\n"))
740 (while (setq file (pop files))
741 (let ((fn (file-name-nondirectory file))
742 (link (file-relative-name file dir))
743 (oldlocal localdir))
744 (when sitemap-sans-extension
745 (setq link (file-name-sans-extension link)))
746 ;; sitemap shouldn't list itself
747 (unless (equal (file-truename sitemap-filename)
748 (file-truename file))
749 (if (eq sitemap-style 'list)
750 (message "Generating list-style sitemap for %s" sitemap-title)
751 (message "Generating tree-style sitemap for %s" sitemap-title)
752 (setq localdir (concat (file-name-as-directory dir)
753 (file-name-directory link)))
754 (unless (string= localdir oldlocal)
755 (if (string= localdir dir)
756 (setq indent-str (make-string 2 ?\ ))
757 (let ((subdirs
758 (split-string
759 (directory-file-name
760 (file-name-directory
761 (file-relative-name localdir dir))) "/"))
762 (subdir "")
763 (old-subdirs (split-string
764 (file-relative-name oldlocal dir) "/")))
765 (setq indent-str (make-string 2 ?\ ))
766 (while (string= (car old-subdirs) (car subdirs))
767 (setq indent-str (concat indent-str (make-string 2 ?\ )))
768 (pop old-subdirs)
769 (pop subdirs))
770 (dolist (d subdirs)
771 (setq subdir (concat subdir d "/"))
772 (insert (concat indent-str " + " d "\n"))
773 (setq indent-str (make-string
774 (+ (length indent-str) 2) ?\ )))))))
775 ;; This is common to 'flat and 'tree
776 (let ((entry
777 (org-publish-format-file-entry
778 org-publish-sitemap-file-entry-format file project-plist))
779 (regexp "\\(.*\\)\\[\\([^][]+\\)\\]\\(.*\\)"))
780 (cond ((string-match-p regexp entry)
781 (string-match regexp entry)
782 (insert (concat indent-str " + " (match-string 1 entry)
783 "[[file:" link "]["
784 (match-string 2 entry)
785 "]]" (match-string 3 entry) "\n")))
787 (insert (concat indent-str " + [[file:" link "]["
788 entry
789 "]]\n"))))))))
790 (save-buffer))
791 (or visiting (kill-buffer sitemap-buffer))))
793 (defun org-publish-format-file-entry (fmt file project-plist)
794 (format-spec
796 `((?t . ,(org-publish-find-title file t))
797 (?d . ,(format-time-string org-publish-sitemap-date-format
798 (org-publish-find-date file)))
799 (?a . ,(or (plist-get project-plist :author) user-full-name)))))
801 (defun org-publish-find-title (file &optional reset)
802 "Find the title of FILE in project."
804 (and (not reset) (org-publish-cache-get-file-property file :title nil t))
805 (let* ((org-inhibit-startup t)
806 (visiting (find-buffer-visiting file))
807 (buffer (or visiting (find-file-noselect file))))
808 (with-current-buffer buffer
809 (org-mode)
810 (let ((title
811 (let ((property (plist-get (org-export-get-environment) :title)))
812 (if property (org-element-interpret-data property)
813 (file-name-nondirectory (file-name-sans-extension file))))))
814 (unless visiting (kill-buffer buffer))
815 (org-publish-cache-set-file-property file :title title)
816 title)))))
818 (defun org-publish-find-date (file)
819 "Find the date of FILE in project.
820 This function assumes FILE is either a directory or an Org file.
821 If FILE is an Org file and provides a DATE keyword use it. In
822 any other case use the file system's modification time. Return
823 time in `current-time' format."
824 (if (file-directory-p file) (nth 5 (file-attributes file))
825 (let* ((visiting (find-buffer-visiting file))
826 (file-buf (or visiting (find-file-noselect file nil)))
827 (date (plist-get
828 (with-current-buffer file-buf
829 (let ((org-inhibit-startup t)) (org-mode))
830 (org-export-get-environment))
831 :date)))
832 (unless visiting (kill-buffer file-buf))
833 ;; DATE is either a timestamp object or a secondary string. If it
834 ;; is a timestamp or if the secondary string contains a timestamp,
835 ;; convert it to internal format. Otherwise, use FILE
836 ;; modification time.
837 (cond ((eq (org-element-type date) 'timestamp)
838 (org-time-string-to-time (org-element-interpret-data date)))
839 ((let ((ts (and (consp date) (assq 'timestamp date))))
840 (and ts
841 (let ((value (org-element-interpret-data ts)))
842 (and (org-string-nw-p value)
843 (org-time-string-to-time value))))))
844 ((file-exists-p file) (nth 5 (file-attributes file)))
845 (t (error "No such file: \"%s\"" file))))))
849 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
850 ;;; Interactive publishing functions
852 ;;;###autoload
853 (defalias 'org-publish-project 'org-publish)
855 ;;;###autoload
856 (defun org-publish (project &optional force async)
857 "Publish PROJECT.
859 PROJECT is either a project name, as a string, or a project
860 alist (see `org-publish-project-alist' variable).
862 When optional argument FORCE is non-nil, force publishing all
863 files in PROJECT. With a non-nil optional argument ASYNC,
864 publishing will be done asynchronously, in another process."
865 (interactive
866 (list
867 (assoc (org-icompleting-read
868 "Publish project: "
869 org-publish-project-alist nil t)
870 org-publish-project-alist)
871 current-prefix-arg))
872 (let ((project-alist (if (not (stringp project)) (list project)
873 ;; If this function is called in batch mode,
874 ;; project is still a string here.
875 (list (assoc project org-publish-project-alist)))))
876 (if async
877 (org-export-async-start 'ignore
878 `(let ((org-publish-use-timestamps-flag
879 (if ',force nil ,org-publish-use-timestamps-flag)))
880 (org-publish-projects ',project-alist)))
881 (save-window-excursion
882 (let* ((org-publish-use-timestamps-flag
883 (if force nil org-publish-use-timestamps-flag)))
884 (org-publish-projects project-alist))))))
886 ;;;###autoload
887 (defun org-publish-all (&optional force async)
888 "Publish all projects.
889 With prefix argument FORCE, remove all files in the timestamp
890 directory and force publishing all projects. With a non-nil
891 optional argument ASYNC, publishing will be done asynchronously,
892 in another process."
893 (interactive "P")
894 (if async
895 (org-export-async-start 'ignore
896 `(progn
897 (when ',force (org-publish-remove-all-timestamps))
898 (let ((org-publish-use-timestamps-flag
899 (if ',force nil ,org-publish-use-timestamps-flag)))
900 (org-publish-projects ',org-publish-project-alist))))
901 (when force (org-publish-remove-all-timestamps))
902 (save-window-excursion
903 (let ((org-publish-use-timestamps-flag
904 (if force nil org-publish-use-timestamps-flag)))
905 (org-publish-projects org-publish-project-alist)))))
908 ;;;###autoload
909 (defun org-publish-current-file (&optional force async)
910 "Publish the current file.
911 With prefix argument FORCE, force publish the file. When
912 optional argument ASYNC is non-nil, publishing will be done
913 asynchronously, in another process."
914 (interactive "P")
915 (let ((file (buffer-file-name (buffer-base-buffer))))
916 (if async
917 (org-export-async-start 'ignore
918 `(let ((org-publish-use-timestamps-flag
919 (if ',force nil ,org-publish-use-timestamps-flag)))
920 (org-publish-file ,file)))
921 (save-window-excursion
922 (let ((org-publish-use-timestamps-flag
923 (if force nil org-publish-use-timestamps-flag)))
924 (org-publish-file file))))))
926 ;;;###autoload
927 (defun org-publish-current-project (&optional force async)
928 "Publish the project associated with the current file.
929 With a prefix argument, force publishing of all files in
930 the project."
931 (interactive "P")
932 (save-window-excursion
933 (let ((project (org-publish-get-project-from-filename
934 (buffer-file-name (buffer-base-buffer)) 'up)))
935 (if project (org-publish project force async)
936 (error "File %s is not part of any known project"
937 (buffer-file-name (buffer-base-buffer)))))))
941 ;;; Index generation
943 (defun org-publish-collect-index (output backend info)
944 "Update index for a file in cache.
946 OUTPUT is the output from transcoding current file. BACKEND is
947 the back-end that was used for transcoding. INFO is a plist
948 containing publishing and export options.
950 The index relative to current file is stored as an alist. An
951 association has the following shape: (TERM FILE-NAME PARENT),
952 where TERM is the indexed term, as a string, FILE-NAME is the
953 original full path of the file where the term in encountered, and
954 PARENT is a reference to the headline, if any, containing the
955 original index keyword. When non-nil, this reference is a cons
956 cell. Its CAR is a symbol among `id', `custom-id' and `name' and
957 its CDR is a string."
958 (let ((file (plist-get info :input-file)))
959 (org-publish-cache-set-file-property
960 file :index
961 (delete-dups
962 (org-element-map (plist-get info :parse-tree) 'keyword
963 (lambda (k)
964 (when (equal (org-element-property :key k) "INDEX")
965 (let ((parent (org-export-get-parent-headline k)))
966 (list (org-element-property :value k)
967 file
968 (cond
969 ((not parent) nil)
970 ((let ((id (org-element-property :ID parent)))
971 (and id (cons 'id id))))
972 ((let ((id (org-element-property :CUSTOM_ID parent)))
973 (and id (cons 'custom-id id))))
974 (t (cons 'name
975 ;; Remove statistics cookie.
976 (replace-regexp-in-string
977 "\\[[0-9]+%\\]\\|\\[[0-9]+/[0-9]+\\]" ""
978 (org-element-property :raw-value parent)))))))))
979 info))))
980 ;; Return output unchanged.
981 output)
983 (defun org-publish-index-generate-theindex (project directory)
984 "Retrieve full index from cache and build \"theindex.org\".
985 PROJECT is the project the index relates to. DIRECTORY is the
986 publishing directory."
987 (let ((all-files (org-publish-get-base-files
988 project (plist-get (cdr project) :exclude)))
989 full-index)
990 ;; Compile full index and sort it alphabetically.
991 (dolist (file all-files
992 (setq full-index
993 (sort (nreverse full-index)
994 (lambda (a b) (string< (downcase (car a))
995 (downcase (car b)))))))
996 (let ((index (org-publish-cache-get-file-property file :index)))
997 (dolist (term index)
998 (unless (member term full-index) (push term full-index)))))
999 ;; Write "theindex.inc" in DIRECTORY.
1000 (with-temp-file (expand-file-name "theindex.inc" directory)
1001 (let ((current-letter nil) (last-entry nil))
1002 (dolist (idx full-index)
1003 (let* ((entry (org-split-string (car idx) "!"))
1004 (letter (upcase (substring (car entry) 0 1)))
1005 ;; Transform file into a path relative to publishing
1006 ;; directory.
1007 (file (file-relative-name
1008 (nth 1 idx)
1009 (plist-get (cdr project) :base-directory))))
1010 ;; Check if another letter has to be inserted.
1011 (unless (string= letter current-letter)
1012 (insert (format "* %s\n" letter)))
1013 ;; Compute the first difference between last entry and
1014 ;; current one: it tells the level at which new items
1015 ;; should be added.
1016 (let* ((rank (if (equal entry last-entry) (1- (length entry))
1017 (loop for n from 0 to (length entry)
1018 unless (equal (nth n entry) (nth n last-entry))
1019 return n)))
1020 (len (length (nthcdr rank entry))))
1021 ;; For each term after the first difference, create
1022 ;; a new sub-list with the term as body. Moreover,
1023 ;; linkify the last term.
1024 (dotimes (n len)
1025 (insert
1026 (concat
1027 (make-string (* (+ rank n) 2) ? ) " - "
1028 (if (not (= (1- len) n)) (nth (+ rank n) entry)
1029 ;; Last term: Link it to TARGET, if possible.
1030 (let ((target (nth 2 idx)))
1031 (format
1032 "[[%s][%s]]"
1033 ;; Destination.
1034 (case (car target)
1035 ('nil (format "file:%s" file))
1036 (id (format "id:%s" (cdr target)))
1037 (custom-id (format "file:%s::#%s" file (cdr target)))
1038 (otherwise (format "file:%s::*%s" file (cdr target))))
1039 ;; Description.
1040 (car (last entry)))))
1041 "\n"))))
1042 (setq current-letter letter last-entry entry))))
1043 ;; Create "theindex.org", if it doesn't exist yet, and provide
1044 ;; a default index file.
1045 (let ((index.org (expand-file-name "theindex.org" directory)))
1046 (unless (file-exists-p index.org)
1047 (with-temp-file index.org
1048 (insert "#+TITLE: Index\n\n#+INCLUDE: \"theindex.inc\"\n\n")))))))
1052 ;;; External Fuzzy Links Resolution
1054 ;; This part implements tools to resolve [[file.org::*Some headline]]
1055 ;; links, where "file.org" belongs to the current project.
1057 (defun org-publish-collect-numbering (output backend info)
1058 (org-publish-cache-set-file-property
1059 (plist-get info :input-file) :numbering
1060 (mapcar (lambda (entry)
1061 (cons (org-split-string
1062 (replace-regexp-in-string
1063 "\\[[0-9]+%\\]\\|\\[[0-9]+/[0-9]+\\]" ""
1064 (org-element-property :raw-value (car entry))))
1065 (cdr entry)))
1066 (plist-get info :headline-numbering)))
1067 ;; Return output unchanged.
1068 output)
1070 (defun org-publish-resolve-external-fuzzy-link (file fuzzy)
1071 "Return numbering for headline matching FUZZY search in FILE.
1073 Return value is a list of numbers, or nil. This function allows
1074 to resolve external fuzzy links like:
1076 [[file.org::*fuzzy][description]"
1077 (when org-publish-cache
1078 (cdr (assoc (org-split-string
1079 (if (eq (aref fuzzy 0) ?*) (substring fuzzy 1) fuzzy))
1080 (org-publish-cache-get-file-property
1081 (expand-file-name file) :numbering nil t)))))
1085 ;;; Caching functions
1087 (defun org-publish-write-cache-file (&optional free-cache)
1088 "Write `org-publish-cache' to file.
1089 If FREE-CACHE, empty the cache."
1090 (unless org-publish-cache
1091 (error "`org-publish-write-cache-file' called, but no cache present"))
1093 (let ((cache-file (org-publish-cache-get ":cache-file:")))
1094 (unless cache-file
1095 (error "Cannot find cache-file name in `org-publish-write-cache-file'"))
1096 (with-temp-file cache-file
1097 (let (print-level print-length)
1098 (insert "(setq org-publish-cache (make-hash-table :test 'equal :weakness nil :size 100))\n")
1099 (maphash (lambda (k v)
1100 (insert
1101 (format (concat "(puthash %S "
1102 (if (or (listp v) (symbolp v))
1103 "'" "")
1104 "%S org-publish-cache)\n") k v)))
1105 org-publish-cache)))
1106 (when free-cache (org-publish-reset-cache))))
1108 (defun org-publish-initialize-cache (project-name)
1109 "Initialize the projects cache if not initialized yet and return it."
1111 (unless project-name
1112 (error "Cannot initialize `org-publish-cache' without projects name in `org-publish-initialize-cache'"))
1114 (unless (file-exists-p org-publish-timestamp-directory)
1115 (make-directory org-publish-timestamp-directory t))
1116 (unless (file-directory-p org-publish-timestamp-directory)
1117 (error "Org publish timestamp: %s is not a directory"
1118 org-publish-timestamp-directory))
1120 (unless (and org-publish-cache
1121 (string= (org-publish-cache-get ":project:") project-name))
1122 (let* ((cache-file
1123 (concat
1124 (expand-file-name org-publish-timestamp-directory)
1125 project-name ".cache"))
1126 (cexists (file-exists-p cache-file)))
1128 (when org-publish-cache (org-publish-reset-cache))
1130 (if cexists (load-file cache-file)
1131 (setq org-publish-cache
1132 (make-hash-table :test 'equal :weakness nil :size 100))
1133 (org-publish-cache-set ":project:" project-name)
1134 (org-publish-cache-set ":cache-file:" cache-file))
1135 (unless cexists (org-publish-write-cache-file nil))))
1136 org-publish-cache)
1138 (defun org-publish-reset-cache ()
1139 "Empty org-publish-cache and reset it nil."
1140 (message "%s" "Resetting org-publish-cache")
1141 (when (hash-table-p org-publish-cache)
1142 (clrhash org-publish-cache))
1143 (setq org-publish-cache nil))
1145 (defun org-publish-cache-file-needs-publishing
1146 (filename &optional pub-dir pub-func base-dir)
1147 "Check the timestamp of the last publishing of FILENAME.
1148 Return non-nil if the file needs publishing. Also check if
1149 any included files have been more recently published, so that
1150 the file including them will be republished as well."
1151 (unless org-publish-cache
1152 (error
1153 "`org-publish-cache-file-needs-publishing' called, but no cache present"))
1154 (let* ((case-fold-search t)
1155 (key (org-publish-timestamp-filename filename pub-dir pub-func))
1156 (pstamp (org-publish-cache-get key))
1157 (org-inhibit-startup t)
1158 (visiting (find-buffer-visiting filename))
1159 included-files-ctime buf)
1161 (when (equal (file-name-extension filename) "org")
1162 (setq buf (find-file (expand-file-name filename)))
1163 (with-current-buffer buf
1164 (goto-char (point-min))
1165 (while (re-search-forward
1166 "^#\\+INCLUDE:[ \t]+\"\\([^\t\n\r\"]*\\)\"[ \t]*.*$" nil t)
1167 (let* ((included-file (expand-file-name (match-string 1))))
1168 (add-to-list 'included-files-ctime
1169 (org-publish-cache-ctime-of-src included-file) t))))
1170 (unless visiting (kill-buffer buf)))
1171 (if (null pstamp) t
1172 (let ((ctime (org-publish-cache-ctime-of-src filename)))
1173 (or (< pstamp ctime)
1174 (when included-files-ctime
1175 (not (null (delq nil (mapcar (lambda(ct) (< ctime ct))
1176 included-files-ctime))))))))))
1178 (defun org-publish-cache-set-file-property
1179 (filename property value &optional project-name)
1180 "Set the VALUE for a PROPERTY of file FILENAME in publishing cache to VALUE.
1181 Use cache file of PROJECT-NAME. If the entry does not exist, it
1182 will be created. Return VALUE."
1183 ;; Evtl. load the requested cache file:
1184 (if project-name (org-publish-initialize-cache project-name))
1185 (let ((pl (org-publish-cache-get filename)))
1186 (if pl (progn (plist-put pl property value) value)
1187 (org-publish-cache-get-file-property
1188 filename property value nil project-name))))
1190 (defun org-publish-cache-get-file-property
1191 (filename property &optional default no-create project-name)
1192 "Return the value for a PROPERTY of file FILENAME in publishing cache.
1193 Use cache file of PROJECT-NAME. Return the value of that PROPERTY
1194 or DEFAULT, if the value does not yet exist. If the entry will
1195 be created, unless NO-CREATE is not nil."
1196 ;; Evtl. load the requested cache file:
1197 (if project-name (org-publish-initialize-cache project-name))
1198 (let ((pl (org-publish-cache-get filename)) retval)
1199 (if pl
1200 (if (plist-member pl property)
1201 (setq retval (plist-get pl property))
1202 (setq retval default))
1203 ;; no pl yet:
1204 (unless no-create
1205 (org-publish-cache-set filename (list property default)))
1206 (setq retval default))
1207 retval))
1209 (defun org-publish-cache-get (key)
1210 "Return the value stored in `org-publish-cache' for key KEY.
1211 Returns nil, if no value or nil is found, or the cache does not
1212 exist."
1213 (unless org-publish-cache
1214 (error "`org-publish-cache-get' called, but no cache present"))
1215 (gethash key org-publish-cache))
1217 (defun org-publish-cache-set (key value)
1218 "Store KEY VALUE pair in `org-publish-cache'.
1219 Returns value on success, else nil."
1220 (unless org-publish-cache
1221 (error "`org-publish-cache-set' called, but no cache present"))
1222 (puthash key value org-publish-cache))
1224 (defun org-publish-cache-ctime-of-src (file)
1225 "Get the ctime of FILE as an integer."
1226 (let ((attr (file-attributes
1227 (expand-file-name (or (file-symlink-p file) file)
1228 (file-name-directory file)))))
1229 (+ (lsh (car (nth 5 attr)) 16)
1230 (cadr (nth 5 attr)))))
1233 (provide 'ox-publish)
1235 ;; Local variables:
1236 ;; generated-autoload-file: "org-loaddefs.el"
1237 ;; End:
1239 ;;; ox-publish.el ends here