diff options
author | Jon Pither <jon.pither@gmail.com> | 2016-02-28 12:37:50 +0000 |
---|---|---|
committer | Jon Pither <jon.pither@gmail.com> | 2016-02-28 12:37:50 +0000 |
commit | 946627ba4f56b543291c8e73e2ea448f7ac943a4 (patch) | |
tree | 328f8bcea583cfce7a903864252842f0e7d37859 /nrepl-client.el | |
parent | 6cbcf4eef48450c87669b2ed61e6d73ed6c510dd (diff) |
[Fix #1578] Add a guard for missing process-buffer
Diffstat (limited to 'nrepl-client.el')
-rw-r--r-- | nrepl-client.el | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/nrepl-client.el b/nrepl-client.el index 8e5da4cb..a72b5829 100644 --- a/nrepl-client.el +++ b/nrepl-client.el @@ -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") |