Function: pfuture-new

pfuture-new is an autoloaded and byte-compiled function defined in pfuture.el.

Signature

(pfuture-new &rest CMD)

Documentation

Create a new future process for command CMD.

Any arguments after the command are interpreted as arguments to the command. This will return a process object with additional 'stderr and 'stdout properties, which can be read via (process-get process 'stdout) and
(process-get process 'stderr) or alternatively with
(pfuture-result process) or (pfuture-stderr process).

Note that CMD must be a *sequence* of strings, meaning this is wrong: (pfuture-new "git status") this is right: (pfuture-new "git" "status")

Source Code

;; Defined in ~/.emacs.d/elpa/pfuture-20220913.1401/pfuture.el
;;;###autoload
(defun pfuture-new (&rest cmd)
  "Create a new future process for command CMD.
Any arguments after the command are interpreted as arguments to the command.
This will return a process object with additional \\='stderr and \\='stdout
properties, which can be read via \(process-get process \\='stdout\) and
\(process-get process \\='stderr\) or alternatively with
\(pfuture-result process\) or \(pfuture-stderr process\).

Note that CMD must be a *sequence* of strings, meaning
this is wrong: (pfuture-new \"git status\")
this is right: (pfuture-new \"git\" \"status\")"
  (let ((stderr (make-pipe-process
                 :name " Process Future stderr"
                 ;; Use a dummy buffer for the stderr process. make-pipe-process creates a
                 ;; buffer unless one is specified, even when :filter is specified and the
                 ;; buffer is not used at all.
                 :buffer (or pfuture--dummy-buffer
                             (setq pfuture--dummy-buffer (get-buffer-create " *pfuture stderr dummy*")))
                 :noquery t
                 :filter #'pfuture--append-stderr)))
    ;; Make sure that the same buffer is not shared between processes.
    ;; This is not a race condition, since the pipe is not yet connected and
    ;; cannot receive input.
    (set-process-buffer stderr nil)
    (condition-case err
        (let* ((name (format " Pfuture-Buffer %s" cmd))
               (pfuture-buffer
                (let (buffer-list-update-hook)
                  (generate-new-buffer name)))
               (process
                (make-process
                 :name "Process Future"
                 :stderr stderr
                 :sentinel #'pfuture--sentinel
                 :filter #'pfuture--append-output-to-buffer
                 :command cmd
                 :noquery t))
               ;; Make the processes share their plist so that 'stderr is easily accessible.
               (plist (list 'buffer pfuture-buffer 'stdout "" 'stderr "" 'stderr-process stderr)))
          (set-process-plist process plist)
          (set-process-plist stderr plist)
          process)
      (error
       (pfuture--delete-process stderr)
       (signal (car err) (cdr err))))))