Re: [Orgmode] [PATCH 2/3] Serialize publishing project cache with `puthash' expressions.
On May 23, 2010, at 4:22 PM, Sebastian Rose wrote: Carsten Dominik writes: On May 22, 2010, at 4:10 PM, David Maus wrote: --- 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 I think it would be more future-proof to put the statement initializing the hash also into the cache file, so that the caches file then reads (setq org-publish-cache (make-hash...)) (puthash.) . Or maybe I am wrong? Sebastian, do you have a comment? And it is the backward compatible way. Every one here has cache files on disk already that read like (setq org-publish-cache Thanks a lot for looking into this David! I did apply Davids patch, with an additional fix that make-hast is called in the load file. - Carsten Sebastian Also, for long tables it might be more efficient to write the hash out as a list, and then loop over it to fill the cache again. Not sure how large projects get out there, though. So this is not important now. - Carsten (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 ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode - Carsten - Carsten ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
Re: [Orgmode] [PATCH 2/3] Serialize publishing project cache with `puthash' expressions.
Carsten Dominik writes: > On May 22, 2010, at 4:10 PM, David Maus wrote: > >> --- >> 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 > > I think it would be more future-proof to put the statement initializing the > hash > also into the cache file, so that the caches file then reads > > (setq org-publish-cache (make-hash...)) > (puthash.) > . > > > Or maybe I am wrong? Sebastian, do you have a comment? And it is the backward compatible way. Every one here has cache files on disk already that read like (setq org-publish-cache Thanks a lot for looking into this David! Sebastian > Also, for long tables it might be more efficient to write the > hash out as a list, and then loop over it to fill the cache again. > Not sure how large projects get out there, though. So this is not > important > now. > > - Carsten > > >> >> (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 >> >> >> ___ >> Emacs-orgmode mailing list >> Please use `Reply All' to send replies to the list. >> Emacs-orgmode@gnu.org >> http://lists.gnu.org/mailman/listinfo/emacs-orgmode > > - Carsten > > ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
Re: [Orgmode] [PATCH 2/3] Serialize publishing project cache with `puthash' expressions.
On May 22, 2010, at 4:10 PM, David Maus wrote: --- 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 I think it would be more future-proof to put the statement initializing the hash also into the cache file, so that the caches file then reads (setq org-publish-cache (make-hash...)) (puthash.) . Or maybe I am wrong? Sebastian, do you have a comment? Also, for long tables it might be more efficient to write the hash out as a list, and then loop over it to fill the cache again. Not sure how large projects get out there, though. So this is not important now. - Carsten (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 ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode - Carsten ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode