I try to join an IRC channel with ERC in my elisp script. If there is no active ERC process running I want to create one. So far I got this:
(progn (if (not (and (fboundp 'erc-buffer-list) (erc-buffer-list))) (call-interactively 'twitch-chat)) (switch-to-buffer "irc.chat.twitch.tv:6667") (erc-join-channel "foo"))
twitch-chat looks like this
(defun twitch-chat () "connect to twitch chat" (interactive) (erc :server "irc.chat.twitch.tv" :port "6667" :password "oauth:XXX"))
The problem is that
(twitch-chat) returns immediately. I get the right behaviour if ERC is already running but it fails otherwise.