Add ability to specify number of spaces used for indentation.

This commit is contained in:
Michael Fiano 2019-04-30 19:47:13 -04:00
parent e1e8588220
commit 46ee71963a
2 changed files with 5 additions and 2 deletions

View File

@ -47,6 +47,7 @@
(:export
#:*pretty*
#:*indent-level*
#:*indent-spaces*
#:indent
#:write-sheet-object
#:write-sheet-part

View File

@ -10,6 +10,8 @@
"Directs whether to pretty-print using whitespace or not.")
(defvar *indent-level* 0
"Directs the current amount of spaces used to indent.")
(defvar *indent-spaces* 4
"Specifies the number of spaces to use for indentation.")
;; SHEET ::= (BLOCK*)
;; BLOCK ::= (:BLOCK SELECTOR PROPERTY*)
@ -43,7 +45,7 @@ if *PRETTY* is non-NIL.")
(let ((*indent-level* (+ *indent-level* 2 (length type))))
(write-sheet-object (car selector) (cdr selector) stream)))
(format stream "{")
(let ((*indent-level* (+ *indent-level* 4)))
(let ((*indent-level* (+ *indent-level* *indent-spaces*)))
(dolist (block blocks)
(when *pretty* (fresh-line stream))
(write-sheet-object (car block) (cdr block) stream)))
@ -55,7 +57,7 @@ if *PRETTY* is non-NIL.")
(format stream "~a" (indent))
(write-sheet-object (car selector) (cdr selector) stream)
(format stream "{")
(let ((*indent-level* (+ *indent-level* 4)))
(let ((*indent-level* (+ *indent-level* *indent-spaces*)))
(dolist (inner body)
(when *pretty* (fresh-line stream))
(write-sheet-object (car inner) (cdr inner) stream)))