Changeset 22339 in project


Ignore:
Timestamp:
01/10/11 21:50:51 (9 years ago)
Author:
Christian Kellermann
Message:

gazette 17: recipe added

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gazette/src/issues/17.wiki

    r22336 r22339  
    2121== 4. Omelette Recipes
    2222
     23Today I would like to introduce a really promising work in progress,
     24that surely folks in the #chicken channel greatly enjoy so far: Mr. [[
     25http://www.doof.me.uk/|Nick
     26Gasson]] [[http://www.doof.me.uk/2010/12/12/using-slime-with-chicken-scheme/|announced]]
     27in
     28[[http://www.doof.me.uk/2011/01/01/update-to-chicken-swank-server/|his]]
     29[[http://www.doof.me.uk/2011/01/02/chicken-slime-describe-and-apropos/|blog]]
     30that he has implemented a backend for
     31[[http://common-lisp.net/project/slime/|SLIME]]: The Superior Lisp
     32Interaction Mode for Emacs.
     33
     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.
     39
     40The architecture looks closely like this (taken from Tobias
     41Rittweiler's Presentation on SLIME via
     42[[http://bc.tech.coop/blog/081209.html|Bill Clementson's article]]):
     43
     44[[image:/img/17/slime-swank.jpg|Picture showing slimes client server architecture]]
     45
     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:
     50
     51 git clone git://github.com/nickg/swank-chicken.git
     52
     53Also you need to grap SLIME from cvs (this is recommended by its authors):
     54
     55 cvs -d :pserver:anonymous:anonymous@common-lisp.net:/project/slime/cvsroot co slime
     56
     57Now add to your ''.emacs''
     58
     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)))
     68
     69
     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.
     73
     74Reload your ''.emacs'' and start a repl with 'M-x chicken-slime'.
     75
     76You will be presented with a CSI> prompt waiting for a nice chicken
     77expression to munch on. So what can you do now?
     78
     79
     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.
     83
     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!
     87
     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).
     91
     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.
     99
     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.
     104
     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.
     110
     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:
     115
     116 $ cd path/to/swank-chicken
     117 $ git pull http://pestilenz.org/~ckeen/repos/swank-chicken
     118
     119Restart slime and try the following expression:
     120
     121 CSI> (let ((a 42) (b 'test)) (+ a b))
     122
     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.
     127
     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:
     131
     132 $ csi -R swank -e'(swank-server-start)'
     133
     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!
     137
     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 [[http://common-lisp.net/project/slime/doc/html/|Slime
     143manual]] explains all the possible customisations.
     144
     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.
     150
     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!
     154
    23155== 5. About the Chicken Gazette
    24156
Note: See TracChangeset for help on using the changeset viewer.