<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet href="/assets/rss.xsl" type="text/xsl"?><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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"

>
<channel>
	<title>Sacha Chua - tag - search</title>
	<atom:link href="https://sachachua.com/blog/tag/search/feed/index.xml" rel="self" type="application/rss+xml" />
	<atom:link href="https://sachachua.com/blog/tag/search" rel="alternate" type="text/html" />
	<link>https://sachachua.com/blog/tag/search/feed/index.xml</link>
	<description>Emacs, sketches, and life</description>
  
	<lastBuildDate>Tue, 09 Jun 2026 02:51:39 GMT</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>daily</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>11ty</generator>
  <item>
		<title>Emacs Gnus: Searching Mail</title>
		<link>https://sachachua.com/blog/2008/05/emacs-gnus-searching-mail/</link>
		<dc:creator><![CDATA[Sacha Chua]]></dc:creator>
		<pubDate>Sat, 31 May 2008 12:49:37 GMT</pubDate>
    <category>emacs</category>
<category>wickedcoolemacs</category>
		<guid isPermaLink="false">https://sachachua.com/blog/?p=4902</guid>
		<description><![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 align="left">
<col align="left">
<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&#8217;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&#8217;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&#8217;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 &#8220;~/elisp/imap.el&#8221;, 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&#8217;s what we&#8217;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&#8217;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&#8217;ve installed Namazu, create a directory for Namazu&#8217;s index<br>
files, such as ~/.namazu-mail. Then index your mail by typing this at<br>
the command-line:
</p>
<pre>
mknmz &#45;&#45;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&#8217;re using the Namazu search engine, then you can use more<br>
sophisticated search queries such as:
</p>
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<col align="left">
<col align="left">
<tbody>
<tr>
<td>Linux Emacs</td>
<td>messages that contain both &#8220;Linux&#8221; and &#8220;Emacs&#8221;</td>
</tr>
<tr>
<td>Linux or Emacs</td>
<td>messages that contain either &#8220;Linux&#8221; or &#8220;Emacs&#8221;</td>
</tr>
<tr>
<td>Emacs not Linux</td>
<td>messages that contain &#8220;Emacs&#8221; but not &#8220;Linux&#8221;</td>
</tr>
<tr>
<td>Emacs and (Linux or Windows)</td>
<td>messages that contain &#8220;Emacs&#8221; and either &#8220;Linux&#8221; or &#8220;Windows&#8221;</td>
</tr>
<tr>
<td>&#8220;apple pie&#8221;</td>
<td>messages that contain the phrase &#8220;apple pie&#8221;</td>
</tr>
<tr>
<td>{apple pie}</td>
<td>messages that contain the phrase &#8220;apple pie&#8221;</td>
</tr>
<tr>
<td>+from:example@example.com</td>
<td>messages with example@example.com in the From: header</td>
</tr>
<tr>
<td>+subject:&#8221;apple pie&#8221;</td>
<td>messages with the phrase &#8220;apple pie&#8221; in the Subject: header</td>
</tr>
<tr>
<td>+subject:apple +subject:pie</td>
<td>messages whose Subject: headers contain both &#8220;apple&#8221; and &#8220;pie&#8221;</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&#8217;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&#8217;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="https://sachachua.com/blog/category/wickedcoolemacs">Wicked Cool Emacs</a> book I&#8217;m working on. =) Hope it helps!<p></p>

<p>You can <a href="https://sachachua.com/blog/2008/05/emacs-gnus-searching-mail/#comment">view 1 comment</a> or <a href="mailto:sacha@sachachua.com?subject=Comment%20on%20https%3A%2F%2Fsachachua.com%2Fblog%2F2008%2F05%2Femacs-gnus-searching-mail%2F&body=Name%20you%20want%20to%20be%20credited%20by%20(if%20any)%3A%20%0AMessage%3A%20%0ACan%20I%20share%20your%20comment%20so%20other%20people%20can%20learn%20from%20it%3F%20Yes%2FNo%0A">e-mail me at sacha@sachachua.com</a>.</p>]]></description>
		</item>
	</channel>
</rss>