source: trunk/source/cocoa-ide/swank-ccl-ide.el @ 12164

Last change on this file since 12164 was 12164, checked in by mikel, 11 years ago

SLIME can now request that CCL load and start swank, and automatically connect the SLIME session to the resulting swank server. The UI for this process is still severely impoverished and, in fact, wrong.

File size: 2.1 KB
Line 
1;;;; ***********************************************************************
2;;;; FILE IDENTIFICATION
3;;;;
4;;;; Name:          swank-ccl-ide.el
5;;;; Project:       CCL IDE
6;;;; Purpose:       swank extensions for use with the CCL IDE
7;;;;
8;;;; ***********************************************************************
9
10;;; ABOUT
11;;; ------------------------------------------------------------------------
12
13;;; this file implements an extension to SLIME that talks to CCL's
14;;; Cocoa app
15;;; it provides utilities that:
16;;; 1. tell CCL to find and load the swank-loader currently in use by
17;;;    the running Emacs
18;;; 2.  start a swank server on a specified port.
19;;; 3. tell SLIME to connect to swank on the specified port
20
21(defun swank-loader-path () (concat slime-path "swank-loader.lisp"))
22
23(defvar *ccl-swank-listener-host* "127.0.0.1")
24(defvar *ccl-swank-listener-port* 4884)
25(defvar *ccl-swank-listener-proc* nil)
26
27(defvar *ccl-swank-output* nil)
28;;; TODO: make this filter function start up a connection to
29;;;       the CCL swank server if it reads a success message,
30;;;       or display an informative error if it reads a
31;;;       failure message
32(defun slime-ccl-swank-filter (process string)
33  (let* ((status (read string))
34         (active? (plist-get status :active)))
35    (if active?
36        (let ((port (plist-get status :port)))
37          (slime-connect *ccl-swank-listener-host* port)))))
38
39(defvar $emacs-ccl-swank-request-marker "[emacs-ccl-swank-request]")
40
41(defun request-ccl-load-swank (&optional host listener-port connection-port loader-path)
42  (let* ((host (or host *ccl-swank-listener-host*))
43         (listener-port (or listener-port *ccl-swank-listener-port*))
44         (connection-port (or connection-port slime-port))
45         (loader-path (or loader-path (swank-loader-path)))
46         (ping (concat $emacs-ccl-swank-request-marker (format "%d" connection-port) ":" loader-path "\n"))
47         (ccl-proc (open-network-stream "SLIME CCL Swank" nil host listener-port)))
48    (setq *ccl-swank-listener-proc* ccl-proc)
49    (set-process-filter ccl-proc 'slime-ccl-swank-filter)
50    ;; send ping
51    (process-send-string ccl-proc ping)
52    ccl-proc))
53
Note: See TracBrowser for help on using the repository browser.