The best way to keep a program properly indented is to use Emacs to reindent it as you change it. Emacs has commands to indent either a single line, a specified number of lines, or all of the lines inside a single parenthetical grouping.
See Indentation, for general information about indentation. This section describes indentation features specific to programming language modes.
|• Basic Indent||Indenting a single line.|
|• Multi-line Indent||Commands to reindent many lines at once.|
|• Lisp Indent||Specifying how each Lisp function should be indented.|
|• C Indent||Extra features for indenting C and related modes.|
|• Custom C Indent||Controlling indentation style for C and related modes.|
Emacs also provides a Lisp pretty-printer in the
which reformats Lisp objects with nice-looking indentation.
See pp in The Emacs Lisp Reference Manual.