summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Maus <dmaus@ictsoc.de>2010-05-22 16:10:34 +0200
committerCarsten Dominik <carsten.dominik@gmail.com>2010-05-25 11:38:42 +0200
commitd7e15f0c887a50cc5053d7efac9197ad3958b5bd (patch)
tree77487a418cb8b1f18137e2186e0ea81f1d58099e
parent70966091826ae2559d7859e452a169864546976b (diff)
downloadorg-mode-d7e15f0c887a50cc5053d7efac9197ad3958b5bd.tar.gz
Serialize the publishing cache
* lisp/org-publish.el (org-publish-write-cache-file): Write a serialized version of the cache hash. (org-publish-initialize-cache): Reset the cache hash before creating a new one.Serialize publishing project cache with `puthash' expressions.
-rw-r--r--lisp/org-publish.el27
1 files changed, 17 insertions, 10 deletions
diff --git a/lisp/org-publish.el b/lisp/org-publish.el
index fefd50d..fc18a9a 100644
--- a/lisp/org-publish.el
+++ b/lisp/org-publish.el
@@ -902,15 +902,19 @@ If FREE-CACHE, empty the cache."
(let ((cache-file (org-publish-cache-get ":cache-file:")))
(unless cache-file
- (error "%s" "Cannot find cache-file name in `org-publish-write-cache-file'"))
+ (error
+ "%s" "Cannot find cache-file name in `org-publish-write-cache-file'"))
(with-temp-file cache-file
(let ((print-level nil)
- (print-length nil))
- (insert
- "(setq org-publish-cache\n "
- (replace-regexp-in-string "\\([^\\ \t]\"\\) \\([^ \t]\\)" "\\1\n\\2"
- (format "%S" org-publish-cache))
- ")\n")))
+ (print-length nil))
+ (insert "(setq org-publish-cache (make-hash-table :test 'equal :weakness nil :size 100))\n")
+ (maphash (lambda (k v)
+ (insert
+ (format (concat "(puthash %S "
+ (if (or (listp v) (symbolp v))
+ "'" "")
+ "%S org-publish-cache)\n") k v)))
+ org-publish-cache)))
(when free-cache (org-publish-reset-cache))))
(defun org-publish-initialize-cache (project-name)
@@ -929,14 +933,17 @@ and return it."
(unless (and org-publish-cache
(string= (org-publish-cache-get ":project:") project-name))
- (when org-publish-cache (org-publish-reset-cache))
(let* ((cache-file (concat
(expand-file-name org-publish-timestamp-directory)
project-name
".cache"))
(cexists (file-exists-p cache-file)))
- (if cexists (load-file cache-file))
- (unless org-publish-cache
+
+ (when org-publish-cache
+ (org-publish-reset-cache))
+
+ (if cexists
+ (load-file cache-file)
(setq org-publish-cache
(make-hash-table :test 'equal :weakness nil :size 100))
(org-publish-cache-set ":project:" project-name)