CREATED:
UPDATED: Author: Chen BinGnus is a fine email client. But its learning curve is a little steep even for some geeks. I am a geek and I've read all the Gnus tutorials I could get from the internet. For a very long time, I was still frustrated by Gnus frequently. Finally I decided to list the most important tasks I need Gnus to do and figure out all the details task by task.
That's why I write this tutorial which is short, simple and containing all the key points.
Gnus is written in 1988. Many sections in the manual does not make sense for a modern email client (For example, what Gnus manual calls "Summary Buffer" is actually "list of emails").
Gnus is fully docu.mented. That's actually a problem, though. Because it could take your many hours to dig out the useful key points from the manual.
See http://www.emacswiki.org/emacs/GnusGmail on setting up Gnus for Gmail.
Then You need input command "M-x gnus" to start Gnus.
If the Gnus properly set up, you will come to the "Group Buffer" window which lists the email folders. But in Gnus, the folder is named "Group". By default, the groups is NOT visible. You need subscribe the groups. For example, my Gmail folder "Inbox" is a group named "nnimap+gmail:INBOX" in "Group Buffer" and it's invisible by default!. If I don't subscribe that group, I can't read email in my INBOX. I know this is confusing. But this is the way of Gnus. Check my next section to see how to subscribe groups.
After subscribing the INBOX, the group INBOX could still be invisible if INBOX does not contain unread emails. That makes no sense for a email client (OK for a news reader, though)! Anyway, the solution is simple, `C-u 5 gnus-group-list-all-groups` will get desired result. I assigned hotkey "o" to it. Here is my elisp code you could paste into your .emacs. See the Gnus Manual on Listing Groups for more details.
(defun my-gnus-group-list-subscribed-groups () "List all subscribed groups with or without un-read messages" (interactive) (gnus-group-list-all-groups 5) ) (add-hook 'gnus-group-mode-hook ;; list all the subscribed groups even they contain zero un-read messages (lambda () (local-set-key "o" 'my-gnus-group-list-subscribed-groups )) )
In the "Group Buffer", you can select a group (email folder) by pressing "RET" to see emails in that folder. But I strongly suggest pressing "C-u RET" instead because your intention could be seeing ALL the emails instead the emails filtered by "smart" Gnus.
After selecting a group and pressing "RET", you reach the "Summary Buffer" which is, as I said before, a list of your email.
Now everything is simple, you can press "RET" to see the email and use normail Emacs hotkeys for navigation. Hotkey "q" is for quitting "Summary Buffer".
In summary, you only need remember "Group Buffer" for mail folders and "Summary Buffer" for mails.
That's all you need to know about Gnus. Short tutorial, eh?
"G G" to search in current selected group at "Group Buffer".
"/ /" to limit the emails by subject at "Summary Buffer". "Limiting" is kind of searching mail locally".
"/ a" to limit the emails by author at "Summary Buffer".
"/ w" to cancel the current filter.
You can apply the limits sequentially and cancel them one by one using "/ w"
BTW, I love "Limiting" in Gnus. See http://www.gnu.org/software/emacs/manual/html_mono/gnus.html#Limiting for more limiting tricks.
See http://sachachua.com/blog/2008/05/emacs-gnus-searching-mail/ for details.
I admit this part of UI is actually far from elegant.
"A A" in "Group Buffer" to list all groups on all the connected server. It may take a while. I suggest pressing "L" to avoid querying data from all the servers if possible.
After getting the list of all subscribed/unsubscribed groups, press "u" to subscribe/unsubscribe specific group.
I repeat, in order to see the emails in "INBOX" folder/group, you need MANUALLY subscribe the group "INBOX", right here, right now!
"l" to navigate back the default view of group buffer which you may find confusing, as I mentioned before. Press "o" is much better if you uses my elisp code to show all the subscribed groups.
"g" to refresh groups list.
"R" to reply with quoted text. "r" to reply without quoted.
"a" or "m"
BTW, you don't need open Gnus to compose a mail. You can type "C-x m" directly in Emacs.
"C-c C-a"
"C-c C-c".By default, Emacs always use the hotkey "C-c C-c" to submit/stop something.
"/ N", "M-x gnus-summary-insert-new-articles"
"C-u RET" in "Group Buffer", or "C-u M-g" in "Summary Buffer". That's the most important part of this article! That's why I want to write this article.
Check http://stackoverflow.com/questions/4982831/i-dont-want-to-expire-mail-in-gnus for the details.
The ~/.gnus.el
; -*- Lisp -*- (require 'nnir) ;;@see http://www.emacswiki.org/emacs/GnusGmail#toc1 (setq gnus-select-method '(nntp "news.gmane.org")) ;; ask encyption password once (setq epa-file-cache-passphrase-for-symmetric-encryption t) (setq smtpmail-auth-credentials "~/.authinfo.gpg") ;;@see http://gnus.org/manual/gnus_397.html (add-to-list 'gnus-secondary-select-methods '(nnimap "gmail" (nnimap-address "imap.gmail.com") (nnimap-server-port 993) (nnimap-stream ssl) (nnir-search-engine imap) (nnimap-authinfo-file "~/.authinfo.gpg") ; @see http://www.gnu.org/software/emacs/manual/html_node/gnus/Expiring-Mail.html ;; press 'E' to expire email (nnmail-expiry-target "nnimap+gmail:[Gmail]/Trash") (nnmail-expiry-wait 90) ) ) (setq-default gnus-summary-line-format "%U%R%z %(%&user-date; %-15,15f %B%s%)\n" gnus-user-date-format-alist '((t . "%Y-%m-%d %H:%M")) gnus-summary-thread-gathering-function 'gnus-gather-threads-by-references gnus-sum-thread-tree-false-root "" gnus-sum-thread-tree-indent "" gnus-sum-thread-tree-leaf-with-other "-> " gnus-sum-thread-tree-root "" gnus-sum-thread-tree-single-leaf "|_ " gnus-sum-thread-tree-vertical "|") (setq gnus-thread-sort-functions '( (not gnus-thread-sort-by-date) (not gnus-thread-sort-by-number) )) ; NO 'passive (setq gnus-use-cache t) (setq gnus-use-adaptive-scoring t) (setq gnus-save-score t) (add-hook 'mail-citation-hook 'sc-cite-original) (add-hook 'message-sent-hook 'gnus-score-followup-article) (add-hook 'message-sent-hook 'gnus-score-followup-thread) ; @see http://stackoverflow.com/questions/945419/how-dont-use-gnus-adaptive-scoring-in-some-newsgroups (setq gnus-parameters '(("nnimap.*" (gnus-use-scoring nil)) )) (defvar gnus-default-adaptive-score-alist '((gnus-kill-file-mark (from -10)) (gnus-unread-mark) (gnus-read-mark (from 10) (subject 30)) (gnus-catchup-mark (subject -10)) (gnus-killed-mark (from -1) (subject -30)) (gnus-del-mark (from -2) (subject -15)) (gnus-ticked-mark (from 10)) (gnus-dormant-mark (from 5)))) (setq gnus-score-find-score-files-function '(gnus-score-find-hierarchical gnus-score-find-bnews bbdb/gnus-score) ) ;; BBDB: Adress list (when (file-exists-p "/usr/share/emacs/site-lisp/bbdb") (add-to-list 'load-path "/usr/share/emacs/site-lisp/bbdb") (require 'bbdb) (bbdb-initialize 'message 'gnus 'sendmail) (setq bbdb-file "~/bbdb.db") (add-hook 'gnus-startup-hook 'bbdb-insinuate-gnus) (setq bbdb/mail-auto-create-p t bbdb/news-auto-create-p t) (defvar bbdb-time-internal-format "%Y-%m-%d" "The internal date format.") ;;;###autoload (defun bbdb-timestamp-hook (record) "For use as a `bbdb-change-hook'; maintains a notes-field called `timestamp' for the given record which contains the time when it was last modified. If there is such a field there already, it is changed, otherwise it is added." (bbdb-record-putprop record 'timestamp (format-time-string bbdb-time-internal-format (current-time)))) ) (add-hook 'message-mode-hook '(lambda () (flyspell-mode t) (local-set-key "<TAB>" 'bbdb-complete-name))) ;; Fetch only part of the article if we can. I saw this in someone ;; else's .gnus (setq gnus-read-active-file 'some) ;; Tree view for groups. I like the organisational feel this has. (add-hook 'gnus-group-mode-hook 'gnus-topic-mode) ;; Threads! I hate reading un-threaded email -- especially mailing ;; lists. This helps a ton! (setq gnus-summary-thread-gathering-function 'gnus-gather-threads-by-subject) ;; Also, I prefer to see only the top level message. If a message has ;; several replies or is part of a thread, only show the first ;; message. 'gnus-thread-ignore-subject' will ignore the subject and ;; look at 'In-Reply-To:' and 'References:' headers. (setq gnus-thread-hide-subtree t) (setq gnus-thread-ignore-subject t) ; Personal Information (setq user-full-name "My Name" user-mail-address "[email protected]" ;message-generate-headers-first t ) ;; Change email address for work folder. This is one of the most ;; interesting features of Gnus. I plan on adding custom .sigs soon ;; for different mailing lists. ;; Usage, FROM: My Name <work> (setq gnus-posting-styles '((".*" (name "My Name" (address "[email protected]" (organization "") (signature-file "~/.signature") ("X-Troll" "Emacs is better than Vi") ))))) ; You need install the ClI brower 'w3m' and Emacs plugin 'w3m' (setq mm-text-html-renderer 'w3m) (setq message-send-mail-function 'smtpmail-send-it smtpmail-starttls-credentials '(("smtp.gmail.com" 587 nil nil)) smtpmail-auth-credentials '(("smtp.gmail.com" 587 "[email protected]" nil)) smtpmail-default-smtp-server "smtp.gmail.com" smtpmail-smtp-server "smtp.gmail.com" smtpmail-smtp-service 587 smtpmail-local-domain "homepc") ;http://www.gnu.org/software/emacs/manual/html_node/gnus/_005b9_002e2_005d.html (setq gnus-use-correct-string-widths nil) (gnus-compile)
The ~/.authinfo.gpg
machine imap.gmail.com login [email protected] password my-secret-password port 993 machine smtp.gmail.com login [email protected] password my-secret-password port 587
Please note .authinfo.gpg is a encrypted file. You must use Emacs to edit it. Emacs will do the encryption/descryption on this file automatically. See http://emacswiki.org/emacs/EasyPG for technical details.