Skip to content

Commit fa51378

Browse files
committed
Ensure repl scrolls on insert
When inserting forms into the repl, the buffer doesn't always scroll to show the new input and result. This has been fixed in CIDER in a similar way so bringing the same trick here. clojure-emacs/cider#2590
1 parent f436760 commit fa51378

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

inf-clojure.el

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -920,16 +920,19 @@ Prefix argument AND-GO means switch to the Clojure buffer afterwards."
920920
"Insert FORM into process and evaluate.
921921
Indent FORM. FORM is expected to have been trimmed."
922922
(let ((clojure-process (inf-clojure-proc)))
923-
(with-current-buffer (process-buffer clojure-process)
924-
(comint-goto-process-mark)
925-
(let ((beginning (point)))
926-
(insert (format "%s" form))
927-
(let ((end (point)))
928-
(goto-char beginning)
929-
(indent-sexp end)
930-
;; font-lock the inserted code
931-
(font-lock-ensure beginning end)))
932-
(comint-send-input t t))))
923+
(with-selected-window (or (get-buffer-window inf-clojure-buffer)
924+
(selected-window))
925+
(with-current-buffer (process-buffer clojure-process)
926+
(comint-goto-process-mark)
927+
(let ((beginning (point)))
928+
(insert form)
929+
(let ((end (point)))
930+
(goto-char beginning)
931+
(indent-sexp end)
932+
;; font-lock the inserted code
933+
(font-lock-ensure beginning end)
934+
(goto-char end)))
935+
(comint-send-input t t)))))
933936

934937
(defun inf-clojure-insert-defun ()
935938
"Send current defun to process."

0 commit comments

Comments
 (0)