How to format and indent ZIL-code? I found this page about formatting Lisp and put together a small list of “rules” for my ZIL-code.
ABOUT FORMATTING AND INDENTATION OF ZIL
=======================================
0. DON'T put closing brackets on their own line.
1. Routine arguments on single line or left-align with 1st argument.
<ROUTINE TEST-F (ARG1 ARG2 ARG3...)
Or
<ROUTINE TEST-F (ARG1 ARG2 ARG3 "AUX" VAR1
VAR2 VAR3 ...)
2. Indent routine-body with 4 spaces.
<ROUTINE TEST-F ()
<ROUTINE-BODY>>
3. Conditions
3.1 Align Conditions on the left parantheses.
<COND (<WHEN-THIS> <DO-THIS>)
(<WHEN-THIS> <DO-THIS>)>
3.2 Align body in conditions on left bracket.
<COND (<WHEN-THIS>
<DO-THIS>
<AND-THIS>)
(<WHEN-THIS>
<DO-THIS>
<AND-THIS>)>
3.3 Example of nested conditions
<COND (<WHEN-THIS>
<COND (<WHEN-THIS>
<DO-THIS>
<AND-THIS>)>)
(<WHEN-THIS>
<COND (<WHEN-THIS> <DO-THIS>)
(<WHEN-THIS> <DO-THIS>)>)
(ELSE
<DO-THIS>
<AND-THIS>)>
4. Align nested forms that requires multiline on left bracket.
(The routine below returns TRUE when taking object (OBJ) is
not invisible and not held and have either TAKEBIT or TRYTAKEBIT.
It also returns TRUE when dropping object (OBJ) and it's held.)
<ROUTINE ALL-INCLUDES? (OBJ)
<NOT <OR <FSET? .OBJ ,INVISIBLE>
<AND <VERB? TAKE> <HELD? .OBJ>>
<AND <VERB? DROP> <NOT <HELD? .OBJ>>>
<=? .OBJ ,WINNER>
<AND <VERB? TAKE DROP>
<NOT <OR <FSET? .OBJ ,TAKEBIT>
<FSET? .OBJ ,TRYTAKEBIT>>>>>>>
5. Text that requires multiline in, for example, TELL or LDESC
should begin in column 1 with the opening double-quote.
<ROOM SMALL-ROOM
(DESC "Small Room")
(IN ROOMS)
(LDESC
"You are in a small room containing a vending machine.
Beside the stairway leading down stands a huge troll,
brandishing a large axe. You can also go up through a
hole in the ceiling.")
(UP TO INSIDE-HOUSE)
(DOWN PER SMALL-ROOM-EXIT)
(ACTION SMALL-ROOM-F)
(FLAGS LIGHTBIT)>
Or
<ROUTINE SMALL-ROOM-F ()
<COND (<WHEN-THIS>
<TELL
"You are in a small room containing a vending machine.
Beside the stairway leading down stands a huge troll,
brandishing a large axe. You can also go up through a
hole in the ceiling.">)
(<WHEN-THIS>
<DO-THIS>
<AND-THIS>)>>
Any suggestions for revisions, additions and removals for this set of “rules”?