Changeset 22339 in project

01/10/11 21:50:51 (10 years ago)
Christian Kellermann

gazette 17: recipe added

1 edited


  • gazette/src/issues/

    r22336 r22339  
    2121== 4. Omelette Recipes
     23Today I would like to introduce a really promising work in progress,
     24that surely folks in the #chicken channel greatly enjoy so far: Mr. [[
     26Gasson]] [[|announced]]
     30that he has implemented a backend for
     31[[|SLIME]]: The Superior Lisp
     32Interaction Mode for Emacs.
     34Slime has many things to offer for Emacs users: A REPL integraded into
     35your favorite editor, including debugger, help system and
     36autocompletion. While other modes for lisp and chicken, such as the
     37built in scheme support, quack, cluck, and scheme-complete also
     38offer a REPL in a buffer, by executing the interpreter directly, slime offers a client / server framework.
     40The architecture looks closely like this (taken from Tobias
     41Rittweiler's Presentation on SLIME via
     42[[|Bill Clementson's article]]):
     44[[image:/img/17/slime-swank.jpg|Picture showing slimes client server architecture]]
     46The dotted box on the right is the block Nick has implemented up to a
     47point it is usable for testing on a wider scale. Preparations are
     48under way to make his work available through the usual
     49''chicken-install'' mechanism, but for now you need to pull it from Nick's github:
     51 git clone git://
     53Also you need to grap SLIME from cvs (this is recommended by its authors):
     55 cvs -d co slime
     57Now add to your ''.emacs''
     59 (setq slime-csi-path "/path/to/csi")
     60 (setq swank-chicken-path nil)
     61 (add-to-list 'load-path "~/lib/emacs/slime/")  ; your SLIME directory
     62 (require 'slime)
     63 (slime-setup '(slime-fancy slime-banner))
     64 (autoload 'chicken-slime "chicken-slime" "SWANK backend for Chicken" t)
     65 (add-hook 'scheme-mode-hook
     66          (lambda ()
     67            (slime-mode t)))
     70Now copy the file ''chicken-slime.el'' from the ''swank-chicken''
     71directory into slime's. Build the chicken-swank module with (sudo)
     72chicken-install in the ''swank-chicken'' directory.
     74Reload your ''.emacs'' and start a repl with 'M-x chicken-slime'.
     76You will be presented with a CSI> prompt waiting for a nice chicken
     77expression to munch on. So what can you do now?
     80* Pressing '','' allows you to enter special slime commands, typing
     81  ''help'' will list them all. ''sayoonara'' quits all of slime if you
     82  want to quit scheme hacking.
     84* Start entering an sexpr calling a function, for example enter
     85  ''(fold''. Notice how the minibuffer will display the signature of
     86  the procedure fold. No need to lookup the order of arguments again!
     88* Also if you do have an index for [[egg:chicken-doc]] installed,
     89  typing ''C-c C-d d'' will open up the chicken-doc page for the
     90  procedure or module under point (the name of the cursor in emacs).
     92* In case you need to lookup a procedure but you only remember parts
     93  of the name you can type ''C-c C-d a'' and enter a (chicken) regexp
     94  which will then produce a list of possible choices. To look up all
     95  procedures with ''string'' in their name you can type ''C-c C-d a
     96  string <return>'' and it will show a rather long list. Hitting
     97  return on any of the results will open the chicken-doc section of
     98  this command. Try ''list->string '' as an example.
     100* Loading of scheme code can be done with files (''C-c C-l'') or
     101  s-expressions (''C-c C-c'') in scheme file buffers. ''C-x C-e''
     102  evaluates the last expression before point, ''C-x C-r'' evaluates
     103  marked regions of code.
     105* In case you have an error in your code or the code raises a
     106  condition you will get thrown into the slime lisp debugger
     107  SLDB. This shows you the recent call-chain leading to the
     108  error. Hitting ''q'' will close the window and will get you back
     109  wherever you have ebeen before.
     111The more curious can try Christian's experimental git repo, which
     112includes some bugfixes not (yet) present in Nick's code: Display of
     113stack frame contents as know by the CSI '',c'' and '',f'' commands.
     114To get the goodness you can pull from the repo like this:
     116 $ cd path/to/swank-chicken
     117 $ git pull
     119Restart slime and try the following expression:
     121 CSI> (let ((a 42) (b 'test)) (+ a b))
     123An SLDB window will open up showing a call chain, hit enter on the
     124first frame that says ''[ more... ]''. You will see the values of
     125''a'' and ''b''. Implementation for the inspector is on its way as
     126well as inspection of the raised condition.
     128Also note that because of the client server architecture, you can
     129connect to repls that are sitting on remote machines! The default port
     130is 4005, so you start csi on the remote machine:
     132 $ csi -R swank -e'(swank-server-start)'
     134And connect to it with ''M-x slime-connect''. The default tries to
     135connect to localhost on port 4005, so you will need to adjust
     136the hostname. And off you go with your remote repl!
     138Also note that SLIME does support different repls, even different
     139backends at the same time, so you can easily test code on different
     140machines, probably different architectures! Linux, Windows, Mac
     141schemes are all bound into one interface one keystroke away. The short
     142but fine [[|Slime
     143manual]] explains all the possible customisations.
     145Beware that despite the admireable effort from Nick, not every
     146function is implemented. Some functionality cannot be implemented due
     147to chicken being scheme and not lisp, some might have been forgotten
     148about or not understood fully yet, as the underlaying SWANK protocol
     149is badly documented.
     151In any case I have been using this since christmas and I am already
     152like it. I hope you do too! Please share your criticism, suggestions
     153and patches on chicken-users with the fellow chickenistas!
    23155== 5. About the Chicken Gazette
Note: See TracChangeset for help on using the changeset viewer.