From 73323d4335994afce4d7580194bd50df46f04c51 Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Mon, 24 Oct 2022 09:37:22 -0500 Subject: Add: anaphoric unary lambda macro (->), and with-temp-dir macro --- utilities.lisp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'utilities.lisp') 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)))) -- cgit v1.2.3