define-record
definitions will stay on a single line, and so the question of how
subsequent lines are indented will be irrelevant. But if you should
ever start a new line, for example
(define-record this-record-has-a-long-name (component1 ; a comment explaining component1 component2))you'll find that DrScheme's default indentation is less than ideal (up through DrScheme 101: a change is forthcoming). What you can do is go to the Preferences panel under the Edit menu, select the Indenting category, and add
define-record
as a "lambda-like
keyword."
The situation with variant-case
is a little different.
Not only does the book routinely break these into multiple lines (as
it surely must), but also there is no way you can get DrScheme to
indent them quite right. However, you can get close if you do two
things:
variant-case
as a "lambda-like keyword," as
described above.
variant-case
expression, in each
clause that you are going to split over multiple lines, start a new
line after the type name that begins the clause, rather than only
after the list of field names. For example, rather than page 81's
(define leaf-sum (lambda (tree) (variant-case tree (leaf (number) number) (interior (left-tree right-tree) (+ (leaf-sum left-tree) (leaf-sum right-tree))) (else (error "leaf-sum: Invalid tree" tree)))))you would type
(define leaf-sum (lambda (tree) (variant-case tree (leaf (number) number) (interior (left-tree right-tree) (+ (leaf-sum left-tree) (leaf-sum right-tree))) (else (error "leaf-sum: Invalid tree" tree)))))
interior
.