Watch the video on YouTube!
If you haven't already heard, it's possible to do yet another thing in Emacs that you might already be doing on a daily basis using some other set of programs. We've already seen on this channel that you can use Emacs for your e-mail, so it probably won't come as a surprise that you can also use Emacs as a chat client!
In this episode show you the basics of using the IRC chat protocol with Emacs' built-in client called ERC so that you can chat with other people from the comfort of your Emacs window!
Internet Relay Chat, commonly known as IRC, is a protocol that enables real-time chat across a number of servers that are connected together to form something called an IRC network. You might have heard of Freenode, EFNet, DALnet, and many other popular IRC networks.
If you're not familiar with IRC, you can think of it like a Slack or Discord server; you join a server on a particular IRC network and there are a bunch of channels that you can join to chat about a variety of topics. One difference though is that you must join the channels you want to participate in. You also don't see the history of a channel when you join it like you do in Slack or Discord; I'll show some ways to fix that in a future video.
The nice thing about IRC is that it's an open protocol which means there are an incredible number of clients available for it on the Internet. What's even better is that can join a server right now with no account creation necessary using packages that are already included with Emacs!
We're going to take a look at one of them today: ERC.
ERC is a featureful and extensible IRC client written in Emacs Lisp. It's not the only IRC client that comes with Emacs (see rcirc) but it's probably the one that you'll want to use long-term if you stick with in-box clients.
One nice thing about it is that you don't really even need to configure it to use it, you can run it right out of the box!
Joining a server with ERC is very easy, you can just run M-x erc-tls to connect to a particular IRC server address and you'll be prompted for your "nickname" (the name you will use on the server) and your password. You can skip the password prompt since you may not have an account yet!
You can also use M-x erc but I highly recommend connecting using M-x erc-tls if the server supports SSL/TLS to ensure that you make a secure connection to the server! This is very important for protecting the passwords you transmit to the server.
I recommend joining the Libera.Chat server at irc.libera.chat. Official chat rooms for many free and open source projects you know are there (#emacs, #guix, #sr.ht) and you can also join the #systemcrafters channel!
Let's do that now!
Once you've connected to a server, you can join a channel by typing the following command:
After you join the channel, a new buffer will appear in Emacs for that channel with the channel's name as the buffer name. You can switch to this buffer at any time to read the chat or send messages. Let's try typing a message to see if anyone responds!
You'll probably notice that things look pretty minimal compared to more modern chat programs: no images, no profile icons, no emojis, etc. Some of these things can be added with extension modules, though!
If you ever want to leave a channel, you can use the /part command:
You can also leave a specific channel by passing the channel name to /part.
You can get a list of all the channels on your IRC server by typing the /list command:
ERC will show a new buffer with a listing of all the available channels in the server. Since this is a normal Emacs buffer you can use your normal search key bindings to find channels with a particular string in the name or "topic."
You can get a little bit more information about a particular user with the /whois command:
This can return information like:
You can send someone a private message a couple of different ways. The most convenient way is to use the /query command:
This will open a new Emacs buffer for the private conversation between you and the recipient. You can type any message into this buffer and press RET to send the message. Replies from the user will also be written to the buffer.
You can also use the /msg command to send a one-time message without opening a new buffer:
/msg daviwil Hello there!
If the user responds, a query buffer will be opened!
If you aren't satisfied with the name you chose when you joined the server, you can use the /nick command to change your name:
Users across all the channels you're in will now see you as the new name!
If you'd like to quit the server, use the /quit command. You can also add a message which will be seen by everyone in the chat rooms you're currently in when you leave:
/quit See you all later!
If you want to reconnect to the IRC server, you can use the /reconnect command inside of a buffer for that server, like one of the chat windows:
NOTE: You might need to do this if you use a laptop and it wakes up from sleep! ERC doesn't do a good job of reconnecting reliably for me in this case so I have to reconnect manually pretty often.
Here's a basic ERC configuration you can use to get started:
(setq erc-server "irc.libera.chat" erc-nick "your-favorite-nick" ; Change this! erc-user-full-name "Emacs User" ; And this! erc-track-shorten-start 8 erc-autojoin-channels-alist '(("irc.libera.chat" "#systemcrafters" "#emacs")) erc-kill-buffer-on-part t erc-auto-query 'bury)
This will set your user details, default server, and channels to join upon connecting. It will also control how some buffers get created or closed when you leave channels or receive messages from other users!
In future videos I'll show some modules you can enable to improve your experience even further!
System Crafters community member Shom wrote up some helpful tips on the wiki that you might find useful!
Also, if you're a long-time IRC user, feel free to leave a note in the comments with some of your favorite IRC tips!