diff options
author | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2017-12-27 23:44:55 +0100 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2017-12-27 23:44:55 +0100 |
commit | 01e150eb59d06969fc5d08319a622d130934a9d3 (patch) | |
tree | 7b490b3688cb7092e3286e285c34d8e44ded9f19 | |
parent | b30afa39b05501d31df463296cd807e7ecb0a679 (diff) | |
download | org-mode-01e150eb59d06969fc5d08319a622d130934a9d3.tar.gz |
ox-publish: Cache results for `org-publish-find-date'
* lisp/ox-publish.el (org-publish-find-date): Cache results.
(org-publish-find-title): Tiny refactoring.
Reported-by: Lorenzo Bolla <lbolla@gmail.com>
<http://lists.gnu.org/r/emacs-orgmode/2017-12/msg00561.html>
-rw-r--r-- | lisp/ox-publish.el | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/lisp/ox-publish.el b/lisp/ox-publish.el index 28d8200..37e74b4 100644 --- a/lisp/ox-publish.el +++ b/lisp/ox-publish.el @@ -851,8 +851,7 @@ PROPERTY, i.e. \"behavior\" parameter from `org-export-options-alist'." (org-no-properties (org-element-interpret-data parsed-title)) (file-name-nondirectory (file-name-sans-extension file))))) - (org-publish-cache-set-file-property file :title title) - title)))) + (org-publish-cache-set-file-property file :title title))))) (defun org-publish-find-date (file project) "Find the date of FILE in PROJECT. @@ -861,18 +860,21 @@ If FILE is an Org file and provides a DATE keyword use it. In any other case use the file system's modification time. Return time in `current-time' format." (let ((file (org-publish--expand-file-name file project))) - (if (file-directory-p file) (nth 5 (file-attributes file)) - (let ((date (org-publish-find-property file :date project))) - ;; DATE is a secondary string. If it contains a time-stamp, - ;; convert it to internal format. Otherwise, use FILE - ;; modification time. - (cond ((let ((ts (and (consp date) (assq 'timestamp date)))) - (and ts - (let ((value (org-element-interpret-data ts))) - (and (org-string-nw-p value) - (org-time-string-to-time value)))))) - ((file-exists-p file) (nth 5 (file-attributes file))) - (t (error "No such file: \"%s\"" file))))))) + (or (org-publish-cache-get-file-property file :date nil t) + (org-publish-cache-set-file-property + file :date + (if (file-directory-p file) (nth 5 (file-attributes file)) + (let ((date (org-publish-find-property file :date project))) + ;; DATE is a secondary string. If it contains + ;; a time-stamp, convert it to internal format. + ;; Otherwise, use FILE modification time. + (cond ((let ((ts (and (consp date) (assq 'timestamp date)))) + (and ts + (let ((value (org-element-interpret-data ts))) + (and (org-string-nw-p value) + (org-time-string-to-time value)))))) + ((file-exists-p file) (nth 5 (file-attributes file))) + (t (error "No such file: \"%s\"" file))))))))) (defun org-publish-sitemap-default-entry (entry style project) "Default format for site map ENTRY, as a string. |