From cf7dc2892c1f3a474b7c49f35cbab08bfa08ef71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Manuel=20Tom=C3=A1s?= Date: Mon, 20 Feb 2023 08:37:05 -0300 Subject: Add with-package to utils --- utils.lisp | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 utils.lisp (limited to 'utils.lisp') diff --git a/utils.lisp b/utils.lisp new file mode 100644 index 0000000..d0f61d5 --- /dev/null +++ b/utils.lisp @@ -0,0 +1,11 @@ +(in-package #:utils) + +(defmacro with-package (pkg-sym &body body) + (let ((pkg-name (symbol-name pkg-sym))) + (unless (find-package pkg-name) + (make-package pkg-name)) + (let ((body-as-string (format nil "(cl:progn ~{~s~&~})" body)) + (body-as-form)) + (let ((*package* (find-package pkg-name))) + (setq body-as-form (read-from-string body-as-string))) + body-as-form))) -- cgit v1.2.3