[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.6 Other Sources

Gnus can do more than just read news or mail. The methods described below allow Gnus to view directories and files as if they were newsgroups.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.6.1 Directory Groups

If you have a directory that has lots of articles in separate files in it, you might treat it as a newsgroup. The files have to have numerical names, of course.

This might be an opportune moment to mention ange-ftp (and its successor efs), that most wonderful of all wonderful Emacs packages. When I wrote nndir, I didn’t think much about it—a back end to read directories. Big deal.

ange-ftp changes that picture dramatically. For instance, if you enter the ange-ftp file name ‘/ftp.hpc.uh.edu:/pub/emacs/ding-list/’ as the directory name, ange-ftp or efs will actually allow you to read this directory over at ‘sina’ as a newsgroup. Distributed news ahoy!

nndir will use NOV files if they are present.

nndir is a “read-only” back end—you can’t delete or expire articles with this method. You can use nnmh or nnml for whatever you use nndir for, so you could switch to any of those methods if you feel the need to have a non-read-only nndir.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.6.2 Anything Groups

From the nndir back end (which reads a single spool-like directory), it’s just a hop and a skip to nneething, which pretends that any arbitrary directory is a newsgroup. Strange, but true.

When nneething is presented with a directory, it will scan this directory and assign article numbers to each file. When you enter such a group, nneething must create “headers” that Gnus can use. After all, Gnus is a newsreader, in case you’re forgetting. nneething does this in a two-step process. First, it snoops each file in question. If the file looks like an article (i.e., the first few lines look like headers), it will use this as the head. If this is just some arbitrary file without a head (e.g., a C source file), nneething will cobble up a header out of thin air. It will use file ownership, name and date and do whatever it can with these elements.

All this should happen automatically for you, and you will be presented with something that looks very much like a newsgroup. Totally like a newsgroup, to be precise. If you select an article, it will be displayed in the article buffer, just as usual.

If you select a line that represents a directory, Gnus will pop you into a new summary buffer for this nneething group. And so on. You can traverse the entire disk this way, if you feel like, but remember that Gnus is not dired, really, and does not intend to be, either.

There are two overall modes to this action—ephemeral or solid. When doing the ephemeral thing (i.e., G D from the group buffer), Gnus will not store information on what files you have read, and what files are new, and so on. If you create a solid nneething group the normal way with G m, Gnus will store a mapping table between article numbers and file names, and you can treat this group like any other groups. When you activate a solid nneething group, you will be told how many unread articles it contains, etc., etc.

Some variables:


All the mapping files for solid nneething groups will be stored in this directory, which defaults to ‘~/.nneething/’.


All files that match this regexp will be ignored. Nice to use to exclude auto-save files and the like, which is what it does by default.


Regexp saying what files to include in the group. If this variable is non-nil, only files matching this regexp will be included.


Name of the map files.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.6.3 Document Groups

nndoc is a cute little thing that will let you read a single file as a newsgroup. Several files types are supported:


The Babyl format.


The standard Unix mbox file.


The MMDF mail box format.


Several news articles appended into a file.


The rnews batch transport format.


Netscape mail boxes.


MIME multipart messages.


The standard (RFC 1153) digest format.


A MIME digest of messages.


Announcement messages from LANL Gov Announce.


git commit messages.


A message forwarded according to RFC822.


The Outlook mail box.


The Outlook Express dbx mail box.


A bounce message from the Exim MTA.


A message forwarded according to informal rules.


An RFC934-forwarded message.


A mailman digest.


A digest of Clarinet brief news items.


Non-standard digest format—matches most things, but does it badly.


The last resort.

You can also use the special “file type” guess, which means that nndoc will try to guess what file type it is looking at. digest means that nndoc should guess what digest type the file is.

nndoc will not try to change the file or insert any extra headers into it—it will simply, like, let you use the file as the basis for a group. And that’s it.

If you have some old archived articles that you want to insert into your new & spiffy Gnus mail back end, nndoc can probably help you with that. Say you have an old ‘RMAIL’ file with mail that you now want to split into your new nnml groups. You look at that file using nndoc (using the G f command in the group buffer (see section Foreign Groups)), set the process mark on all the articles in the buffer (M P b, for instance), and then re-spool (B r) using nnml. If all goes well, all the mail in the ‘RMAIL’ file is now also stored in lots of nnml directories, and you can delete that pesky ‘RMAIL’ file. If you have the guts!

Virtual server variables:


This should be one of mbox, babyl, digest, news, rnews, mmdf, forward, rfc934, rfc822-forward, mime-parts, standard-digest, slack-digest, clari-briefs, nsmail, outlook, oe-dbx, mailman, and mail-in-mail or guess.


This variable says whether Gnus is to consider the group a news group or a mail group. There are two valid values: mail (the default) and news.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ] Document Server Internals

Adding new document types to be recognized by nndoc isn’t difficult. You just have to whip up a definition of what the document looks like, write a predicate function to recognize that document type, and then hook into nndoc.

First, here’s an example document type definition:

 (article-begin .  "^\^A\^A\^A\^A\n")
 (body-end .  "^\^A\^A\^A\^A\n"))

The definition is simply a unique name followed by a series of regexp pseudo-variable settings. Below are the possible variables—don’t be daunted by the number of variables; most document types can be defined with very few settings:


If present, nndoc will skip past all text until it finds something that match this regexp. All text before this will be totally ignored.


This setting has to be present in all document type definitions. It says what the beginning of each article looks like. To do more complicated things that cannot be dealt with a simple regexp, you can use article-begin-function instead of this.


If present, this should be a function that moves point to the beginning of each article. This setting overrides article-begin.


If present, this should be a regexp that matches the head of the article. To do more complicated things that cannot be dealt with a simple regexp, you can use head-begin-function instead of this.


If present, this should be a function that moves point to the head of the article. This setting overrides head-begin.


This should match the end of the head of the article. It defaults to ‘^$’—the empty line.


This should match the beginning of the body of the article. It defaults to ‘^\n’. To do more complicated things that cannot be dealt with a simple regexp, you can use body-begin-function instead of this.


If present, this function should move point to the beginning of the body of the article. This setting overrides body-begin.


If present, this should match the end of the body of the article. To do more complicated things that cannot be dealt with a simple regexp, you can use body-end-function instead of this.


If present, this function should move point to the end of the body of the article. This setting overrides body-end.


If present, this should match the beginning of the file. All text before this regexp will be totally ignored.


If present, this should match the end of the file. All text after this regexp will be totally ignored.

So, using these variables nndoc is able to dissect a document file into a series of articles, each with a head and a body. However, a few more variables are needed since not all document types are all that news-like—variables needed to transform the head or the body into something that’s palatable for Gnus:


If present, this function will be called when requesting an article. It will be called with point at the start of the body, and is useful if the document has encoded some parts of its contents.


If present, this function is called when requesting an article. It’s meant to be used for more wide-ranging transformation of both head and body of the article.


If present, this function is called to generate a head that Gnus can understand. It is called with the article number as a parameter, and is expected to generate a nice head for the article in question. It is called when requesting the headers of all articles.


If present, this function is called to generate an entire article that Gnus can understand. It is called with the article number as a parameter when requesting all articles.


If present, this function is called to dissect a document by itself, overriding first-article, article-begin, article-begin-function, head-begin, head-begin-function, head-end, body-begin, body-begin-function, body-end, body-end-function, file-begin, and file-end.

Let’s look at the most complicated example I can come up with—standard digests:

 (first-article . ,(concat "^" (make-string 70 ?-) "\n\n+"))
 (article-begin . ,(concat "\n\n" (make-string 30 ?-) "\n\n+"))
 (prepare-body-function . nndoc-unquote-dashes)
 (body-end-function . nndoc-digest-body-end)
 (head-end . "^ ?$")
 (body-begin . "^ ?\n")
 (file-end . "^End of .*digest.*[0-9].*\n\\*\\*\\|^End of.*Digest *$")
 (subtype digest guess))

We see that all text before a 70-width line of dashes is ignored; all text after a line that starts with that ‘^End of’ is also ignored; each article begins with a 30-width line of dashes; the line separating the head from the body may contain a single space; and that the body is run through nndoc-unquote-dashes before being delivered.

To hook your own document definition into nndoc, use the nndoc-add-type function. It takes two parameters—the first is the definition itself and the second (optional) parameter says where in the document type definition alist to put this definition. The alist is traversed sequentially, and nndoc-type-type-p is called for a given type type. So nndoc-mmdf-type-p is called to see whether a document is of mmdf type, and so on. These type predicates should return nil if the document is not of the correct type; t if it is of the correct type; and a number if the document might be of the correct type. A high number means high probability; a low number means low probability with ‘0’ being the lowest valid number.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.6.4 Mail-To-News Gateways

If your local nntp server doesn’t allow posting, for some reason or other, you can post using one of the numerous mail-to-news gateways. The nngateway back end provides the interface.

Note that you can’t read anything from this back end—it can only be used to post with.

Server variables:


This is the address of the mail-to-news gateway.


News headers often have to be transformed in some odd way or other for the mail-to-news gateway to accept it. This variable says what transformation should be called, and defaults to nngateway-simple-header-transformation. The function is called narrowed to the headers to be transformed and with one parameter—the gateway address.

This default function just inserts a new To header based on the Newsgroups header and the gateway address. For instance, an article with this Newsgroups header:

Newsgroups: alt.religion.emacs

will get this To header inserted:

To: alt-religion-emacs@GATEWAY

The following pre-defined functions exist:


Creates a To header that looks like newsgroup@nngateway-address.


Creates a To header that looks like nngateway-address.

Here’s an example:

(setq gnus-post-method

So, to use this, simply say something like:

(setq gnus-post-method '(nngateway "GATEWAY.ADDRESS"))

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.6.5 The Empty Backend

nnnil is a backend that can be used as a placeholder if you have to specify a backend somewhere, but don’t really want to. The classical example is if you don’t want to have a primary select methods, but want to only use secondary ones:

(setq gnus-select-method '(nnnil ""))
(setq gnus-secondary-select-methods
      '((nnimap "foo")
        (nnml "")))

[ < ] [ > ]   [ << ] [ Up ] [ >> ]

This document was generated on January 25, 2015 using texi2html 1.82.