swank-picolisp

Unnamed repository; edit this file to name it for gitweb.
git clone https://logand.com/git/swank-picolisp.git/
Log | Files | Refs

commit cf6a1b5b8be6f645b35fbb7b4331013f0ea92511
parent 49bd4e4d740cc38b610a59af9d951ba2a5371052
Author: Tomas Hlavaty <tom@logand.com>
Date:   Tue, 26 Apr 2011 21:19:59 +0200

basic slime repl working

Diffstat:
Mswank-picolisp.l | 81++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 76 insertions(+), 5 deletions(-)

diff --git a/swank-picolisp.l b/swank-picolisp.l @@ -32,11 +32,82 @@ (use Sock (loop (setq Sock (listen P)) - (serve Sock) + (loop> (new NIL '(+SwankConnection) Sock)) (close Sock) ) ) ) ) -(de serve (Sock) - (println Sock) - (flush) - (println (in Sock (line)) ) +(class +SwankConnection) +# sock + +(dm T (Sock) + (=: sock Sock) ) + +(dm loop> () + (while T + (dispatch> This (read-packet> This)) ) ) + +(dm read-packet> () + (in (: sock) + (read) # ignore length for now + (read) ) ) + +(dm dispatch> (Ev) + (println Ev) + (unless (= ":emacs-rex" (car Ev)) + (throw "Unhandled event" Ev) ) + #(apply emacs-rex> This (cdr Ev)) + (emacs-rex> This (cadr Ev) (caddr Ev) (cadddr Ev) (cadr (cdddr Ev))) ) + +(dm send-to-emacs> (Obj) + (let Payload (sym Obj) + (out (: sock) + (prin (pad 6 (hex (length Payload))) Payload) + (flush) ) + (prinl (pad 6 (hex (length Payload))) Payload) + (flush) ) ) + +(dm emacs-rex> (Form Pkg Thread Id) + (send-to-emacs> This (list ':return (list ':ok (eval Form)) Id)) ) + +(de swank:connection-info () + (list + ':pid *Pid + ':style 'nil #NIL #"TODO style" #,(connection.communication-style c) + ':encoding '(:coding-system "utf-8" #,(connection.coding-system c) + :external-format "utf-8" #,(princ-to-string (connection.external-format c)) ) + ) + ':lisp-implementation '(:type "PicoLisp type" #,(lisp-implementation-type) + :name "PicoLisp name" #,(lisp-implementation-type-name) + :version "PicoLisp version" #,(lisp-implementation-version) + :program "PicoLisp program" #,(lisp-implementation-program) ) + ) + ':machine '(:instance "X(machine-instance)" + :type "X(machine-type)" + :version "X(machine-version)" ) + ':features '(:hi :hello) #NIL #'(features-for-emacs) + ':modules '("module1" "module2") #NIL #,*modules* + ':package '(:name "PIL" #,(package-name *package*) + :prompt "Pil>" #,(package-string-for-prompt *package*) ) + ) + ':version 'nil #NIL #,*swank-wire-protocol-version* + ) ) + +(de swank:autodoc (RawForm Key PrintRightMargin) + "Arg1 ===> Arg2 <=== Arg3" ) + +(de swank:swank-require (Lst)) + +(de swank:create-repl () + (list "PIL2" "Pil2") ) + +(de swank:listener-eval (Str) + (cons ':values (list (sym (mapc eval (str Str))))) ) + +(de swank:interactive-eval (Str) + (sym (mapc eval (str Str))) ) + +(de swank:clear-repl-results () + T ) + +(de swank:buffer-first-change (File) + (println 'swank:buffer-first-change File) (flush) )