forked from jochu/swank-clojure
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswank.clj
46 lines (41 loc) · 1.43 KB
/
swank.clj
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
;;;; swank-clojure.clj --- Swank server for Clojure
;;;
;;; Copyright (C) 2008 Jeffrey Chu
;;;
;;; This file is licensed under the terms of the GNU General Public
;;; License as distributed with Emacs (press C-h C-c to view it).
;;;
;;; See README file for more information about installation
;;;
(ns swank
(:use (swank core)
(swank.core connection server)
(swank.util.concurrent thread))
(:require (swank.util.concurrent [mbox :as mb])
(swank commands)
(swank.commands basic indent contrib inspector)))
(defn ignore-protocol-version [version]
(dosync (ref-set *protocol-version* version)))
(defn- connection-serve [conn]
(let [control
(dothread-swank
(thread-set-name "Swank Control Thread")
(control-loop conn))
read
(dothread-swank
(thread-set-name "Read Loop Thread")
(read-loop conn control))]
(dosync
(ref-set (conn :control-thread) control)
(ref-set (conn :read-thread) read))))
(defn start-server
"Start the server and write the listen port number to
PORT-FILE. This is the entry point for Emacs."
([port-file & opts]
(let [opts (apply hash-map opts)]
(setup-server (get opts :port 0)
(fn announce-port [port]
(announce-port-to-file port-file port)
(simple-announce port))
connection-serve
opts))))