Sams Teach Yourself Emacs in 24 Hours

ContentsIndex

Hour 20: Gnus Basics

Previous HourNext Hour

Sections in this Hour:

 

Reading Mail and News


Now when you have set up Gnus for your personal account, it's time to start learning about Gnus. To start Gnus, press M-x and type either gnus or Gnus-no-server. The second method starts up Gnus without querying any of the news servers for news, but only the mail backends.

The first buffer you get to is the Group buffer. This buffer contains all the groups you are subscribed to. A subscribed group is one that Gnus should check for new messages in. The Group buffer can be seen in Figure 20.1. Each line represents a newsgroup or a mail folder. The first column indicates the number of unread messages in the given group. The second column states both the backend used and the name of the group. In most cases, however, you don't care about which backend is used for a given group. The lines that describe the groups can be customized as much as you want. Customization of the group line is described in the next hour.

Only groups containing new messages are listed. To see all subscribed groups (that is, those without new messages too), press L. To hide the groups without any messages, press l.

Note - Gnus works with groups on four different levels: subscribed groups, unsubscribed groups, killed groups, and zombie groups. The difference between unsubscribed groups and killed groups is that Gnus still remembers which messages you have read in unsubscribed groups, which isn't the case for killed groups. When you press L, you also see the unsubscribed groups. Zombie groups are discussed in the next section.

Subscribe or Unsubscribe to Groups

When you start Gnus for the first time, you are subscribed to a few newsgroups, but as you surely know, there are many more available. (My news sources have almost 40,000 newsgroups!) To see a complete list of newsgroups, simply type A A. This exchanges the content of the Group buffer with a list of all newsgroups. Fortunately, this list is sorted, so it should be easy to get to the hierarchies you are interested in. If you are searching for a specific group, you can use the normal search functions of Emacs to get to the group you are looking for. (See Hour 7, "Searching for Text in a Buffer" for a reference of all the ways to search for text in a buffer.)

When you have found a group that you want to subscribe to, press u to subscribe to it. As mentioned previously, u is a toggle, so pressing u once again unsubscribes you from the group.

To get back to the ordinary group overview press l or L, as described earlier.

When you are in the Group Overview buffer, you can unsubscribe from any group there by pressing u when point is located on the given group. Unsubscribing might, however, not be what you want to do, because Gnus still keeps some information about the group when it is unsubscribed (as mentioned previously). If you really think that you are finished with a given group and do not expect to read it for a long time, you should instead kill the group. Killing a group is done by pressing C-k when point is located on the line listing the group.

Tip - Killing a group is preferred to unsubscribing from it if you do not expect to read the group for a long time, because this makes Gnus start up much faster.


There also exists another way to subscribe to a group, which is to press U. This queries you in the minibuffer for the newsgroup to subscribe to.

Whenever Gnus starts up, it asks your servers for new groups that have come to existence since the last time you used Gnus. Any new group becomes a zombie. A zombie is a subscription level even lower than unsubscribed groups, but more alive than killed groups. You must explicitly subscribe to these zombie groups before they become part of your daily news repertoire (that is, you do not see them in the normal overview buffer). To see the list of zombie groups, press A z in the Group buffer. This takes you to a buffer from which you can subscribe to the zombie groups you want to read. When you have subscribed to the zombie groups of interest, you can delete the rest of them by pressing S z. This brings you back to your normal group overview.

Note - This also applies to mail groups read from directories, so if you use procmail to sort mail into several different files, and you have told Emacs to read these files from a directory, a new file in this directory does not show up in your Group buffer before you have subscribed to it from the zombie subscription buffer.


To ask Gnus to query the server for new messages in the groups, press g. This queries Gnus for new messages in all groups. If you want only to see whether there is any new email, press C-2 g. Finally if you want to search for new mail only in the current group, press M-g.

Reading the Articles

The previous section told you about subscribing and unsubscribing to groups, so finally it's time to learn how to read the actual messages. Pressing the Enter key on top of a group brings you to a Summary buffer, such as the one seen in Figure 20.2. From this Summary buffer you can get further on to the actual messages by pressing the Enter key on top of one of the messages, which splits the window in two and shows the message in one of the windows (refer to Figure 20.3).

If the text spans more than one window, you can switch to the window containing the message and use the normal movement commands to scroll through the text. An alternative is to stay in the Summary buffer, and use the Spacebar to scroll one page forward and the Delete key to scroll one page backward.

In the Summary buffer you can move up and down, as in any other buffer, but additional commands exist for traversing the threads. All these commands can be seen in the menu item called Threads.

As well as moving past a whole thread, you might also want to fold a thread, showing only the top of it. (This is equivalent to using outline mode, described in Hour 15, "Getting an Overview of a File"). Hiding all the threads in the Summary buffer is done by pressing T H. When you press Enter on top of on of the thread, the message at the top of the thread is shown, and the whole thread is once again shown. An example of folding all threads can be seen in Figure 20.7.

Figure 20.7
An ellipsis indicates that the thread has been folded.

Some people do not quote enough of a letter for you to understand the answer they give. In these situations it might be useful to see the message they answer to or comment on. The whole thread can't, however, be shown at a given time, due to the fact that you already might have read some of the messages earlier in the thread. By pressing ^ (that is, the caret) in the Summary buffer, you ask Gnus to query the server for the message previous message in the thread.

If the group contains any unread messages or any ticked messages (ticked messages are described in the next section), only the unread and ticked messages are shown in the Summary buffer when you enter it. To see all the messages, you must press C-u before you press the Enter key to enter the group (from the Group buffer). If on the other hand, the group has neither any unread articles nor any ticked ones, all the read articles in the group are shown when you enter the Summary buffer.

If you are located in the summary buffer, you can ask Gnus to query the server for new messages (and hide the ones you already have read) by pressing g. Likewise, you can ask Gnus to search for new messages and list all articles at the same time by pressing M-g.

Expiring Messages

Though it would be nice to keep messages infinitely, it seldom is possible. Both newsgroups and your own incoming mailing lists need to be trimmed once in a while. The expiration is done based on the age of the messages. That is, messages can be deleted when they are older than a day or when they are older than 100 years (that depends solely on the news server or, in case of mail, on the mail group). There is nothing you can do about the expiring process at the news server, but you are responsible for configuring the expiring process for your own mail groups.

Starting with newsgroups, as stated previously, there is nothing you can change about the expiring process for them. You might, however, once in a while see a message that you find valuable, and thus want to keep beyond the lifetime of the article in the news server. What you do in these cases is simply to press the asterisk key (*) on top of the article. This copies the message to your local hard disk and keeps it there until you press M-*, which tells Gnus to delete it from your local disk again. Articles marked with an asterisk are not shown when you enter the Summary buffer, unless you press C-u before pressing Enter to enter it. Later I get back to what it means to press the asterisk in a mail group.

Gnus treats mail messages like news articles in the interface. That is, when you have read a message, Gnus marks this message as read, but it does not delete it from disk immediately; instead it expires the message later. Surprised? Well that is the way it works with news, right?

In fact, in the default setup of Gnus, mail is never deleted, unless you explicitly tell Gnus to do so.

To tell Gnus to delete a message, you must press E on top of the message. This tells Gnus that this message should be expired. When you leave the group, Gnus deletes all messages marked for expiring, if and only if they are older than a specified age (the default age is seven days).

Autoexpiring

It might be quite annoying to tell Gnus to mark messages as expirable for each message you have read; thus, it is possible to tell Gnus that messages should be marked as expirable instead of read whenever you have read a message or whenever you tell Gnus to catch up with the group (catching up is discussed shortly). This featured is called autoexpiring. Autoexpiring can be enabled based on the name of the group. This is done by forming a regular expression that matches the groups which you want autoexpiring enabled for. To enable autoexpiring for the groups junk-mail and dotfile-mailing-list, insert the following into your .Gnus file:


(setq gnus-auto-expirable-newsgroups  
     "junk-mail\\|dotfile-mailing-list")  

To enable autoexpiring for all your mail groups instead, insert the following into your .Gnus file:


(setq gnus-auto-expirable-newsgroups "")

This is a regular expression that matches any group name.

Note - Though the name of the variable included the name newsgroups, this does only make sense for mail groups; you still don't have any control over when messages are expired on the news server.

Expiring Period

Whenever you leave a mail group, Gnus expires all messages marked for expiring that are older than a given age. This age can be set for all groups by setting the variable gnus-expiry-wait. Its value can be a number that states the number of days; the word immediate, which means that the messages should be expired as soon as possible (when the mail group is left); or the word never, which means that expiring should never be done. To tell Gnus to wait 31 days before expiring a message, insert the following into your .Gnus file:


(setq gnus-expiry-wait 31)

To tell Gnus to do expiring at once, insert the following into your .Gnus file:


(setq gnus-expiry-wait 'immediate)

You might, however, be in a situation where you want Gnus to expire mail at once in some groups, wait for a month in others, and finally never do expiring in a third set of groups. This can be achieved by setting the variable Gnus-expiry-wait-function to a function that determines the value based on the name of the group. The following is an example of such a function:


01: (setq nnmail-expiry-wait-function  
02:       (lambda (group)  
03:         (cond ((string= group "mail.private")  
04:                31)  
05:               ((string= group "mail.junk")  
06:                'immediate)  
07:               ((string= group "important")  
08:                'never)  
09:               (t  
10:                6))))  

Mail in the group mail.private in line 3 should expire after 31 days, which is listed in line 4. Mail in the group mail.junk shown in line 5 should expire immediately (notice line 6). As shown in lines 7 and 8, mail in the group important should never expire. Finally, mail in any other group should expire after 6 days, which you can see in line 10.

You should be able to customize this without knowing much about Lisp. Be careful with the parentheses!

Deleting Mail at Once

In a few situations you might really want to get rid of a letter at once instead of waiting for it to expire. This might, for example, be the case if someone sends you a letter containing a 5MB attachment and your account doesn't allow you to have more than 5MB on your disk.

To delete the letter for good, press B DEL (that is, a capital b and the delete key). Emacs asks you with a yes/no question whether you really intend to delete the letter forever. In case you want to delete many letters, you can mark each letter by pressing # (that is, the pound sign or hash mark) on each letter, and then pressing B DEL. (This method is discussed in detail in the next hour.)

Using Marks in the Summary Buffer

A few different marks exist, with which you can change the status of a message. You have already seen the asterisk, which is used to copy an article from the news server to a local directory. Table 20.2 shows a list of the most important marks, their indication in the Summary buffer, and how to set them. The indication is shown in the first column of the Summary buffer.

Table 20.2  Article Marks and Their Indication in the Summary Buffer

Indication

Key Used to Set the Mark

Description of the Mark

!

!

The exclamation mark is used to tick an article. Ticked articles are shown together with unread articles, when ever you enter the summary buffer. Ticked articles are not expired in mail folders, but they are expired in news groups. To keep an article in a newsgroup, use the asterisk. Both the asterisk and the exclamation mark can be used at the same time.

*

*

The asterisk is used to make an article unexpirable as described in the beginning of this section. Articles marked with an asterisk are not shown when you enter the summary buffer. For newsgroups, it might be a good idea to use both the asterisk and the exclamation mark to make an article visible all the time, and unexpirable. In mail groups on the other hand, the asterisk is not necessary to make the article unexpirable (when the exclamation mark is used). In mail groups it might, on the other hand, be used to save articles that you do not want to see every time you enter the Summary buffer, but that you do not want to expire.

?

?

The question mark is like the exclamation mark, with the exception that the message is shown only when an unread successor exists. This is often used when you post an article on a newsgroup. In these cases, your message shows up whenever someone answers it or comments on a article that stems from your article.

E

E

Pressing E makes the article expirable. This is useful only if you do not use autoexpire.

R


An article is marked with a uppercase R whenever it is read, but not marked as expirable. (Remember: only mail messages can be marked as expirable.)

r

d

A lowercase r indicates that the article has not been read, but it has been marked as such (this can also happen when you catch up a group).


A few additional marks exist that are seen more seldom and are beyond the scope of this book. To erase all the marks for a message press M-u. This marks the article as unread (which is indicated by the absence of a mark).

Catching Up

When reading newsgroups or mailing lists (but not your incoming mail!) you might want to skip the rest of the messages in the group. This is called catching up with the group . Pressing c in the summary buffer or the group buffer catches up with the group by marking any unread messages as read. Two other very useful combinations for catching up with a group also exist only in the Summary buffer. These are M H, which catches up with all the messages before the one you are currently located at, and C-w, which catches up with all the messages between point and mark. The first of these (M H) is useful if you skim the subject of the messages, have to leave the group in the middle, and want to mark the messages you have skimmed so far as read.

Sams Teach Yourself Emacs in 24 Hours

ContentsIndex

Hour 20: Gnus Basics

Previous HourNext Hour

Sections in this Hour: