Common Lisp programmers are blessed with the awesome SLIME development environment for Emacs; but sadly Schemers have nothing comparable. There are a few SLIME backends for various Schemes around, in varying states of completeness, but as far as I can tell none for my Scheme implementation of choice: Chicken Scheme.
Therefore I present swank-chicken: a SWANK server written in Chicken Scheme. (SWANK is the protocol SLIME uses to talk to the inferior Lisp process.) I’ve been hacking it together over the past week or two and it’s now reached the point where it is more or less usable. Click on the screenshot below for an example:
Supported features so far:
- REPL support with input/output (i.e.
read
andwrite
work as expected) - Complile region and load file commands (e.g. C-c C-l, C-c C-c)
- Basic SLDB support with back trace
- Parameter argument hints in the minibuffer
Huge swathes of SLIME features are obviously missing at the moment, but the most useful ones are there. In particular, I think it’s at least as functional as the normal inferior-scheme mode. The most significant omission at the moment is support for interrupting Scheme evaluation from Emacs – C-c C-c at the REPL will currently kill the backend process completely. Naïvely this should be implemented in the same way as the debugger-abort command: by calling the top-level continuation. However, perhaps unsurprisingly, calling a continuation from a Scheme SIGINT handler turns out to be a bad idea. So if you have a runaway process you must kill and restart it with C-c C-c M-x slime-restart-inferior-lisp
.
UPDATE: some of these issues have been fixed.
To get started clone the git repository using:
git clone git://github.com/nickg/swank-chicken.git
Alternatively just download swank-chicken.scm and chicken-slime.el.
First we need to install a few Chicken extensions:
chicken-install format symbol-utils
Obviously you also need to install SLIME: I’ve been using the latest code from CVS but older versions should work too.
Next, place chicken-slime.el somewhere in your Emacs load-path and add the following to your .emacs:
(autoload 'chicken-slime "chicken-slime" "SWANK backend for Chicken" t) (setq swank-chicken-path "/path/to/swank-chicken.scm") (add-hook 'scheme-mode-hook (lambda () (slime-mode t)))
Now you should be able to use SLIME commands in a Scheme buffer. To start a Scheme REPL do M-x chicken-slime
.
That’s it! Let me know if you have any problems/suggestions. I intend to do some more work on this and package it up as an Egg. The code is available under the MIT license.
!! CSI!
December 12, 2010 @ 6:33 pm
> !! CSI!
Yah, it’s the Chicken Scheme Interpreter: it goes where the Common Lisp package would normally go.
December 12, 2010 @ 6:42 pm
http://blodgett.doof.me.uk/wp-content/uploads/2010/12/csi.png
~~~ chicken scheme investigator ~~~
ongoing story arc follows its struggles with having a slightly gimpy right leg, caused by injury with a farming implement. it was sustained whilst leading a botched escape attempt from captivity of which it was the only survivor. now HAUNTED with GUILT, it attempts to absolve itself through solving nefarious crimes against chicken-kind.
December 12, 2010 @ 6:47 pm
oh wait didn’t see your reply
December 12, 2010 @ 6:48 pm
> oh wait didn’t see your reply
Actually, I think I prefer your explanation
December 12, 2010 @ 6:51 pm
blodgett had completely forgotten about this post. upon this rediscovery, it must now confess it was party to the killing of a cockerel over the holiday period, which was subsequently converted into a curry. possibly blodgett should turn itself in before the vengeful investigator discovers its misdemeanours… :O
December 28, 2010 @ 1:10 am
Chicken Scheme Investigator very busy this time of year
December 31, 2010 @ 3:26 pm
[…] made some improvements to the Chicken Scheme SWANK server I posted previously. Thank you to all the people who emailed me about it! I’ve fixed several minor bugs and […]
January 1, 2011 @ 6:35 pm
Congratulations! Great work.
Please, do not give up. While considering whether to learn Scheme or Common Lisp, the availability of Emacs/SLIME support heavily influenced my decision to settle on the latter.
And happy new year!
January 7, 2011 @ 4:16 pm
Thank you :)
January 7, 2011 @ 7:59 pm
If I ever get my hands on that Chicken Scheme, I’ll wring its neck!
And don’t we all have fond memories of Swank back in the 80s – nothing better than a copy of Swank and a box of tissues…..before that new-fangled interwebs.
January 11, 2011 @ 6:37 am
Hi
Where does the file “swank-chicken.scm” needs to be placed?
Right now i am having it in the same place as “chicken-slime.el”, tried also to put it in the slime folder, but getting the same error while starting the swank server, that it can not find the file.
Running Windows 7 and SBCL.
Thanks
Matus
November 25, 2011 @ 1:42 pm
My exact problem is with chicken-doc and CHICKEN_DOC_REPOSITORY which needs to be set on windows. I am working on it. If I am not successful i will come again.
Matus
November 25, 2011 @ 2:18 pm
Hi Matus,
Unfortunately I can’t help much as I’ve never tried using Chicken or SLIME on Windows. Let us know what you had to do to get it working!
November 29, 2011 @ 7:23 am
Hi,
Sorry for my delayed reply.
I can’t remember anymore what exactly did it, but i was just missing some point in the tutorial on installing chicken-doc. Following the tutorial accurately solved the issue.
However, i had another problem starting chicken-slime which i reported here: https://github.com/nickg/swank-chicken/issues/3
It seems to be OS independent problem.
Greetings
Matus
April 4, 2012 @ 10:49 am
Hi Matus,
Looks like this is caused by a recent change to upstream SLIME. I’ve fixed this in the Egg repository and the GitHub version (see my last few commits there).
April 8, 2012 @ 9:10 pm
Hi,
I have just installed your slime-plugin by downloading the corresponding chicken scheme egg. Unfortunately the following error messages occur when I use the REPL:
error in process filter: Wrong type argument: char-or-string-p, (“(+ ===> z1 … <===)" t)
How to solve this issue?
Thank you!
April 12, 2012 @ 1:12 pm
What version of SLIME, Emacs, and Chicken are you using?
April 15, 2012 @ 10:01 am
Hi nick,
I am using the following versions:
GNU Emacs 23.2.1
Chicken Scheme Version 4.7.0
SLIME 2010-07-21
Best regards
April 16, 2012 @ 7:21 pm
Hi again,
I installed the latest slime-version (2012-04-11) and the error message disappeared. I have tried the following features which also work for me:
– C-c C-c
– C-c C-l
– Hint-text in the mini-buffer showing the command structure
However autocompletion is still not working! I have installed the provided chicken-egg “slime”. At the moment, my .emacs-configuration-file looks as follows:
…
(add-to-list ‘load-path “/var/lib/chicken/5/”)
(add-to-list ‘load-path “~/.emacs.d/slime-2012-04-16”)
(autoload ‘chicken-slime “chicken-slime” “SWANK backend for Chicken” t)
(require ‘slime)
(slime-setup ‘(slime-fancy slime-banner))
(slime-setup ‘(slime-autodoc))
(add-hook ‘scheme-mode-hook
(lambda ()
(slime-mode t)))
Maybe you have an idea, why autocompletion does not work.
I also installed the required eggs
– symbol-utils
– apropos
– chicken-doc
– fmt
Best regards!
April 16, 2012 @ 8:28 pm
Have you installed the documentation repository for chicken-doc? See the chicken-doc-admin page for how to do this:
http://wiki.call-cc.org/eggref/4/chicken-doc-admin
April 23, 2012 @ 8:38 am
Hi nick,
The documentation is only supported in the CSI-interpreter. It is not available in opened scheme-files. Maybe this is not supported.
Does chicken-slime also support a pretty printer mode, which supports tidying up the scheme code?
Best regards
April 28, 2012 @ 4:34 pm
> Does chicken-slime also support a pretty printer mode, which supports tidying up the scheme code?
No, but you can use chicken-slime with other Scheme modes. Maybe paredit supports this?
May 1, 2012 @ 7:39 am
Hi nick,
I found library duck.el which does the job by applying function duck-tidy-up!
Best regards
May 1, 2012 @ 10:19 am