Gnus Quick Start
Gnus is designed to be a newsreader, and not an email client. It is a bit different from your typical email client, but if you give Gnus a try and stick with it, it will really be worth it.
This quick start guide will help you set up gnus to manage one gmail account.
Telling Gnus who you are
(setq
user-mail-address "joe@gmail.com"
user-full-name "Joe Rogan")Define your gmail connection
Most email clients use IMAP. IMAP is an email protocol that stores all of your email on the server and not on your local machine. This can save you some disk space. You just need to tell Gnus where your imap server is.
(setq gnus-select-method
'(nnimap "gmail"
(nnimap-address "imap.gmail.com")))Starting Gnus for the first time
M-x Gnus
After Gnus loads you should see a mostly empty screen. This is your group buffer. It displays all of your groups, which a normal email client would call folders. Gnus doesn’t show you for email folders, because you need to tell Gnus which folders to use by default. Press the ^.
You are now in the server buffer. The server buffer shows you all of your email accounts and how you interact with each server. If you use gnus with 5 different email accounts, then you will see 5 different servers. Press RET on your email server. If you are using gmail, your server will have gmail in the name.
Now you should see your email folders or groups. To subscribe to a group press “u”. You should probably subscribe to your Inbox, Sent, Trash, and Draft folders. When you are done subscribing to groups (folders), press q.
Some more information
read these pages: https://github.com/redguardtoo/mastering-emacs-in-one-year-guide/blob/master/gnus-guide-en.org http://www.mostlymaths.net/2010/12/emacs-30-day-challenge-glimpse-of-bbdb.html http://www.mostlymaths.net/2010/12/emacs-30-day-challenge-using-gnus-to.html set up gnus to use Purdue IMAP practical gnus tutorial http://blog.binchen.org/posts/notes-on-using-gnus.html#sec-1 http://sachachua.com/blog/2008/05/emacs-gnus-searching-mail/ using mime in gnus http://orgmode.org/worg/org-contrib/org-mime.html When you first start gnus you need to type “t”. Not sure why, but you do. You also need to type j (jump) to a particular folder also sometimes your inboxes won’t sure up (if they are contain no unread mail mail) so to see all inbex
(setq smtpmail-smtp-service 587 gnus-ignored-newsgroups “^to\.\|^[0-9. ]+\( \|$\)\|^["]"[#’()]”) Put the following in your ~/.authinfo file, replacing <USER> with your email address and replacing <PASSWORD> with your password—or your application-specific password:
When sending your first email from gnus, you might get a STARTTLS error. If you’re using homebrew in Mac OS X, you can install the necessary package with brew install gnutls.
You can find more information in the following sections.
Setting up Gnus
Let’s tell gnus who we are. init-gnus-secret looks like:
(setq user-mail-address “<your email address>” user-full-name “<Your Full Name>”)
I hope you don’t mind that I’m not telling you my email address. I’d rather that not be public info.
This files just sets up some variables that I use later on.
(require 'gnus)
;; (setq path "~/.emacs.d/lisp/init-gnus-secret.org")
(let ((path "~/.emacs.d/lisp/init-gnus-secret.org"))
(when
(f-exists? path)
(org-babel-load-file path)))Posting Styles
Changing my signature based on what email account I’m using.
Posting an article is the same thing as sending an email, since gnus is a usenet reader, gnus uses usenet terminology.
I can specify posting styles depending on the account. So for example I can specify that when I reply to an article (email), I should use a specific From field. That’s what this next bit of code does.
(setq gnus-posting-styles
'(
;; My default hotmail posting style
(.*
(signature "some Cool Signature")
(address "someHotmailAccount@hotmail.com"))
;; when I post to purdue stuff
(".*Some-string-that-matche-your-server.*"
(signature "Some Cool Signature\nThis is on a new line")
(address "someEmailAccount@gmail.com"))
))
Making Gnus prettier
My default summary line format(setq gnus-summary-line-format "%d %U%R%z%I%(%[%4L: %-23,23f%]%) %s \n")more attractive summary buffer http://groups.google.com/group/gnu.emacs.gnus/browse_thread/thread/a673a74356e7141f
(when window-system
(setq gnus-sum-thread-tree-indent " ")
(setq gnus-sum-thread-tree-root "● ")
(setq gnus-sum-thread-tree-false-root "◯ ")
(setq gnus-sum-thread-tree-single-indent "◎ ")
(setq gnus-sum-thread-tree-vertical "│")
(setq gnus-sum-thread-tree-leaf-with-other "├─► ")
(setq gnus-sum-thread-tree-single-leaf "╰─► "))
(setq gnus-summary-line-format
(concat
"%0{%U%R%z%}"
"%3{│%}" "%1{%d%}" "%3{│%}" ;; date
" "
"%4{%-20,20f%}" ;; name
" "
"%3{│%}"
" "
"%1{%B%}"
"%s\n"))
(setq gnus-summary-display-arrow t)
Make gnus startup faster
These two variables make gnus not check for any new newsgroups and stops gnus from trying to filter out outdated newsgroups. After you’ve opened up gnus a couple of times, you don’t need gnus to do these things. But you can always subscribe to new groups by pressing “U” in the group buffer.(setq gnus-check-new-newsgroups nil
gnus-check-bogus-newsgroups nil)Don’t change gnu-read-active-file
setting the next line to nil will slow down gnus apparently info:gnus#The Active File So don’t do this in your gnus set up. (setq gnus-read-active-file nil)
Fixing the Summary Buffer
There’s no need to recenter the summary buffer all the time. It only slows gnus down.(setq gnus-auto-center-summary nil)Let’s enter the summary buffer faster eh?
(setq gnus-nov-is-evil nil
gnus-show-threads nil
gnus-use-cross-reference nil)checking for new news
I got this code from John Wigley’s .emacsI’m not sure if this function will tell you if you have new news. I’m also pretty sure that it won’t flash an awesome popup window to tell you you have new news.
(defun gnus-demon-scan-news ()
(interactive)
(when gnus-plugged
(let ((win (current-window-configuration))
(gnus-read-active-file nil)
(gnus-check-new-newsgroups nil)
(gnus-verbose 2)
(gnus-verbose-backends 5))
(unwind-protect
(save-window-excursion
(when (gnus-alive-p)
(with-current-buffer gnus-group-buffer
(gnus-group-get-new-news gnus-activate-level))))
(set-window-configuration win)))))
;;
;;
;; (with-eval-after-load 'gnus
;; (gnus-demon-add-handler 'gnus-demon-scan-news-2 5 2))Managing Spam
Gnus comes with som enice spamming features(setq spam-blacklist "/home/joshua/.emacs.d/lisp/blacklist"
spam-use-blacklist t)
(spam-initialize)Searching in Gnus
set up search in GNUS http://www.emacswiki.org/emacs/GnusGmail#toc21(use-package nnir)Kill mail buffer after you send an email
Message mode is rather silly in that it does not kill the send message buffer after you send an email. It’s silly to still see the sent buffer after you’ve sent it, so this fixes that. After you send a message, the sent buffer disappears.
(setq message-kill-buffer-on-exit t)Setting up your email Account
Tell gnus to use my purdue email, and to enable searching my inbox typing GG in the buffer group, lets me search the current group for a string you have to hit “t” when you first open gnus to get purdue working again uncomment this whole thing
(setq gnus-select-method ‘(nnimap “imap.gmail.com” ;; (nnimap-address “imap.gmail.com”) ; it could also be imap.googlemail.com if that’s your server. (nnimap-server-port “993”) (nnimap-stream ssl) (nnir-search-engine imap) ))
The variable smtpmail-stream-type controls what form of connection the SMTP library uses. The default value is nil, which means to use a plain connection, but try to switch to a STARTTLS encrypted connection if the server supports it. Other possible values are: starttls to insist on STARTTLS; ssl to use TLS/SSL; and plain for encryption.
(setq smtpmail-smtp-server “smtp.gmail.com” ;; smtpmail-default-smtp-server “smtp.gmail.com” send-mail-function (quote smtpmail-send-it) smtpmail-stream-type ‘ssl smtpmail-smtp-service 465 )
Sending email
;; (require 'init-gnus-secret-smtp)
;; I am trying to use use-package so that emacs won't start on an error if someone tries to clone
;; my config
;; (use-package init-gnus-secret-smtp)init-gnus-secret-smtp looks like (require ‘smtpmail) (setq message-send-mail-function ‘smtpmail-send-it smtpmail-starttls-credentials ‘((“smtp.gmail.com” 587 nil nil)) smtpmail-auth-credentials ‘((“smtp.gmail.com” 587 “<your gmail address>” nil)) smtpmail-default-smtp-server “smtp.gmail.com” smtpmail-smtp-server “smtp.gmail.com” smtpmail-smtp-service 587)
(setq user-mail-address “<your gmail address>”) (setq send-mail-function ‘smtpmail-send-it)
Apparently this will spell check my messages before I send them, which is quite nice.
I used to have this set to mail-send-hook, but that apparently is just not the right thing to do, because I get this error if that is what I have set:
Warning (mail): The default mail mode is now Message mode. You have the following Mail mode variable customized:
mail-send-hook
To use Mail mode, set `mail-user-agent’ to sendmail-user-agent. To disable this warning, set `compose-mail-user-agent-warnings’ to nil. Warning (mail): The default mail mode is now Message mode. You have the following Mail mode variable customized:
mail-send-hook
To use Mail mode, set `mail-user-agent’ to sendmail-user-agent. To disable this warning, set `compose-mail-user-agent-warnings’ to nil.
I’ve used this is the past, but with html-mail, it doesn’t work very well.
(add-hook ‘message-send-hook ‘ispell-message)
Asynchronous Email
This might not be worth it. Make gnus load more than 1 email in the background. This seems to slow stuff down in the initial connection, and it doesn’t seem all that fast once everything is opened.
(setq gnus-asynchronous t ;; fetch 15 messages by default gnus-use-article-prefetch 15)
Setting up Gnus to work with bbdb
get bbdb set up (insidious big brother database) it manages your mail contacts http://bbdb.sourceforge.net/bbdb.html#SEC13 When you are about to email someone you can easily start typing their name then press tab to try to complete the email address
Now you should be ready to go. Say ‘M-x bbdb RET RET’ to open a bbdb buffer showing all entries. Say ‘c’ to create a new entry, ‘b’ to search your BBDB and ‘C-o’ to add a new field to an entry. If you want to add a sender to the BBDB you can also just hit ‘:’ on the posting in the summary buffer and you are done. When you now compose a new mail, hit ‘TAB’ to cycle through know recipients.
(use-package bbdb :ensure t)These are are needed to initial bbdb for gnus and message mode
(bbdb-initialize 'gnus 'message )http://www.mostlymaths.net/2010/12/emacs-30-day-challenge-glimpse-of-bbdb.html Use bbdb when you read a message and when you send a message. Though I should probably only store someone’s email address when I send an email.
(require 'bbdb)
(bbdb-initialize 'gnus 'message)Use bbdb in message mode. This lets you begin to type out someone’s name and then tab to complete their email address.
(bbdb-insinuate-message)Initialize bbdb for gnus.
(add-hook 'gnus-startup-hook 'bbdb-insinuate-gnus);; info:gnus#FAQ 5-7 how to use bbdb with gnus
(setq bbdb/gnus-summary-prefer-real-names t
bbdb-file "~/.emacs.d/bbdb"
bbdb-default-area-code 765
bbdb-user-mail-names "bransoj@hotmail.com")Don’t set the variable bbdb/news-auto-create-p to t. It creates bbdb records for all email that you read. BUT you might on occasion be fooded into reading junk mail.
Make bbdb pop up when you are using it in gnus. It’ll pop up when you are sending an email. This is to let you know that gnus is saving a new record of that email address. Also make bbdb-save records without asking, because this is really nice.
(setq
bbdb-use-pop-up t
bbdb-offer-save 1
bbdb-update-records-p t)Gnus will recognize these email addresses as mine.
(setq
bbdb-user-mail-address-re
(regexp-opt
'("bransoj@hotmail.com" "jbranso@purdue.edu" ))
message-dont-reply-to-names bbdb-user-mail-address-re
gnus-ignored-from-addresses bbdb-user-mail-address-re)I’m not sure what this does.
(bbdb-mua-auto-update-init 'message)ranking groups
Make Gnus sort the group buffer based on how often I read each group. When you exit the summary buffer, increase the score of that group. This makes that group a little bit more important.
(add-hook 'gnus-summary-exit-hook 'gnus-summary-bubble-group)displaying your topics when you enter gnus
(add-hook 'gnus-group-mode-hook 'gnus-topic-mode)Posting Styles aka change your “From” based on what you reply to
info:gnus#Posting StylesThis is quite complicated…
BUT basically, if I have a bunch of email accounts, It would be nice that when I reply or post new articles (email), than Gnus will change the From automatically. This method will definitely work for posting articles, but will to work when replying to articles?
(add-hook 'kill-emacs-hook #'(lambda ()
(interactive)
(when (get-buffer "*Group*")
(gnus-group-exit))))read html mail
You have 2 main options here. You can use the elisp shr for this or you can use gnus-w3m if you have w3m installed. Shr is written in elisp. w3m is written in C or C++. So I’m guessing that w3m is faster. So I’m going to use gnus-w3m.
I’m assuming that w3m is faster than the built in shr which is used by eww.
I can also use w3m, which uses the emacs-w3m, but I’m not sure how updated that is.
I’ve decided that I like the default ‘shr. the w3m is really annoying to try to use.
and 3wm has not seen much updates in the past couple of years.
;;(use-package w3m :ensure t)
;;(setq mm-text-html-renderer 'w3m)
(setq mm-text-html-renderer 'shr)Delete mail immediately after it has been marked expired
(setq nnmail-expiry-wait 'immediate)deleting boring headers from email
info:gnus#Hiding Headers(setq gnus-treat-hide-boring-headers 'head)
automatically configuring how my mail looks
The following variables can have the following values:
- nil (don’t do this treatment)
- t (do this treatment on all parts of the message)
- head (do this treatment on the headers of the message)
- first (do this treatment on the first body part)
- last (do this on the last body part)
(setq gnus-treat-strip-multiple-blank-lines t) (setq gnus-treat-trailing-blank-lines t) ;; let's see some smiles in gnus (setq gnus-treat-display-smileys t) (setq gnus-treat-emphasize 'head)
using gnus automatic scoring stuff
Make gnus rank which articles are important to you.
(setq gnus-use-adaptive-scoring t)close gnus when you exit emacs.
That way gnus exits properly, and you don’t have to read the active file when you open gnus again.(add-hook 'kill-emacs-hook #'(lambda ()
(interactive)
(when (get-buffer "*Group*")
(gnus-group-exit))))Provide init-gnus
(provide 'init-gnus)