(defun pretty-procedures ()
  "Reformat procedure declarations according to the One True Style."
  (interactive "*")
  (goto-char (point-min))
  (if (search-forward "PROCEDURE" nil t)
      (progn (beginning-of-line)
	     (narrow-to-region (point) (point-max))
	     ; white space
	     (goto-char (point-min))
	     (replace-regexp "[ \t][ \t]*" " " nil)
	     ; procedures
	     (goto-char (point-min))
	     (replace-string " PROCEDURE" "PROCEDURE" nil)
	     ; left paren
	     (goto-char (point-min))
	     (replace-regexp "[ \n]*([ \n]*" "(\n\t" nil)
	     ; right paren
	     (goto-char (point-min))
	     (replace-regexp "[ \n]*)[ \n]*" "\n\t)" nil)
	     ; extra parameters
	     (goto-char (point-min))
	     (replace-string "; " ";\n\t" nil)
	     ; left margin
	     (goto-char (point-min))
	     (replace-regexp "^ " "\t" nil)
	     ; colon
	     (goto-char (point-min))
	     (replace-regexp "[ \n]*:[ \n]*" " : " nil)
	     (widen)
	     )
    (message "no PROCEDUREs")
    )
  )
