Skip to content

Commit 660bc81

Browse files
committed
Harden parsing of repl responses
Add more nil checks and ignore-errors around both the reading of LISP expression and the inf-clojure--response-match-p functionality.
1 parent 9ba23b0 commit 660bc81

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

inf-clojure.el

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,7 @@ prefix argument PROMPT-FOR-SYMBOL, it prompts for a symbol name."
940940
;; Originally from:
941941
;; https://github.com/glycerine/lush2/blob/master/lush2/etc/lush.el#L287
942942
(defun inf-clojure-results-from-process (process command &optional beg-string end-string)
943-
"Send COMMAND to PROCESS.
943+
"Send to PROCESS the given COMMAND.
944944
Return the result of COMMAND starting with BEG-STRING and ending
945945
with END-STRING if non-nil. If BEG-STRING is nil, the result
946946
string will start from (point) in the results buffer. If
@@ -978,7 +978,8 @@ the results buffer. It cuts out the output from
978978
See variable `inf-clojure-arglists-form'."
979979
(let* ((arglists-snippet (format (inf-clojure-arglists-form) fn))
980980
(arglists-result (inf-clojure-results-from-process (inf-clojure-proc) arglists-snippet))
981-
(arglists-data (when arglists-result (read arglists-result))))
981+
;; The following reads the first LISP expression from the string
982+
(arglists-data (when arglists-result (ignore-errors (read arglists-result)))))
982983
(cond
983984
((null arglists-data) nil)
984985
((stringp arglists-data) arglists-data)
@@ -1229,7 +1230,8 @@ to suppress the usage of the target buffer discovery logic."
12291230
"Return MATCH-P on the result of sending FORM to PROC.
12301231
Note that this function will add a \n to the end of the string
12311232
for evaluation, therefore FORM should not include it."
1232-
(funcall match-p (inf-clojure-results-from-process proc form nil)))
1233+
(when-let* ((response (inf-clojure-results-from-process proc form)))
1234+
(funcall match-p response)))
12331235

12341236
;;;; Lumo
12351237
;;;; ====

0 commit comments

Comments
 (0)