elisp-json-rpc icon indicating copy to clipboard operation
elisp-json-rpc copied to clipboard

Support for IPC via STDIO using JSON-RPC

Open amol-mandhane opened this issue 7 years ago • 4 comments

Based on the README, you need a host and port to do json-rpc in elisp. There are many programs which use STDIO for communication (LSP servers, for example). I'm working on a pull request for this. Is it okay to add STDIO support to this library?

amol-mandhane avatar Sep 28 '17 18:09 amol-mandhane

I'm not opposed to this so long as it doesn't interfere with the current functionality. Though I wonder how you plan to pull it off, since access to stdin and stdout from Emacs Lisp is, unfortunately, very limited.

skeeto avatar Sep 29 '17 00:09 skeeto

A typical approach would be to use HTTP-like framing, like the language server protocol (https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#base-protocol). From Emacs you'd start an asynchronous process with make-process. It needs a custom process filter. The filter would insert the new stdout into a temporary buffer and check for completed responses (i.e. where there's enough JSON content to read). Completed responses would be dispatched according to their IDs and removed from the temporary buffer.

phst avatar Oct 08 '17 12:10 phst

Yes, I also want to communicate clangd via stdio/stdout interface.

conao3 avatar Apr 29 '20 06:04 conao3

You can see an example of this kind of implementation in jorgenschaefer/elpy, although as it notes at the top, it uses a limited JSON-RPC implementation itself.

lambdadog avatar Apr 06 '21 02:04 lambdadog