How to Use Emacs As a USENET Reader With Gnus

Usenet Emacs Gnus Reader

USENET is a decentralized global messaging system. It is considered to be the first global social network with more than 100,000 groups that are talking about various topics and specializations. This makes USENET a particularly good repository of knowledge and discussion for the interested reader.

Also read: How to Use Emacs to Play Music with EMMS

What Is gnus?

Despite USENET’s decline in recent years, there are still people who use it to harbor discussions and share news. Most of USENET users these days interface with the network through the Google Groups website. If you are using Emacs, however, there is a way to view USENET newsgroups through it.

Gnus Reader 01 Newsgroup List

Gnus is an Emacs package designed to read newsgroups. It is a rich program that has many powerful features that make news-reading easy and convenient. Further, being inside Emacs, the user can easily manipulate the text within posts and use that with the rest of the Emacs system.

Why Use a Newsreader in Emacs?

Emacs has always been touted as the kitchen sink of extensibility. Not only because it has many packages and extra features, it is also very easy to extend the basic functions of Emacs outside text editing.

Emacs operates on the idea of interoperability. This idea allows Emacs to use its packages to form a complete environment where you can create text and change it in different ways.

Gnus Reader 02 Emacs Interoperability

For example, Emacs comes with its own file manager: dired, a simple Emacs package that allows you to traverse a directory structure and open files. However, unlike other file managers, dired displays its results as text.

If you are also using Org Mode for journalling, you can copy that text and create elaborate links from dired within your Org Files.

Gnus Reader 03 Dired

With the Emacs ability to use the text output of a package as an input in a different package, it makes a newsreader like gnus invaluable to the Emacs ecosystem.

This allows you, for example, to copy a passage of text from a news post, then put that text in Org Mode and add it as a journal entry, agenda post, or idea capture.

Also read: 5 Useful Emacs Packages for Better Productivity

Installing gnus

Gnus comes in every default installation of Emacs since Version 19.32. If you are using a recent version of Emacs, chances are it already comes with gnus.

Gnus Reader 04 Built In Gnus

You can check whether gnus is installed in the system by pressing Alt + X and typing gnus. This will load a bare, unconfigured version of gnus.

Setting Up gnus to Read USENET Groups

The initial setup for gnus is relatively straightforward. You only need to set a couple of options in your init.el file to create a .newsrc file.

The .newsrc file is a standard file for newsgroup readers located in your home directory. Its primary purpose is to log all the available and subscribed groups in a USENET server.

Further, the .newsrc file also acts as a state file that tracks all of the posts that you have already read.

Gnus Reader 05 Usenet List Groups

To create a .newsrc file, run the following command:

touch /home/$USER/.newsrc

Also read: How to Set Up Leafnode as an Offline USENET Server

Initial Configuration

Once done, you can start setting up the init.el file, the configuration file for Emacs. By default, you can find this file either in “/home/$USER/.emacs.d/” or “/home/$USER/.config/emacs.”

To properly initialize gnus, you need to add the following lines to the init.el file:

  (setq user-full-name '"yourusername")
  (setq user-mail-address '"yourname@email.invalid")
  (setq gnus-select-method '(nntp "news.eternal-september.org"))
  • The user-full-name is a general option that sets your username in Emacs. This will be the name that gnus will display in your “From” header when you send news posts.
  • The user-mail-address is also a general option. Similar to user-full-name, it tells gnus to display this email in your “From” header. In my case, I sed an invalid email address.
  • The last option, gnus-select-method, is a gnus-specific option that tells the newsreader which service and server to connect to. In my case, I selected the nntp service with “news.eternal-september.org” as my server.
Gnus Reader 06 Emacs Init El

Also read: 8 Useful and Interesting Bash Prompts

Remote USENET Authentication

One important thing to note is that if you are using a USENET provider that requires authentication, you need to provide your account details in an authinfo file. This is the file where gnus will read the USENET server details as well as your username and password.

Gnus Reader 07 Emacs Authinfo

To create one, you can press Ctrl + X, Ctrl + F and type /home/$USER/.authinfo in Emacs. This command will create an .authinfo file in your home directory and open it in a buffer.

The general syntax of the .authinfo file looks something like this:

machine news.domain.name login yourusername force yes password yourpasswordgoeshere
  • The machine variable indicates that you are connecting to a different machine or server.
  • The domain name field tells gnus that this is the address of the machine you want to connect to.
  • The login field is where you will put the username of your USENET account.
  • The “force yes” option tells gnus to authenticate you even if the server does not require it.
  • Lastly, the password variable contains the password to your USENET account.

Using Local USENET Servers

Furthermore, gnus can also take its sources from a local spool file. This is useful if you have a service that automatically downloads your newsgroups to your local machine.

To do that, you will need to change the nntp setting in the “gnus-select-method” function:

(setq gnus-select-method '(nnspool ""))

However, if you are using Leafnode as your local USENET server, you will need to set it up as an NNTP server. This is because Leafnode behaves more like a USENET server rather than a normal “/var/spool/” directory.

To use a Leafnode server that is running in the same machine, you can type the following:

(setq gnus-select-method '(nntp "localhost"))

With that done, run gnus by pressing Alt + x and typing gnus in the command buffer. This will load gnus and fetch all of the groups that are available in your remote USENET server.

Also read: How to Reset the Root Password in Linux

Basic Usage

Once gnus loads, you will be greeted by a blank screen. This is because, by default, gnus hides all of the newsgroups that are unsubscribed and read.

You can view a list of all the newsgroups available in the USENET server by pressing Shift + 6. This will bring up the Server screen for gnus. In my case, this brought up all of the available newsgroups from Eternal September.

Gnus Reader 08 Usenet Newsgroups

USENET Group Subscription

From here, you can press U to either subscribe or unsubscribe to a particular newsgroup. This will put that group in the landing screen when you first start gnus.

For example, I subscribed to both “alt.religion.emacs” and “alt.folklore.computers” in the Server screen. Once I reloaded gnus, it put those two groups in the main screen for me to browse.

Gnus Reader 09 Gnus Main Screen

Also read: How to Set Up an SFTP Server on Linux

Buffer Movement

From there, press Enter to go into the newsgroup, and use the standard Emacs movement keys, such as Ctrl + N and Ctrl + P, to scroll through the different posts in the group.

Gnus Reader 10 Alt Computers Folklore

You can also press the Enter or Tab key. to open a post and the Backspace and Space key to scroll up and down within the post.

Use Emacs’ search function (Ctrl + S and Ctrl + R) to quickly go through the posts to find what you want.

Posting and Replying to USENET Posts

To create a new post within a newsgroup press A to bring up a message editor where you can write the details for your post.

Gnus Reader 11 New Post

Press Ctrl + C twice when you’re done to send the message to that particular newsgroup.

But if you want to reply to a post in a group, you can press Shift + S, Shift + F. This will initiate a “Followup” buffer where gnus will bring you to a message editor with the original post already quoted for you.

Gnus Reader 12 New Followup

Similar to posting a new message, you can press Ctrl + C twice to send the followup to that post.

Tip: Find out how you can use email within Emacs.

Filtering through Scorefiles

Gnus also has a powerful yet simple-to-use filtering system that uses scorefiles. It’s different than a regular killfile where the posts are automatically “killed” when hitting a particular pattern or criteria.

Scorefiles allow the user to incrementally reduce or increase a particular post’s internal score, which tells gnus which posts to prioritize and which to hide or not pull from the remote server.

Types of Filtering

Furthermore, gnus also has a feature-rich filtering system. It allows the user to control and fine-tune the various parts of a particular filter.

Gnus Reader 13 Filter Property 1

For example, if I want to lower the score of a particular post. I can just highlight it and press L. This will bring up a small menu in the command buffer that will ask me which property of the post I want to base the score on.

The list of properties are extensive, but the ones that are most important are:

  • A to score against the author’s name.
  • S to score against the subject text.
  • L to score against the number of lines.
  • B to score against the body of the text.

In my case, I want to score this post based on the author of the post, so I pressed A.

Methods to Match the Filter

From there, gnus will ask you for the kind of string matching you want to implement in this score. You can choose from exact, substring, fuzzy and regular expressions:

  • Exact uses the entire string to match the text.
  • Substring uses pieces of the string to match the text. This means that the post does not need to have the entire text matched to hit it.
  • Fuzzy uses a predictive model based on the previous posts available for the newsgroup. This is especially useful for creative posters who try to circumvent substring matching by using symbols, numbers and any form of obscuring their text.
  • Regexp uses the more traditional regular expressions to filter text.
Gnus Reader 14 Filter Type

In my case, I selected substring so I pressed S.

Also read: 5 Great AUR Helpers for Arch Linux

Duration of the Filter

Lastly, gnus will ask you if you want this score to be temporary, permanent or immediate.

  • Temporary means that the score will expire on a set date. It’s useful for when you just want to lower or increase the score of a particular post or poster for a limited period of time.
  • Permanent means that the score will not expire. This is useful for filtering out spammers who might come barging into the group.
  • Immediate means that gnus will apply the score to the current buffer without appending it to the scorefile. This is useful if you just want to filter out the posts now but do not want to persistently score them.
Gnus Reader 15 Filter Time

In my case, I wanted this filter to be permanent so I pressed P.

Congratulations! You now have a basic understanding of how to use gnus as a newsreader in Emacs. Further, you also have a basic idea of how to connect to an authenticated USENET server as well as properly utilizing scorefiles and filtering.

However, if all this talk made you interested in learning more about Emacs, then you should learn how to install Doom Emacs.

Also read: What Is Doom Emacs and How to Install It

Frequently Asked Questions

I've written a message and don't want to send it anymore. How can I cancel my post or followup?

It’s unknown, but it may be possible to cancel the current post you are writing. To do that, you can press Ctrl + C, Ctrl + D.

Is it possible to add multiple USENET servers in gnus?

Yes! You just need to add another “gnus-select-method” variable in your init.el file.

For example, your init.el file could look something like the following:

(setq user-full-name '"ramcesred")
(setq user-mail-address '"ramcesred@email.invalid")
(setq gnus-select-method '(nntp "news.eternal-september.org"))
(setq gnus-select-method '(nntp "nntp.aioe.org"))
(setq gnus-select-method '(nntp "localhost"))

Once done, just reload Emacs to reload your gnus configuration.

I have read an article, and now it's gone from my main screen list. Is it possible for me to pin a particular post when I'm actively following it?

Yes! You can do that by using the gnus-summary-tick-article-forward function. You can access this function by pressing the U key while that post is selected.

It is important to note, however, that this will only “pin” this one article. All other replies within that thread would not show up by default. To do that, press Shift + A, Shift + T to reconstruct the whole thread for that topic.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Ramces Red
Ramces Red - Staff Writer

Ramces is a technology writer that lived with computers all his life. A prolific reader and a student of Anthropology, he is an eccentric character that writes articles about Linux and anything *nix.