Skip to content

Commit 59a9f06

Browse files
authored
Ensure repl scrolls on insert (#204)
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 now I'm bringing the same trick here. See clojure-emacs/cider#2590 for more details.
1 parent f436760 commit 59a9f06

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## master (unreleased)
44
* [#202](https://github.com/clojure-emacs/inf-clojure/issues/202): Add ClojureCLR support.
5+
* [#204](https://github.com/clojure-emacs/inf-clojure/issues/204): Scroll repl buffer on insert commands
6+
57

68
## 3.2.1 (2022-07-22)
79

inf-clojure.el

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -920,16 +920,21 @@ 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+
;; ensure the repl buffer scrolls. See similar fix in CIDER:
924+
;; https://github.com/clojure-emacs/cider/pull/2590
925+
(with-selected-window (or (get-buffer-window inf-clojure-buffer)
926+
(selected-window))
927+
(with-current-buffer (process-buffer clojure-process)
928+
(comint-goto-process-mark)
929+
(let ((beginning (point)))
930+
(insert form)
931+
(let ((end (point)))
932+
(goto-char beginning)
933+
(indent-sexp end)
934+
;; font-lock the inserted code
935+
(font-lock-ensure beginning end)
936+
(goto-char end)))
937+
(comint-send-input t t)))))
933938

934939
(defun inf-clojure-insert-defun ()
935940
"Send current defun to process."

0 commit comments

Comments
 (0)