Skip to content

Commit 6c719c6

Browse files
arichiardibbatsov
authored andcommitted
Avoid leaking buffers from inf-clojure--process-response
1 parent 903dd73 commit 6c719c6

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

inf-clojure.el

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,25 +1220,25 @@ output from and including the `inf-clojure-prompt`."
12201220
(sanitized-command (inf-clojure--sanitize-command command)))
12211221
(when (not (string-empty-p sanitized-command))
12221222
(inf-clojure--log-string command "----CMD->")
1223-
(set-buffer (inf-clojure--get-redirect-buffer))
1224-
(erase-buffer)
1225-
(comint-redirect-send-command-to-process sanitized-command redirect-buffer-name process nil t)
1223+
(with-current-buffer (inf-clojure--get-redirect-buffer)
1224+
(erase-buffer)
1225+
(comint-redirect-send-command-to-process sanitized-command redirect-buffer-name process nil t))
12261226
;; Wait for the process to complete
1227-
(set-buffer (process-buffer process))
1228-
(while (and (null comint-redirect-completed)
1229-
(accept-process-output process 1 0 t))
1230-
(sleep-for 0.01))
1227+
(with-current-buffer (process-buffer process)
1228+
(while (and (null comint-redirect-completed)
1229+
(accept-process-output process 1 0 t))
1230+
(sleep-for 0.01)))
12311231
;; Collect the output
1232-
(set-buffer redirect-buffer-name)
1233-
(goto-char (point-min))
1234-
(let* ((buffer-string (buffer-substring-no-properties (point-min) (point-max)))
1235-
(boundaries (inf-clojure--string-boundaries buffer-string inf-clojure-prompt beg-regexp end-regexp))
1236-
(beg-pos (car boundaries))
1237-
(end-pos (car (cdr boundaries)))
1238-
(prompt-pos (car (cdr (cdr boundaries))))
1239-
(response-string (substring buffer-string beg-pos (min end-pos prompt-pos))))
1240-
(inf-clojure--log-string buffer-string "<-RES----")
1241-
response-string))))
1232+
(with-current-buffer redirect-buffer-name
1233+
(goto-char (point-min))
1234+
(let* ((buffer-string (buffer-substring-no-properties (point-min) (point-max)))
1235+
(boundaries (inf-clojure--string-boundaries buffer-string inf-clojure-prompt beg-regexp end-regexp))
1236+
(beg-pos (car boundaries))
1237+
(end-pos (car (cdr boundaries)))
1238+
(prompt-pos (car (cdr (cdr boundaries))))
1239+
(response-string (substring buffer-string beg-pos (min end-pos prompt-pos))))
1240+
(inf-clojure--log-string buffer-string "<-RES----")
1241+
response-string)))))
12421242

12431243
(defun inf-clojure--nil-string-match-p (string)
12441244
"Return true iff STRING is not nil.

0 commit comments

Comments
 (0)