emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: David Maus <dmaus@ictsoc.de>
To: emacs-orgmode@gnu.org
Subject: [PATCH 2/3] Serialize publishing project cache with `puthash' expressions.
Date: Sat, 22 May 2010 16:10:34 +0200	[thread overview]
Message-ID: <1274537435-12497-3-git-send-email-dmaus@ictsoc.de> (raw)
In-Reply-To: <1274537435-12497-1-git-send-email-dmaus@ictsoc.de>

---
 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

  parent reply	other threads:[~2010-05-22 14:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-22 14:10 [PATCH 0/3] Proper serializing of publishing cache + refactor `org-clone-subtree-with-time-shift' David Maus
2010-05-22 14:10 ` [PATCH 1/3] org.el: Remove duplicate code in `org-clone-subtree-with-time-shift' David Maus
2010-05-22 14:10 ` David Maus [this message]
2010-05-23  5:56   ` [PATCH 2/3] Serialize publishing project cache with `puthash' expressions Carsten Dominik
2010-05-23 14:22     ` Sebastian Rose
2010-05-25  9:41       ` Carsten Dominik
2010-05-22 14:10 ` [PATCH 3/3] Update ChangeLog for 37e0fa88c1b0b691e2933808dc6dbcdd886de6af and ba62b4a448ba3f9781c94bed57f60cee50b04c25 David Maus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1274537435-12497-3-git-send-email-dmaus@ictsoc.de \
    --to=dmaus@ictsoc.de \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).