lunes, 14 de septiembre de 2009

read-only IRC channels using erc

Sometimes, when one is managing lots of windows, no matter how well you structured your desktop (GNU Screen, emacs, vim, tiling wm (ratpoison for me)), we can do some nasty things because our mind is in a window, and our desktop focus is in other one.

Tell me if you never wrote ':wq' in a msn window, or ls in an IRC channel :) .

Well, today, I had the pleasure of participating on #perl6 channel at freenode with a great collaboration (My nick is kidd).

it seems some irssi user already thought of that, and wrote a perl script named oops.pl that keeps messages from a list (configurable) without sending. By default the list contains '^ls '. Instead of just deleting the message, it executes a /names comand, but well, the good thing is you don't bug others.

Btw, I've been using emacs as my irc client, for a few reasons (I wanted to start using emacs but couldn't leave vim for editing codes, so I now use emacs for everything but editing text... well, that's not really true but...).

As you know, emacs is scriptable using elisp. Well, then let me paste a code that davazp wrote as we were talking about this problem in #emacs-es. This snippet builds a list where you should write the channels where you want to stay silent. Then, it sets a hook on erc-join-channel, and compares the buffer name with each name on the list. If it matches, it puts the buffer in read-only mode (c-x c-q).

And here is the snippet. Thx to davazp for this little nifty hack :)