Skip to content

Commit 946627b

Browse files
committed
[Fix #1578] Add a guard for missing process-buffer
1 parent 6cbcf4e commit 946627b

File tree

2 files changed

+28
-24
lines changed

2 files changed

+28
-24
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ and try to associate the created connection with this project automatically.
4242

4343
### Bugs fixed
4444

45+
* [#1578](https://github.com/clojure-emacs/cider/issues/1578): nrepl-server-filter called with dead process buffer in Windows.
4546
* [#1441](https://github.com/clojure-emacs/cider/issues/1441): Don't popup a buffer that's already displayed.
4647
* [#1557](https://github.com/clojure-emacs/cider/issues/1557): When a sibling REPL is started by hasn't yet turned into a cljs REPL, it won't hijack clj requests.
4748
* [#1562](https://github.com/clojure-emacs/cider/issues/1562): Actually disable cider-mode when it gets disabled.

nrepl-client.el

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,30 +1110,33 @@ the port, and the client buffer."
11101110

11111111
(defun nrepl-server-filter (process output)
11121112
"Process nREPL server output from PROCESS contained in OUTPUT."
1113-
(with-current-buffer (process-buffer process)
1114-
;; auto-scroll on new output
1115-
(let ((moving (= (point) (process-mark process))))
1116-
(save-excursion
1117-
(goto-char (process-mark process))
1118-
(insert output)
1119-
(set-marker (process-mark process) (point)))
1120-
(when moving
1121-
(goto-char (process-mark process))
1122-
(when-let ((win (get-buffer-window)))
1123-
(set-window-point win (point))))))
1124-
;; detect the port the server is listening on from its output
1125-
(when (string-match "nREPL server started on port \\([0-9]+\\)" output)
1126-
(let ((port (string-to-number (match-string 1 output))))
1127-
(message "nREPL server started on %s" port)
1128-
(with-current-buffer (process-buffer process)
1129-
(let* ((client-proc (nrepl-start-client-process nil port process))
1130-
(client-buffer (process-buffer client-proc)))
1131-
(setq nrepl-client-buffers
1132-
(cons client-buffer
1133-
(delete client-buffer nrepl-client-buffers)))
1134-
1135-
(when (functionp nrepl-post-client-callback)
1136-
(funcall nrepl-post-client-callback client-buffer)))))))
1113+
;; In Windows this can be false:
1114+
(let ((server-buffer (process-buffer process)))
1115+
(when (buffer-live-p server-buffer)
1116+
(with-current-buffer server-buffer
1117+
;; auto-scroll on new output
1118+
(let ((moving (= (point) (process-mark process))))
1119+
(save-excursion
1120+
(goto-char (process-mark process))
1121+
(insert output)
1122+
(set-marker (process-mark process) (point)))
1123+
(when moving
1124+
(goto-char (process-mark process))
1125+
(when-let ((win (get-buffer-window)))
1126+
(set-window-point win (point))))))
1127+
;; detect the port the server is listening on from its output
1128+
(when (string-match "nREPL server started on port \\([0-9]+\\)" output)
1129+
(let ((port (string-to-number (match-string 1 output))))
1130+
(message "nREPL server started on %s" port)
1131+
(with-current-buffer server-buffer
1132+
(let* ((client-proc (nrepl-start-client-process nil port process))
1133+
(client-buffer (process-buffer client-proc)))
1134+
(setq nrepl-client-buffers
1135+
(cons client-buffer
1136+
(delete client-buffer nrepl-client-buffers)))
1137+
1138+
(when (functionp nrepl-post-client-callback)
1139+
(funcall nrepl-post-client-callback client-buffer)))))))))
11371140

11381141
(declare-function cider--close-connection-buffer "cider-client")
11391142

0 commit comments

Comments
 (0)