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?

  • Does he select a region in top window and just the marked text is copied or is the entire top window inserted into the bottom window?
    – Melioratus
    Commented Dec 15, 2015 at 20:17
  • I think he presses one set of keys and the current statement is copied down to window below Commented Dec 15, 2015 at 23:41

1 Answer 1


Here's how to do it with vanilla Emacs commands:

  1. C-SPC C-M-n M-w mark the list with a region and copy it to the kill ring.
  2. C-x o C-y switch to other window and paste.
  3. C-x o switch back to the original window.

Here's how to evaluate an expression before point with geiser:

  1. C-x C-e calls geiser-eval-last-sexp.

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 geiser:

  1. e calls lispy-eval.

Defun for the first method

(defun copy-sexp-to-other-window ()
  (let* ((end (save-excursion (forward-list 1) (point)))
         (str (buffer-substring (point) end)))
      (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.

  • (1) to (3) works... but the other method, if need to install geiser, then I might consider it because I don't know how much I will use this for. However, if I am familiar with how to do a macro on keyboard (C-x (), is there a way just to do a macro for step 1 to 3 and then bind it to C-x C-e and then save it in the emacs start up file? Commented Dec 15, 2015 at 13:04
  • Geiser is a good REPL for Scheme. If you're serious about using Scheme in Emacs, you'll learn it sooner or later. I can add a simple defun that you can save, but using REPL is much better.
    – abo-abo
    Commented Dec 15, 2015 at 13:12
  • oh I am interested in knowing that defun... Commented Dec 15, 2015 at 13:16
  • Doesn't Geiser have send-defun out of the box? I think the description matches that behavior.
    – wvxvw
    Commented Dec 15, 2015 at 13:24
  • 1
    – abo-abo
    Commented Dec 15, 2015 at 17:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.