Gnus Manual. Node: Saving Articles

PREVArticle Backlog UPThe Summary Buffer NEXTDecoding Articles

3.15: Saving Articles

Gnus can save articles in a number of ways. Below is the documentation for saving articles in a fairly straight-forward fashion (i.e., little processing of the article is done before it is saved). For a different approach (uudecoding, unsharing) you should use gnus-uu (see Decoding Articles).

If gnus-save-all-headers is non-nil, Gnus will not delete unwanted headers before saving the article.

If the preceding variable is nil, all headers that match the gnus-saved-headers regexp will be kept, while the rest will be deleted before saving.

O o
o

Save the current article using the default article saver (gnus-summary-save-article).

O m

Save the current article in mail format (gnus-summary-save-article-mail).

O r

Save the current article in rmail format (gnus-summary-save-article-rmail).

O f

Save the current article in plain file format (gnus-summary-save-article-file).

O F

Write the current article in plain file format, overwriting any previous file contents (gnus-summary-write-article-file).

O b

Save the current article body in plain file format (gnus-summary-save-article-body-file).

O h

Save the current article in mh folder format (gnus-summary-save-article-folder).

O v

Save the current article in a VM folder (gnus-summary-save-article-vm).

O p

Save the current article in a pipe. Uhm, like, what I mean is---Pipe the current article to a process (gnus-summary-pipe-output).

All these commands use the process/prefix convention (see Process/Prefix). If you save bunches of articles using these functions, you might get tired of being prompted for files to save each and every article in. The prompting action is controlled by the gnus-prompt-before-saving variable, which is always by default, giving you that excessive prompting action you know and loathe. If you set this variable to t instead, you'll be prompted just once for each series of articles you save. If you like to really have Gnus do all your thinking for you, you can even set this variable to nil, which means that you will never be prompted for files to save articles in. Gnus will simply save all the articles in the default files.

You can customize the gnus-default-article-saver variable to make Gnus do what you want it to. You can use any of the four ready-made functions below, or you can create your own.

gnus-summary-save-in-rmail

This is the default format, babyl. Uses the function in the gnus-rmail-save-name variable to get a file name to save the article in. The default is gnus-plain-save-name.

gnus-summary-save-in-mail

Save in a Unix mail (mbox) file. Uses the function in the gnus-mail-save-name variable to get a file name to save the article in. The default is gnus-plain-save-name.

gnus-summary-save-in-file

Append the article straight to an ordinary file. Uses the function in the gnus-file-save-name variable to get a file name to save the article in. The default is gnus-numeric-save-name.

gnus-summary-save-body-in-file

Append the article body to an ordinary file. Uses the function in the gnus-file-save-name variable to get a file name to save the article in. The default is gnus-numeric-save-name.

gnus-summary-save-in-folder

Save the article to an MH folder using rcvstore from the MH library. Uses the function in the gnus-folder-save-name variable to get a file name to save the article in. The default is gnus-folder-save-name, but you can also use gnus-Folder-save-name, which creates capitalized names.

gnus-summary-save-in-vm

Save the article in a VM folder. You have to have the VM mail reader to use this setting.

All of these functions, except for the last one, will save the article in the gnus-article-save-directory, which is initialized from the SAVEDIR environment variable. This is `~/News/' by default.

As you can see above, the functions use different functions to find a suitable name of a file to save the article in. Below is a list of available functions that generate names:

gnus-Numeric-save-name

File names like `~/News/Alt.andrea-dworkin/45'.

gnus-numeric-save-name

File names like `~/News/alt.andrea-dworkin/45'.

gnus-Plain-save-name

File names like `~/News/Alt.andrea-dworkin'.

gnus-plain-save-name

File names like `~/News/alt.andrea-dworkin'.

You can have Gnus suggest where to save articles by plonking a regexp into the gnus-split-methods alist. For instance, if you would like to save articles related to Gnus in the file `gnus-stuff', and articles related to VM in vm-stuff, you could set this variable to something like:

(("^Subject:.*gnus\\|^Newsgroups:.*gnus" "gnus-stuff")
 ("^Subject:.*vm\\|^Xref:.*vm" "vm-stuff")
 (my-choosing-function "../other-dir/my-stuff")
 ((equal gnus-newsgroup-name "mail.misc") "mail-stuff"))

We see that this is a list where each element is a list that has two elements---the match and the file. The match can either be a string (in which case it is used as a regexp to match on the article head); it can be a symbol (which will be called as a function with the group name as a parameter); or it can be a list (which will be evaled). If any of these actions have a non-nil result, the file will be used as a default prompt. In addition, the result of the operation itself will be used if the function or form called returns a string or a list of strings.

You basically end up with a list of file names that might be used when saving the current article. (All ``matches'' will be used.) You will then be prompted for what you really want to use as a name, with file name completion over the results from applying this variable.

This variable is ((gnus-article-archive-name)) by default, which means that Gnus will look at the articles it saves for an Archive-name line and use that as a suggestion for the file name.

Here's an example function to clean up file names somewhat. If you have lots of mail groups called things like `nnml:mail.whatever', you may want to chop off the beginning of these group names before creating the file name to save to. The following will do just that:

(defun my-save-name (group)
  (when (string-match "^nnml:mail." group)
    (substring group (match-end 0))))

(setq gnus-split-methods
      '((gnus-article-archive-name)
        (my-save-name)))

Finally, you have the gnus-use-long-file-name variable. If it is nil, all the preceding functions will replace all periods (`.') in the group names with slashes (`/')---which means that the functions will generate hierarchies of directories instead of having all the files in the top level directory (`~/News/alt/andrea-dworkin' instead of `~/News/alt.andrea-dworkin'.) This variable is t by default on most systems. However, for historical reasons, this is nil on Xenix and usg-unix-v machines by default.

This function also affects kill and score file names. If this variable is a list, and the list contains the element not-score, long file names will not be used for score files, if it contains the element not-save, long file names will not be used for saving, and if it contains the element not-kill, long file names will not be used for kill files.

If you'd like to save articles in a hierarchy that looks something like a spool, you could

(setq gnus-use-long-file-name '(not-save)) ; to get a hierarchy
(setq gnus-default-article-saver 'gnus-summary-save-in-file) ; no encoding

Then just save with o. You'd then read this hierarchy with ephemeral nneething groups---G D in the group buffer, and the top level directory as the argument (`~/News/'). Then just walk around to the groups/directories with nneething.

PREVArticle Backlog UPThe Summary Buffer NEXTDecoding Articles