The old scala-mode works on emacs 23 and newer. It is available from Marmalade and from https://github.com/scala/scala-dist/tree/master/tool-support/src/emacs
SBT support for scala-mode2 is available as a separate mode from https://github.com/hvesalai/sbt-mode
Here is an example configuration using the old scala-mode with ensime. However ensime now suggests using scala-mode2.
(setq exec-path (append exec-path (list "/home/seth/.opt/scala/bin" ))) ;;change to location of scala bin!!! necessary for comint. (require 'scala-mode-auto) (require 'ensime) (add-hook 'scala-mode-hook 'ensime-scala-mode-hook) (eval-after-load "scala-mode" '(progn (define-key scala-mode-map (kbd "<f9>") 'ensime-builder-build) (define-key scala-mode-map (kbd "<f10>") 'ensime-inf-switch))) (eval-after-load "scala-mode" '(progn (add-hook 'scala-mode-hook 'ensime-scala-mode-hook) (define-key scala-mode-map (kbd "<f9>") 'scala-run) (define-key scala-mode-map (kbd "RET") 'newline-and-indent) )) (defun scala-run () (interactive) (ensime-sbt-action "run") (ensime-sbt-action "~compile") (let ((c (current-buffer))) (switch-to-buffer-other-window (get-buffer-create (ensime-sbt-build-buffer-name))) (switch-to-buffer-other-window c))) (setq exec-path (append exec-path (list "~/.opt/scala/bin"))) ;;REPLACE THIS with the directory of your scalac executable!
Ok, so create a random file in the source directory created by sbt that contains some random code. Run ensime-config-project, follow instructions, etc. It should suggest that the project is of type sbt. Now, run the command ‘ensime’ – it should connect with ensime. Now, type C-c C-v s, this will start the scala sbt process. I suggest opening it in another frame by using ‘C-x 5 2’.
And you can now hit f9 to run your code - ok, so you have to hit it twice for some reason!