Skip to content

Commit

Permalink
fixup! FIX louietan#76: handle both old and new function signatures o…
Browse files Browse the repository at this point in the history
…f `request--curl-callback'

Check for the new 3-arg arity. By default, expect the stable, 2-arg arity from
'request.el'
  • Loading branch information
Sodel-the-Vociferous committed Jul 4, 2022
1 parent b543552 commit 9de20a2
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions anki-editor.el
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,14 @@ See https://apps.ankiweb.net/docs/manual.html#latex-conflicts.")
;; why here we manually invoke callbacks to receive the result.
(unless (request-response-done-p response)
;; (request--curl-callback "localhost" (get-buffer-process (request-response--buffer response)) "finished\n")))
(if (equalp '(2 . 2) (func-arity 'request--curl-callback))
;; Handle the older, stable version of 'request.el' in which
;; `request--curl-callback' has two args.
(request--curl-callback (get-buffer-process (request-response--buffer response)) "finished\n")
;; Handle new 3-argument function signature as of 'request.el' commit
;; '8ccbae1b5e5e2ae68112dd46a6bee67d318b0deb'. Should fix anki-editor
;; errors for those using newer versions of 'request.el'.
(request--curl-callback url (get-buffer-process (request-response--buffer response)) "finished\n"))))
(if (equalp '(3 . 3) (func-arity 'request--curl-callback))
;; Handle new 3-argument function signature as of 'request.el' commit
;; '8ccbae1b5e5e2ae68112dd46a6bee67d318b0deb'. Should fix anki-editor
;; errors for those using newer versions of 'request.el'.
(request--curl-callback url (get-buffer-process (request-response--buffer response)) "finished\n")
;; Handle the older, stable version of 'request.el' in which
;; `request--curl-callback' has two args.
(request--curl-callback (get-buffer-process (request-response--buffer response)) "finished\n"))))

(when err (error "Error communicating with AnkiConnect using cURL: %s" err))
(or reply (error "Got empty reply from AnkiConnect"))))
Expand Down

0 comments on commit 9de20a2

Please sign in to comment.