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 2ba2874f114fc0137233634c8b56b9a0b045d0f8
parent 46bc2609f4b9f5611bd97797262ff3ff0c282df3
Author: Tomas Hlavaty <tom@logand.com>
Date:   Sat, 30 Apr 2011 13:50:13 +0200

use simple functions instead of +SwankConnection

Diffstat:
Mswank-picolisp.l | 51++++++++++++++++++++++-----------------------------
1 file changed, 22 insertions(+), 29 deletions(-)

diff --git a/swank-picolisp.l b/swank-picolisp.l @@ -41,19 +41,19 @@ ## (setq slime-protocol-version 'ignore) ## (format "%S\n" ## `(prog (load ,(expand-file-name "/path/to/swank-picolisp.l")) -## (start-swank ,file)))) +## (swank-start ,file)))) ## --- end .emacs --- ## ## Also, set up slime to your taste. (de swank (Port) (default Port 4005) - (accept-connections Port NIL) ) + (swank-accept-connections Port NIL) ) -(de start-swank (PortFile) - (accept-connections NIL PortFile) ) +(de swank-start (PortFile) + (swank-accept-connections NIL PortFile) ) -(de accept-connections (Port PortFile) +(de swank-accept-connections (Port PortFile) (let P (port (or Port 0) 'Port) (prinl "## Listening on port " Port) (when PortFile @@ -61,41 +61,34 @@ (use Sock (loop (setq Sock (listen P)) - (loop> (new NIL '(+SwankConnection) Sock)) + (swank-loop Sock) (close Sock) ) ) ) ) -(class +SwankConnection) -# sock +(de swank-loop (Sock) + (while (swank-read-packet Sock) + (swank-dispatch Sock @) ) ) -(dm T (Sock) - (=: sock Sock) ) - -(dm loop> () - (while (read-packet> This) - (dispatch> This @) ) ) - -(dm read-packet> () - (in (: sock) - (read) # ignore length for now +(de swank-read-packet (Sock) + (in Sock + (read) ## TODO do not ignore length (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))) ) +(de swank-dispatch (Sock Form) + (println Form) + (case (car Form) + (":emacs-rex" (apply swank-emacs-rex (cdr Form) Sock)) + (T (throw "Unhandled swank event" Form)) ) ) -(dm send-to-emacs> (Obj) - (let Payload (sym Obj) - (out (: sock) +(de swank-send-to-emacs (Sock Form) + (let Payload (sym Form) + (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-emacs-rex (Sock Form Pkg Thread Id) + (swank-send-to-emacs Sock (list ':return (list ':ok (eval Form)) Id)) ) (de swank:connection-info () (list