forked from magnars/.emacs.d
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsetup-scala-mode.el
executable file
·41 lines (38 loc) · 1.61 KB
/
setup-scala-mode.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
;;(require 'scala-mode nil 'noerror)
(defun my-scala-eval-line ()
"eval current line"
(interactive)
(scala-eval-region (line-beginning-position) (line-end-position))
)
(defun my-scala-eval ()
"Send the current 'definition' to the Scala interpreter.
Cursor is on a line that doesn't start w/ ws or }: eval current line
or else: find prev and next such line that starts w/ non ws { }. That's the start/end of a defn.
"
(interactive)
(save-excursion
;; find the first non-empty line
(beginning-of-line)
(while (and (not (= (point) (point-min)))
(looking-at "\\s-*$"))
(next-line -1))
(while and (not (= (point) (point-max))) (looking-at "\\s") (next-line 1))
(end-of-line)
(let ((end (point)))
;; now we need to find the start
(beginning-of-line)
(while (and (not (= (point) (point-min)))
(looking-at (mapconcat (lambda (x) x)
'("^$" ; empty lines
"^\\s-+" ; empty lines or lines that start with whitespace
"^\\s-*}") ; lines that start with a '}'
"\\|")))
(next-line -1)
(beginning-of-line))
(message "region %s %s" (point) end)
(scala-eval-region (point) end))))
;;(add-hook 'scala-mode-hook (lambda () (local-set-key (kbd "M-;") 'my-scala-eval-line) (local-set-key (kbd "M-'") 'scala-eval-region)))
;(require 'scala-mode)
;;(require 'scala-mode)
;;(add-to-list 'auto-mode-alist '("\\.scala\\'" . scala-mode))
(provide 'setup-scala-mode)