This repository has been archived by the owner on Sep 24, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 132
/
Copy pathensime-sbt.el
116 lines (97 loc) · 3.47 KB
/
ensime-sbt.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
;;; ensime-sbt.el --- SBT support for ENSIME
;;
;;;; License
;;
;; Copyright (C) 2008 Raymond Paul Racine
;; Portions Copyright (C) Free Software Foundation
;; Portions Copyright (C) 2010 Aemon Cannon
;;
;; Authors: Luke Amdor, Raymond Racine, Aemon Cannon
;;
;; This file includes code from slime.el of the SLIME project
;; (also licensend under the GNU General Public License.) The
;; following copyrights therefore apply:
;;
;; Copyright (C) 2003 Eric Marsden, Luke Gorrie, Helmut Eller
;; Copyright (C) 2004,2005,2006 Luke Gorrie, Helmut Eller
;; Copyright (C) 2007,2008,2009 Helmut Eller, Tobias C. Rittweiler
;;
;;
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation; either version 2 of
;; the License, or (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public
;; License along with this program; if not, write to the Free
;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
;; MA 02111-1307, USA.
;; Support for running sbt in inferior mode.
;; 20090918 Suggestions from Florian Hars
;; - Removed global manipulations.
;; - Removed colorization attempts to use base sbt anis colorization.
(eval-when-compile
(require 'cl)
(require 'ensime-macros))
(require 'sbt-mode)
(defgroup ensime-sbt nil
"Support for sbt build REPL."
:group 'ensime
:prefix "ensime-sbt-")
(defcustom ensime-sbt-perform-on-save nil
"Which (if any) sbt action to perform when a file is saved."
:type '(choice (const nil) string)
:group 'ensime-sbt)
(defun ensime-sbt ()
"Switch to the sbt shell (create if necessary) if or if already there, back.
If already there but the process is dead, restart the process. "
(interactive)
(ensime-with-conn-interactive
conn
(with-current-buffer (sbt-start)
(setq ensime-buffer-connection conn)
(add-hook 'ensime-source-buffer-saved-hook 'ensime-sbt-maybe-auto-compile)
(add-hook 'comint-output-filter-functions 'ensime-inf-postoutput-filter))))
(defun ensime-sbt-maybe-auto-compile ()
(when (and
(ensime-connected-p)
ensime-sbt-perform-on-save
(get-buffer (sbt:buffer-name)))
(sbt-command ensime-sbt-perform-on-save)))
(defun ensime-sbt-switch ()
(interactive)
(ensime-sbt))
(defun ensime-sbt-do-compile ()
(interactive)
(sbt-command "compile"))
(defun ensime-sbt-do-run ()
(interactive)
(sbt-command "run"))
(defun ensime-sbt-do-clean ()
(interactive)
(sbt-command "clean"))
(defun ensime-sbt-do-package ()
(interactive)
(sbt-command "package"))
(defun ensime-sbt-do-test ()
(interactive)
(sbt-command "test"))
(defun ensime-sbt-do-test-quick ()
(interactive)
(sbt-command "testQuick"))
(defun ensime-sbt-do-test-only ()
(interactive)
(let* ((impl-class
(or (ensime-top-level-class-closest-to-point)
(return (message "Could not find top-level class"))))
(cleaned-class (replace-regexp-in-string "<empty>\\." "" impl-class))
(command (concat "test-only" " " cleaned-class)))
(sbt-command command)))
(provide 'ensime-sbt)
;; Local Variables:
;; End: