Schema formatting tool

Is there a GNU equivalent indent or clang-format for Scheme? That is, a command line tool (rather than an interactive Emacs command) that takes a set of Scheme source files and formats them with standard indentation, and so on?

+4
source share
3 answers

OK, now there is. (Designed for the circuit, should be easily adapted to other Lisp dialects.)

https://github.com/russellw/scheme-format/

+3
source

I do not know a ready-made command line tool for re-entering schema code. However, many implementations of the Scheme come with a pretty printer.

For example: http://docs.racket-lang.org/reference/pretty-print.html

Creating a tool that reads a program one at a time and then uses the pretty-printed version is easy. The reader considers 'foo and (quote foo) the same, so the output may not be 100% identical (even modulo white space).

UPDATE

Doray Sitaram has this indenter on his home page:

http://www.ccs.neu.edu/home/dorai/scmindent/scmindent.rkt

And here is the explanation: http://ds26gte.imtqy.com/scmindent/index.html

+2
source

Call the capable editor programmatically. I would expect Emacs to do this too, but since I know Vim can, here is an example made in a simple script:

 % <scmindent.zsh # or generic-indent.zsh #! /usr/bin/env zsh scm=${1?Must provide code file} # Maybe not the most elegant invocation vim -c ':norm gg=G' -c ':wq' $scm % scmindent.zsh my-ugly-file.scm 

This runs Vims = ( 'equalprg' ) from the top ( gg ) to the bottom ( G ) file, then writes and exits. So this is similar to seds in-place ( -i ) mode. You can configure it to output my-pretty-file.scm . Also configure it to run through multiple files or have a script loop.

In fact, it is completely general - a good template for any file that requires padding that you want Vim to handle. I did not use it with the vanilla .vimrc setting, but editing would be equivalent to editing the indent s .indent.pro configuration file.

+1
source

All Articles