Function: nrepl-client-filter

nrepl-client-filter is a byte-compiled function defined in nrepl-client.el.

Signature

(nrepl-client-filter PROC STRING)

Documentation

Decode message(s) from PROC contained in STRING and dispatch them.

Errors raised by individual response handlers (or by the global nrepl-response-handler-functions hook) are demoted to messages so that a single misbehaving callback cannot poison the response queue and drop later responses on the floor.

Source Code

;; Defined in ~/.emacs.d/elpa/cider-20260822.1520/nrepl-client.el
(defun nrepl-client-filter (proc string)
  "Decode message(s) from PROC contained in STRING and dispatch them.
Errors raised by individual response handlers (or by the global
`nrepl-response-handler-functions' hook) are demoted to messages so that
a single misbehaving callback cannot poison the response queue and drop
later responses on the floor."
  (let ((string-q (process-get proc :string-q)))
    (queue-enqueue string-q string)
    ;; Start decoding only if the last letter is 'e'
    (when (eq ?e (aref string (1- (length string))))
      (let ((response-q (process-get proc :response-q)))
        (nrepl-bdecode string-q response-q)
        (while (queue-head response-q)
          (with-current-buffer (process-buffer proc)
            (let ((response (queue-dequeue response-q)))
              (with-demoted-errors "Error in one of the `nrepl-response-handler-functions': %s"
                (run-hook-with-args 'nrepl-response-handler-functions response))
              (with-demoted-errors "Error in nREPL response dispatch: %s"
                (nrepl--dispatch-response response)))))))))