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))))
Pushed. Thanks for the patch Daniel!
On Thu, Sep 10, 2009 at 11:33 PM, Daniel White daniel@whitehouse.id.au wrote:
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))))
-- 1.6.4.2
parenscript-devel mailing list parenscript-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
parenscript-devel@common-lisp.net