From a09e3305a9baf6c127b5be142b4864635532f8bb Mon Sep 17 00:00:00 2001 From: louie Date: Sun, 9 Jun 2019 00:21:09 +0800 Subject: [PATCH] Update comment on a hack. --- anki-editor.el | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/anki-editor.el b/anki-editor.el index 2bf8020..e51a09a 100644 --- a/anki-editor.el +++ b/anki-editor.el @@ -153,16 +153,10 @@ See https://apps.ankiweb.net/docs/manual.html#latex-conflicts.") (setq err (string-trim (cdr error-thrown))))) :sync t))) - ;; HACK: I expect the behavior of the sync mode to be that - ;; callbacks get called before the invocation to `request' ends, - ;; but it seems not to be the case (or I get it wrong ?) that - ;; sometimes when the curl process finishes, the - ;; `request--curl-callback' (the sentinel of the curl process, - ;; which calls `request--callback', which subsequently calls the - ;; callbacks) get called after `request--curl-sync' ends. Here I - ;; check if the `done-p' is nil (which will be set to `t' after - ;; callbacks have been called) and call `request--curl-callback' - ;; manually. + ;; HACK: With sync set to t, `request' waits for curl process to + ;; exit, then response data becomes available, but callbacks + ;; might not be called right away but at a later time, that's + ;; why here we manually invoke callbacks to receive the result. (unless (request-response-done-p response) (request--curl-callback (get-buffer-process (request-response--buffer response)) "finished\n")))