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):

:cider--nrepl-server-ready set to t when the server is successfully brought
up.

Source Code

;; Defined in ~/.emacs.d/elpa/cider-20260414.1619/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):

:cider--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 ((host (or (match-string 2 output)
                                       (file-remote-p default-directory 'host)
                                       "localhost"))
                             (port (string-to-number (match-string 1 output))))
                         (message "[nREPL] server started on %s" port)
                         (list :host host :port port))))))
            (when end
              (setq nrepl-endpoint end)
              (cider--process-plist-put process :cider--nrepl-server-ready t)
              (when nrepl-on-port-callback
                (funcall nrepl-on-port-callback (process-buffer process))))))))))