I’ve spent part of the morning setting up Gnus on my OS X, to replace Mail.app and ease synchronization with my GNU/Linux boxes. I won’t enter in the details of basic Gnus setup (see, for instance, the Gnus tutorial), but offer some customization tips, and mention two of my favourite Gnus-enhancing packages (which are not OS X-specific, by the way).
First thing was to import my Mail.app mailboxes. Easy. Open the mailbox in Mail, select all messages and execute the menu command
Save as... (under
File); in the save dialog, be sure to select
Raw Message Source. The saved file is in mbox format, a Gnus import friendly one. All you need to get those messages into Gnus is to press
B f in the *Group* buffer, providing your mbox file when asked. A new group is created with all your messages. You can, for instance, mark all of them and
B c to copy them in, say, a regular
Setting Gnus to read and send messages via Gmail was also easy following the instructions here. A caveat: you’ll need also the file ssl.el from the Gnus CVS repository to make POP3 work (and of course gnutls, which i installed via the fink package gnutls14; be sure to tell Emacs about your fink path:
(add-to-list 'exec-path "/sw/bin")).
With that, I had a functional Gnus running and could move on to more interesting stuff. I don’t know about you, but i absolutely need random mail signatures, selected from my growing collection. To that end, i’ve been using randomsig.el since i can remember. Just put the file in your load path (or, if you’re on Debian, install the
gnus-bonus-el package), and add to your initialisation files something along the lines of:
(when (require 'randomsig nil t)
(define-key message-mode-map (kbd "C-c s") 'randomsig-replace-sig)
(define-key message-mode-map (kbd "C-c S") 'randomsig-select-sig)
(require 'gnus-sum) ; probably required for `gnus-summary-save-map'
(define-key gnus-summary-save-map "-" 'gnus/randomsig-summary-read-sig)
(setq randomsig-dir "~/Library/Emacs/Gnus/")
(setq randomsig-files '("signatures.txt"))
;; or (setq randomsig-files (randomsig-search-sigfiles))
;; or (setq randomsig-files 'randomsig-search-sigfiles)
(setq message-signature 'randomsig-signature)
(setq randomsig-delimiter-pattern "^--"))
As you can see, i put my signatures in a file called signatures.txt. Now, every time i start editing an email, a random signature taken from this file is inserted for me. If i don’t like it, i can request another one typing
C-c s. And if i’m reading anything inside and Emacs buffer and find a new text to add to my
M-x randomsig-message-read-sig will add the region marked in the buffer to my collection. Perfect bliss.
Mail.app comes with a sophisticated search engine based on Spotlight. But i’ve noticed that i never use the 95% of its features, not to mention that it’s annoyingly slow. What i really need is a simple and quick keyword search, and i’ve had it for many years now with Gnus and nnir.el. This package provides an Emacs/Gnus front-end to several indexers, my preferred one being namazu. So, besides getting
nnir.el, you’ll need to install it. In Debian, it’s as easy as installing the corresponding package (namazu2), but, theres no namazu package to be seen in fink. Fortunately, you can compile it from source just by following the instructions: they worked in my MacBook without a glitch. With namazu installed, you can index your extant email in a breeze: create a directory to hold the index files (i use
~/Library/Caches/namazu) and type:
mknmz --mailnews ~/Library/Emacs/Gnus/Mail
(using the appropriate directories, of course), and the index directory will get populated. Now, with
nnir.el in your load path, tell Emacs how to find those index files:
(when (require 'nnir nil t)
(setq nnir-search-engine 'namazu)
(setq nnir-mail-backend (nth 0 gnus-secondary-select-methods)))
(i put this code in my Gnus configuration file). We are all setup: go to the *Group* buffer and type
G G to search your emails. A temporal group containing the messages that match your query will be created for you, for your browsing pleasure. Inside that group,
G T will teletransport you to the original message, in case you need to recover its context. As you’ll notice, namazu searches are at least an order of magnitude faster than Spotlight.
The only bit left is to set an entry in your crontab running
mknmz for you periodically (i’ve got it set up with a period of one hour). Indexing is incremental, i.e., fast. Yeah, it’s not that immediate indexing of Spotlight or Beagle, but, you know, it’s not like i get a mail every five seconds, or that i need engine to find a mail i read twenty minutes ago.
There are many other tricks to play with Gnus, but i’ll save them for future posts.