Advertisement
Shinmera

jQuery Like Syntax Macro for CL

Jun 13th, 2013
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 0.78 KB | None | 0 0
  1. (defmacro $ (selector-or-nodes &rest modifiers)
  2.   (if (not selector-or-nodes)
  3.       `*CREAM-MASTER-DOCUMENT*
  4.       `(let ((working-nodes *CREAM-MASTER-DOCUMENT*))            
  5.          ,(if (stringp selector-or-nodes)
  6.               `(setf working-nodes (css:query ,selector-or-nodes working-nodes))
  7.               `(setf working-nodes ,selector-or-nodes))
  8.          
  9.          (if (not (listp working-nodes))
  10.              (setf working-nodes (list working-nodes)))
  11.          
  12.          ,(if modifiers
  13.               `(progn
  14.                  ,@(loop for mod in modifiers collect
  15.                         `(setf working-nodes (loop for node in working-nodes collect
  16.                                                   (,(car mod) node ,@(cdr mod)))))))
  17.          
  18.          working-nodes)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement