So Emacs is pretty good at editing Scheme/Racket/Lisp code. One good thing it does is when you type code like:
(define (make-position-table)
(for/list ([i (in-range 256)])
`()))
It does a very clever thing and indents the second line to two columns. Now the third line it does what it does with all lisp code and indents that to align all the arguments.
How do I customize Emacs so that it indents the third line as though I was introducing a new body. What I'd like is:
(define (make-position-table)
(for/list ([i (in-range 256)])
`()))
I'm guessing this is possible and that I just haven't figured out the arcane Emacs variable to set. Does anyone know how to do this?
Emacs normally uses both tabs and spaces to indent lines. If you prefer, all indentation can be made from spaces only. To request this, set indent-tabs-mode to nil . This is a per-buffer variable; altering the variable affects only the current buffer, but there is a default value which you can change as well.
Select multiply lines, then type C-u 8 C-x Tab , it will indent the region by 8 spaces.
The indent command fits as many words (separated by blanks, tabs, or new-lines) on a line as possible. Blank lines break paragraphs. A block comment is a comment that is not to the right of the code, and extends for more than one line.
You can add this to your .emacs
file:
(put 'for/list 'scheme-indent-function 1)
See also a hacked version of scheme mode that does many more racket-isms.
I believe (put 'for/list 'scheme-indent-function 'defun)
should do what you want.
Repeat for other symbols. My .emacs includes
(mapc (lambda (sym) (put sym 'scheme-indent-function 'defun))
(list 'for 'for/list 'for/and 'for/or
'match 'case 'syntax-parse 'test-suite 'test-case
'define-syntax-rule 'match-let 'match-let*))
from the days when I was dabbling in PLT Scheme.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With