For example: (chain ($ "foo") (bar x z) frob (baz 5) => $('foo').bar(x, z).frob.baz(5); --- src/lib/ps-macro-lib.lisp | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/src/lib/ps-macro-lib.lisp b/src/lib/ps-macro-lib.lisp index be90b79..2ef7d82 100644 --- a/src/lib/ps-macro-lib.lisp +++ b/src/lib/ps-macro-lib.lisp @@ -84,7 +84,9 @@ (defpsmacro chain (&rest method-calls) (labels ((do-chain (method-calls) (if (cdr method-calls) - `((@ ,(do-chain (cdr method-calls)) ,(caar method-calls)) ,@(cdar method-calls)) + (if (listp (car method-calls)) + `((@ ,(do-chain (cdr method-calls)) ,(caar method-calls)) ,@(cdar method-calls)) + `(@ ,(do-chain (cdr method-calls)) ,(car method-calls))) (car method-calls)))) (do-chain (reverse method-calls))))