Search code examples
emacsslime

Emacs / Slime Key Binding / Sending command to Swank Server


I'm familiar with scheme, but new to emacs (switching over from VIM) and elisp.

I know how to do the following:

  • make a simple key binding
    • C-c iwb = indent whole buffer
    • F2 = turns folding on/off
  • use slime from emacs
  • some basic keys, like C-x 2, paredit keys, some basic movement keys

I need help doing something a bit more advanced:

I want F3 to equal:

  • put emacs into C-x 2 mode
  • in bottom window, switch to "slime-repl" buffer
  • in the "slime-repl" buffer, send the command "(test/run)" <-- note, this is meant to be sent to the swank server, NOT to elisp

I realize it's terrible form to ask people to write a script for me; however, if anyone could do that, I would learn rather quickly from it. [And it would allow me to do more complicated types of scripting through studying your example.]

Thanks!


Solution

  • This is not exactly what you want, but should be a good starting point for further tweaking:

    (defun slime-run-test ()
      (interactive)
      (slime-interactive-eval "(test/run)")
      (slime-pop-to-buffer (slime-output-buffer) t))
    
    (global-set-key (kbd "<f3>") 'slime-run-test)