Skip to content

Instantly share code, notes, and snippets.

@rmhsilva
Last active December 18, 2017 22:35
Show Gist options
  • Save rmhsilva/46a91bec843db2882ab242d31a8a63ae to your computer and use it in GitHub Desktop.
Save rmhsilva/46a91bec843db2882ab242d31a8a63ae to your computer and use it in GitHub Desktop.
CLSS-LET
;; Yay freedom of expression
(defmacro clss-let (doc bindings &body body)
"Evaluate BODY after selecting tags specified in BINDINGS from DOC
BINDINGS should be a list of LET bindings, execept the second element refers
to a tag in DOC to be bound to the variable.
e.g (clss-let (plump:parse doc-html)
((paragraph \"p.foo\")
...)
(format t (plump:text foo)))"
(let ((bindings-let (iter
(for (var sel) in bindings)
(collecting `(,var (clss:select ,sel ,doc))))))
`(let (,@bindings-let)
,@body)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment