Function: cider--close-connection

cider--close-connection is a byte-compiled function defined in cider-connection.el.

Signature

(cider--close-connection REPL &optional NO-KILL)

Documentation

Close connection associated with REPL.

When NO-KILL is non-nil stop the connection but don't kill the REPL buffer.

Source Code

;; Defined in ~/.emacs.d/elpa/cider-20260414.1619/cider-connection.el
(defun cider--close-connection (repl &optional no-kill)
  "Close connection associated with REPL.
When NO-KILL is non-nil stop the connection but don't kill the REPL
buffer."
  (when (buffer-live-p repl)
    (with-current-buffer repl
      (when spinner-current (spinner-stop))
      (when nrepl-tunnel-buffer
        (cider--close-buffer nrepl-tunnel-buffer))
      (when no-kill
        ;; inform sentinel not to kill the server, if any
        (thread-first (get-buffer-process repl)
                      (process-plist)
                      (plist-put :keep-server t))))
    (let ((proc (get-buffer-process repl)))
      (when (and (process-live-p proc)
                 (or (not nrepl-server-buffer)
                     ;; Sync request will hang if the server is dead.
                     (process-live-p (get-buffer-process nrepl-server-buffer))))
        (nrepl-sync-request:close repl)
        ;; give a chance to the REPL to respond to the closing of the connection
        (sleep-for 0.5)
        (delete-process proc)))
    (when-let* ((messages-buffer (and nrepl-log-messages
                                      (nrepl-messages-buffer repl))))
      (kill-buffer messages-buffer))
    (unless no-kill
      (kill-buffer repl)))
  (when repl
    (sesman-remove-object 'CIDER nil repl (not no-kill) t)))