* [PATCH 0/3] Proper serializing of publishing cache + refactor `org-clone-subtree-with-time-shift'
@ 2010-05-22 14:10 David Maus
2010-05-22 14:10 ` [PATCH 1/3] org.el: Remove duplicate code in `org-clone-subtree-with-time-shift' David Maus
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: David Maus @ 2010-05-22 14:10 UTC (permalink / raw)
To: emacs-orgmode
Patches available on
git://github.com/dmj/dmj-org-mode.git quickfix
- publishing cache is now serialized with `puthash' expressions, not
in printed representation
- duplicate code in `org-clone-subtree-with-time-shift' removed;
preparing a clone of a subtree is done before maybe shifting time
stamps
- patch 3 is for the ChangeLog file
HTH
-- David
David Maus (3):
org.el: Remove duplicate code in `org-clone-subtree-with-time-shift'.
Serialize publishing project cache with `puthash' expressions.
Update ChangeLog for 37e0fa88c1b0b691e2933808dc6dbcdd886de6af and
ba62b4a448ba3f9781c94bed57f60cee50b04c25.
lisp/ChangeLog | 9 +++++++++
lisp/org-publish.el | 29 +++++++++++++++++------------
lisp/org.el | 40 ++++++++++++++--------------------------
3 files changed, 40 insertions(+), 38 deletions(-)
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/3] org.el: Remove duplicate code in `org-clone-subtree-with-time-shift'.
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 ` David Maus
2010-05-22 14:10 ` [PATCH 2/3] Serialize publishing project cache with `puthash' expressions David Maus
2010-05-22 14:10 ` [PATCH 3/3] Update ChangeLog for 37e0fa88c1b0b691e2933808dc6dbcdd886de6af and ba62b4a448ba3f9781c94bed57f60cee50b04c25 David Maus
2 siblings, 0 replies; 7+ messages in thread
From: David Maus @ 2010-05-22 14:10 UTC (permalink / raw)
To: emacs-orgmode
Operating on the clone (e.g. remove/recreated ID property) is
independent on whether the subtree is cloned with time shift or not.
---
lisp/org.el | 40 ++++++++++++++--------------------------
1 files changed, 14 insertions(+), 26 deletions(-)
diff --git a/lisp/org.el b/lisp/org.el
index 6dcc520..c6d928b 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -7213,30 +7213,18 @@ and still retain the repeater to cover future instances of the task."
(setq nmin 0 nmax (1+ nmax) n-no-remove nmax))
(goto-char end)
(loop for n from nmin to nmax do
- (if (not doshift)
- (setq task (if (not idprop) template
- (with-temp-buffer
- (insert template)
- (org-mode)
- (goto-char (point-min))
- (if org-clone-delete-id
- (org-entry-delete nil "ID")
- (org-id-get-create t))
- (while (re-search-forward
- org-property-drawer-re nil t)
- (org-remove-empty-drawer-at
- "PROPERTIES" (point)))
- (buffer-string))))
- (with-temp-buffer
- (insert template)
- (org-mode)
- (goto-char (point-min))
- (and idprop (if org-clone-delete-id
- (org-entry-delete nil "ID")
- (org-id-get-create t)))
- (while (re-search-forward org-property-drawer-re nil t)
- (org-remove-empty-drawer-at "PROPERTIES" (point)))
- (goto-char (point-min))
+ ;; prepare clone
+ (with-temp-buffer
+ (insert template)
+ (org-mode)
+ (goto-char (point-min))
+ (and idprop (if org-clone-delete-id
+ (org-entry-delete nil "ID")
+ (org-id-get-create t)))
+ (while (re-search-forward org-property-drawer-re nil t)
+ (org-remove-empty-drawer-at "PROPERTIES" (point)))
+ (goto-char (point-min))
+ (when doshift
(while (re-search-forward org-ts-regexp-both nil t)
(org-timestamp-change (* n shift-n) shift-what))
(unless (= n n-no-remove)
@@ -7245,8 +7233,8 @@ and still retain the repeater to cover future instances of the task."
(save-excursion
(goto-char (match-beginning 0))
(if (looking-at "<[^<>\n]+\\( +\\+[0-9]+[dwmy]\\)")
- (delete-region (match-beginning 1) (match-end 1))))))
- (setq task (buffer-string))))
+ (delete-region (match-beginning 1) (match-end 1)))))))
+ (setq task (buffer-string)))
(insert task))
(goto-char beg)))
--
1.7.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/3] Serialize publishing project cache with `puthash' expressions.
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
2010-05-23 5:56 ` Carsten Dominik
2010-05-22 14:10 ` [PATCH 3/3] Update ChangeLog for 37e0fa88c1b0b691e2933808dc6dbcdd886de6af and ba62b4a448ba3f9781c94bed57f60cee50b04c25 David Maus
2 siblings, 1 reply; 7+ messages in thread
From: David Maus @ 2010-05-22 14:10 UTC (permalink / raw)
To: emacs-orgmode
---
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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/3] Update ChangeLog for 37e0fa88c1b0b691e2933808dc6dbcdd886de6af and ba62b4a448ba3f9781c94bed57f60cee50b04c25.
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 ` [PATCH 2/3] Serialize publishing project cache with `puthash' expressions David Maus
@ 2010-05-22 14:10 ` David Maus
2 siblings, 0 replies; 7+ messages in thread
From: David Maus @ 2010-05-22 14:10 UTC (permalink / raw)
To: emacs-orgmode
---
lisp/ChangeLog | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 1fc20b7..8653197 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,12 @@
+2010-05-22 David Maus <dmaus@ictsoc.de>
+
+ * org.el (org-clone-subtree-with-time-shift): Remove duplicate
+ code preparing the clone.
+
+ * org-publish.el (org-publish-write-cache-file): Serialize
+ cache file with `puthash' expressions.
+ (org-publish-initialize-cache): Load serialized hash table.
+
2010-05-21 Carsten Dominik <carsten.dominik@gmail.com>
* org.el (org-emph-re): Document the match groups.
--
1.7.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 2/3] Serialize publishing project cache with `puthash' expressions.
2010-05-22 14:10 ` [PATCH 2/3] Serialize publishing project cache with `puthash' expressions David Maus
@ 2010-05-23 5:56 ` Carsten Dominik
2010-05-23 14:22 ` Sebastian Rose
0 siblings, 1 reply; 7+ messages in thread
From: Carsten Dominik @ 2010-05-23 5:56 UTC (permalink / raw)
To: David Maus, Sebastian Rose; +Cc: emacs-orgmode
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/3] Serialize publishing project cache with `puthash' expressions.
2010-05-23 5:56 ` Carsten Dominik
@ 2010-05-23 14:22 ` Sebastian Rose
2010-05-25 9:41 ` Carsten Dominik
0 siblings, 1 reply; 7+ messages in thread
From: Sebastian Rose @ 2010-05-23 14:22 UTC (permalink / raw)
To: Carsten Dominik; +Cc: emacs-orgmode
Carsten Dominik <carsten.dominik@gmail.com> 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
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/3] Serialize publishing project cache with `puthash' expressions.
2010-05-23 14:22 ` Sebastian Rose
@ 2010-05-25 9:41 ` Carsten Dominik
0 siblings, 0 replies; 7+ messages in thread
From: Carsten Dominik @ 2010-05-25 9:41 UTC (permalink / raw)
To: Sebastian Rose; +Cc: emacs-orgmode
On May 23, 2010, at 4:22 PM, Sebastian Rose wrote:
> Carsten Dominik <carsten.dominik@gmail.com> 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
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2010-05-25 9:41 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH 2/3] Serialize publishing project cache with `puthash' expressions David Maus
2010-05-23 5:56 ` 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
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.