 
 GENERIC: add-listener ( irc-client irc-listener -- )
 M: irc-listener add-listener ( irc-client irc-listener -- )
-    current-irc-client swap [ (add-listener) ] curry with-variable ;
+    current-irc-client swap '[ , (add-listener) ] with-variable ;

    [ [ name>> ] [ password>> ] bi /JOIN ]
    [ [ [ drop irc> join-messages>> ]
        [ timeout>> ]
        [ name>> [ swap trailing>> = ] curry ]
        tri mailbox-get-timeout? trailing>> ] keep set+run-listener
    ] bi ;

M: irc-nick-listener (add-listener) ( irc-nick-listener -- )
   [ name>> ] keep set+run-listener ;

: (connect-irc) ( irc-client -- )
    [ profile>> [ server>> ] keep port>> /CONNECT ] keep

! ======================================

: set+run-listener ( name irc-listener -- )
    [ '[ , , listener-loop ] "listener" spawn-irc-loop ]
    [ swap irc> listeners>> set-at ]
    2bi ;

