@@ -922,15 +922,19 @@ REQUEST is a pair list of the form (\"op\" \"operation\" \"par1-name\"
922
922
(puthash id callback nrepl-pending-requests)
923
923
(process-send-string nil message))))
924
924
925
- (defun nrepl-send-sync-request (request )
925
+ (defun nrepl-send-sync-request (request &optional abort-on-input )
926
926
" Send REQUEST to the nREPL server synchronously.
927
927
Hold till final \" done\" message has arrived and join all response messages
928
- of the same \" op\" that came along."
928
+ of the same \" op\" that came along.
929
+ If ABORT-ON-INPUT is non-nil, the function will return nil at the first
930
+ sign of user input, so as not to hang the interface."
929
931
(let* ((time0 (current-time ))
930
932
(response (cons 'dict nil ))
931
933
status)
932
934
(nrepl-send-request request (lambda (resp ) (nrepl--merge response resp)))
933
- (while (not (member " done" status))
935
+ (while (and (not (member " done" status))
936
+ (not (and abort-on-input
937
+ (input-pending-p ))))
934
938
(setq status (nrepl-dict-get response " status" ))
935
939
; ; If we get a need-input message then the repl probably isn't going
936
940
; ; anywhere, and we'll just timeout. So we forward it to the user.
@@ -947,16 +951,18 @@ of the same \"op\" that came along."
947
951
; ; Clean up the response, otherwise we might repeatedly ask for input.
948
952
(nrepl-dict-put response " status" nil )
949
953
(accept-process-output nil 0.01 ))
950
- (-when-let* ((ex (nrepl-dict-get response " ex" ))
951
- (err (nrepl-dict-get response " err" )))
952
- (cider-repl-emit-interactive-err-output err)
953
- (message err))
954
- (-when-let (id (nrepl-dict-get response " id" ))
955
- ; ; FIXME: This should go away eventually when we get rid of
956
- ; ; pending-request hash table
957
- (with-current-buffer (nrepl-current-connection-buffer)
958
- (remhash id nrepl-pending-requests)))
959
- response))
954
+ ; ; If we couldn't finish, return nil.
955
+ (when (member " done" status)
956
+ (-when-let* ((ex (nrepl-dict-get response " ex" ))
957
+ (err (nrepl-dict-get response " err" )))
958
+ (cider-repl-emit-interactive-err-output err)
959
+ (message err))
960
+ (-when-let (id (nrepl-dict-get response " id" ))
961
+ ; ; FIXME: This should go away eventually when we get rid of
962
+ ; ; pending-request hash table
963
+ (with-current-buffer (nrepl-current-connection-buffer)
964
+ (remhash id nrepl-pending-requests)))
965
+ response)))
960
966
961
967
(defun nrepl-request:stdin (input callback )
962
968
" Send a :stdin request with INPUT.
0 commit comments