Function: nrepl-client-sentinel

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

Signature

(nrepl-client-sentinel PROCESS MESSAGE)

Documentation

Handle sentinel events from PROCESS.

Notify MESSAGE and if the process is closed run nrepl-disconnected-hook and kill the process buffer.

Source Code

;; Defined in ~/.emacs.d/elpa/cider-20260414.1619/nrepl-client.el
(defun nrepl-client-sentinel (process message)
  "Handle sentinel events from PROCESS.
Notify MESSAGE and if the process is closed run `nrepl-disconnected-hook'
and kill the process buffer."
  (if (string-match "deleted\\b" message)
      (message "[nREPL] Connection closed")
    (message "[nREPL] Connection closed unexpectedly (%s)"
             (substring message 0 -1)))
  (when (equal (process-status process) 'closed)
    (when-let* ((client-buffer (process-buffer process)))
      (sesman-remove-object 'CIDER nil client-buffer
                            (not (process-get process :keep-server))
                            'no-error)
      (nrepl--clear-client-sessions client-buffer)
      (with-current-buffer client-buffer
        (goto-char (point-max))
        (insert-before-markers
         (propertize
          (format "\n*** Closed on %s ***\n" (replace-regexp-in-string "  +"
                                                                       " "
                                                                       (current-time-string)))
          'face 'cider-repl-stderr-face))
        (run-hooks 'nrepl-disconnected-hook)
        (let ((server-buffer nrepl-server-buffer))
          (when (and (buffer-live-p server-buffer)
                     (not (process-get process :keep-server)))
            (setq nrepl-server-buffer nil)
            (nrepl--maybe-kill-server-buffer server-buffer)))))))