diff options
author | Bastien Guerry <bzg@altern.org> | 2011-07-06 17:04:07 +0200 |
---|---|---|
committer | Bastien Guerry <bzg@altern.org> | 2011-07-06 17:04:07 +0200 |
commit | c6b22dee33fa418b344fa68bf36bb496db473a89 (patch) | |
tree | 40655ce4e47579f7cd45935372e6e9477d8b67e9 | |
parent | 514ed6b79c0643057def9a3de3d64801899f081d (diff) | |
download | org-mode-c6b22dee33fa418b344fa68bf36bb496db473a89.tar.gz |
org-publish.el: Take #+INCLUDE: directives into account.
* install/git/org-mode/lisp/org-publish.el
(org-publish-cache-file-needs-publishing): Takes care of more
recently included files, returning `t' in case the file including
them needs to be republished.
-rw-r--r-- | lisp/org-publish.el | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/lisp/org-publish.el b/lisp/org-publish.el index ce22bc9..fd07911 100644 --- a/lisp/org-publish.el +++ b/lisp/org-publish.el @@ -1096,15 +1096,28 @@ If FREE-CACHE, empty the cache." (defun org-publish-cache-file-needs-publishing (filename &optional pub-dir pub-func) "Check the timestamp of the last publishing of FILENAME. -Return `t', if the file needs publishing" +Return `t', if the file needs publishing. The function also +checks if any included files have been more recently published, +so that the file including them will be republished as well." (unless org-publish-cache (error "%s" "`org-publish-cache-file-needs-publishing' called, but no cache present")) (let* ((key (org-publish-timestamp-filename filename pub-dir pub-func)) - (pstamp (org-publish-cache-get key))) + (pstamp (org-publish-cache-get key)) + included-files-ctime) + (with-temp-buffer + (find-file (expand-file-name filename)) + (goto-char (point-min)) + (while (re-search-forward "^#\\+INCLUDE: \\(.+\\)[ ^\t]*$" nil t) + (let* ((included-file (expand-file-name (match-string 1)))) + (add-to-list 'included-files-ctime + (org-publish-cache-ctime-of-src included-file) t)))) (if (null pstamp) t (let ((ctime (org-publish-cache-ctime-of-src filename))) - (< pstamp ctime))))) + (or (< pstamp ctime) + (when included-files-ctime + (not (null (delq nil (mapcar (lambda(ct) (< ctime ct)) + included-files-ctime)))))))))) (defun org-publish-cache-set-file-property (filename property value &optional project-name) "Set the VALUE for a PROPERTY of file FILENAME in publishing cache to VALUE. |