ERC: IRC with emacs
I am migrating more and more of my computer tasks to
emacs; I already
discussed Twitter and e-mail (with Wanderlust); I'm also using emacs-w3m for
some of my web browsing (more about that some other time).
Reason for this ongoing emacsication is to get some return on investment for those countless hours spent on mastering the One True Editor. And it pays off - I can manipulate and glue all these programs together so they fit my workflow like a glove.
Recently, I have also started use emacs for IRC, another great Finnish
invention. I am not really an IRC power-user, but I do use; before, I used
irssi for that, in a
ansi-term console (as explained). But now I have
switched to ERC, the emacs IRC-client. You can do just about anything with
ERC – I have only barely scratched the surface. But let me share my basic
There first step is getting ERC; it's bundled with any recent emacs, so all you need to do is to add it to your .emacs:
That was not too hard, was it?
Now, the thing this is to determine what irc-servers / channels you'd like to
join (of course you can do that later manually, but automate what we can). So,
;; joining && autojoing ;; make sure to use wildcards for e.g. freenode as the actual server ;; name can be be a bit different, which would screw up autoconnect (erc-autojoin-mode t) (setq erc-autojoin-channels-alist '((".*\\.freenode.net" "#emacs" "#gnu" "#gcc" "#modest" "#maemo") (".*\\.gimp.org" "#unix" "#gtk+")))
So, the first element is the IRC-server (with appropriate wildcards), the other elements are channels. This will make ERC automatically join the channels when it notices you're connected to the IRC-server.
And read the comment – it took me some time to figure out why things weren't working. Also, you might want to change these IRC-channels to your own favorites.
The next thing is tracking: ERC can track the various channels you're in, and notify you when there is something new in the channel (it will colorize the channelname in your modeline). This is generally useful, but I don't really care about when people join or leave, or other IRC-meta spam. So:
;; check channels (erc-track-mode t) (setq erc-track-exclude-types '("JOIN" "NICK" "PART" "QUIT" "MODE" "324" "329" "332" "333" "353" "477")) ;; don't show any of this (setq erc-hide-list '("JOIN" "PART" "QUIT" "NICK"))
Note, the last line has nothing to do with this tracking, that's just telling ERC that I am not interested in those things at all, so it should hide them.
Almost there. Now, I have some function to actually start ERC; it's based on some code in found somewhere, but cannot find right now. The function will start ERC, or switch to it if it's already running – it will actually switch to the most recently active ERC-buffer, which makes things a bit easier to manage.
(defun djcb-erc-start-or-switch () "Connect to ERC, or switch to last active buffer" (interactive) (if (get-buffer "irc.freenode.net:6667") ;; ERC already active? (erc-track-switch-buffer 1) ;; yes: switch to last active (when (y-or-n-p "Start ERC? ") ;; no: maybe start ERC (erc :server "irc.freenode.net" :port 6667 :nick "foo" :full-name "bar") (erc :server "irc.gimp.org" :port 6667 :nick "foo" :full-name "bar"))))
Note: don't forget to replace the
:server-value as well as
bar with your own preferences. It should be clear what they mean…
You can bind this function to some easy key, and things get really convenient; for example:
;; switch to ERC with Ctrl+c e (global-set-key (kbd "C-c e") 'djcb-erc-start-or-switch) ;; ERC
Once you have started ERC and are connected to some channels, things work pretty much as in any IRC-client. For each channel, a buffer is opened, and from their on it is up to you to have enlightening conversations with other people around the globe…
Once more, I have only barely scratched the surface of ERC. These are just some basic instructions for getting things working. After that, there are a million things you can do; EmacsWiki has an extensive section on it, with more information and customization then you'll probably ever need.