louietan / anki-editor

Emacs minor mode for making Anki cards with Org
699 stars 87 forks source link

Wrong number of arguments: request--curl-callback, 2 #76

Open Honeypot95 opened 4 years ago

Honeypot95 commented 4 years ago

I started getting this error after a fresh recompilation of emacs from the latest feature/native-comp. Despite the error, the cards get pushed to anki. The problem is the echo message and the fact that instead of writing the ANKI_NOTE_ID field, I get an error field.

After some investigation, I discovered that the request.el package has changed the signature of the request--curl-callback function, about 10 months ago, from (proc event) (url proc event). It passes the extra url argument to another function request--curl-preprocess, for which the url argument is optional.

Adding a url such as "localhost" to the function anki-editor--anki-connect-invoke which is the function that calls request--curl-callback gets rid of the error field and brings back the ANKI_NOTE_ID field. But this still keeps a different error in the message buffer.

BlindingDark commented 4 years ago

workaround:

(defun anki-editor--anki-connect-invoke! (orig-fun &rest args)
    (let ((request--curl-callback
           (lambda (proc event) (request--curl-callback "localhost" proc event))))
      (apply orig-fun args)))

(advice-add 'anki-editor--anki-connect-invoke :around #'anki-editor--anki-connect-invoke!)
sprajagopal commented 3 years ago

@BlindingDark tried this, didn't work for me. I also opened an issue #78 which may be related to this. I'm gonna try and roll back the request package and see if that works too.

EDIT: Previous workaround may still work for you. My configuration had other issues

BlindingDark commented 3 years ago

@sprajagopal The above method just add first parameter "localhost" to request--curl-callback. If it doesn't work for you, you can try to modify the source file directly. Just change https://github.com/louietan/anki-editor/blob/master/anki-editor.el#L161

(request--curl-callback (get-buffer-process (request-response--buffer response)) "finished\n")))

to

(request--curl-callback "localhost" (get-buffer-process (request-response--buffer response)) "finished\n")))

I did not encounter the second error(about ANKI_NOTE_ID), so your problem may be related to it.

sprajagopal commented 3 years ago

@BlindingDark That worked! Everything's smooth now. Even the ANKI_NOTE_ID is updated properly now.