7.2

6 Changing syntax

What the hell is a macro?

Here is a bit of code from my "utils.scrbl" file:

#lang scribble/manual
@(provide (all-defined-out))
 
@(define-syntax-rule (itemlist-indented . text)
   (nested #:style 'inset (itemlist . text)))

The define-syntax-rule macro allows me to change the behaviour of syntax to make the indentation of lists more convenient.

For example, instead of typing out the following code every time I want to make an indented list:

@nested[#:style 'inset]{
  @itemlist[
    @item{This is an item in a list}]}

I can now just type:

@itemlist-indented[
  @item{This is an item in a list}]