Jordan Ellis Coppard <jc+o.em...@wz.ht> writes:

> Hi Michael,

Hi Jordan,

> I'm going to try and add support for remote formatting commands for
> this package: https://github.com/purcell/emacs-reformatter/issues/32
>
> The entire package itself is ~350 lines of elisp with a majority of
> that being documentation comments. I wonder if you can advise me on
> the best approach to take here.
>
> Imagine the scenario where a user is working on a remote project using
> Tramp and they want to run whatever their project's source-code
> formatting tool is. There are two possible cases:
>
> 1. The user just happens to have that same tool installed locally;
> 2. The user only has the tool installed remotely where their project is.
>
> In (1)s case I imagine an on-save hook simply uses call-process to
> execute the formatting tool, the formatted contents replace the
> buffer, and when the buffer is saved Tramp handles copying the file to
> the remote -- effectively this is no different from _not_ using a
> formatting tool and saving a buffer which Tramp is going to copy to a
> remote anyway.

Yep.

> In (2)s case, and preferring asynchronous processes so as to not block
> Emacs, would you advise using make-pipe-process, make-process,
> start-file-process (or others)?

make-pipe-process isn't supported by Tramp. start-file-proces, in Tramp,
is just a wrapper around make-process. See tramp-handle-start-file-process.

> In the case the remote formatting command is given as an absolute path
> I imagine a pipe process could work best (no shell required, extra
> Tramp regex-matching, looking through $PATH to find the command
> executable); am I mistaken there or is that generally true?

In general yes. I don't remember completely the details, but I believe a
direct async process, calling make-process remotely, with
:connection-type 'pipe' would be the best, according to my gut feeling.

> /Jordan

Best regards, Michael.

Reply via email to