Skip to content

Commit

Permalink
Merge pull request #1590 from jonpither/master
Browse files Browse the repository at this point in the history
[Fix #1578] Add a guard for missing process-buffer
  • Loading branch information
bbatsov committed Feb 28, 2016
2 parents 010f47d + 946627b commit d8aed58
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 24 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ and try to associate the created connection with this project automatically.

### Bugs fixed

* [#1578](https://github.com/clojure-emacs/cider/issues/1578): nrepl-server-filter called with dead process buffer in Windows.
* [#1441](https://github.com/clojure-emacs/cider/issues/1441): Don't popup a buffer that's already displayed.
* [#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.
* [#1562](https://github.com/clojure-emacs/cider/issues/1562): Actually disable cider-mode when it gets disabled.
Expand Down
51 changes: 27 additions & 24 deletions nrepl-client.el
Original file line number Diff line number Diff line change
Expand Up @@ -1110,30 +1110,33 @@ the port, and the client buffer."

(defun nrepl-server-filter (process output)
"Process nREPL server output from PROCESS contained in OUTPUT."
(with-current-buffer (process-buffer process)
;; auto-scroll on new output
(let ((moving (= (point) (process-mark process))))
(save-excursion
(goto-char (process-mark process))
(insert output)
(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 (string-match "nREPL server started on port \\([0-9]+\\)" output)
(let ((port (string-to-number (match-string 1 output))))
(message "nREPL server started on %s" port)
(with-current-buffer (process-buffer process)
(let* ((client-proc (nrepl-start-client-process nil port process))
(client-buffer (process-buffer client-proc)))
(setq nrepl-client-buffers
(cons client-buffer
(delete client-buffer nrepl-client-buffers)))

(when (functionp nrepl-post-client-callback)
(funcall nrepl-post-client-callback client-buffer)))))))
;; 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)
(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 (string-match "nREPL server started on port \\([0-9]+\\)" output)
(let ((port (string-to-number (match-string 1 output))))
(message "nREPL server started on %s" port)
(with-current-buffer server-buffer
(let* ((client-proc (nrepl-start-client-process nil port process))
(client-buffer (process-buffer client-proc)))
(setq nrepl-client-buffers
(cons client-buffer
(delete client-buffer nrepl-client-buffers)))

(when (functionp nrepl-post-client-callback)
(funcall nrepl-post-client-callback client-buffer)))))))))

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

Expand Down

0 comments on commit d8aed58

Please sign in to comment.