Skip to content
This repository has been archived by the owner on May 16, 2022. It is now read-only.

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
russellw committed Oct 8, 2018
1 parent 3d74a76 commit d93f91e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
5 changes: 5 additions & 0 deletions etc.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,8 @@
(loop
for a in s
append (flatten a)))))

(defun write-file (file s)
(with-open-file (*standard-output* file :direction :output :if-exists
:supersede :if-does-not-exist :create)
(princ s)))
13 changes: 3 additions & 10 deletions write.lisp → fmt.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -345,13 +345,6 @@ across
)
)

(defun write-all (s)
(dolist (a s)
(format t "~a~%" (fmt 0 a))
)
)

(defun write-file (file s)
(with-open-file (*standard-output* file :direction :output :if-exists
:supersede)
(write-all s)))
(defun fmt-all (s)
(format nil "~a~%"
(fmt-lines-indent-separator s)))
5 changes: 2 additions & 3 deletions main.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
(load "add-blanks")
(load "etc")
(load "read")
(load "write")
(load "fmt")

;Code transformations
(load "comment-case")
Expand Down Expand Up @@ -107,15 +107,14 @@
)

(defun do-file (file)
(let ((s (read-file file))
(let ((s(fmt-all(transform (read-file file))))
(backup (make-pathname
:defaults file
:directory "/tmp/")))
(ignore-errors
(delete-file backup))
(ignore-errors
(rename-file file backup))
(setf s(transform s))
(write-file file s))
)

Expand Down
2 changes: 1 addition & 1 deletion test.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -180,5 +180,5 @@ do(lex)))
(let ((s (read-file file))
)
(setf s(transform s))
(write-all s))
(princ(fmt-all s)))
))

0 comments on commit d93f91e

Please sign in to comment.