Function: async-send

async-send is a natively compiled function defined in async.el.

Signature

(async-send PROCESS-OR-KEY &rest ARGS)

Documentation

Send the given message to the asynchronous child or parent Emacs.

To send messages from the parent to a child, PROCESS-OR-KEY is the child process object. ARGS is a plist. Example:

  (async-send proc :operation :load-file :file "this file")

To send messages from the child to the parent, PROCESS-OR-KEY is the first key of the plist, ARGS is a value followed by optionally more key-value pairs. Example:

  (async-send :status "finished" :file-size 123)

Source Code

;; Defined in /nix/store/jhxqyr2zk061dl3wd3vm38lw3zin47b9-emacs-packages-deps/share/emacs/site-lisp/elpa/async-20260729.1431/async.el
(defun async-send (process-or-key &rest args)
  "Send the given message to the asynchronous child or parent Emacs.

To send messages from the parent to a child, PROCESS-OR-KEY is
the child process object.  ARGS is a plist.  Example:

  (async-send proc :operation :load-file :file \"this file\")

To send messages from the child to the parent, PROCESS-OR-KEY is
the first key of the plist, ARGS is a value followed by
optionally more key-value pairs.  Example:

  (async-send :status \"finished\" :file-size 123)"
  (let ((args (append args '(:async-message t))))
    (if async-in-child-emacs
        ;; `princ' because async--insert-sexp already quotes everything.
        (princ
         (with-temp-buffer
           (async--insert-sexp (cons process-or-key args))
           ;; always make sure that one message package has its own
           ;; line as there can be any random debug garbage printed
           ;; above it.
           (concat "\n" (buffer-string))))
      (async--transmit-sexp process-or-key (list 'quote args)))))