JMM’s notes on

Gnus

Get informed through Emacs.

Gnus is a newsreader in Emacs. You can use it to read mailing lists, mail, RSS, and probably other things.

Back in undergrad I used it to subscribe to the CS 61a newsgroup (before they used Piazza) and later I used it a bunch for mail and even RSS. I made a bunch of utilities for “washing” articles to remove tracking links, and I think I had a somewhat complex setup. At some point, though, I switched to using “notmuch” because it let me search mail quickly, store mail locally, and even set multiple tags and filter based on these. But as I’ve started to use multiple clients (e.g. a mobile mail client), I’m kinda wanting state to be synced and not only stored on my laptop. And the problem is that notmuch’s tags are only visible to notmuch. So now, near the end of 2024, I’m starting to use Gnus to check IMAP again. And let me say, I’ve forgotten fucking everything.

IMAP

Here are some keybindings I need to remember:

Context Key Description Notes
Group buffer G m Make a new IMAP folder It’s kinda weird that Gnus is one of the few programs that actually lets me make a new IMAP folder. K-9 Mail in Android doesn’t, and I think Geary doesn’t either.
B m Move an email Gnus will also create folders for you if they don’t exist yet.
# Mark an email for bulk processing
T # Mark a thread for bulk processing
A T Fetch articles in a thread. Like, if you want to see previous read messages in a thread. You can also pass it a prefix to have it search other groups.
B delete Permanently delete mail.
d Mark an email as read
M-u Mark an email as unread
C-c C-s C-a Sort by author (might not actually be what I want?)
C-u g Show the raw article (for like seeing headers)
t gnus-summary-toggle-header - Show headers
/ a Limit to author Useful for acting on a bunch of spam political mail at once.
M-g gnus-summary-rescan-group/refresh summary buffer
Groups G G Search a group Maybe see https://developers.google.com/gmail/imap/imap-extensions#extension_of_the_search_command_x-gm-raw

Examples of IMAP syntax (see RFC 9051):

  • FROM "josh moller-mara" (For my server, this seems to specifically only search the display name and not the email address. See below for how to search by address.)
  • FROM <josh@test.example> Seems like you need the angle brackets to actually match on the address. But it needs to be an exact address and not a substring.
  • FLAGGED
  • BODY potato (search “potato” in body, not headers)
  • TEXT "some potato" (search exact phrase “some potato” in body OR headers)
  • TEXT some TEXT potato (Has both words “some” and “potato” in body or headers)
  • ANSWERED (emails you answered)
  • HEADER Message-ID <someid@test.example> (retrieve a specific message ID)
  • HEADER x-mailgun-sid "" (Any message with the “X-Mailgun-SID” header, since the empty string "" is a substring of any string.)
  • ON 18-Aug-2026 (messages sent on August 18, 2026)
Article X m gnus-summary-save-parts - Save parts
Article o Save part
Group buffer T n Make a new topic (“gnus-topic-create-topic”) See Topic Commands (Gnus Manual)
Group buffer C-k and C-y Kill and yank groups or topics to move them around.
Article or summary? A P gnus-summary-print-article - Print current or all process-marked articles

You can mark a bunch of articles you haven’t read yet and print them. This’ll also mark them as read. I kinda like this because I can print some stressful emails, close my computer, then read the emails in printed form at my desk.

You can also print RSS articles

Article or summary? S w or S W (to include original)
S v or S V
Wide or very wide reply, capital key includes original I think the difference for “very wide reply” is that it may look at previous articles in the same thread?
Article or summary? S f or S F gnus-summary-followup - Follow up on an email you sent

Unlike a reply, it goes to the same person.

Groups G R Make an RSS group
Article or summary? X m Save MIME parts I needed this when trying to save an inline image in an HTML email.

Might want to set (nnmail-expiry-target "nnimap+gmail:[Gmail]/Trash") to expire mail to a trash file.

Kinda seems like Gnus might be reordering email in some way? Like, when I later tried to fetch email from a folder in K-9 mail, it was showing mail from 2017 instead of the most recent.

Here’s a page that describes how to set up multiple IMAP accounts (https://www.bounga.org/tips/2020/05/03/multiple-smtp-accounts-in-gnus-without-external-tools/).

Setup

Here are some things I use to set up Gnus. You can put this in a file named ~/.gnus.el.

(setq gnus-posting-styles
      '((".*" ; Matches all groups of messages
	 ;; address overrides user-mail-address
         (address "j.mollermara@email.example")
	 ;; Overrides (user-full-name)
         (name "Josh Mōller-Mara")
	 (signature-file "~/.signature-1")
	 )
        ("work" ; Matches Gnus group called "work"
         (address "jmm@work.example")
	 (name "Josh Moller-Mara")
         ;; (organization "Corp")
         (signature-file "~/.signature-work")
         ("X-Message-SMTP-Method" "smtp smtp.email.example 587 jmm@work.example")
	 )))
(add-hook 'gnus-group-mode-hook 'gnus-topic-mode)

Misc

Todos