From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Maus Subject: [PATCH 2/3] Serialize publishing project cache with `puthash' expressions. Date: Sat, 22 May 2010 16:10:34 +0200 Message-ID: <1274537435-12497-3-git-send-email-dmaus@ictsoc.de> References: <1274537435-12497-1-git-send-email-dmaus@ictsoc.de> Return-path: Received: from [140.186.70.92] (port=37589 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OFpQJ-0005IR-6b for emacs-orgmode@gnu.org; Sat, 22 May 2010 10:11:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OFpQH-0001lX-Me for emacs-orgmode@gnu.org; Sat, 22 May 2010 10:11:31 -0400 Received: from mysql1.xlhost.de ([213.202.242.106]:48241) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OFpQH-0001lO-HO for emacs-orgmode@gnu.org; Sat, 22 May 2010 10:11:29 -0400 In-Reply-To: <1274537435-12497-1-git-send-email-dmaus@ictsoc.de> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --- lisp/org-publish.el | 29 +++++++++++++++++------------ 1 files changed, 17 insertions(+), 12 deletions(-) diff --git a/lisp/org-publish.el b/lisp/org-publish.el index fefd50d..dc94f7d 100644 --- a/lisp/org-publish.el +++ b/lisp/org-publish.el @@ -902,15 +902,18 @@ 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)) + (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,16 +932,18 @@ 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 - (setq org-publish-cache - (make-hash-table :test 'equal :weakness nil :size 100)) + + (when org-publish-cache + (org-publish-reset-cache)) + (setq org-publish-cache + (make-hash-table :test 'equal :weakness nil :size 100)) + + (if cexists (load-file cache-file) (org-publish-cache-set ":project:" project-name) (org-publish-cache-set ":cache-file:" cache-file)) (unless cexists (org-publish-write-cache-file nil)))) -- 1.7.1