mirror of
https://github.com/vale981/apheleia
synced 2025-03-04 17:11:40 -05:00
Use :connection-type pipe when creating local processes (#119)
* Use :connection-type pipe when creating local processes This is helpful because some formatters, rather than having an option to enable reading from stdin, simply check whether their input comes from a pipe or terminal. Should close #118 * Document changes * Break long lines * Link to PR Co-authored-by: Radon Rosborough <radon@intuitiveexplanations.com>
This commit is contained in:
parent
0c5e40e8bc
commit
ebb62564a8
2 changed files with 13 additions and 5 deletions
|
@ -8,6 +8,9 @@ The format is based on [Keep a Changelog].
|
|||
* shfmt uses 4 spaces instead of tabs by default.
|
||||
* Formatters using `'filepath` (OCamlFormat and Prettier) are no
|
||||
longer prevented from running on a modified buffer ([#109], [#110]).
|
||||
* Buffer content is now always passed to formatters using a pipe. This
|
||||
fixes issues with formatters that behave differently when receiving
|
||||
input on stdin versus being run on a tty ([#119]).
|
||||
|
||||
### Formatters
|
||||
* [bean-format](https://github.com/beancount/beancount) for Beancount
|
||||
|
@ -18,6 +21,7 @@ The format is based on [Keep a Changelog].
|
|||
[#105]: https://github.com/radian-software/apheleia/pull/105
|
||||
[#109]: https://github.com/radian-software/apheleia/issues/109
|
||||
[#110]: https://github.com/radian-software/apheleia/pull/110
|
||||
[#119]: https://github.com/radian-software/apheleia/pull/119
|
||||
|
||||
## 3.0 (released 2022-06-01)
|
||||
### Breaking changes
|
||||
|
|
14
apheleia.el
14
apheleia.el
|
@ -309,7 +309,8 @@ at once.")
|
|||
This points into a log buffer.")
|
||||
|
||||
(cl-defun apheleia--make-process
|
||||
(&key name stdin stdout stderr command remote noquery callback)
|
||||
(&key name stdin stdout stderr command
|
||||
remote noquery connection-type callback)
|
||||
"Helper to run a formatter process asynchronously.
|
||||
This starts a formatter process using COMMAND and then connects STDIN,
|
||||
STDOUT and STDERR buffers to the processes different streams. Once the
|
||||
|
@ -326,6 +327,7 @@ See `make-process' for a description of the NAME and NOQUERY arguments."
|
|||
:command command
|
||||
:file-handler remote
|
||||
:noquery noquery
|
||||
:connection-type connection-type
|
||||
:sentinel
|
||||
(lambda (proc _event)
|
||||
(unless (process-live-p proc)
|
||||
|
@ -344,7 +346,8 @@ See `make-process' for a description of the NAME and NOQUERY arguments."
|
|||
proc))
|
||||
|
||||
(cl-defun apheleia--call-process
|
||||
(&key name stdin stdout stderr command remote noquery callback)
|
||||
(&key name stdin stdout stderr command
|
||||
remote noquery connection-type callback)
|
||||
"Helper to synchronously run a formatter process.
|
||||
This function essentially runs COMMAND synchronously passing STDIN
|
||||
as standard input and saving output to the STDOUT and STDERR buffers.
|
||||
|
@ -352,9 +355,9 @@ Once the process is finished CALLBACK will be invoked with the exit
|
|||
code (see `process-exit-status') of the process.
|
||||
|
||||
This function accepts all the same arguments as `apheleia--make-process'
|
||||
for simplicity, however some may not be used. This includes: NAME, and
|
||||
NO-QUERY."
|
||||
(ignore name noquery)
|
||||
for simplicity, however some may not be used. This includes: NAME,
|
||||
NO-QUERY, and CONNECTION-TYPE."
|
||||
(ignore name noquery connection-type)
|
||||
(let* ((run-on-remote (and (eq apheleia-remote-algorithm 'remote)
|
||||
remote))
|
||||
(stderr-file (apheleia--make-temp-file run-on-remote "apheleia"))
|
||||
|
@ -470,6 +473,7 @@ spawned on remote machines."
|
|||
:stderr stderr
|
||||
:command command
|
||||
:remote remote
|
||||
:connection-type 'pipe
|
||||
:noquery t
|
||||
:callback
|
||||
(lambda (proc-exit-status)
|
||||
|
|
Loading…
Add table
Reference in a new issue