Closed lawlist closed 10 years ago
This is a good suggestion. To make it a bit more generic, what do you think of always calling the sync function (even with an error), but the function gets called with the list for counters.
Basically it would look like this at the end:
(let* ((imod (length server-edit-tasks))
(idel (length server-delete-tasks))
(onew new-tasks-count)
(omod (length edit-tasks))
(odel (length delete-tasks))
(tot (+ imod idel onew omod odel)))
(when (called-interactively-p 'interactive)
... generate the right message...
)
(when org-toodledo-post-sync-func
(funcall org-toodledo-post-sync-func tot imod idel onew omod odel errors))
(list tot imod idel onew omod odel errors))
This ensures it's always called even when non-interactive. (You're version is inside the interactive section).
Also -- can you give me an idea of the problems you were having with folder mode?
(setq org-toodledo-folder-support-mode nil)
On rare occasion, I encounter errors during synchronization -- the local and server windows display what seems to be the exact same version of the task and I am not sure why I am being asked to choose one version or the other. My normal way of dealing with this is to do a complete restore to the Toodledo server from the most recent backup *.xml
file and then populate a new blank org file with a complete restoration of everything on the Toodledo server. My best guess is that there may have been something wrong with the format of one or more of my tasks -- e.g., manually edited a time stamp incorrectly and the day of the week does not match the date.
Due to the rare error that occurs during synchronization, I had a concern that org-toodledo-post-sync-func
should be aborted (or at least have the option / confirmation to abort) under such a circumstance. Errors were reported during the synchronization process . . . do you wish to proceed with org-toodledo-post-sync-func
. . . Yes or No ?
(setq org-toodledo-folder-support-mode 'heading)
I believe the problem with folder mode is that I did not find a way to reliably populate a blank org file when several folders and multiple tasks exist on the server. Many tasks previously assigned to one particular folder ended up being reassigned to a different folder.
My knowledge has increased slightly since the initial testing was done with folder mode, so it is possible I could write a org-toodledo-post-sync-func
to deal with this issue. However, that would take quite a bit of work.
In my opinion, it is very useful to be able to populate a blank org file with everything on the server.
EDIT: As I think more about this, I don't think a org-toodledo-post-sync-func
could fix the problem with org-toodledo-folder-support-mode
when populating a blank org file with several existing folders / tasks on the Toodledo server.
I added support via a new custom variable org-toodledo-post-sync-hook. It calls the hook(s) after org-toodledo-sync complete, success or failure. The hook function is passed a list of numbers indicated what was accomplished, including errors. This can be used to decide if the hook should still be run.
Example:
(add-hook 'org-toodledo-post-sync-hook
(lambda (result)
(message "My post-sync hook: %S" result)))
This will call the function and generate a message like:
My post-sync hook 1: (1 0 0 0 1 0 0)
Thank you very much -- I'm looking forward to using this new feature -- greatly appreciated !
As a feature request, please consider adding the option for a custom
user-post-sync-function
-- the option would default tonil
, unless the user chooses to implement such a function. The option could be added at the following two (2) specific locations in theorg-toodledo.el
script -- i.e., line 1361; and, line 1375. The custom function is needed at these two (2) specific locations, because there are two (2) possible conditions for a successful run, and because the custom function should not run if errors occur during the synchronization process.;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
I have been using the above-mentioned custom modification since day one. My experience with
org-toodledo-folder-support-mode
has never been good -- i.e., it is unreliable. Instead, I choose to haveToodledoFolder
property drawers for every task and then I useorg-archive-subtree
with a backward search and refile every task underneath the appropriate heading.Here is a sample: