Go to the first, previous, next, last section, table of contents.


Program Layout

The layout that I have used for all the Lisp programs included with Jade is as follows, obviously this isn't ideal but it seems ok.

  1. The first line of the file is the header comment, including the name of the file and its general function.
  2. Copyright banner.
  3. Any require forms needed followed by a provide form for this module. The require forms should be before the provide in case the required modules aren't available.
  4. Variable and constant definitions. As a variable is defined any initialisation it needs is done immediately afterwards. For example a keymap is defined with defvar then initialised with the bind-keys function. For example,
    (defvar debug-buffer (make-buffer "*debugger*")
      "Buffer to use for the Lisp debugger.")
    (set-buffer-special debug-buffer t)
    (add-buffer debug-buffer)
    
    (defvar debug-ctrl-c-keymap (make-keylist)
      "Keymap for debugger's ctrl-c prefix.")
    (bind-keys debug-ctrl-c-keymap
      "Ctrl-s" 'debug-step
      ...
    
  5. Finally the functions which make up the program, it often improves readability if the entry points to the program are defined first.


Go to the first, previous, next, last section, table of contents.