Skip to content

Commit ee72d95

Browse files
committed
Optimize list scanning in response
1 parent be72ac4 commit ee72d95

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

inf-clojure.el

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -965,18 +965,15 @@ the `inf-clojure-prompt`."
965965
;; Collect the output
966966
(set-buffer work-buffer)
967967
(goto-char (point-min))
968-
;; Skip past the command, if it was echoed
969-
(and (looking-at command)
970-
(forward-line))
971-
(let* ((beg (if beg-string
972-
(progn (search-forward beg-string nil t) (match-beginning 0))
973-
(point)))
974-
(end (if end-string
975-
(search-forward end-string nil t)
976-
(point-max)))
977-
(buffer-string (buffer-substring-no-properties beg end)))
978-
(when (and buffer-string (string-match inf-clojure-prompt buffer-string))
979-
(substring buffer-string 0 (match-beginning 0)))))))
968+
(let* ((beg (or (when (and beg-string (search-forward beg-string nil t))
969+
(match-beginning 0))
970+
(point-min)))
971+
(end (or (when end-string
972+
(search-forward end-string nil t))
973+
(point-max)))
974+
(prompt (when (search-forward inf-clojure-prompt nil t)
975+
(match-beginning 0))))
976+
(buffer-substring-no-properties beg (or prompt end))))))
980977

981978
(defun inf-clojure--nil-string-match-p (string)
982979
"Return true iff STRING is not nil.
@@ -1025,7 +1022,7 @@ for evaluation, therefore FORM should not include it."
10251022
See variable `inf-clojure-arglists-form'."
10261023
(thread-first
10271024
(format (inf-clojure-arglists-form) fn)
1028-
(inf-clojure--process-response (inf-clojure-proc))
1025+
(inf-clojure--process-response (inf-clojure-proc) "(" ")")
10291026
(inf-clojure--read-or-nil)
10301027
(inf-clojure--list-or-nil)))
10311028

@@ -1098,7 +1095,7 @@ See variable `inf-clojure-buffer'."
10981095
(when (not (string-blank-p expr))
10991096
(thread-first
11001097
(format (inf-clojure-completion-form) (substring-no-properties expr))
1101-
(inf-clojure--process-response (inf-clojure-proc))
1098+
(inf-clojure--process-response (inf-clojure-proc) "(" ")")
11021099
(inf-clojure--read-or-nil)
11031100
(inf-clojure--list-or-nil))))
11041101

0 commit comments

Comments
 (0)