diff options
author | Juan Manuel Tomás <jtomas1815@gmail.com> | 2023-02-20 08:37:05 -0300 |
---|---|---|
committer | Juan Manuel Tomás <jtomas1815@gmail.com> | 2023-02-20 08:37:05 -0300 |
commit | cf7dc2892c1f3a474b7c49f35cbab08bfa08ef71 (patch) | |
tree | 9dfb32e87a531027210032639099f82543930694 /utils.lisp | |
parent | a8b56704b52488f2865387d8cded8e5f13cdf919 (diff) | |
download | utils-cf7dc2892c1f3a474b7c49f35cbab08bfa08ef71.tar.gz utils-cf7dc2892c1f3a474b7c49f35cbab08bfa08ef71.zip |
Add with-package to utils
Diffstat (limited to 'utils.lisp')
-rw-r--r-- | utils.lisp | 11 |
1 files changed, 11 insertions, 0 deletions
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))) |