aboutsummaryrefslogtreecommitdiff
path: root/src/util.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.lisp')
-rw-r--r--src/util.lisp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/util.lisp b/src/util.lisp
new file mode 100644
index 0000000..2fc079b
--- /dev/null
+++ b/src/util.lisp
@@ -0,0 +1,20 @@
+;;;; util.lisp -- some utilities
+
+(in-package :oneliners.api)
+
+(defun plist-find (indicator plist &key (test 'eq) (key 'identity))
+ (loop for (ind val . more) on plist by #'cddr
+ when (funcall test indicator (funcall key ind))
+ return val))
+
+(defmacro with-plist ((&rest keys) plist &rest body)
+ (let ((the-plist (gensym)))
+ `(let ((,the-plist ,plist))
+ (let
+ ,(loop for key in keys
+ collect `(,key (plist-find (symbol-name ',key)
+ ,the-plist
+ :test #'string-equal
+ :key #'symbol-name)))
+ ,@body))))
+