4

I'm using Chicken-scheme.I use M-x run-scheme to start a scheme repl, and then I use things like C-c C-l to test my work.

However, this is an indentation nightmare. Things generally look like this:

> (+ 1 
(* 2
3)
4)

instead of the desired:

> (+ 1
     (* 2
        3)
     4)

How can I easily fix this? I know I can start a chicken repl with geiser, but that breaks keybindings and I'd really just prefer to not make stuff more complicated than it is. I just want it to correctly indent when I press enter, just like in my non-repl buffer, that's all.

I'd just like the simplest possible solution to get some nice indentation, like is standard for lisp. I'd like to add that my buffer in which I edit the file is totally fine, it's just the repl that doesn't work.

Lara
  • 2,594
  • 4
  • 24
  • 36
  • This is very strange: I have a default Geiser setup and on `` or `C-j` everything is indented correctly. What version of Emacs and Geiser are you using? – mobiuseng Feb 24 '16 at 07:33
  • @mobiuseng I'm not using geiser. I have geiser installed and have tried it, but like I said it creates additional problems though it fixes indentation. A fix for geiser would be fine too. The problems I'm having with geiser are that I can't seem to load files to geiser. Also some keybindings change but I can live with that. Basically if I run scheme through geiser and do `Eval buffer` I will get the message "No geiser REPL for this buffer" – Lara Feb 24 '16 at 07:41
  • This if fixable: you just need to tell geiser to use Chicken *for the opened file (buffer)* (in my case it uses Guile by default) by `C-c C-s chicken` (you can set default Scheme implementation in Geiser settings, check its documentation). And when you run `M-x run-chicken`, this buffer will be connected to Chicken REPL. – mobiuseng Feb 24 '16 at 07:48
  • @mobiuseng when I `Eval buffer and go` it doesn't seem to work. All definitions are left unbound. – Lara Feb 24 '16 at 07:54
  • I usually do just `geiser-eval-buffer`, `C-c C-b`. But `C-c M-b` also works (check if there is an echo-message in mini-buffer after evaluating the buffer). If you use modules, you will need to switch to the module `C-c C-a` or import the exported names from it before using internal identifiers. – mobiuseng Feb 24 '16 at 08:44
  • @mobiuseng If I do `C-c M-b` it says `mark set`. If I do `C-c C-b` it says `menu-bar geiserm Eval buffer`. Both have no effect (except for `C-c M-b` switching the cursor to another buffer) – Lara Feb 24 '16 at 09:03
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/104388/discussion-between-mobiuseng-and-darklightus). – mobiuseng Feb 24 '16 at 10:11
  • Since it's almost a year since you may want to add the solution as an answer or delete it if you feel it will not contribute to other schemer in the future. I'm voting to close because of the latter. – Sylwester Jan 20 '18 at 12:59
  • I've added the solution as suggested – Lara Feb 22 '21 at 14:54

1 Answers1

0

Bind RET to

(defun comint-send-input-indent ()
  (interactive)
  (let ((parens (or (car (syntax-ppss)) 0)))
    (if (zerop parens)
        (comint-send-input)
      (newline-and-indent))))

As found here

Lara
  • 2,594
  • 4
  • 24
  • 36