jueves, 15 de octubre de 2009

How I use Emacs + irc (or erc for dummies)

Given a certain interest by some about using emacs as an IRC client, I'll try to explain how I use it and the configurations I use.

First thing to know is erc. erc comes bundled with emacs from 22 on (IIRC). The way to run it is fairly intuitive to any emacs user: M-x erc

After that command, you'll be asked some questions, but defaults are ok for most situations (freenode, yourUser, :6667 ).

Tip: If you happen to be behind a corporative environment (ehem, $uni/$work) , try ports 8001 or 7001.
when you're in the main freenode buffer, you can use IRC commands like /join /nick /names (when in a channel) /query /dcc .... but you better learn some shortcuts.

As most major modes, erc shortcuts start with c-c. then:

c-c c-j : /join

c-c c-n : /names

When something new happens in any erc buffer, it will apear in the modeline, and you can move to it with old c-x b , or c-c c-b will use a cooler way to change between erc buffers (only erc buffers, using ido-mode and with acceptable guessing).

if you have to visit many erc buffers, you can use c-c c-space, to travel to erc buffers with changes. after the last erc buffer with changes, you'll go to the last non-erc buffer you where last time. Great, isn't it?

you can move pretty well around erc buffers. Now the autojoin thing.

(require 'erc-join) 
(erc-autojoin-mode 1)

(erc :server "irc.freenode.net" :port 6667 :nick "mynick" )
(erc :server "irc.perl.org" :port 6667 :nick "mynick" )
(setq erc-autojoin-channels-alist
'(("freenode.net" "#channel0" "#channel1")
("co.uk" "#channel2")))

With this config, every time you start emacs, it'll start an erc session and join automagically to channel0 and channel1 in freenode, and channel2 in perl.org server . if you don't want to autojoin automatically, well... deactivate autojoin.

Another good trick is the readonly channels.

That's all for now. If you investigate on erc, you'll see it can autosave logs, and so. It's quite powerful, but I think don't have the need for so much power :)