anki-editor icon indicating copy to clipboard operation
anki-editor copied to clipboard

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

Open Honeypot95 opened this issue 3 years ago • 4 comments

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.

Honeypot95 avatar Sep 10 '20 19:09 Honeypot95

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!)

BlindingDark avatar Sep 12 '20 07:09 BlindingDark

@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

sprajagopal avatar Oct 22 '20 07:10 sprajagopal

@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.

BlindingDark avatar Oct 22 '20 07:10 BlindingDark

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

sprajagopal avatar Oct 22 '20 08:10 sprajagopal