I saw a teacher in iTunes U doing this: have 2 windows open in Emacs, the top is the Scheme (or Lisp) source code, and the bottom is the Scheme interpreter. He seems to press something on the keyboard and the whole Scheme statement will be copied down to the buffer below. How is that done?
Here's how to do it with vanilla Emacs commands:
- C-SPC C-M-n M-w mark the list with a region and copy it to the kill ring.
- C-x o C-y switch to other window and paste.
- C-x o switch back to the original window.
Here's how to evaluate an expression before point with geiser:
- C-x C-e calls
There's no need to use the REPL window at all if you can just evaluate the expression in place.
Here's how to evaluate an expression before or after point using lispy interface to
- e calls
Defun for the first method
(defun copy-sexp-to-other-window () (interactive) (let* ((end (save-excursion (forward-list 1) (point))) (str (buffer-substring (point) end))) (save-window-excursion (other-window 1) (insert str "\n"))))
Perhaps you'll want to remove
save-window-excursion, since you'll want to press RET in the REPL at some point.