Common Lisp Package: SWANK-CLIENT

A client interface to Swank servers.

README:

FUNCTION

Public

SLIME-CLOSE (CONNECTION)

Closes CONNECTION to a Swank server.

SLIME-CONNECT (HOST-NAME PORT &OPTIONAL CONNECTION-CLOSED-HOOK)

Connects to the Swank server running on HOST-NAME that is listening on PORT. Returns a SWANK-CONNECTION if the connection attempt is successful. Otherwise, returns NIL. May signal SLIME-NETWORK-ERROR if the user has a Slime secret file and there are network problems sending its contents to the remote Swank server. If provided, function CONNECTION-CLOSED-HOOK is called when the connection is closed.

SLIME-EVAL (SEXP CONNECTION)

Sends SEXP over CONNECTION to a Swank server for evaluation and waits for the result. When the result is received, it is returned. Signals SLIME-NETWORK-ERROR when there are network problems sending SEXP.

SLIME-EVAL-ASYNC (SEXP CONNECTION &OPTIONAL CONTINUATION)

Sends SEXP over CONNECTION to a Swank server for evaluation, then immediately returns. Some time later, after the evaluation is finished, CONTINUATION is called with the result as argument. Signals SLIME-NETWORK-ERROR when there are network problems sending SEXP.

SLIME-MIGRATE-EVALS (OLD-CONNECTION NEW-CONNECTION)

Evaluates on NEW-CONNECTION all the work pending on a closed OLD-CONNECTION. Signals SLIME-NETWORK-ERROR when there are network problems.

SLIME-PENDING-EVALS-P (CONNECTION)

Returns T if there are outstanding evaluations pending on CONNECTION; otherwise, returns NIL.

Private

ADD-OPEN-CONNECTION (CONNECTION)

Adds CONNECTION to the set of open Swank connections.

FIND-CONNECTION-FOR-THREAD-ID (THREAD-ID)

Returns the open Swank connection associated with THREAD-ID.

REMOVE-OPEN-CONNECTION (CONNECTION)

Removes CONNECTION from the set of open Swank connections.

SEND-TO-EMACS (EVENT)

Sends EVENT to Emacs.

SERVER-THREAD-ID (THREAD-ID)

Maps the THREAD-ID in an event that must be forwarded to the thread ID known by the remote Lisp to which it will be sent.

SLIME-DISPATCH-EVENT (EVENT CONNECTION)

Handles EVENT for a Swank CONNECTION. Signals SLIME-NETWORK-ERROR if there are communications problems.

SLIME-DISPATCH-EVENTS (CONNECTION CONNECTION-CLOSED-HOOK)

Reads and dispatches incoming events for a CONNECTION to a Swank server. If provided, function CONNECTION-CLOSED-HOOK is called when CONNECTION is closed.

SLIME-NET-CONNECT (HOST-NAME PORT)

Establishes a connection to the Swank server listening on PORT of HOST-NAME. Returns a SWANK-CONNECTION when the connection attempt is successful. Otherwise, returns NIL. May signal SLIME-NETWORK-ERROR if the user has a Slime secret file and there are network problems sending its contents to the remote Swank server.

SLIME-NET-ENCODE-LENGTH (N)

Encodes an integer as a 6-character, 24-bit hex string.

SLIME-NET-READ (CONNECTION)

Reads a Swank message from a network CONNECTION to a Swank server. Returns the Swank event or NIL, if there was a problem reading data.

SLIME-NET-SEND (SEXP USOCKET)

Sends SEXP to a Swank server over USOCKET. The s-expression is read and evaluated by the remote Lisp.

SLIME-SECRET

Finds the secret file in the user's home directory. Returns NIL if the file doesn't exist; otherwise, returns the first line of the file.

SLIME-SEND (SEXP CONNECTION)

Sends SEXP to a Swank server using CONNECTION. Signals SLIME-NETWORK-ERROR if there are communications problems.

SOCKET-KEEP-ALIVE (SOCKET)

Configures TCP keep alive packets for SOCKET. The socket connection will be considered dead if keep alive packets are lost.

MACRO

Public

WITH-SLIME-CONNECTION ((VARIABLE HOST-NAME PORT &OPTIONAL CONNECTION-CLOSED-HOOK) &BODY BODY)

Wraps BODY in a LET form where VARIABLE is bound to the value returned by (SLIME-CONNECT HOST-NAME PORT CONNECTION-CLOSED-HOOK). Arranges for the Swank connection to be closed when control exits BODY.

Private

DESTRUCTURE-CASE (VALUE &BODY PATTERNS)

Dispatches VALUE to one of PATTERNS. A cross between CASE and DESTRUCTURING-BIND. The pattern syntax is: ((HEAD . ARGS) . BODY). The list of patterns is searched for a HEAD that's EQ to the car of VALUE. If one is found, BODY is executed with ARGS bound to the corresponding values in the CDR of VALUE.

SLIME-REX ((&REST SAVED-VARS) (SEXP CONNECTION) &BODY CONTINUATIONS)

(slime-rex (VAR ...) (SEXP CONNECTION) CLAUSES ...) Remote EXecute SEXP. VARs are a list of saved variables visible in the other forms. Each VAR is either a symbol or a list (VAR INIT-VALUE). SEXP is evaluated and the PRINCed version is sent over CONNECTION to a remote Lisp. CLAUSES is a list of patterns with same syntax as `destructure-case'. The result of the evaluation of SEXP is dispatched on CLAUSES. The result is either a sexp of the form (:ok VALUE) or (:abort CONDITION). CLAUSES is executed asynchronously. Signals SLIME-NETWORK-ERROR when there are network problems sending SEXP.

SLOT-ACCESSOR

Private

CONNECTION-LOCK (OBJECT)

Lock protecting slots of this connection that are read and written by concurrently running threads.

CONTINUATION-COUNTER (OBJECT)

Used to associate an ID with each evaluated form.

SETFCONTINUATION-COUNTER (NEW-VALUE OBJECT)

Used to associate an ID with each evaluated form.

HOST-NAME (OBJECT)

Name of the host where the Swank server is running.

PORT (OBJECT)

Port number used to make a Swank server connection.

REX-CONTINUATIONS (OBJECT)

List of (ID, continuation) pairs, one for each evaluation in progress. Used to match each returned value with the continuation it should be passed to.

SETFREX-CONTINUATIONS (NEW-VALUE OBJECT)

List of (ID, continuation) pairs, one for each evaluation in progress. Used to match each returned value with the continuation it should be passed to.

STATE (OBJECT)

State of the connection, either :ALIVE, :CLOSING, or :DEAD.

SETFSTATE (NEW-VALUE OBJECT)

State of the connection, either :ALIVE, :CLOSING, or :DEAD.

THREAD-OFFSET (OBJECT)

All threads for this connection are presented to Emacs with this value added to their thread ID.

USOCKET (OBJECT)

USOCKET used to communicate with the Swank server.

VARIABLE

Private

*CONNECTIONS-LOCK*

Lock protecting *OPEN-CONNECTIONS*.

*OPEN-CONNECTIONS*

List of all open Swank connections.

*THREAD-OFFSET*

Counter used to assign each Swank connection a unique range of thread IDs.

Undocumented

*IO-PACKAGE*

CLASS

Public

SWANK-CONNECTION

A connection to a Swank server.

CONDITION

Public

SLIME-NETWORK-ERROR

Network problem while evaluating a form.

CONSTANT

Private

+ABORT+

Unique object used to signal that a computation was aborted on the server.

+MAXIMUM-THREAD-COUNT+

Maximum number of threads per Swank connection.