0

I've just installed Chez Scheme and combined it with the Geiser package using this tutorial M-x run-chez runs quite fine but C-x C-e causes the Emacs Lisp rather than Chez Scheme evaluate the code.

I've read through the Geiser cheat sheet but the key combinations listed there didn't seem to work.

What sould I do to evaluate the Chez Scheme code with C-x C-e ? Thanks.

Terry
  • 370
  • 2
  • 14
  • What major mode is the buffer in? What is ^x^e bound to try ^hv^x^e – mmmmmm Aug 13 '19 at 14:33
  • After I start the Chez Scheme, at the bottom of the buffer frame it writes * Chez REPL * The `C-x C-e` seems to bound to Emacs Lisp because when I enter it without any input it says `Debugger entered--Lisp error: (void-variable >) eval(> nil) elisp--eval-last-sexp(nil) eval-last-sexp(nil)` – Terry Aug 14 '19 at 11:04
  • What exactly is ^x^e bound to - use help to get it there should be no seems as to what it is bound to. – mmmmmm Aug 14 '19 at 11:09
  • I don't know how to see what ^x^e is bound to because I can't even know what ^x^e means. Is it C-x C-e? – Terry Aug 14 '19 at 11:12
  • Before Chez Scheme, I had installed Chicken Scheme too and when that mode is activated (`M-x run-scheme`) the `C-x C-e` works properly. FYI. – Terry Aug 14 '19 at 11:19
  • Yes it is C-x C-e - so what is it bound to you can tell by C-h k C-x C-e Also note that the mode is not set ny the run command - that starts the interpreter/REPL. To see more run M-x describe-mode – mmmmmm Aug 14 '19 at 11:45
  • `C-h k C-x C-e` gives `C-x C-e runs the command scheme-send-last-sexp (found in inferior-scheme-mode-map), which is an interactive compiled Lisp function in ‘cmuscheme.el’. It is bound to C-x C-e. (scheme-send-last-sexp) Send the previous sexp to the inferior Scheme process.` – Terry Aug 14 '19 at 12:29
  • Here are the lines from `.emacs` file related to the Chicken Scheme: `(add-to-list 'load-path "~/.emacs.d/elpa/chicken-scheme-20141116.1939/") (defun scheme-send-buffer () (interactive) (scheme-send-region (point-min) (point-max))) (add-hook 'scheme-mode-hook '(lambda () (local-set-key (kbd "M-RET") 'scheme-send-buffer))) (add-hook 'scheme-mode-hook (lambda () (paredit-mode +1))) (setq *scheme* "C:/Programs/chicken-4.13.0/bin/csi -:c -w")` – Terry Aug 14 '19 at 16:34

1 Answers1

1

Here's what I did to get things running in my Emacs on macOS.

  • After installing chez via brew install chezscheme, I started my Emacs.

  • In my scratch buffer I ran (use-package geiser) to install/initialize geiser.

  • Then I ran M-x customize-group geiser, selected "Geiser Chez", changed the "Geiser Chez Binary" from scheme to chez, and clicked "Apply and Save"

  • Created a new file /tmp/foo.ss via C-x C-f

  • The modeline had Racket as the Scheme implementation, so I did C-c C-s chez to change it to Chez

  • Next I did M-x run-geiser chez. The window split with the Chez chez repl on the bottom

  • C-x O to switch out of the Chez repl back to my foo.ss scheme source buffer

  • There I did (+ 1 2) Ret Ret Ret for a cheap Scheme expression and some space

  • Next I did C-x C-e (geiser-eval-last-sexp) and got "=> 3" in the echo area. (It also works with C-x C-b (geiser-eval-buffer)). It looked a bit like this:

screenshot of eval'ing a scheme sexp in geiser+shez

Some things to consider:

  • Make sure "Geiser Chez Binary" is point to the right binary. You can do this in a Geiser buffer with C-h v geiser-chez-binary.

  • Make sure Chez is your active scheme implementation. This will be indicated on your modeline.

  • Try this under emacs -q or emacs -Q. If it works there, but not normally the problem is in your init file(s). Bisect your init file to find the problem.

nega
  • 3,091
  • 15
  • 21
  • Thank you for the answer. However AFAIK the `C-x C-e` you use seem to invoke the Emacs Lisp not the Chez Scheme. You can check this out by trying a Scheme specific function like `(define (myadd arg1 arg2) (+ arg1 arg2))` If `C-x C-e` returns `symbol's function definition is void: define` than it really isn't Chez Scheme compiler being invoked. – Terry Aug 12 '19 at 16:25
  • 1
    @Romario Check what the key is bound to - here it is geiser-eval-last-sexp – mmmmmm Aug 13 '19 at 14:32
  • @Romario `C-x C-e` is bound to `geiser-eval-last-sexp`. `C-c C-b` is bound to `geiser-eval-buffer` and eval'ing your example returns `=> #`. Maybe you have something in your init file rebinding `C-x C-e`. Try all of this while running `emacs` with `-q` or `-Q`. – nega Aug 13 '19 at 16:16
  • If I run emacs with -q/-Q all packages are off so I cannot make `M-x run-chez` or run-geiser and so I cannt test it. – Terry Aug 14 '19 at 11:16
  • Yes. That is the point. You would then use your scratch buffer (in `lisp-interaction-mode`) to manually initialize `geiser`. – nega Aug 14 '19 at 12:48