<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>

<channel>
	<title>sacha chua :: enterprise 2.0 consultant, storyteller, geek &#187; gnus</title>
	<atom:link href="http://sachachua.com/wp/category/gnus/feed/" rel="self" type="application/rss+xml" />
	<link>http://sachachua.com/wp</link>
	<description>I help people connect through blogs, wikis, other Web 2.0 tools. I'm also writing a book about Emacs.</description>
	<pubDate>Fri, 05 Sep 2008 13:52:09 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.1</generator>
	<language>en</language>
			<item>
		<title>Emacs and Gnus: zomg, new chapter out the door!</title>
		<link>http://sachachua.com/wp/2008/08/04/emacs-and-gnus-zomg-new-chapter-out-the-door/</link>
		<comments>http://sachachua.com/wp/2008/08/04/emacs-and-gnus-zomg-new-chapter-out-the-door/#comments</comments>
		<pubDate>Mon, 04 Aug 2008 18:25:34 +0000</pubDate>
		<dc:creator>Sacha Chua</dc:creator>
		
		<category><![CDATA[emacs]]></category>

		<category><![CDATA[gnus]]></category>

		<category><![CDATA[wickedcoolemacs]]></category>

		<guid isPermaLink="false">http://sachachua.com/wp/2008/08/04/emacs-and-gnus-zomg-new-chapter-out-the-door/</guid>
		<description><![CDATA[So I _finally_ pulled everything together and got my Gnus chapter out the door. Hooray, hooray, hooray!

Reading Mail with Gnus (PDF)
Reading Mail with Gnus (HTML), produced by Org

Disclaimers: It&#039;s rough, it probably makes a few assumptions about whatever version of Emacs I&#039;m running, it&#039;s probably missing your favorite tips (and I&#039;d love to add them!), [...]]]></description>
			<content:encoded><![CDATA[<p>So I _finally_ pulled everything together and got my Gnus chapter out the door. Hooray, hooray, hooray!</p>
<ul>
<li><a href="http://sachachua.com/notebook/wickedcool/wc-emacs-05-gnus.pdf">Reading Mail with Gnus (PDF)</a></li>
<li><a href="http://sachachua.com/notebook/wickedcool/wc-emacs-05-gnus.html">Reading Mail with Gnus (HTML)</a>, produced by Org</li>
</ul>
<p>Disclaimers: It&#039;s rough, it probably makes a few assumptions about whatever version of Emacs I&#039;m running, it&#039;s probably missing your favorite tips (and I&#039;d love to add them!), and it probably has typos. Meep. But it&#039;s out there!</p>
<p>Hooray, hooray, hooray!</p>
<p>Next step: write about web-browsing in Emacs&#8230;</p>

<!-- start wp-tags-to-technorati 0.95 -->

<!-- end wp-tags-to-technorati -->
]]></content:encoded>
			<wfw:commentRss>http://sachachua.com/wp/2008/08/04/emacs-and-gnus-zomg-new-chapter-out-the-door/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Emacs Gnus: Filter Spam</title>
		<link>http://sachachua.com/wp/2008/06/07/emacs-gnus-filter-spam/</link>
		<comments>http://sachachua.com/wp/2008/06/07/emacs-gnus-filter-spam/#comments</comments>
		<pubDate>Sun, 08 Jun 2008 00:19:10 +0000</pubDate>
		<dc:creator>Sacha Chua</dc:creator>
		
		<category><![CDATA[emacs]]></category>

		<category><![CDATA[gnus]]></category>

		<category><![CDATA[wickedcoolemacs]]></category>

		<category><![CDATA[elisp]]></category>

		<category><![CDATA[filtering]]></category>

		<category><![CDATA[mail]]></category>

		<category><![CDATA[spam]]></category>

		<guid isPermaLink="false">http://sachachua.com/wp/?p=4913</guid>
		<description><![CDATA[(draft for an upcoming book called Wicked Cool Emacs)

Ah, spam, the bane of our Internet lives. There is no completely
reliable way to automatically filter spam. Spam messages that slip
through the filters and perfectly legitimate messages that get
labelled spam are all part of the occupational hazards of using the
Internet.


The fastest way to filter spam is to [...]]]></description>
			<content:encoded><![CDATA[<p>(draft for an upcoming book called <a href="http://sachachua.com/wp/category/wickedcoolemacs">Wicked Cool Emacs</a>)</p>
<div class="outline-4">
<p>Ah, spam, the bane of our Internet lives. There is no completely<br />
reliable way to automatically filter spam. Spam messages that slip<br />
through the filters and perfectly legitimate messages that get<br />
labelled spam are all part of the occupational hazards of using the<br />
Internet.
</p>
<p>
The fastest way to filter spam is to use an external spam-filtering<br />
program such as Spamassassin or Bogofilter, so your spam can be<br />
filtered in the background and you don&#039;t have to spend time in Emacs<br />
filtering it yourself. In an ideal world, this would be done on the<br />
mail server so that you don&#039;t even need to download unwanted<br />
messages. If your inbox isn&#039;t full of ads for medicine or stocks, your<br />
mail server is probably doing a decent job of filtering the mail for<br />
you.
</p>
<h3>Server-based mail filtering</h3>
<p>
As spam filtering isn&#039;t an exact science, you&#039;ll want to find out how<br />
you can check your spam folder for misclassified mail. If you download<br />
your mail through POP, find out if there&#039;s a webmail interface that<br />
will allow you to check if any real mail has slipped into the junk<br />
mail pile. If you&#039;re on IMAP, your mail server might automatically<br />
file spam messages in a different group. Here&#039;s how to add the spam<br />
group to your list of groups:
</p>
<ol>
<li>
Type M-x gnus to bring up the group buffer.
</li>
<li>
Type ^ (gnus-group-enter-server-mode).
</li>
<li>
Choose the nnimap: entry for your mail server and press RET (gnus-server-read-server).
</li>
<li>
Find the spam or junk mail group if it exists.
</li>
<li>
Type u (gnus-browse-unsubscribe-current-group) to toggle the subscription. Subscribed groups will appear in your M-x gnus screen if they contain at least one unread message.</p>
</li>
</ol>
<p>Another alternative is to have all the mail (spam and non-spam)<br />
delivered to your inbox, and then let Gnus be in charge of filing it<br />
into your spam and non-spam groups. If other people manage your mail<br />
server, ask them if you can have your mail processed by the spam<br />
filter but still delivered to your inbox. If you&#039;re administering your<br />
own mail server, set up a spam filtering system such as SpamAssassin<br />
or BogoFilter, then read the documentation of your spam filtering<br />
system to find out how to process the mail.
</p>
<p>
Spam filtering systems typically add a header such as &#034;X-Spam-Status&#034;<br />
or &#034;X-Bogosity&#034; to messages in order to indicate which messages are<br />
spam or even how spammy they are. To check if your mail server tags<br />
your messages as spam, open one of your messages in Gnus and type C-u<br />
g (gnus-summary-show-article) to view the complete headers and<br />
message. If you find a spam-related header such as X-Spam-Status, you<br />
can use it to split your mail. Add the following to your ~/.gnus:
</p>
<p><pre>
 (setq spam-use-regex-headers t) ;; (1)
 (setq spam-regex-headers-spam "^X-Spam-Status: Yes")   ;; (2)
 (require 'spam) ;; (3)
 (spam-initialize) ;; (4)
</pre>
</p>
<p>
This configures spam.el to detect spam based on message<br />
headers(1). Set spam-regex-headers-spam to a regular expression<br />
matching the header your mail server uses to indicate spam.(2) This<br />
configuration should be done before the spam.el library is loaded(3)<br />
and initialized(4), because spam.el uses the spam-use-* variables to<br />
determine which parts of the spam library to load.
</p>
<p>
In order to take advantage of this, you&#039;ll also need to add a rule<br />
that splits spam messages into a different group. If you haven&#039;t set<br />
up mail splitting yet, read qthe instructions on setting up fancy mail<br />
splitting in &#034;Project XXX: Organize mail into groups&#034;. Add (:<br />
spam-split) to either nnmail-split-fancy or nnimap-split-fancy,<br />
depending on your configuration. For example, your ~/.gnus may look<br />
like this:
</p>
<pre>
(setq nnmail-split-fancy
'(
;; ... other split rules go here ...
(: spam-split)
;; ... other split rules go here ...
"mail.misc")) ; default mailbox
</pre>
</div>
<p>(draft for an upcoming book called <a href="http://sachachua.com/wp/category/wickedcoolemacs">Wicked Cool Emacs</a>, more to come!)</p>

<!-- start wp-tags-to-technorati 0.95 -->

<p class='technorati-tags'>Technorati Tags: <a class='technorati-link' href='http://technorati.com/tag/elisp' rel='tag' target='_self'>elisp</a>, <a class='technorati-link' href='http://technorati.com/tag/emacs' rel='tag' target='_self'>emacs</a>, <a class='technorati-link' href='http://technorati.com/tag/filtering' rel='tag' target='_self'>filtering</a>, <a class='technorati-link' href='http://technorati.com/tag/gnus' rel='tag' target='_self'>gnus</a>, <a class='technorati-link' href='http://technorati.com/tag/mail' rel='tag' target='_self'>mail</a>, <a class='technorati-link' href='http://technorati.com/tag/spam' rel='tag' target='_self'>spam</a>, <a class='technorati-link' href='http://technorati.com/tag/wickedcoolemacs' rel='tag' target='_self'>wickedcoolemacs</a></p>

<!-- end wp-tags-to-technorati -->
]]></content:encoded>
			<wfw:commentRss>http://sachachua.com/wp/2008/06/07/emacs-gnus-filter-spam/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Emacs Gnus: Organize Your Mail</title>
		<link>http://sachachua.com/wp/2008/05/31/emacs-gnus-organize-your-mail/</link>
		<comments>http://sachachua.com/wp/2008/05/31/emacs-gnus-organize-your-mail/#comments</comments>
		<pubDate>Sat, 31 May 2008 20:47:17 +0000</pubDate>
		<dc:creator>Sacha Chua</dc:creator>
		
		<category><![CDATA[emacs]]></category>

		<category><![CDATA[gnus]]></category>

		<category><![CDATA[wickedcoolemacs]]></category>

		<category><![CDATA[mail]]></category>

		<guid isPermaLink="false">http://sachachua.com/wp/?p=4905</guid>
		<description><![CDATA[
People handle large volumes of mail in different ways. Keeping
everything in one mailbox can quickly become unmanageable because
messages you need to read get lost among messages you don&#039;t need to
read.


You can move mail manually by selecting them in the summary buffer and
typing B m (gnus-summary-move-article). Then type the name of the
group to which you would [...]]]></description>
			<content:encoded><![CDATA[<p>
People handle large volumes of mail in different ways. Keeping<br />
everything in one mailbox can quickly become unmanageable because<br />
messages you need to read get lost among messages you don&#039;t need to<br />
read.
</p>
<p>
You can move mail manually by selecting them in the summary buffer and<br />
typing B m (gnus-summary-move-article). Then type the name of the<br />
group to which you would like to move the message. The group will be<br />
created if it doesn&#039;t exist.
</p>
<p>
To move multiple messages, mark them with #<br />
(gnus-summary-mark-as-processable) and then type B m<br />
(gnus-summary-move-article). To unmark a message, type M-#<br />
(gnus-summary-unmark-as-processable). To unmark all messages, type M P<br />
U (gnus-summary-unmark-all-processable).
</p>
<h3>Automatically filing mail</h3>
<p>
Moving messages by hand is tedious and time-consuming. One way to deal<br />
with this is to set up rules that automatically file mail into<br />
different groups (or folders, as they&#039;re called in other mail<br />
clients). Gnus calls this &#034;splitting&#034; mail, and you can split mail on<br />
IMAP servers as well as mail downloaded from POP3 servers to your<br />
computer.
</p>
<p>
For example, if you&#039;re using Gnus to read mail from an IMAP server,<br />
you can split your messages by adding this to your ~/.gnus:
</p>
<p><pre>
 (setq nnimap-split-inbox "INBOX") ;; (1)
 (setq nnimap-split-predicate "UNDELETED") ;; (2)
 (setq nnimap-split-rule
       '(
         ("INBOX.emacs" "^Subject:.*emacs")
         ("INBOX.work" "^To:.*you@work.example.com")
         ("INBOX.personal" "^To:.*you@personal.example.com")
         ("INBOX.errors" "^From:.*\\(mailer.daemon\\|postmaster\\)")
        ))
</pre>
</p>
<p>
If you use a different inbox, change the value of<br />
nnimap-split-inbox(1). Any messages in the inbox will be split<br />
according to nnimap-split-rule(2), which is a list where each element<br />
is a list containing the group&#039;s name and a regular expression<br />
matching the header of messages that should be filed in the group.  In<br />
this example, Gnus will move mail with subjects containing the word<br />
&#034;emacs&#034; to INBOX.emacs, mail directed to you@work.example.com to the<br />
INBOX.work group, mail directed to you@personal.example.com to the<br />
INBOX.personal group, and mail error messages to INBOX.errors. All<br />
other messages will be stored in INBOX.
</p>
<p>
If you&#039;re downloading your mail from a POP3 server and storing it in<br />
nnml, add this to your ~/.gnus instead:
</p>
<p><pre>
 (setq nnmail-split-methods
      '(
        ("mail.emacs" "^Subject:.*emacs")
        ("mail.work" "^To:.*you@work.example.com")
        ("mail.personal" "^To:.*you@personal.example.com")
        ("mail.errors" "^From:.*\\(mailer.daemon\\|postmaster\\)")
       ))
</pre>
</p>
<p>
All other messages will be stored in mail.misc.
</p>
<p>
Start M-x gnus again, and your mail will be split into the different<br />
groups.
</p>
<h3>Where are my groups?</h3>
<p>
If you don&#039;t see your new groups in the group buffer displayed by M-x<br />
gnus, type A A (gnus-group-list-active) to see all the groups. Go to<br />
the group that you would like to add to the group buffer, then type u<br />
(gnus-group-unsubscribe-current-group) to toggle its subscription. In<br />
this example, INBOX.automated is not subscribed to, but INBOX is.
</p>
<p><pre>
 U    13: INBOX.automated
      76: INBOX
</pre>
</p>
<p>
When you type M-x gnus again, you&#039;ll see your subscribed groups if<br />
they have unread messages.
</p>
<p>
nnimap-split-rule and nnmail-split-methods allow you to filter<br />
interesting or uninteresting mail into different groups based on their<br />
headers. Gnus comes with an even more powerful mail splitting engine.<br />
In fact, Gnus comes with &#034;fancy mail splitting.&#034;
</p>
<h3>Fancy mail splitting</h3>
<p>
With fancy mail splitting and some configuration, you can split mail<br />
based on a combination of criteria. You can even manually file a<br />
message and have Gnus automatically file incoming replies in the same<br />
group.
</p>
<p>
To configure an IMAP connection to use fancy mail splitting, add the<br />
following to your ~/.gnus:
</p>
<p><pre>
 (setq nnimap-split-inbox "INBOX")
 (setq nnimap-split-predicate "UNDELETED")
 (setq nnmail-split-fancy ;; (1)
       '(|                                ;; (2)
         (: gnus-registry-split-fancy-with-parent) ;; (3)
         ;; splitting rules go here       ;; (4)
         "INBOX"                          ;; (5)
        ))
 (setq nnimap-split-rule 'nnmail-split-fancy)
 (setq nnmail-split-methods 'nnimap-split-fancy) ;; (6)
 (gnus-registry-initialize) ;; (7)
</pre>
</p>
<p>
This configures IMAP to use the nnmail-split-fancy function to<br />
determine the group for messages. Note that we&#039;re setting the<br />
nnmail-split-fancy variable here. If you want to process your IMAP<br />
mail separately from your other mail, you can set the<br />
nnimap-split-fancy variable instead. If so, also set nnimap-split-rule<br />
to &#039;nnimap-split-fancy. Using nnmail-split-fancy here makes the other<br />
examples easier to understand, though.
</p>
<p>
The nnmail-split-fancy variable controls the splitting behavior(1). The<br />
&#034;|&#034; symbol means that that the first matching rule is used(2). For<br />
example, if the message being processed is a reply to a message that<br />
Gnus knows about, then the gnus-registry-split-fancy-with-parent<br />
function will return the name of the group, and nnmail-split-fancy<br />
will file the message there(3).  You can add other splitting rules as<br />
well(4). If messages don&#039;t match any of these rules, the last rule<br />
specifies that the messages will be filed in INBOX(5). Set<br />
nnmail-split-methods to nnimap-split-fancy as well in order to work<br />
around some assumptions in other parts of the code(6). After that,<br />
initialize the Gnus registry(7), which is responsible for tracking<br />
moved and deleted messages. This allows you to automatically split<br />
replies into the same folders as the original messages.
</p>
<p>
To configure fancy mail splitting with an nnml backend (suggested<br />
configuration for POP3), add the following to your ~/.gnus instead:
</p>
<p><pre>
 (gnus-registry-initialize)
 (setq nnmail-split-fancy
       '(|
         (: gnus-registry-split-fancy-with-parent)
         ;; splitting rules go here
         "mail.misc"                          ;; (1)
        ))
 (setq nnmail-split-methods 'nnmail-split-fancy)
</pre>
</p>
<p>
This code is similar to the IMAP example, except that the default<br />
mailbox name for nnml is mail.misc(1).
</p>
<p>
Here&#039;s how the previous rules in nnmail-split-methods would be<br />
translated to nnmail-split-fancy rules for an IMAP configuration:
</p>
<p><pre>
 (setq nnmail-split-fancy
      '(|
        (: gnus-registry-split-fancy-with-parent)
         ;; splitting rules go here
        (from mail "INBOX.errors")   ;; (1)
        (any "you@work.example.com" "INBOX.work")   ;; (2)
        (any "you@personal.example.com" "INBOX.personal") ;;
        ("subject" "emacs" "INBOX.emacs") ;; (3)
        "INBOX"    ;; or "mail.misc" for nnml/POP3
       ))
</pre>
</p>
<p>
The <code>from</code> keyword matches against the &#034;From&#034;, &#034;Sender&#034;, and<br />
&#034;Resent-From&#034; fields, while the mail keyword matches common mail<br />
system addresses(1). The corresponding <code>to</code> keyword matches against<br />
the &#034;To&#034;, &#034;Cc&#034;, &#034;Apparently-To&#034;, &#034;Resent-To&#034; and &#034;Resent-Cc&#034; headers,<br />
while <code>any</code> matches the fields checked by the <code>from</code> and <code>to</code><br />
keywords(2). You can also compare against the subject<br />
and other headers(3).
</p>
<p>
You can use logic in splitting rules, too. For example, if you like<br />
reading the jokes on joke-mailing-list@example.com, but you don&#039;t like<br />
the ones sent by vi-guy@example.com (he not only has a bad sense of<br />
humor, but also likes picking on Emacs!), you can use a rule like<br />
this in your nnmail-split-fancy:
</p>
<p><pre>
         ;; ... other splitting rules go here...
         (any "joke-mailing-list@example.com"   ;; (1)
              (| (from "vi-guy@example.com" "INBOX.junk") ;; (2)
                 "INBOX.jokes")) ;; (3)
         ;; ... other splitting rules go here
</pre>
</p>
<p>
The first rule matches all messages with<br />
&#034;joke-mailing-list@example.com&#034; in from- or to-related headers.<br />
Matching messages are processed with another split rule, which moves<br />
messages from vi-guy@example.com to a separate group(2) and files the<br />
other messages in INBOX.jokes(3). To learn more about creating complex<br />
rules, read the Gnus Info manual for &#034;Fancy Mail Splitting&#034;.</p>

<!-- start wp-tags-to-technorati 0.95 -->

<p class='technorati-tags'>Technorati Tags: <a class='technorati-link' href='http://technorati.com/tag/emacs' rel='tag' target='_self'>emacs</a>, <a class='technorati-link' href='http://technorati.com/tag/gnus' rel='tag' target='_self'>gnus</a>, <a class='technorati-link' href='http://technorati.com/tag/mail' rel='tag' target='_self'>mail</a>, <a class='technorati-link' href='http://technorati.com/tag/wickedcoolemacs' rel='tag' target='_self'>wickedcoolemacs</a></p>

<!-- end wp-tags-to-technorati -->
]]></content:encoded>
			<wfw:commentRss>http://sachachua.com/wp/2008/05/31/emacs-gnus-organize-your-mail/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Emacs Gnus: Searching Mail</title>
		<link>http://sachachua.com/wp/2008/05/31/emacs-gnus-searching-mail/</link>
		<comments>http://sachachua.com/wp/2008/05/31/emacs-gnus-searching-mail/#comments</comments>
		<pubDate>Sat, 31 May 2008 12:49:37 +0000</pubDate>
		<dc:creator>Sacha Chua</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[emacs]]></category>

		<category><![CDATA[gnus]]></category>

		<category><![CDATA[wickedcoolemacs]]></category>

		<category><![CDATA[mail]]></category>

		<category><![CDATA[namazu]]></category>

		<category><![CDATA[nnir]]></category>

		<category><![CDATA[search]]></category>

		<guid isPermaLink="false">http://sachachua.com/wp/?p=4902</guid>
		<description><![CDATA[
There are several ways to find messages in Emacs. From the summary
buffer, you can use / o (gnus-summary-insert-old-articles) to display
all or some old messages. You can then scan through the headers in the
summary buffer by using C-s (isearch-forward), or you can limit the
displayed messages with these commands:





Messages from a given author
/&#160;a
gnus-summary-limit-to-author


Messages whose subjects matching a [...]]]></description>
			<content:encoded><![CDATA[<p>
There are several ways to find messages in Emacs. From the summary<br />
buffer, you can use / o (gnus-summary-insert-old-articles) to display<br />
all or some old messages. You can then scan through the headers in the<br />
summary buffer by using C-s (isearch-forward), or you can limit the<br />
displayed messages with these commands:
</p>
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<col align="left"></col><col align="left"></col><col align="left"></col></p>
<tbody>
<tr>
<td>Messages from a given author</td>
<td width=50>/&nbsp;a</td>
<td>gnus-summary-limit-to-author</td>
</tr>
<tr>
<td>Messages whose subjects matching a given regular expression</td>
<td>/ /</td>
<td>gnus-summary-limit-to-subject</td>
</tr>
<tr>
<td>Messages that match a given extra header</td>
<td>/ x</td>
<td>gnus-summary-limit-to-extra-headers</td>
</tr>
<tr>
<td>Messages at least N days old</td>
<td>/ t</td>
<td>gnus-summary-limit-to-age</td>
</tr>
</tbody>
</table>
<p>
Limits work on the messages that are currently displayed, so you can<br />
apply multiple limits. If you make a mistake, use / w<br />
(gnus-summary-pop-limit) to remove the previous limit. You can repeat<br />
/ w (gnus-summary-pop-limit) until satisfied. To remove all the<br />
limits, type C-u / w (gnus-summary-popl-limit).
</p>
<p>
If you specify a prefix, the limit&#039;s meaning is reversed.  For<br />
example, C-u / a (gnus-summary-limit-to-author) will remove the<br />
messages from the matching author or authors.
</p>
<p>
You can use Gnus to search the currently-displayed messages by using<br />
M-s (gnus-summary-search-article-forward) and M-r<br />
(gnus-summary-search-article-backward).
</p>
<p>
If you want to search a lot of mail, you&#039;ll find NNIR handy. NNIR is a<br />
front-end to mail search engines which can index your mail and return<br />
search results quickly. If you want to use NNIR with a local or remote<br />
IMAP server, you will need to use nnir.el and imap.el. If you download<br />
your mail using fetchmail or connect to a POP3 server and use an nnml<br />
backend, you can use NNIR with a search engine such as swish-e to<br />
search your ~/Mail directory efficiently.
</p>
<div class="outline-5">
<h5 id="sec-17">1.6.7.1 Setting up IMAP and NNIR</h5>
<p>
If you use IMAP, then your mail is stored on the mail server and<br />
you&#039;ll need to use the IMAP search interface to search through<br />
it. Download nnir.el from<br />
<a href="http://www.emacswiki.org/cgi-bin/wiki/download/nnir.el">http://www.emacswiki.org/cgi-bin/wiki/download/nnir.el</a> and save it to<br />
your ~/elisp directory. You will also need an imap.el that is newer<br />
than the one that comes with Emacs 22. Download imap.el from<br />
<a href="http://www.emacswiki.org/cgi-bin/wiki/download/imap.el">http://www.emacswiki.org/cgi-bin/wiki/download/imap.el</a> and save it to<br />
your ~/elisp directory as well. Because Gnus comes with an older<br />
version of imap.el, you will need to make sure that the new version of<br />
imap.el is loaded. Add the following to your ~/.gnus:
</p>
<pre>
(add-to-list 'load-path "~/elisp")
(load-file "~/elisp/imap.el")
(require 'nnir)
</pre>
<p>
Restart your Emacs. You can check if the correct version of imap.el<br />
has been loaded by typing M-x locate-library and specifying<br />
imap.el. If Emacs reports &#034;~/elisp/imap.el&#034;, then Gnus is configured<br />
to use the updated imap.el.
</p>
</div>
<div class="outline-5">
<h5 id="sec-18">1.6.7.2 Setting up POP3 and NNIR</h5>
<p>
If you use the configuration for POP3 that is suggested in this<br />
chapter, then your mail is stored in the nnml backend, which uses one<br />
file per message. To search this using NNIR, to install nnir.el and an<br />
external search mail engine. The Namazu search engine runs on Linux,<br />
UNIX, and Microsoft Windows, so that&#039;s what we&#039;ll talk about here. To<br />
find and configure other mail search engines supported by NNIR, check<br />
out the comments in nnir.el.
</p>
<p>
First, you&#039;ll need to download and install Namazu. If Namazu is<br />
available as a package for your distribution, install it that way, as<br />
it depends on a number of other programs. An installer for Microsoft<br />
Windows can be found at <a href="http://www.namazu.org/windows/">http://www.namazu.org/windows/</a> . If you need<br />
to build Namazu from source, you can get the source code and instructions<br />
from <a href="http://www.namazu.org">http://www.namazu.org</a> .
</p>
<p>
After you&#039;ve installed Namazu, create a directory for Namazu&#039;s index<br />
files, such as ~/.namazu-mail. Then index your mail by typing this at<br />
the command-line:
</p>
<pre>
mknmz --mailnews -O ~/.namazu-mail ~/Mail
</pre>
<p>
and add the following to your ~/.gnus:
</p>
<pre>
(add-to-list 'load-path "~/elisp")
(require 'nnir)
(setq nnir-search-engine 'namazu)
(setq nnir-namazu-index-directory (expand-file-name "~/.namazu-mail"))
(setq nnir-namazu-remove-prefix (expand-file-name "~/Mail"))
(setq nnir-mail-backend gnus-select-method)
</pre>
</div>
<div class="outline-5">
<h5 id="sec-19">1.6.7.3 Searching your mail with NNIR</h5>
<p>
From the group buffer displayed by M-x gnus, you can type G G<br />
(gnus-group-make-nnir-group) to search your mail for a keyword.</p>
<p>
If you&#039;re using the Namazu search engine, then you can use more<br />
sophisticated search queries such as:
</p>
<p>
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<col align="left"></col><col align="left"></col></p>
<tbody>
<tr>
<td>Linux Emacs</td>
<td>messages that contain both &#034;Linux&#034; and &#034;Emacs&#034;</td>
</tr>
<tr>
<td>Linux or Emacs</td>
<td>messages that contain either &#034;Linux&#034; or &#034;Emacs&#034;</td>
</tr>
<tr>
<td>Emacs not Linux</td>
<td>messages that contain &#034;Emacs&#034; but not &#034;Linux&#034;</td>
</tr>
<tr>
<td>Emacs and (Linux or Windows)</td>
<td>messages that contain &#034;Emacs&#034; and either &#034;Linux&#034; or &#034;Windows&#034;</td>
</tr>
<tr>
<td>&#034;apple pie&#034;</td>
<td>messages that contain the phrase &#034;apple pie&#034;</td>
</tr>
<tr>
<td>{apple pie}</td>
<td>messages that contain the phrase &#034;apple pie&#034;</td>
</tr>
<tr>
<td>+from:example@example.com</td>
<td>messages with example@example.com in the From: header</td>
</tr>
<tr>
<td>+subject:&#034;apple pie&#034;</td>
<td>messages with the phrase &#034;apple pie&#034; in the Subject: header</td>
</tr>
<tr>
<td>+subject:apple +subject:pie</td>
<td>messages whose Subject: headers contain both &#034;apple&#034; and &#034;pie&#034;</td>
</tr>
</tbody>
</table>
<p> If<br />
matching messages are found, then you will see a temporary group with<br />
the results. Although you can&#039;t delete messages from this view,<br />
reading and replying to these messages is the same as reading and<br />
replying to regular messages.
</p>
<p>
To see a message in its original context, type G T<br />
(gnus-summary-nnir-goto-thread) from the summary buffer. This opens<br />
the message&#039;s original group. If Gnus asks you how many articles to<br />
load, press RET to accept the default of all the articles.
</p>
</div>
<hr size="1"/>
This is a draft for the <a href="http://sachachua.com/wp/category/wickedcoolemacs">Wicked Cool Emacs</a> book I&#039;m working on. =) Hope it helps!</p>

<!-- start wp-tags-to-technorati 0.95 -->

<p class='technorati-tags'>Technorati Tags: <a class='technorati-link' href='http://technorati.com/tag/emacs' rel='tag' target='_self'>emacs</a>, <a class='technorati-link' href='http://technorati.com/tag/gnus' rel='tag' target='_self'>gnus</a>, <a class='technorati-link' href='http://technorati.com/tag/mail' rel='tag' target='_self'>mail</a>, <a class='technorati-link' href='http://technorati.com/tag/namazu' rel='tag' target='_self'>namazu</a>, <a class='technorati-link' href='http://technorati.com/tag/nnir' rel='tag' target='_self'>nnir</a>, <a class='technorati-link' href='http://technorati.com/tag/search' rel='tag' target='_self'>search</a>, <a class='technorati-link' href='http://technorati.com/tag/wickedcoolemacs' rel='tag' target='_self'>wickedcoolemacs</a></p>

<!-- end wp-tags-to-technorati -->
]]></content:encoded>
			<wfw:commentRss>http://sachachua.com/wp/2008/05/31/emacs-gnus-searching-mail/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Gnus multi-pane tricks, or I heart Planet Emacsen</title>
		<link>http://sachachua.com/wp/2007/12/16/gnus-multi-pane-tricks-or-i-heart-planet-emacsen/</link>
		<comments>http://sachachua.com/wp/2007/12/16/gnus-multi-pane-tricks-or-i-heart-planet-emacsen/#comments</comments>
		<pubDate>Mon, 17 Dec 2007 02:20:00 +0000</pubDate>
		<dc:creator>Sacha Chua</dc:creator>
		
		<category><![CDATA[emacs]]></category>

		<category><![CDATA[gnus]]></category>

		<guid isPermaLink="false">http://sachachua.com/notebook/wiki/2007.12.16.php#anchor-3</guid>
		<description><![CDATA[<p>The tips Joseph Miklojcik shared for <a href="http://jfm3-repl.blogspot.com/2007/12/emacs-tricks-7-use-gnus-for-email.html">reading e-mail in Gnus</a> included this _really_ nifty thing that I hadn't come across when I set up my Gnus before: <b>multi-pane reading</b>.</p>

<p>You know how modern news readers have a folder pane, a summary pane
and a preview pane?</p>

<p>Well, you can have that too.</p>

<pre class="example">
(gnus-add-configuration
 '(article
   (horizontal 1.0
        (vertical 60 (group 1.0))
        (vertical 1.0
    (summary 0.20 point)
    (article 1.0)))))

(gnus-add-configuration
 '(summary
   (horizontal 1.0
        (vertical 60 (group 1.0))
        (vertical 1.0 (summary 1.0 point)))))
</pre>

<p>This is good stuff. =)</p>

<p>On Technorati: <a href="http://www.technorati.com/tag/emacs" rel="tag">emacs</a>, <a href="http://www.technorati.com/tag/gnus" rel="tag">gnus</a></p>

<p>Random Emacs symbol: sacha/gnus-add-subject-to-bbdb-record - Function: Add datestamped subject note for each person this message has been sent to.</p>
]]></description>
			<content:encoded><![CDATA[<p>The tips Joseph Miklojcik shared for <a href="http://jfm3-repl.blogspot.com/2007/12/emacs-tricks-7-use-gnus-for-email.html">reading e-mail in Gnus</a> included this _really_ nifty thing that I hadn't come across when I set up my Gnus before: <b>multi-pane reading</b>.</p>

<p>You know how modern news readers have a folder pane, a summary pane
and a preview pane?</p>

<p>Well, you can have that too.</p>

<pre class="example">
(gnus-add-configuration
 '(article
   (horizontal 1.0
        (vertical 60 (group 1.0))
        (vertical 1.0
    (summary 0.20 point)
    (article 1.0)))))

(gnus-add-configuration
 '(summary
   (horizontal 1.0
        (vertical 60 (group 1.0))
        (vertical 1.0 (summary 1.0 point)))))
</pre>

<p>This is good stuff. =)</p>

<p>On Technorati: <a href="http://www.technorati.com/tag/emacs" rel="tag">emacs</a>, <a href="http://www.technorati.com/tag/gnus" rel="tag">gnus</a></p>

<p>Random Emacs symbol: sacha/gnus-add-subject-to-bbdb-record - Function: Add datestamped subject note for each person this message has been sent to.</p>
]]></content:encoded>
			<wfw:commentRss>http://sachachua.com/wp/2007/12/16/gnus-multi-pane-tricks-or-i-heart-planet-emacsen/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Contact report</title>
		<link>http://sachachua.com/wp/2006/11/02/contact-report/</link>
		<comments>http://sachachua.com/wp/2006/11/02/contact-report/#comments</comments>
		<pubDate>Thu, 02 Nov 2006 20:07:00 +0000</pubDate>
		<dc:creator>Sacha Chua</dc:creator>
		
		<category><![CDATA[bbdb]]></category>

		<category><![CDATA[emacs]]></category>

		<category><![CDATA[gnus]]></category>

		<category><![CDATA[pimpmyemacs]]></category>

		<category><![CDATA[planner]]></category>

		<guid isPermaLink="false">http://sachachua.com/notebook/wiki/2006.11.02.php#anchor-2</guid>
		<description><![CDATA[<p>I started tracking e-mail sent on 2006.09.01 with a
<a href="http://sachachua.com/notebook/wiki/2006.09.01#2">nifty piece of Emacs Lisp code</a> I wrote just for the
purpose. Now I have two months of interesting data which include not
only e-mail but also the occasional in-person contact or phone call
that I remember to note. It's not complete - e-mail's the only thing
that gets automatically tracked - but it does give me interesting
information. Here's the contact report for your amusement:</p>

<p><a href="http://sachachua.com/notebook/wiki/2006.10#contact">Contact report</a></p>

<p>It's sorted by overall frequency and then by regular frequency.
Warning! Parentheses follow.</p>

<pre class="example">
(defun sacha/count-matches (regexp string)
  (let ((count 0)
        (start 0))
    (while (string-match regexp string start)
      (setq start (match-end 0)
            count (1+ count)))
    count))

(defun sacha/bbdb-contact-report-as-alist (&#038;rest regexps)
  "Creates a list of (name count-regexp1 count-regexp2 count-regexp3)..."
  (setq regexps (reverse regexps))
  (delq nil
        (mapcar
         (lambda (rec)
           (when (bbdb-record-name (car rec))
             (let ((reg regexps)
                   (notes (bbdb-record-notes (car rec)))
                   list)
               (while reg
                 (setq list (cons (sacha/count-matches (car reg) notes)
                                  list))
                 (setq reg (cdr reg)))
               (cons (sacha/planner-bbdb-annotation-from-bbdb rec)
                     list))))
         bbdb-records)))

(defun sacha/bbdb-alist-sort-by-total (alist)
  "Sort ALIST by total contact."
  (sort alist 'sacha/bbdb-contact-sort-predicate))

(defun sacha/bbdb-contact-sort-predicate (a b)
  (and a b
       (let ((count-a (apply '+ (cdr a)))
             (count-b (apply '+ (cdr b))))
         (or
          (> count-a count-b)
          (and (= count-a count-b)
               ;; If equal, look at the subtotal of the rest
               (sacha/bbdb-contact-sort-predicate (cdr a) (cdr b)))))))

(defun sacha/bbdb-kill-contact-barchart (alist)
  "Kill a barchart with the contact report for ALIST."
  (kill-new
   (mapconcat
    (lambda (entry)
      (concat
       (car entry)
       " &#124; "
       (mapconcat (lambda (count)
                    (if (= count 0)
                        "&#160;"
                      (make-string count ?-)))
                  (cdr entry)
                  " &#124; ")))
    alist
    "\n")))

;; Usage: (sacha/bbdb-kill-contact-barchart
;;         (sacha/bbdb-alist-sort-by-total
;;          (sacha/bbdb-contact-report-as-alist "2006.09" "2006.10")))
;; Then yank (paste) this into another buffer
</pre>

<p>On Technorati: <a href="http://www.technorati.com/tag/emacs" rel="tag">emacs</a>, <a href="http://www.technorati.com/tag/pimpmyemacs" rel="tag">pimpmyemacs</a>, <a href="http://www.technorati.com/tag/bbdb" rel="tag">bbdb</a>, <a href="http://www.technorati.com/tag/gnus" rel="tag">gnus</a>, <a href="http://www.technorati.com/tag/planner" rel="tag">planner</a></p>

<p>Random Emacs symbol: standard-display-cyrillic-translit - Command: Display a cyrillic buffer using a transliteration.</p>
]]></description>
			<content:encoded><![CDATA[<p>I started tracking e-mail sent on 2006.09.01 with a
<a href="http://sachachua.com/notebook/wiki/2006.09.01#2">nifty piece of Emacs Lisp code</a> I wrote just for the
purpose. Now I have two months of interesting data which include not
only e-mail but also the occasional in-person contact or phone call
that I remember to note. It's not complete - e-mail's the only thing
that gets automatically tracked - but it does give me interesting
information. Here's the contact report for your amusement:</p>

<p><a href="http://sachachua.com/notebook/wiki/2006.10#contact">Contact report</a></p>

<p>It's sorted by overall frequency and then by regular frequency.
Warning! Parentheses follow.</p>

<pre class="example">
(defun sacha/count-matches (regexp string)
  (let ((count 0)
        (start 0))
    (while (string-match regexp string start)
      (setq start (match-end 0)
            count (1+ count)))
    count))

(defun sacha/bbdb-contact-report-as-alist (&rest regexps)
  "Creates a list of (name count-regexp1 count-regexp2 count-regexp3)..."
  (setq regexps (reverse regexps))
  (delq nil
        (mapcar
         (lambda (rec)
           (when (bbdb-record-name (car rec))
             (let ((reg regexps)
                   (notes (bbdb-record-notes (car rec)))
                   list)
               (while reg
                 (setq list (cons (sacha/count-matches (car reg) notes)
                                  list))
                 (setq reg (cdr reg)))
               (cons (sacha/planner-bbdb-annotation-from-bbdb rec)
                     list))))
         bbdb-records)))

(defun sacha/bbdb-alist-sort-by-total (alist)
  "Sort ALIST by total contact."
  (sort alist 'sacha/bbdb-contact-sort-predicate))

(defun sacha/bbdb-contact-sort-predicate (a b)
  (and a b
       (let ((count-a (apply '+ (cdr a)))
             (count-b (apply '+ (cdr b))))
         (or
          (> count-a count-b)
          (and (= count-a count-b)
               ;; If equal, look at the subtotal of the rest
               (sacha/bbdb-contact-sort-predicate (cdr a) (cdr b)))))))

(defun sacha/bbdb-kill-contact-barchart (alist)
  "Kill a barchart with the contact report for ALIST."
  (kill-new
   (mapconcat
    (lambda (entry)
      (concat
       (car entry)
       " | "
       (mapconcat (lambda (count)
                    (if (= count 0)
                        "&nbsp;"
                      (make-string count ?-)))
                  (cdr entry)
                  " | ")))
    alist
    "\n")))

;; Usage: (sacha/bbdb-kill-contact-barchart
;;         (sacha/bbdb-alist-sort-by-total
;;          (sacha/bbdb-contact-report-as-alist "2006.09" "2006.10")))
;; Then yank (paste) this into another buffer
</pre>

<p>On Technorati: <a href="http://www.technorati.com/tag/emacs" rel="tag">emacs</a>, <a href="http://www.technorati.com/tag/pimpmyemacs" rel="tag">pimpmyemacs</a>, <a href="http://www.technorati.com/tag/bbdb" rel="tag">bbdb</a>, <a href="http://www.technorati.com/tag/gnus" rel="tag">gnus</a>, <a href="http://www.technorati.com/tag/planner" rel="tag">planner</a></p>

<p>Random Emacs symbol: standard-display-cyrillic-translit - Command: Display a cyrillic buffer using a transliteration.</p>
]]></content:encoded>
			<wfw:commentRss>http://sachachua.com/wp/2006/11/02/contact-report/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Keeping track of the age of messages</title>
		<link>http://sachachua.com/wp/2006/10/27/keeping-track-of-the-age-of-messages/</link>
		<comments>http://sachachua.com/wp/2006/10/27/keeping-track-of-the-age-of-messages/#comments</comments>
		<pubDate>Fri, 27 Oct 2006 23:35:00 +0000</pubDate>
		<dc:creator>Sacha Chua</dc:creator>
		
		<category><![CDATA[emacs]]></category>

		<category><![CDATA[gnus]]></category>

		<category><![CDATA[pimpmyemacs]]></category>

		<guid isPermaLink="false">http://sachachua.com/notebook/wiki/2006.10.27.php#anchor-4</guid>
		<description><![CDATA[<p>I can get pretty bad at responding to e-mail. This is an experiment to
see whether the negative reinforcement of seeing just how old a
message is will help me be more responsive. Either that, or I can
strive for a Mean Time Between Responses of whatever... ;)</p>

<p>Hmm, maybe I should combine this with my blog and start distinguishing
between E-mail to and Reply to...</p>

<pre class="example">
(defadvice gnus-post-news (around sacha/gnus-track-message-age activate)
  "Insert a header showing how old a message is, to shame me into replying faster."
  ;; Before you post the news, figure out how old it is
  (let (days)
    (when article-buffer
      (setq days
            (- (time-to-days (current-time))
               (time-to-days
                (gnus-date-get-time
                 (mail-header-date
                  (gnus-summary-article-header
                   (gnus-summary-article-number))))))))
    ad-do-it
    (when days
      (goto-char (point-min))
      (when (re-search-forward "--text follows this line--" nil t)
        (forward-line 1)
        (insert "In reply to a message sent by "
                (mail-header-from message-reply-headers)
                " "
                (cond
                 ((= days 0) "today")
                 ((= days 1) "yesterday")
                 (t (format "%d days ago" days)))
                ": \n\n")))))
(setq message-citation-line-function nil)
</pre>

<p>On Technorati: <a href="http://www.technorati.com/tag/emacs" rel="tag">emacs</a>, <a href="http://www.technorati.com/tag/pimpmyemacs" rel="tag">pimpmyemacs</a>, <a href="http://www.technorati.com/tag/gnus" rel="tag">gnus</a></p>

<p>Random Emacs symbol: tramp-perl-directory-files-and-attributes - Variable: Perl script implementing `directory-files-attributes' as Lisp `read'able</p>
]]></description>
			<content:encoded><![CDATA[<p>I can get pretty bad at responding to e-mail. This is an experiment to
see whether the negative reinforcement of seeing just how old a
message is will help me be more responsive. Either that, or I can
strive for a Mean Time Between Responses of whatever... ;)</p>

<p>Hmm, maybe I should combine this with my blog and start distinguishing
between E-mail to and Reply to...</p>

<pre class="example">
(defadvice gnus-post-news (around sacha/gnus-track-message-age activate)
  "Insert a header showing how old a message is, to shame me into replying faster."
  ;; Before you post the news, figure out how old it is
  (let (days)
    (when article-buffer
      (setq days
            (- (time-to-days (current-time))
               (time-to-days
                (gnus-date-get-time
                 (mail-header-date
                  (gnus-summary-article-header
                   (gnus-summary-article-number))))))))
    ad-do-it
    (when days
      (goto-char (point-min))
      (when (re-search-forward "--text follows this line--" nil t)
        (forward-line 1)
        (insert "In reply to a message sent by "
                (mail-header-from message-reply-headers)
                " "
                (cond
                 ((= days 0) "today")
                 ((= days 1) "yesterday")
                 (t (format "%d days ago" days)))
                ": \n\n")))))
(setq message-citation-line-function nil)
</pre>

<p>On Technorati: <a href="http://www.technorati.com/tag/emacs" rel="tag">emacs</a>, <a href="http://www.technorati.com/tag/pimpmyemacs" rel="tag">pimpmyemacs</a>, <a href="http://www.technorati.com/tag/gnus" rel="tag">gnus</a></p>

<p>Random Emacs symbol: tramp-perl-directory-files-and-attributes - Variable: Perl script implementing `directory-files-attributes' as Lisp `read'able</p>
]]></content:encoded>
			<wfw:commentRss>http://sachachua.com/wp/2006/10/27/keeping-track-of-the-age-of-messages/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Emacs Gnus hack: Prioritize based on the number of recipients</title>
		<link>http://sachachua.com/wp/2006/10/04/emacs-gnus-hack-prioritize-based-on-the-number-of-recipients/</link>
		<comments>http://sachachua.com/wp/2006/10/04/emacs-gnus-hack-prioritize-based-on-the-number-of-recipients/#comments</comments>
		<pubDate>Wed, 04 Oct 2006 19:15:00 +0000</pubDate>
		<dc:creator>Sacha Chua</dc:creator>
		
		<category><![CDATA[emacs]]></category>

		<category><![CDATA[emacslisp]]></category>

		<category><![CDATA[gnus]]></category>

		<category><![CDATA[pimpmyemacs]]></category>

		<guid isPermaLink="false">http://sachachua.com/notebook/wiki/2006.10.04.php#anchor-2</guid>
		<description><![CDATA[<p>Ever found yourself confronted with an inbox overflowing with general
messages that you can ignore and messages that you and only you can
act on? Here's something to help you sort the wheat from the chaff.</p>

<p>This indicates how personal messages are so you can immediately see which messages are just for you and which are part of a long Cc. Stephen Perelgut showed me the feature in Lotus Notes and I wanted to steal it sometime, so I did it while waiting for the Instant Rails archive.</p>

<p>To use it, add %ur to your gnus-summary-line-format.</p>

<pre class="example">
(add-to-list 'nnmail-extra-headers 'To)
(add-to-list 'nnmail-extra-headers 'Cc)
(defvar sacha/gnus-count-recipients-threshold 5
  "*Number of recipients to consider as large.")

(defun sacha/gnus-count-recipients (header)
  "Given a Gnus message header, returns priority mark.
If I am the only recipient, return \"!\".
If I am one of a few recipients, but I'm listed in To:, return \"*\".
If I am one of a few recipients, return \"/\".
If I am one of many recipients, return \".\".
Else, return \" \"."
  (let* ((to (or (cdr (assoc 'To (mail-header-extra header))) ""))
         (cc (or (cdr (assoc 'Cc (mail-header-extra header))) "")))
    (cond
     ((string-match gnus-ignored-from-addresses to)
      (let ((len (length (bbdb-split to ","))))
        (cond
         ((= len 1) "!")
         ((< len sacha/gnus-count-recipients-threshold) "*")
         (t "/"))))
     ((string-match gnus-ignored-from-addresses
                    (concat to ", " cc))
      (if (< (length (bbdb-split (concat to ", " cc) ","))
             sacha/gnus-count-recipients-threshold)
          "/"
        "."))
     (t " "))))

(defalias 'gnus-user-format-function-r 'sacha/gnus-count-recipients)
</pre>

<p>Random Emacs symbol: dired-listing-switches - Variable: *Switches passed to `ls' for Dired.  MUST contain the `l' option.</p>

<p>On Technorati: <a href="http://www.technorati.com/tag/emacs" rel="tag">emacs</a>, <a href="http://www.technorati.com/tag/gnus" rel="tag">gnus</a>, <a href="http://www.technorati.com/tag/pimpmyemacs" rel="tag">pimpmyemacs</a>, <a href="http://www.technorati.com/tag/emacslisp" rel="tag">emacslisp</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Ever found yourself confronted with an inbox overflowing with general
messages that you can ignore and messages that you and only you can
act on? Here's something to help you sort the wheat from the chaff.</p>

<p>This indicates how personal messages are so you can immediately see which messages are just for you and which are part of a long Cc. Stephen Perelgut showed me the feature in Lotus Notes and I wanted to steal it sometime, so I did it while waiting for the Instant Rails archive.</p>

<p>To use it, add %ur to your gnus-summary-line-format.</p>

<pre class="example">
(add-to-list 'nnmail-extra-headers 'To)
(add-to-list 'nnmail-extra-headers 'Cc)
(defvar sacha/gnus-count-recipients-threshold 5
  "*Number of recipients to consider as large.")

(defun sacha/gnus-count-recipients (header)
  "Given a Gnus message header, returns priority mark.
If I am the only recipient, return \"!\".
If I am one of a few recipients, but I'm listed in To:, return \"*\".
If I am one of a few recipients, return \"/\".
If I am one of many recipients, return \".\".
Else, return \" \"."
  (let* ((to (or (cdr (assoc 'To (mail-header-extra header))) ""))
         (cc (or (cdr (assoc 'Cc (mail-header-extra header))) "")))
    (cond
     ((string-match gnus-ignored-from-addresses to)
      (let ((len (length (bbdb-split to ","))))
        (cond
         ((= len 1) "!")
         ((< len sacha/gnus-count-recipients-threshold) "*")
         (t "/"))))
     ((string-match gnus-ignored-from-addresses
                    (concat to ", " cc))
      (if (< (length (bbdb-split (concat to ", " cc) ","))
             sacha/gnus-count-recipients-threshold)
          "/"
        "."))
     (t " "))))

(defalias 'gnus-user-format-function-r 'sacha/gnus-count-recipients)
</pre>

<p>Random Emacs symbol: dired-listing-switches - Variable: *Switches passed to `ls' for Dired.  MUST contain the `l' option.</p>

<p>On Technorati: <a href="http://www.technorati.com/tag/emacs" rel="tag">emacs</a>, <a href="http://www.technorati.com/tag/gnus" rel="tag">gnus</a>, <a href="http://www.technorati.com/tag/pimpmyemacs" rel="tag">pimpmyemacs</a>, <a href="http://www.technorati.com/tag/emacslisp" rel="tag">emacslisp</a></p>
]]></content:encoded>
			<wfw:commentRss>http://sachachua.com/wp/2006/10/04/emacs-gnus-hack-prioritize-based-on-the-number-of-recipients/feed/</wfw:commentRss>
		</item>
		<item>
		<title>More Emacs goodness: Refresh your memory when you e-mail using notes from BBDB</title>
		<link>http://sachachua.com/wp/2006/09/02/more-emacs-goodness-refresh-your-memory-when-you-e-mail-using-notes-from-bbdb/</link>
		<comments>http://sachachua.com/wp/2006/09/02/more-emacs-goodness-refresh-your-memory-when-you-e-mail-using-notes-from-bbdb/#comments</comments>
		<pubDate>Sat, 02 Sep 2006 19:58:00 +0000</pubDate>
		<dc:creator>Sacha Chua</dc:creator>
		
		<category><![CDATA[bbdb]]></category>

		<category><![CDATA[crm]]></category>

		<category><![CDATA[emacs]]></category>

		<category><![CDATA[gnus]]></category>

		<category><![CDATA[networking]]></category>

		<category><![CDATA[pimpmyemacs]]></category>

		<guid isPermaLink="false">http://sachachua.com/notebook/wiki/2006.09.02.php#anchor-1</guid>
		<description><![CDATA[<p>Inspired by an e-mail-based customer relationship management system briefly described by <a href="http://blog.digitalketchup.net/">Daniel Charles</a> of <a href="http://www.digitalketchup.net">digital ketchup</a> at Shoeless Joe's last Friday, I decided to hack together a system that would allow me to see the notes from my contact database (aptly named the Big Brother Database, or BBDB) when I write e-mail using the Gnus mail client in Emacs.</p>

<p>The first thing I needed to build, of course, was something that
removed my notes from outgoing messages. People really don't need to
see the kinds of notes I keep on them. ;) Well, they're fairly
innocuous notes: how we met and what they're interested in, usually,
although sometimes I'll have notes on people's food preferences or
shoe sizes. I've recently started keeping track of the subjects of
e-mail I send them, too.</p>

<pre class="example">
(defun sacha/gnus-remove-notes ()
  "Remove everything from --- NOTES --- to the signature."
  (goto-char (point-min))
  (when (re-search-forward "^--- NOTES ---" nil t)
    (let ((start (match-beginning 0))
          (end (and (re-search-forward "^--- END NOTES ---") (match-end 0))))
      (delete-region start end))))
(add-hook 'message-send-hook 'sacha/gnus-remove-notes)
</pre>

<p>Then it was easy to write another function that composed individual
messages to all the people currently displayed in the BBDB buffer,
adding notes to each message.</p>

<pre class="example">
(defun sacha/gnus-send-message-to-all (subject)
  "Compose message to everyone, with notes."
  (interactive "MSubject: ")
  (let ((records bbdb-records))
    (while records
      (when (bbdb-record-net (caar records))
        (bbdb-send-mail (caar records) subject)
        (when (bbdb-record-notes (caar records))
          (save-excursion
            (insert "\n--- NOTES ---\n"
                    (bbdb-record-notes (caar records))
                    "\n--- END NOTES ---\n"))))
      (setq records (cdr records)))))
</pre>

<p>I use BBDB to display only the people I want to e-mail, then I call
M-x sacha/gnus-send-message-to-all and specify a message subject. This
creates a gazillion message buffers which I can then edit. If I feel
particularly paranoid, I can remove the notes section myself with C-c
C-z (message-kill-to-signature), but sacha/gnus-remove-notes does it
as long as it's in message-send-hook.</p>

<p>This code works particularly well with these other customizations:</p>

<ul>
<li><a href="http://sachachua.com/notebook/wiki/2006.07.20.php#anchor-1">Emacs BBDB magic: Greeting people with nicknames</a></li>
<li><a href="http://sachachua.com/notebook/wiki/2006.09.01.php#anchor-2">Emacs: Keep track of messages sent</a></li>
<li><a href="http://sachachua.com/notebook/wiki/2006.06.03.php#anchor-5">BBDB pinging code</a> - for adding datestamped notes to people's entries; can be rewritten without the use of Planner</li>
</ul>

<p>It supersedes <a href="http://sachachua.com/notebook/wiki/2006.09.01.php#anchor-4">More Emacs fun: Composing mail to everyone with notes</a>.</p>

<p>On Technorati: <a href="http://www.technorati.com/tag/emacs" rel="tag">emacs</a>, <a href="http://www.technorati.com/tag/bbdb" rel="tag">bbdb</a>, <a href="http://www.technorati.com/tag/gnus" rel="tag">gnus</a>, <a href="http://www.technorati.com/tag/crm" rel="tag">crm</a>, <a href="http://www.technorati.com/tag/networking" rel="tag">networking</a>, <a href="http://www.technorati.com/tag/pimpmyemacs" rel="tag">pimpmyemacs</a></p>

<p><a href="../emacs/dotgnus.el">../emacs/dotgnus.el</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Inspired by an e-mail-based customer relationship management system briefly described by <a href="http://blog.digitalketchup.net/">Daniel Charles</a> of <a href="http://www.digitalketchup.net">digital ketchup</a> at Shoeless Joe's last Friday, I decided to hack together a system that would allow me to see the notes from my contact database (aptly named the Big Brother Database, or BBDB) when I write e-mail using the Gnus mail client in Emacs.</p>

<p>The first thing I needed to build, of course, was something that
removed my notes from outgoing messages. People really don't need to
see the kinds of notes I keep on them. ;) Well, they're fairly
innocuous notes: how we met and what they're interested in, usually,
although sometimes I'll have notes on people's food preferences or
shoe sizes. I've recently started keeping track of the subjects of
e-mail I send them, too.</p>

<pre class="example">
(defun sacha/gnus-remove-notes ()
  "Remove everything from --- NOTES --- to the signature."
  (goto-char (point-min))
  (when (re-search-forward "^--- NOTES ---" nil t)
    (let ((start (match-beginning 0))
          (end (and (re-search-forward "^--- END NOTES ---") (match-end 0))))
      (delete-region start end))))
(add-hook 'message-send-hook 'sacha/gnus-remove-notes)
</pre>

<p>Then it was easy to write another function that composed individual
messages to all the people currently displayed in the BBDB buffer,
adding notes to each message.</p>

<pre class="example">
(defun sacha/gnus-send-message-to-all (subject)
  "Compose message to everyone, with notes."
  (interactive "MSubject: ")
  (let ((records bbdb-records))
    (while records
      (when (bbdb-record-net (caar records))
        (bbdb-send-mail (caar records) subject)
        (when (bbdb-record-notes (caar records))
          (save-excursion
            (insert "\n--- NOTES ---\n"
                    (bbdb-record-notes (caar records))
                    "\n--- END NOTES ---\n"))))
      (setq records (cdr records)))))
</pre>

<p>I use BBDB to display only the people I want to e-mail, then I call
M-x sacha/gnus-send-message-to-all and specify a message subject. This
creates a gazillion message buffers which I can then edit. If I feel
particularly paranoid, I can remove the notes section myself with C-c
C-z (message-kill-to-signature), but sacha/gnus-remove-notes does it
as long as it's in message-send-hook.</p>

<p>This code works particularly well with these other customizations:</p>

<ul>
<li><a href="http://sachachua.com/notebook/wiki/2006.07.20.php#anchor-1">Emacs BBDB magic: Greeting people with nicknames</a></li>
<li><a href="http://sachachua.com/notebook/wiki/2006.09.01.php#anchor-2">Emacs: Keep track of messages sent</a></li>
<li><a href="http://sachachua.com/notebook/wiki/2006.06.03.php#anchor-5">BBDB pinging code</a> - for adding datestamped notes to people's entries; can be rewritten without the use of Planner</li>
</ul>

<p>It supersedes <a href="http://sachachua.com/notebook/wiki/2006.09.01.php#anchor-4">More Emacs fun: Composing mail to everyone with notes</a>.</p>

<p>On Technorati: <a href="http://www.technorati.com/tag/emacs" rel="tag">emacs</a>, <a href="http://www.technorati.com/tag/bbdb" rel="tag">bbdb</a>, <a href="http://www.technorati.com/tag/gnus" rel="tag">gnus</a>, <a href="http://www.technorati.com/tag/crm" rel="tag">crm</a>, <a href="http://www.technorati.com/tag/networking" rel="tag">networking</a>, <a href="http://www.technorati.com/tag/pimpmyemacs" rel="tag">pimpmyemacs</a></p>

<p><a href="../emacs/dotgnus.el">../emacs/dotgnus.el</a></p>
]]></content:encoded>
			<wfw:commentRss>http://sachachua.com/wp/2006/09/02/more-emacs-goodness-refresh-your-memory-when-you-e-mail-using-notes-from-bbdb/feed/</wfw:commentRss>
		</item>
		<item>
		<title>More Emacs fun: Composing mail to everyone with notes</title>
		<link>http://sachachua.com/wp/2006/09/01/more-emacs-fun-composing-mail-to-everyone-with-notes/</link>
		<comments>http://sachachua.com/wp/2006/09/01/more-emacs-fun-composing-mail-to-everyone-with-notes/#comments</comments>
		<pubDate>Fri, 01 Sep 2006 16:24:00 +0000</pubDate>
		<dc:creator>Sacha Chua</dc:creator>
		
		<category><![CDATA[bbdb]]></category>

		<category><![CDATA[emacs]]></category>

		<category><![CDATA[gnus]]></category>

		<category><![CDATA[hack]]></category>

		<category><![CDATA[lisp]]></category>

		<category><![CDATA[pimpmyemacs]]></category>

		<guid isPermaLink="false">http://sachachua.com/notebook/wiki/2006.09.01.php#anchor-4</guid>
		<description><![CDATA[<pre class="example">
(defun sacha/compose-mail-to-everyone (&#038;optional subject)
  (mapc (lambda (rec)
          (setq rec (car rec))
          (when (bbdb-record-net rec)
            (bbdb-send-mail rec subject)
            (save-excursion
              (message-goto-signature)
              (forward-line -2)
              (insert "\n---- NOTES ---\n" (bbdb-record-notes rec) "\n"))))
        bbdb-records))

(defun sacha/gnus-delete-notes ()
  (goto-char (point-min))
  (when (re-search-forward "^--- NOTES ---" nil t)
    (goto-char (match-beginning 0))
    (message-kill-to-signature)))
(add-hook 'message-send-hook 'sacha/gnus-delete-notes)
</pre>

<p>On Technorati: <a href="http://www.technorati.com/tag/emacs" rel="tag">emacs</a>, <a href="http://www.technorati.com/tag/lisp" rel="tag">lisp</a>, <a href="http://www.technorati.com/tag/hack" rel="tag">hack</a>, <a href="http://www.technorati.com/tag/gnus" rel="tag">gnus</a>, <a href="http://www.technorati.com/tag/bbdb" rel="tag">bbdb</a>, <a href="http://www.technorati.com/tag/pimpmyemacs" rel="tag">pimpmyemacs</a></p>
]]></description>
			<content:encoded><![CDATA[<pre class="example">
(defun sacha/compose-mail-to-everyone (&optional subject)
  (mapc (lambda (rec)
          (setq rec (car rec))
          (when (bbdb-record-net rec)
            (bbdb-send-mail rec subject)
            (save-excursion
              (message-goto-signature)
              (forward-line -2)
              (insert "\n---- NOTES ---\n" (bbdb-record-notes rec) "\n"))))
        bbdb-records))

(defun sacha/gnus-delete-notes ()
  (goto-char (point-min))
  (when (re-search-forward "^--- NOTES ---" nil t)
    (goto-char (match-beginning 0))
    (message-kill-to-signature)))
(add-hook 'message-send-hook 'sacha/gnus-delete-notes)
</pre>

<p>On Technorati: <a href="http://www.technorati.com/tag/emacs" rel="tag">emacs</a>, <a href="http://www.technorati.com/tag/lisp" rel="tag">lisp</a>, <a href="http://www.technorati.com/tag/hack" rel="tag">hack</a>, <a href="http://www.technorati.com/tag/gnus" rel="tag">gnus</a>, <a href="http://www.technorati.com/tag/bbdb" rel="tag">bbdb</a>, <a href="http://www.technorati.com/tag/pimpmyemacs" rel="tag">pimpmyemacs</a></p>
]]></content:encoded>
			<wfw:commentRss>http://sachachua.com/wp/2006/09/01/more-emacs-fun-composing-mail-to-everyone-with-notes/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Emacs BBDB magic: Greeting people with nicknames</title>
		<link>http://sachachua.com/wp/2006/07/20/emacs-bbdb-magic-greeting-people-with-nicknames/</link>
		<comments>http://sachachua.com/wp/2006/07/20/emacs-bbdb-magic-greeting-people-with-nicknames/#comments</comments>
		<pubDate>Thu, 20 Jul 2006 17:06:00 +0000</pubDate>
		<dc:creator>Sacha Chua</dc:creator>
		
		<category><![CDATA[code]]></category>

		<category><![CDATA[elisp]]></category>

		<category><![CDATA[emacs]]></category>

		<category><![CDATA[gnus]]></category>

		<guid isPermaLink="false">http://sachachua.com/notebook/wiki/2006.07.20.php#anchor-1</guid>
		<description><![CDATA[<p>I use Gnus to read my mail within the Emacs text editor. One of the
advantages of using a mail client that's infinitely programmable is
that you can add all sorts of little tweaks to it. Gnus can be
integrated with Emacs' Big Brother Database (BBDB), a semi-structured
text database in which I store all sorts of weird notes. This little
hack takes the nick field of the database and automatically inserts a
greeting. If someone signs himself as Mikong, I should call him that
instead of Joseph Michael. Similarly, I sign my messages as Sacha, not
Sandra Jean. This little tidbit makes it easier to remember to call
people by their nicknames.</p>

<pre class="example">
(defun sacha/gnus-add-nick-to-message ()
  "Inserts \"Hello, NICK!\" in messages based on the recipient's nick field."
  (interactive)
  (save-excursion
    (let ((bbdb-get-addresses-headers (list (assoc 'recipients bbdb-get-addresses-headers)))
          nicks)
      (setq nicks
            (delq nil
                  (mapcar (lambda (rec) (bbdb-record-getprop rec 'nick))
                          (bbdb-update-records
                           (bbdb-get-addresses nil gnus-ignored-from-addresses 'gnus-fetch-field)
                           nil
                           nil))))
      (goto-char (point-min))
      (when (and nicks
                 (re-search-forward "--text follows this line--" nil t))
        (forward-line 1)
        (insert "Hello, "
                (mapconcat 'identity nicks ", ")
                "!\n\n")))))

(defadvice gnus-post-news (after sacha activate)
  (sacha/gnus-add-nick-to-message))
</pre>

<p>On Technorati: <a href="http://www.technorati.com/tag/emacs" rel="tag">emacs</a>, <a href="http://www.technorati.com/tag/gnus" rel="tag">gnus</a>, <a href="http://www.technorati.com/tag/code" rel="tag">code</a>, <a href="http://www.technorati.com/tag/elisp" rel="tag">elisp</a></p>

<p>Random Japanese sentence: ÃƒÂ¨Ã‚Â™Ã‚ÂŽÃƒÂ£Ã‚Â‚Ã‚Â’ÃƒÂ¥Ã‚Â¤Ã‚Â§ÃƒÂ£Ã‚ÂÃ‚ÂÃƒÂ£Ã‚ÂÃ‚ÂªÃƒÂ§Ã‚ÂŒÃ‚Â«ÃƒÂ£Ã‚ÂÃ‚Â¨ÃƒÂ£Ã‚ÂÃ‚Â„ÃƒÂ£Ã‚ÂÃ‚Â†ÃƒÂ£Ã‚ÂÃ‚ÂªÃƒÂ£Ã‚Â‚Ã‚Â‰ÃƒÂ£Ã‚Â€Ã‚ÂÃƒÂ¥Ã‚ÂÃ‚ÂŒÃƒÂ£Ã‚ÂÃ‚Â˜ÃƒÂ£Ã‚Â‚Ã‚ÂˆÃƒÂ£Ã‚ÂÃ‚Â†ÃƒÂ£Ã‚ÂÃ‚Â«ÃƒÂ§Ã‚ÂŒÃ‚Â«ÃƒÂ£Ã‚Â‚Ã‚Â’ÃƒÂ¥Ã‚Â°Ã‚ÂÃƒÂ£Ã‚ÂÃ‚Â•ÃƒÂ£Ã‚ÂÃ‚ÂªÃƒÂ¨Ã‚Â™Ã‚ÂŽÃƒÂ£Ã‚ÂÃ‚Â¨ÃƒÂ£Ã‚ÂÃ‚Â„ÃƒÂ£Ã‚ÂÃ‚Â£ÃƒÂ£Ã‚ÂÃ‚Â¦ÃƒÂ£Ã‚Â‚Ã‚Â‚ÃƒÂ£Ã‚Â‚Ã‚ÂˆÃƒÂ£Ã‚ÂÃ‚Â„ÃƒÂ£Ã‚Â€Ã‚Â‚	You may as well call a cat a small tiger as call a tiger a big cat.</p>
]]></description>
			<content:encoded><![CDATA[<p>I use Gnus to read my mail within the Emacs text editor. One of the
advantages of using a mail client that's infinitely programmable is
that you can add all sorts of little tweaks to it. Gnus can be
integrated with Emacs' Big Brother Database (BBDB), a semi-structured
text database in which I store all sorts of weird notes. This little
hack takes the nick field of the database and automatically inserts a
greeting. If someone signs himself as Mikong, I should call him that
instead of Joseph Michael. Similarly, I sign my messages as Sacha, not
Sandra Jean. This little tidbit makes it easier to remember to call
people by their nicknames.</p>

<pre class="example">
(defun sacha/gnus-add-nick-to-message ()
  "Inserts \"Hello, NICK!\" in messages based on the recipient's nick field."
  (interactive)
  (save-excursion
    (let ((bbdb-get-addresses-headers (list (assoc 'recipients bbdb-get-addresses-headers)))
          nicks)
      (setq nicks
            (delq nil
                  (mapcar (lambda (rec) (bbdb-record-getprop rec 'nick))
                          (bbdb-update-records
                           (bbdb-get-addresses nil gnus-ignored-from-addresses 'gnus-fetch-field)
                           nil
                           nil))))
      (goto-char (point-min))
      (when (and nicks
                 (re-search-forward "--text follows this line--" nil t))
        (forward-line 1)
        (insert "Hello, "
                (mapconcat 'identity nicks ", ")
                "!\n\n")))))

(defadvice gnus-post-news (after sacha activate)
  (sacha/gnus-add-nick-to-message))
</pre>

<p>On Technorati: <a href="http://www.technorati.com/tag/emacs" rel="tag">emacs</a>, <a href="http://www.technorati.com/tag/gnus" rel="tag">gnus</a>, <a href="http://www.technorati.com/tag/code" rel="tag">code</a>, <a href="http://www.technorati.com/tag/elisp" rel="tag">elisp</a></p>

<p>Random Japanese sentence: ÃƒÂ¨Ã‚Â™Ã‚ÂŽÃƒÂ£Ã‚Â‚Ã‚Â’ÃƒÂ¥Ã‚Â¤Ã‚Â§ÃƒÂ£Ã‚ÂÃ‚ÂÃƒÂ£Ã‚ÂÃ‚ÂªÃƒÂ§Ã‚ÂŒÃ‚Â«ÃƒÂ£Ã‚ÂÃ‚Â¨ÃƒÂ£Ã‚ÂÃ‚Â„ÃƒÂ£Ã‚ÂÃ‚Â†ÃƒÂ£Ã‚ÂÃ‚ÂªÃƒÂ£Ã‚Â‚Ã‚Â‰ÃƒÂ£Ã‚Â€Ã‚ÂÃƒÂ¥Ã‚ÂÃ‚ÂŒÃƒÂ£Ã‚ÂÃ‚Â˜ÃƒÂ£Ã‚Â‚Ã‚ÂˆÃƒÂ£Ã‚ÂÃ‚Â†ÃƒÂ£Ã‚ÂÃ‚Â«ÃƒÂ§Ã‚ÂŒÃ‚Â«ÃƒÂ£Ã‚Â‚Ã‚Â’ÃƒÂ¥Ã‚Â°Ã‚ÂÃƒÂ£Ã‚ÂÃ‚Â•ÃƒÂ£Ã‚ÂÃ‚ÂªÃƒÂ¨Ã‚Â™Ã‚ÂŽÃƒÂ£Ã‚ÂÃ‚Â¨ÃƒÂ£Ã‚ÂÃ‚Â„ÃƒÂ£Ã‚ÂÃ‚Â£ÃƒÂ£Ã‚ÂÃ‚Â¦ÃƒÂ£Ã‚Â‚Ã‚Â‚ÃƒÂ£Ã‚Â‚Ã‚ÂˆÃƒÂ£Ã‚ÂÃ‚Â„ÃƒÂ£Ã‚Â€Ã‚Â‚	You may as well call a cat a small tiger as call a tiger a big cat.</p>
]]></content:encoded>
			<wfw:commentRss>http://sachachua.com/wp/2006/07/20/emacs-bbdb-magic-greeting-people-with-nicknames/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
