Function: nrepl-server-filter
nrepl-server-filter is a byte-compiled function defined in
nrepl-client.el.
Signature
(nrepl-server-filter PROCESS OUTPUT)
Documentation
Process nREPL server output from PROCESS contained in OUTPUT.
The PROCESS plist is updated as (non-exhaustive list):
:nrepl-server-ready set to t when the server is successfully brought
up.
Source Code
;; Defined in ~/.emacs.d/elpa/cider-20260822.1520/nrepl-client.el
(defun nrepl-server-filter (process output)
"Process nREPL server output from PROCESS contained in OUTPUT.
The PROCESS plist is updated as (non-exhaustive list):
:nrepl-server-ready set to t when the server is successfully brought
up."
;; In Windows this can be false:
(let ((server-buffer (process-buffer process)))
(when (buffer-live-p server-buffer)
(with-current-buffer server-buffer
;; auto-scroll on new output
(let ((moving (= (point) (process-mark process))))
(save-excursion
(goto-char (process-mark process))
(insert output)
(ansi-color-apply-on-region (process-mark process) (point))
(set-marker (process-mark process) (point)))
(when moving
(goto-char (process-mark process))
(when-let* ((win (get-buffer-window)))
(set-window-point win (point)))))
;; detect the port the server is listening on from its output
(when (null nrepl-endpoint)
(let ((end (cond
((string-match nrepl-listening-unix-address-regexp output)
(let ((path (match-string 1 output)))
(message "[nREPL] server started on nrepl+unix:%s" path)
(list :host "local-unix-domain-socket"
:port path
:socket-file path)))
((string-match nrepl-listening-inet-address-regexp output)
(let* ((printed-host (match-string 2 output))
(tramp-host (file-remote-p default-directory 'host))
(container-method (nrepl--tramp-container-method))
(port (string-to-number (match-string 1 output)))
(published (and container-method tramp-host
(nrepl--container-published-port
container-method tramp-host port)))
;; When the server prints a wildcard or loopback
;; address, use the TRAMP host (if any) so we
;; connect to the remote machine, not the local
;; one. Otherwise trust the printed host.
;; Containers are special: their TRAMP host (the
;; container name) is not a reachable address, so
;; resolve the port the container publishes on
;; the local host instead.
(host (cond
(published "localhost")
((or (null printed-host)
(member printed-host
'("localhost" "127.0.0.1"
"0.0.0.0" "::1" "::")))
(or tramp-host "localhost"))
(t printed-host))))
(when (and container-method (not published))
(message "[nREPL] Warning: container %s doesn't publish port %s; connecting will likely fail (publish it, e.g. `-p %s:%s`, and make sure the server binds 0.0.0.0)"
tramp-host port port port))
(when published
(message "[nREPL] Container port %s is published on localhost:%s; connecting there" port published))
(message "[nREPL] server started on %s" (or published port))
(list :host host :port (or published port)))))))
(when end
(setq nrepl-endpoint end)
(nrepl--process-plist-put process :nrepl-server-ready t)
(when nrepl-on-port-callback
(funcall nrepl-on-port-callback (process-buffer process))))))))))