diff --git a/modules/lang/scala/autoload.el b/modules/lang/scala/autoload.el index 4733c1561..74b9957cf 100644 --- a/modules/lang/scala/autoload.el +++ b/modules/lang/scala/autoload.el @@ -40,11 +40,15 @@ Meant to be used for `scala-mode's `comment-line-break-function'." (interactive) (if (and (require 'sbt-mode nil t) (sbt:find-root)) - (run-scala) - (let ((buffer-name "*scala-repl") - buffer) - (unless (comint-check-proc buffer-name) - (setq buffer (make-comint-in-buffer - "scala-repl" buffer-name "scala"))) + (let ((buffer-name (sbt:buffer-name))) + (unless (comint-check-proc buffer-name) + (kill-buffer buffer-name)) + (run-scala) + (get-buffer buffer-name)) + (let* ((buffer-name "*scala-repl") + (buffer + (if (comint-check-proc buffer-name) + (get-buffer buffer-name) + (make-comint-in-buffer "scala-repl" buffer-name "scala")))) (display-buffer buffer) buffer)))