Hello.

I'm using swank for a school project, so that, in Emacs, I can use Common Lisp to do database related operations. The thing is that Emacs Lisp doesn't have any good package to do database operations (DDL and DML API, socket connection to a database, ACID properties, etc). I've used, as a first try, sql-mode to fire a mysql client process and did all sql operations from there. However it doesn't support some desired properties (rollbacks, etc), the program would be strongly tied to the specific output of mysql client process (I had to parse the output to get the results) and it was a nightmare to make the select queries synchronous (the function would receive a select query string and block while the mysql process outputs the result - and then parse).

I chosed CL-SQL as a engine to do DB related operations, and now I need a way to comunicate between Emacs and Common Lisp. I don't know if it is the best way to do it, but I'm using swank as the "bridge" between both.

However I don't know, neither can't find documented, the protocol to communicate with swank. Can you help me?




Thats all I did until now:

I've fired swank in a SBCL console:

(require 'swank)
(swank::create-swank-server 4006 :spawn #'swank::simple-announce-function t)

And then I connect in Emacs:

(open-network-stream "swank-process" "swank-buffer" "localhost" 4006)

I find "swank-buffer" which reads:

000025(:open-dedicated-output-stream 46912)

Then I connect to 46912:

(open-network-stream "swank-output" "swank-output-buffer" "localhost" 46912)

However as I try to communicate with "swank-process", using (process-send-string), the connection exits abnormally with code 256. In the SBCL console it shows:

;; Swank started at port: 4006.

4006
* ;; Event history start:
WRITE: (:open-dedicated-output-stream 46912)
;; Event history end.
;; Connection to Emacs lost. [
;;  condition: junk in string "(+ 2 2"
;;  type: SWANK::SLIME-PROTOCOL-ERROR
;;  encoding: :ISO-LATIN-1-UNIX style: :SPAWN dedicated: T]

debugger invoked on a SIMPLE-ERROR in thread
#<THREAD "auto-flush-thread" {B096EE1}>:
  #<SB-SYS:FD-STREAM for "a constant string" {AF7E3A9}> is closed.