diff options
author | Colin Okay <colin@cicadas.surf> | 2022-10-24 09:37:22 -0500 |
---|---|---|
committer | Colin Okay <colin@cicadas.surf> | 2022-10-24 09:37:22 -0500 |
commit | 73323d4335994afce4d7580194bd50df46f04c51 (patch) | |
tree | 136e08fd713d60a80351e80d2f02be888ad50423 /utilities.lisp | |
parent | 185cad97489965f1f7e3bf274204e780333fc0e8 (diff) |
Add: anaphoric unary lambda macro (->), and with-temp-dir macro
Diffstat (limited to 'utilities.lisp')
-rw-r--r-- | utilities.lisp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/utilities.lisp b/utilities.lisp index fb684d4..9fe3dc2 100644 --- a/utilities.lisp +++ b/utilities.lisp @@ -74,4 +74,21 @@ (nth m list) tmp) list)) +(defmacro -> (&body body) + "Anaphoric lambda of one argument" + `(lambda (it) + (declare (ignorable it)) + ,@body)) +(defun tmp-dir-name () + (merge-pathnames + (format nil "~a/" (gensym "tmpdir")) + (uiop:temporary-directory))) + +(defmacro with-temp-dir ((dir) &body body) + "Create temporary directory and bind its full path name to the variable DIR" + `(let ((,dir (tmp-dir-name))) + (ensure-directories-exist ,dir) + (unwind-protect + (progn ,@body) + (uiop:delete-directory-tree ,dir :validate t)))) |