Function: apheleia--make-process

apheleia--make-process is a natively compiled function defined in apheleia-formatters.el.

Signature

(apheleia--make-process &key NAME STDIN STDOUT STDERR COMMAND REMOTE NOQUERY CONNECTION-TYPE CALLBACK)

Documentation

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 process is finished CALLBACK will be invoked with the exit-code of the formatter process as well as a boolean saying whether the process was interrupted before completion. REMOTE if supplied will be passed as the FILE-HANDLER argument to make-process.

See make-process for a description of the NAME and NOQUERY arguments.

Source Code

;; Defined in /nix/store/lwcwryzabcmvjcwwzzs65jrwf7p7d7cs-emacs-packages-deps/share/emacs/site-lisp/elpa/apheleia-20260915.1628/apheleia-formatters.el
(cl-defun apheleia--make-process
    (&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 process is finished CALLBACK will be invoked
with the exit-code of the formatter process as well as a boolean
saying whether the process was interrupted before completion.
REMOTE if supplied will be passed as the FILE-HANDLER argument to
`make-process'.

See `make-process' for a description of the NAME and NOQUERY
arguments."
  (apheleia--log
   'process "Using make-process to create process %s with %S" name command)
  (let ((proc
         (make-process
          :name name
          :buffer stdout
          :stderr stderr
          :command command
          :file-handler remote
          :noquery noquery
          :connection-type connection-type
          :sentinel
          (lambda (proc _event)
            (unless (process-live-p proc)
              (funcall
               callback
               (process-exit-status proc)
               (process-get proc :interrupted)))))))
    (set-process-sentinel (get-buffer-process stderr) #'ignore)
    (when stdin
      (apheleia--log
       'process
       "Sending %d bytes to stdin of process %s" (buffer-size stdin) name)
      (set-process-coding-system
       proc
       nil
       (buffer-local-value 'buffer-file-coding-system stdin))
      (process-send-string
       proc
       (with-current-buffer stdin
         (buffer-string))))
    (process-send-eof proc)
    proc))