[emacs-berlin] Code review for a simple HTTP async client

jman emacs-berlin at city17.xyz
Thu Jan 4 13:24:39 UTC 2024


> If you don't want to let Emacs wait, putting the relevant parts of the
> control flow of your code into callbacks and process filters will solve
> your problem.  This stuff will run automatically when the process status
> has changed and Emacs is idle ("accepts process output").

I've tried capturing the output of the callback using a process filter
but I can't get my head around it. I am not even sure I completely
understand how to get hold of the buffer where the callback is supposed
to write its output.

IIUC the workflow, the logic should be:
- a function runs `url-retrieve url 'callback`
- same function should register (?) a filter process where the callback
will write its output
- the callback parses the HTTP response
- at some point the function should see some output in the filtered
buffer

The documentation here[0] says how to start a process (which I think
this is not what I want) and here[1] how to capture the process output
but I can't connect the dots when I run `url-retrieve` with a callback
and process its output. The example for a process filter[2] is a bit
obscure either.

Until I sort out the above I'll just copy to the kill-ring the result of
that async process.

[0]:
https://www.gnu.org/software/emacs/manual/html_node/elisp/Asynchronous-Processes.html
[1]: https://www.gnu.org/software/emacs/manual/html_node/elisp/Process-Buffers.html
[2]: https://www.gnu.org/software/emacs/manual/html_node/elisp/Filter-Functions.html


More information about the emacs-berlin mailing list