christopherjwhite / org-toodledo

Emacs enhancement for syncing org-mode tasks with Toodledlo
83 stars 16 forks source link

Emacs24 #39

Open mradziej opened 10 years ago

mradziej commented 10 years ago

Please review my commits, I barely find my way around emacs lisp ... it solves my problems getting org-toodledo to run on my GNU Emacs 24.3.1. I added http-post-simple.el because it needed mending, too.

christopherjwhite commented 10 years ago

For the missing 'caddar', can you try adding the following with the other require lines:

(eval-when-compile (require 'cl))

I think this should take care of both issues (the missing caddar as well as values, as they are both in cl). I just do a (require 'cl) in my .emacs, but including it directly in packages is considered bad practice, because not everyone wants common lisp definitions, as some of the functions apparently may be defined differently.

In any event, let me know if the above works for you and I'll check it it.

myuhe commented 10 years ago

In Emacs 24.3, It supports on cl-lib package. Use cl-* function.

colonelpanic8 commented 9 years ago

@myuhe Is your fork of this working in emacs 24.4? It consistently hangs for me as of right now. I'm running OSX with a brew installed version of emacs.

erikstokes commented 9 years ago

@IvanMalison I've had the same issue. I think it's due to a change is Toodledo's API (Issue #46)

christopherjwhite commented 9 years ago

Yeah, one of my first questions was whether @myuhe has implemented the oauth-based authentication required for the new API version. I have some experience with oauth, but not from elisp. It seems there already is an oauth.el available that may help here.

...cj

On 2/19/15 6:21 PM, erikstokes wrote:

@IvanMalison https://github.com/IvanMalison I've had the same issue. I think it's due to a change is Toodledo's API (Issue #46 https://github.com/christopherjwhite/org-toodledo/issues/46)

— Reply to this email directly or view it on GitHub https://github.com/christopherjwhite/org-toodledo/pull/39#issuecomment-75160346.

colonelpanic8 commented 9 years ago

@erikstokes Yeah, I just found that issue. You think that they just silently deleted v2 of the API?

I don't think thats what happened:

 imalison  ~  Dropbox  configs  curl "http://api.toodledo.com/2/account/token.php?userid=td54d3545b780d3;appid=orgtoodledo2"
{"errorCode":8,"errorDesc":"You must sign the request"}%

It's probably a good idea to migrate to the new API anyway though.

erikstokes commented 9 years ago

Not so much silently deleted as let the code rot. The documentation does warn that it may go away at any time.

Even if this just a temporary glitch, eventually it will die, so (as you say) it's a good idea to move to the new API.

myuhe commented 9 years ago

try to use asyc branch ?

https://github.com/myuhe/org-toodledo/tree/async

It works corrctly.

colonelpanic8 commented 9 years ago

@myuhe Why not make that master so that it is available on melpa?

myuhe commented 9 years ago

this branch is not mature yet. I'll merge into master soon.

erikstokes commented 9 years ago

@myuhe The async branch isn't working for me. i get "(error "Before first headline at position 163 in buffer org")" when I M-x org-toodledo-sync. The only buffer I have named "org" is a dired buffer.

If I run (org-toodledo-sync t nil nil) to only push my changes to Toodledo I get a message "no heading" and nothing gets pushed to Toodledo.

myuhe commented 9 years ago

New org-toodledo is added new customize variable. You should set file name like

(setq org-toodledo-file (expand-file-name "~/org.d/Tasks.org"))
colonelpanic8 commented 9 years ago

@myuhe It's still not working for me on your async branch. emacs just seems to get completely hung.

erikstokes commented 9 years ago

@myuhe Stil not working for me either. I now get "deferred error : (error "Call to contexts/get failed, exceeded max num of retries, giving up")". Let debug log is giving:

[19:51:57] [DEBUG] org-toodledo-call-method: 'http://api.toodledo.com/2/contexts/get.php'
[19:51:57] [ERROR] Call to contexts/get failed, exceeded max num of retries, giving up
myuhe commented 9 years ago

Umm... Do you use head version? And try to reset task data?

erikstokes commented 9 years ago

This is with the async branch (commit 2365e). Reseting doesn't help. It seems to fail the first time it gets to a headline with a "@context" tag.

myuhe commented 9 years ago

I cannot reproduce it. Let me show a process to reproduce.

erikstokes commented 9 years ago

If I use a test file containing only

* Tasks
** TODO new task

and run org-toodledo-sync the error about contexts goes away (because there are no contexts). Instead I get "deferred error : (wrong-type-argument stringp nil)" and nothing happens. If instead I use (org-toodledo-sync t nil nil) to only add new tasks it gets as far as setting the :ToodledoID: property and I instead get "deferred error : (error "Call to tasks/add failed, exceeded max num of retries, giving up")"

I've attempted to debug this myself, but my usual toggle-debug-on-error doesn't seem to work with the defereed package.

myuhe commented 9 years ago

Try this https://github.com/myuhe/org-toodledo/commit/fc16e51ea21419eca06de85f24b0cb13cc2668d1

erikstokes commented 9 years ago

I no longer get errors, but now it hangs after giving a message "org-toodledo buffer at latest version 2.16", which is the same problem I had in Issue #46

myuhe commented 9 years ago

hummm... In my environment, It works correctly. It is hard to resolve this issue.

colonelpanic8 commented 9 years ago

@erikstokes That is the issue that i'm having as well.

myuhe commented 9 years ago

Fix it again. https://github.com/myuhe/org-toodledo/tree/async

Check it out.

erikstokes commented 9 years ago

This version works on my test file. The new task appears in Toodledo, but in org-mode the :ToodledoID: property is set to -3 instead of the correct ID.

However I try to add a tag :@home:, I get "deferred error : (error "Not enough arguments for format string")".

myuhe commented 9 years ago

I'm afraid that You execute some action before sync process is complete. Wait untill sync process is complete.

New org-toodledo is not need that org-mode buffer is current buffer. When you open other file, You can execute M-x org-toodledo-sync

erikstokes commented 9 years ago

Even after restarting Emacs I still get the "not enough arguments" error. I finally figured out how to get deferred to give me backtrace:

Debugger entered--Lisp error: (wrong-number-of-arguments (lambda nil (if (org-toodledo-token-valid) nil (request-deferred (concat (if org-toodledo-inhibit-https "http" "https") "://api.toodledo.com/2/account/token.php?f=xml") :params (list (cons (quote userid) org-toodledo-userid) (cons (quote appid) org-toodledo-appid) (cons (quote sig) (md5 (concat org-toodledo-userid org-toodledo-apptoken)))) :parser (function (lambda nil (libxml-parse-xml-region (point-min) (point-max))))))) 1) (lambda nil (if (org-toodledo-token-valid) nil (request-deferred (concat (if org-toodledo-inhibit-https "http" "https") "://api.toodledo.com/2/account/token.php?f=xml") :params (list (cons (quote userid) org-toodledo-userid) (cons (quote appid) org-toodledo-appid) (cons (quote sig) (md5 (concat org-toodledo-userid org-toodledo-apptoken)))) :parser (function (lambda nil (libxml-parse-xml-region (point-min) (point-max)))))))(nil) deferred:call-lambda((lambda nil (if (org-toodledo-token-valid) nil (request-deferred (concat (if org-toodledo-inhibit-https "http" "https") "://api.toodledo.com/2/account/token.php?f=xml") :params (list (cons (quote userid) org-toodledo-userid) (cons (quote appid) org-toodledo-appid) (cons (quote sig) (md5 (concat org-toodledo-userid org-toodledo-apptoken)))) :parser (function (lambda nil (libxml-parse-xml-region (point-min) (point-max))))))) nil) deferred:exec-task([cl-struct-deferred (lambda nil (if (org-toodledo-token-valid) nil (request-deferred (concat (if org-toodledo-inhibit-https "http" "https") "://api.toodledo.com/2/account/token.php?f=xml") :params (list (cons (quote userid) org-toodledo-userid) (cons (quote appid) org-toodledo-appid) (cons (quote sig) (md5 (concat org-toodledo-userid org-toodledo-apptoken)))) :parser (function (lambda nil (libxml-parse-xml-region (point-min) (point-max))))))) deferred:default-errorback deferred:default-cancel [cl-struct-deferred (lambda (res) (if res (progn (if (equal (car ...) (quote error)) (progn (setq org-toodledo-token nil org-toodledo-key nil org-toodledo-token-expiry nil) (error "Could not log in to Toodledo: %s" ...)) (setq org-toodledo-token (elt ... 2)) (setq org-toodledo-token-expiry (seconds-to-time ...)))))) deferred:default-errorback deferred:default-cancel [cl-struct-deferred (lambda nil (deferred:parallel (function (lambda nil (org-toodledo-call-async-method "account/get"))) (function (lambda nil (org-toodledo-call-async-method "folders/get"))))) deferred:default-errorback deferred:default-cancel [cl-struct-deferred (lambda (&rest --cl-rest--) (apply (quote (lambda ... ... ...)) (quote --completed-tasks--) (quote --end--) (quote --errors--) (quote --tasks-by-title-alist--) (quote --delete-tasks--) (quote --edit-tasks--) (quote --new-parent-edit-child-alist--) (quote --edit-child-tasks-alist--) (quote --new-parent-new-child-alist--) (quote --new-child-tasks-alist--) (quote --new-tasks-count--) (quote --new-tasks--) (quote --server-delete-tasks--) (quote --server-edit-tasks--) (quote --deferred-obj--) (quote --init--) (quote --skip-export--) (quote --skip-import--) (quote --columns-pos--) (quote --regexp--) (quote --buf--) --cl-rest--)) deferred:default-errorback deferred:default-cancel [cl-struct-deferred (lambda nil (deferred:wait 500)) deferred:default-errorback deferred:default-cancel [cl-struct-deferred (lambda (&rest --cl-rest--) (apply ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... --cl-rest--)) deferred:default-errorback deferred:default-cancel [cl-struct-deferred (lambda nil ...) deferred:default-errorback deferred:default-cancel [cl-struct-deferred ... deferred:default-errorback deferred:default-cancel [cl-struct-deferred ... deferred:default-errorback deferred:default-cancel [cl-struct-deferred ... deferred:default-errorback deferred:default-cancel [cl-struct-deferred ... deferred:default-errorback deferred:default-cancel nil nil nil] nil nil] nil nil] nil nil] nil nil] nil nil] nil nil] nil nil] nil nil] nil nil] nil nil] ok nil) deferred:worker() apply(deferred:worker nil) timer-event-handler([t 21742 26335 463420 nil deferred:worker nil nil 588000])

myuhe commented 9 years ago

I can not reproduce it. Let me show how to reproduce.

erikstokes commented 9 years ago

The "wrong number of arguments" error seems to be caused by me setting deferred:debug-on-signal to try debbuging myself. Not setting that variable makes the error go away.

If I run org-toodledo-sync I get changes from the server, but my local changes don't seem to get pushed out. If I run (org-toodledo-sync t nil nil) to only push I get "REQUEST [error] Error (error) while connecting to http://api.toodledo.com/2/tasks/edit.php." Is this a temporary error from the API (like maybe from making too many requests)? Or is there maybe something corrupted in my configuration or org files?

srustamo commented 9 years ago

initial sync works ok. after some modifications in Emacs of toodledo tasks, syncing, the sync does not finish properly with REQUEST [error] while connecting to http://api.toodledo.com/2/tasks/edit.php error showing in minibuffer and Emacs hangs.

myuhe commented 9 years ago

@srustamo I can not reproduce it. Let me show how to reproduce.

srustamo commented 9 years ago

it is a bit tricky to catch, now that I try. most likely the issue is API related.

srustamo commented 9 years ago

I still get two errors running org-toodledo-sync every other day or so:

  1. REQUEST [error] while connecting to http://api.toodledo.com/2/tasks/edit.ph
  2. deferred error : (wrong-type-argument stringp nil)

The error 1 freezes the editor (the only option from here is to force-close it), while 2 just reports the error and no sync occurs (the only way to sync after this is to restart the editor, but restarting the editor is possible without a force-close).

I'm happy to report the circumstances, as @myuhe suggested, but trying to debug the error setting 'debug-on-error' option is not entering the debug mode.

aagaard commented 9 years ago

I have the same problem with 1 and 2. I use @myuhe's fork but an issue board is not enabled there.

1 seems to be due to parsed-response just continue to return nil for org-toodledo-call-method calls edit. This creates a deadlock with the server. 2 is probably be due to that org-toodledo-debug2 format string expects three values but only receives two.