From SRS
Jump to: navigation, search

My dot.gnus file - courtesy my good friend Sriram Karra, with a few modifications I pushed in here and there (also copy and pasted). I can't make head or tail out of elisp, alas .. but it does seem to work just fine to read email from multiple IMAP folders and newsgroups, and send pgp signed email. Karra's been kind enough to annotate it extensively, so it is quite newbie friendly, I must say.

You do need [mailcrypt] and [GnuPG] to handle encrypted and signed email, and [leafnode] to fetch and locally spool usenet posts, for this to work as planned.

Note - I've set it up to suppress the Sender: header that gnus inserts - and what you typically get is a combination of which doesnt necessarily make sense when you're running gnus on a PC with a hostname that doesnt exist in DNS (something like foo@localhost.localdomain) - Sender headers like that are just plain useless.

;; Mail & News
(setq mail-yank-prefix ">")
;(setq user-full-name "Suresh Ramasubramanian")
;(setq user-mail-address "")
(setq mail-host-address "")
(setq gnus-local-domain "")
(defun my-gnus-user-agent ()
  "Multi-flavoured custom User-Agent field"
(format "Gnus/%s (Oort %s) "
(gnus-continuum-version (gnus-version)) gnus-version-number)
(cond ((its-gnu) (format "Emacs/%s " emacs-version))
(t (format "XEmacs/%s " emacs-program-version)))
(cond ((eq window-system 'gtk) "(GTK)")
(t (format "(%s)" system-configuration)))))
'(mail-user-agent (quote my-gnus-user-agent))
(setq message-syntax-checks '((sender . disabled))) 
(setq gnus-posting-styles
             ("From" " (Suresh Ramasubramanian)")
;            ("Sender" (message-make-sender))
             ("Organization" "KCircle -")
             ("X-Files" "Great Show")
             ("X-PGP" "EDEDEFB9")
             ("X-PGP-FP" "3CA0 80DE 517F 2B36 3B9B  E5C0 441E 2BF5 EDED EFB9")
             (signature-file "~/.signature"))
             ("From" " (Suresh Ramasubramanian)")
;            ("Sender" (message-make-sender))
             ("Organization" "Hopelessly Disorganized")
             ("X-Files" "Great Show")
             ("X-PGP" "EDEDEFB9")
             ("X-PGP-FP" "3CA0 80DE 517F 2B36 3B9B  E5C0 441E 2BF5 EDED EFB9")
             (signature-file "~/sig.sureshr"))
             ("From" " (Suresh Ramasubramanian)")
;            ("Sender" (message-make-sender))
             ("Organization" "Hopelessly Disorganized")
             ("X-Files" "Great Show")
             ("X-PGP" "EDEDEFB9")
             ("X-PGP-FP" "3CA0 80DE 517F 2B36 3B9B  E5C0 441E 2BF5 EDED EFB9")
             (signature-file "~/sig.sureshr")
;; nnml is a good way to store your retrieved email in your home
;; directory.
(setq gnus-secondary-select-methods '((nnml "private")))
;; Mention the various sources from which you want to fetch email.  You
;; can do local spool, local maildir, pop, imap, read from
;; hotmail... you name it.  The default source is "~/Maildir" and the
;; subdirs are the standard "cur" and "new"
(setq mail-sources `((maildir)))
(setq mail-source-directory "~/Mail/gnus/")
;; This is all you need to read mail from your maildir.
;; I would recommend you start like this.  Suggestions:
;; 1. Start with a clear state.  There is a big problem with Gnus... it
;; stores some state in a horendously formatted human-unreadable format
;; in a file called ~/.newsrc.eld .  Get rid of it.  Get rid of or move
;; your old Mail directory away.  You might want to test this particular
;; file on a "virgin" account, like I did for this file: create a new
;; user just for this purpose.
;; 2. For clarity's sake use diferent directories for your Maildir and
;; nnml backends.  ( Gnus uses sane defaults... ~/Maildir for maildir
;; and ~/Mail for storing nnml mails - just let it be that way)
;; 3. The way your mail is visible in Gnus is a little un-settling, and
;; has been the cause for a lot of newbie panic.  After you have
;; installed this file you SHOULD follow the following steps:
;; - Enter gnus with M-x gnus RET
;; - You might not see anything, even if there is a tonne of mail in
;;   your Maildir.  Do not panic.  Relax, your mail is safe.  You just
;;   have to find it :)  Press the carat key i.e. "^".  That will put in
;;   the "server buffer".  There you must definitely see a line to the
;;   effect:"      {nnml:private} (opened)"  This is good.  If there is
;;   on such line, then you have a really screwed up Emacs
;;   installation.
;; - Move the cursor to the aforementioned line and press the spacebar.
;;   This should put you in a buffer called "*Gnus Browse Server*
;;   {nnml:private} "  Here yo will find lines like
;;      K  1: Default
;;      K  1: tests
;;   etc.  You move your cursor to each of these in turn and press the
;;   "u" key, once on each line.  The K's will disappear.  If this does
;;   not happen, you curse your luck and come back another day.
;; - Press "q" once to get back to the server buffer; press once more to
;;   get back to Groups buffer.   there you must now see things like:
;;     1: nnml+private:tests
;;     1: nnml+private:Default
;;   This now means you have succesfully "subscribed to the groups
;;   Default and tests".  You will not have to repeat these processes
;;   again.. for these two groups.  Keep in mind that if you modify your
;;   nnmail-split-methods variable such that new groups are created, you
;;   must repeat the above routine to make them visible in the Groups
;;   buffer.
;; - Now, that is not all.  Keep in mind that Gnus treats mail very much
;;   like news.  And in news, given the high traffic, one is generally
;;   interested in looking at unread articles.  What this means for you
;;   is... Gnus will hide all read mails from you by default!!!  This is
;;   the single most earth-shaking and hard-to-digest fact that newbies
;;   have a tough time coming to terms with.  so, in the above example,
;;   if you finished reading the two new messages in "Default" and
;;   "tests" groups, quite emacs, and come back into Gnus, you will not
;;   find ANYTHING in the Groups buffer!!  That does NOT mean, Gnus ate
;;   all your mail.  It just means you have no new mail that Gnus wants
;;   you to see.  If you want to look at all the groups, even those with
;;   0 unread messages, you should pess "L".  This is one key stroke
;;   newbies will simply LOVE.
;; I guess that should give you a fair start.
;; --- mail expiration
        gnus-auto-expirable-newsgroups "^nnml:.*"
        nnmail-expiry-wait 7)
(setq mail-archive-file-name "~/mail/sent")
(setq rmail-file-name "~/mail/RMAIL")
(setq nnmail-split-methods
        ("Exim" "^List-Id.*exim-users\\.exim")
        ("LIH" "^List-Id:.*linux-india-help\\.lists\\.sourceforge\\.net")
        ("LIG" "^List-Id:.*linux-india-general\\.lists")
        ("Default" "")))
;; --- mail expiration
 gnus-auto-expirable-newsgroups "^nnml:.*"
 nnmail-expiry-wait 7)
;; --------------------
(message "Gnus: Backend initialized")
(setq nnimap-expunge-on-close t)
(setq mail-signature t)
(setq mail-interactive t)
; mailcrypting stuff
(load-library "mailcrypt")
(mc-setversion "gpg")
(autoload 'mc-install-write-mode "mailcrypt" nil t)
(autoload 'mc-install-read-mode "mailcrypt" nil t)
(add-hook 'gnus-summary-mode-hook 'mc-install-read-mode)
(add-hook 'message-mode-hook 'mc-install-write-mode)
(add-hook 'news-reply-mode-hook 'mc-install-write-mode)
;; If you have more than one key, specify the one to use
(setq mc-gpg-user-id "Suresh Ramasubramanian")
;; Always sign encrypted messages
(setq mc-pgp-always-sign t)
;; How long should mailcrypt remember your passphrase
(setq mc-passwd-timeout 600)
;; Automagically sign all messages
(add-hook 'message-send-hook 'will-you-sign)
(defun will-you-sign ()
        (load-library "mc-toplev")
        (if (y-or-n-p "Do you want to sign this message? ")
;; Call fetchmail 
(defun fetchmail ()
  (shell-command-to-string "fetchmail"))
; replace-signature will replace the signature in an email
(defun replace-signature () (interactive)
  (let ((starthere (point)))
    (goto-char (point-min))
    (search-forward-regexp "^--text")
    (next-line 1)
    (search-forward-regexp "^--")
    (next-line 1)
    (let ((beg (point)))
      (goto-char (point-max))
      (delete-region beg (point)))
    (shell-command-to-string "~suresh/sig.suresh")
    (insert-file "~/.signature")
    (goto-char starthere)))
; Enable syntax highlighting
; Display full iso8859-1 character set
(set-input-mode t nil '8bit)
(standard-display-european 1)
; Custom filename extensions
(setq auto-mode-alist
      (append '(
                ("\\.ephtml$"   . perl-mode)
                ) auto-mode-alist))
(setq auto-mode-alist
      (append '(
                ("\\.dtxt$"   . perl-mode)
                ) auto-mode-alist))
 '(sc-use-only-preference-p t)
 '(gnus-inhibit-startup-message t)
 '(sc-cite-blank-lines-p t)
 '(fontset-default-styles (quote (bold demibold italic oblique bold-italic bold-oblique demibold-italic demibold-oblique)))
 '(mail-extr-guess-middle-initial t)
 '(message-user-path nil)
 '(sc-fixup-whitespace-p t)
 '(sc-nested-citation-p t)
 '(toolbar-news-reader (quote gnus))
 '(toolbar-mail-reader (quote vm))
 '(message-from-style (quote parens))
 '(mail-from-style (quote parens))
 '(mail-specify-envelope-from t)
 '(message-sendmail-f-is-evil nil)
 '(message-send-mail-function quote 'message-send-mail-with-sendmail)
 '(message-sendmail-f-is-evil nil)
 '(message-cite-function (quote sc-cite-original))
 '(require (quote supercite))
 '(frame-background-mode nil)
 '(pc-select-meta-moves-sexps t)
 '(mail-user-agent (quote message-user-agent))
 '(message-signature-file "~/.Sig")
 '(message-user-organization-file "/usr/local/lib/leafnode/organization")
 '(mail-use-rfc822 t)
 '(sc-electric-references-p t)
 '(sc-preferred-attribution-list (quote ("sc-lastchoice" "x-attribution" "firstname" "initials" "lastname")))
 '(pc-selection-mode t nil (pc-select))
(setq minibuffer-max-depth nil)
 '("^-- $" "^-- *$"
   "^ *--------*$"
 gnus-signature-limit 20.0 ; floating point for lines
 message-signature-file "~/.Sig"
;;;; Signature ;;;;