Function: nrepl-start-client-process
nrepl-start-client-process is a byte-compiled function defined in
nrepl-client.el.
Signature
(nrepl-start-client-process &optional HOST PORT SERVER-PROC BUFFER-BUILDER SOCKET-FILE)
Documentation
Create new client process identified by either HOST and PORT or SOCKET-FILE.
If SOCKET-FILE is non-nil, it takes precedence. In remote buffers, HOST
and PORT are taken from the current tramp connection. SERVER-PROC must be
a running nREPL server process within Emacs. BUFFER-BUILDER is a function
of one argument (endpoint returned by nrepl-connect) which returns a
client buffer. Return the newly created client process.
Source Code
;; Defined in ~/.emacs.d/elpa/cider-20260414.1619/nrepl-client.el
(defun nrepl-start-client-process (&optional host port server-proc buffer-builder socket-file)
"Create new client process identified by either HOST and PORT or SOCKET-FILE.
If SOCKET-FILE is non-nil, it takes precedence. In remote buffers, HOST
and PORT are taken from the current tramp connection. SERVER-PROC must be
a running nREPL server process within Emacs. BUFFER-BUILDER is a function
of one argument (endpoint returned by `nrepl-connect') which returns a
client buffer. Return the newly created client process."
(let* ((endpoint (if socket-file
(nrepl--unix-connect (expand-file-name socket-file))
(nrepl-connect host port)))
(client-proc (plist-get endpoint :proc))
(builder (or buffer-builder (error "`buffer-builder' must be provided")))
(client-buf (funcall builder endpoint)))
(set-process-buffer client-proc client-buf)
(set-process-filter client-proc #'nrepl-client-filter)
(set-process-sentinel client-proc #'nrepl-client-sentinel)
(set-process-coding-system client-proc 'utf-8-unix 'utf-8-unix)
(process-put client-proc :string-q (queue-create))
(process-put client-proc :response-q (nrepl-response-queue))
(with-current-buffer client-buf
(when-let* ((server-buf (and server-proc (process-buffer server-proc))))
(setq nrepl-project-dir (buffer-local-value 'nrepl-project-dir server-buf)
nrepl-server-buffer server-buf))
(setq nrepl-endpoint endpoint
nrepl-tunnel-buffer (when-let* ((tunnel (plist-get endpoint :tunnel)))
(process-buffer tunnel))
nrepl-pending-requests (make-hash-table :test 'equal)
nrepl-completed-requests (make-hash-table :test 'equal)))
(with-current-buffer client-buf
(nrepl--init-client-sessions client-proc)
(nrepl--init-capabilities client-buf)
(run-hooks 'nrepl-connected-hook))
client-proc))