Skip to content

Conversation

jkxyz
Copy link

@jkxyz jkxyz commented Mar 21, 2025

Two changes need to be made to support Tramp remote buffers:

  1. Pass the second REMOTE arg to executable-find to find the executable on the remote host

  2. Avoid using call-process-region, which doesn't have a Tramp equivalent

This change replaces call-process-region with process-file which supports executing via Tramp. This function requires writing the buffer contents to a temporary file first.

Although writing the buffer to a file may have perfomance implications vs. writing from memory to stdin, they are likely to be negligibile. Furthermore, this approach is similar to other formatting libraries like prettier.el:

https://github.com/jscheid/prettier.el/blob/master/prettier.el#L1494

I've also found it to be more reliable than process-send-string.

Two changes need to be made to support Tramp remote buffers:

    1. Pass the second REMOTE arg to `executable-find` to find the
    executable on the remote host

    2. Avoid using `call-process-region`, which doesn't have a Tramp
    equivalent

This change replaces `call-process-region` with `process-file` which
supports executing via Tramp. This function requires writing the
buffer contents to a temporary file first.

Although writing the buffer to a file may have perfomance implications
vs. writing from memory to stdin, they are likely to be
negligibile. Furthermore, this approach is similar to other formatting
libraries like prettier.el:

https://github.com/jscheid/prettier.el/blob/master/prettier.el#L1494

I've also found it to be more reliable than `process-send-string`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant