@@ -1043,6 +1043,20 @@ been determined."
1043
1043
(propertize cmd 'face 'font-lock-keyword-face ))
1044
1044
serv-proc)))
1045
1045
1046
+ (defconst nrepl-listening-address-regexp
1047
+ (rx (or
1048
+ ; ; standard
1049
+ (and " nREPL server started on port " (group-n 1 (+ (any " 0-9" ))))
1050
+ ; ; babashka
1051
+ (and " Started nREPL server at "
1052
+ (group-n 2 (+? any)) " :" (group-n 1 (+ (any " 0-9" ))))))
1053
+ " A regexp to search an nREPL's stdout for the address it is listening on.
1054
+
1055
+ If it matches, the address components can be extracted using the following
1056
+ match groups:
1057
+ 1 for the port, and
1058
+ 2 for the host (babashka only)." )
1059
+
1046
1060
(defun nrepl-server-filter (process output )
1047
1061
" Process nREPL server output from PROCESS contained in OUTPUT."
1048
1062
; ; In Windows this can be false:
@@ -1062,10 +1076,12 @@ been determined."
1062
1076
(set-window-point win (point )))))
1063
1077
; ; detect the port the server is listening on from its output
1064
1078
(when (and (null nrepl-endpoint)
1065
- (string-match " nREPL server started on port \\ ([0-9]+\\ )" output))
1066
- (let ((port (string-to-number (match-string 1 output))))
1067
- (setq nrepl-endpoint (list :host (or (file-remote-p default-directory 'host )
1068
- " localhost" )
1079
+ (string-match nrepl-listening-address-regexp output))
1080
+ (let ((host (or (match-string 2 output)
1081
+ (file-remote-p default-directory 'host )
1082
+ " localhost" ))
1083
+ (port (string-to-number (match-string 1 output))))
1084
+ (setq nrepl-endpoint (list :host host
1069
1085
:port port))
1070
1086
(message " [nREPL] server started on %s " port)
1071
1087
(when nrepl-on-port-callback
0 commit comments