]> code.delx.au - gnu-emacs/blob - doc/emacs/rmail.texi
d05af468fa17c01658de3b043f7d4ad277903aeb
[gnu-emacs] / doc / emacs / rmail.texi
1 @c This is part of the Emacs manual.
2 @c Copyright (C) 1985-1987, 1993-1995, 1997, 2001-2011
3 @c Free Software Foundation, Inc.
4 @c See file emacs.texi for copying conditions.
5 @node Rmail
6 @chapter Reading Mail with Rmail
7 @cindex Rmail
8 @cindex reading mail
9 @findex rmail
10 @findex rmail-mode
11 @vindex rmail-mode-hook
12
13 Rmail is an Emacs subsystem for reading and disposing of mail that
14 you receive. Rmail stores mail messages in files called Rmail files.
15 Reading the messages in an Rmail file is done in a special major mode,
16 Rmail mode, which redefines most letters to run commands for managing mail.
17 @menu
18 * Basic: Rmail Basics. Basic concepts of Rmail, and simple use.
19 * Scroll: Rmail Scrolling. Scrolling through a message.
20 * Motion: Rmail Motion. Moving to another message.
21 * Deletion: Rmail Deletion. Deleting and expunging messages.
22 * Inbox: Rmail Inbox. How mail gets into the Rmail file.
23 * Files: Rmail Files. Using multiple Rmail files.
24 * Output: Rmail Output. Copying messages out to files.
25 * Labels: Rmail Labels. Classifying messages by labeling them.
26 * Attrs: Rmail Attributes. Certain standard labels, called attributes.
27 * Reply: Rmail Reply. Sending replies to messages you are viewing.
28 * Summary: Rmail Summary. Summaries show brief info on many messages.
29 * Sort: Rmail Sorting. Sorting messages in Rmail.
30 * Display: Rmail Display. How Rmail displays a message; customization.
31 * Coding: Rmail Coding. How Rmail handles decoding character sets.
32 * Editing: Rmail Editing. Editing message text and headers in Rmail.
33 * Digest: Rmail Digest. Extracting the messages from a digest message.
34 * Rot13: Rmail Rot13. Reading messages encoded in the rot13 code.
35 * Movemail:: More details of fetching new mail.
36 * Remote Mailboxes:: Retrieving mail from remote mailboxes.
37 * Other Mailbox Formats:: Retrieving mail from local mailboxes in
38 various formats.
39 @end menu
40
41 @node Rmail Basics
42 @section Basic Concepts of Rmail
43
44 @cindex primary Rmail file
45 @vindex rmail-file-name
46 Using Rmail in the simplest fashion, you have one Rmail file
47 @file{~/RMAIL} in which all of your mail is saved. It is called your
48 @dfn{primary Rmail file}. The command @kbd{M-x rmail} reads your primary
49 Rmail file, merges new mail in from your inboxes, displays the first
50 message you haven't read yet, and lets you begin reading. The variable
51 @code{rmail-file-name} specifies the name of the primary Rmail file.
52
53 Rmail displays only one message in the Rmail file at a time.
54 The message that is shown is called the @dfn{current message}. Rmail
55 mode's special commands can do such things as delete the current
56 message, copy it into another file, send a reply, or move to another
57 message. You can also create multiple Rmail files and use Rmail to move
58 messages between them.
59
60 @cindex message number
61 Within the Rmail file, messages are normally arranged sequentially in
62 order of receipt; you can specify other ways to sort them (@pxref{Rmail
63 Sorting}). Messages are identified by consecutive integers which are
64 their @dfn{message numbers}. The number of the current message is
65 displayed in Rmail's mode line, followed by the total number of messages
66 in the file. You can move to a message by specifying its message number
67 with the @kbd{j} key (@pxref{Rmail Motion}).
68
69 @kindex s @r{(Rmail)}
70 @findex rmail-expunge-and-save
71 Following the usual conventions of Emacs, changes in an Rmail file
72 become permanent only when you save the file. You can save it with
73 @kbd{s} (@code{rmail-expunge-and-save}), which also expunges deleted
74 messages from the file first (@pxref{Rmail Deletion}). To save the
75 file without expunging, use @kbd{C-x C-s}. Rmail also saves the Rmail
76 file after merging new mail from an inbox file (@pxref{Rmail Inbox}).
77
78 @kindex q @r{(Rmail)}
79 @findex rmail-quit
80 @kindex b @r{(Rmail)}
81 @findex rmail-bury
82 You can exit Rmail with @kbd{q} (@code{rmail-quit}); this expunges
83 and saves the Rmail file, then buries the Rmail buffer as well as its
84 summary buffer, if present (@pxref{Rmail Summary}). But there is no
85 need to ``exit'' formally. If you switch from Rmail to editing in
86 other buffers, and never switch back, you have exited. Just make sure
87 to save the Rmail file eventually (like any other file you have
88 changed). @kbd{C-x s} is a suitable way to do this (@pxref{Save
89 Commands}). The Rmail command @kbd{b}, @code{rmail-bury}, buries the
90 Rmail buffer and its summary buffer without expunging and saving the
91 Rmail file.
92
93 @node Rmail Scrolling
94 @section Scrolling Within a Message
95
96 When Rmail displays a message that does not fit on the screen, you
97 must scroll through it to read the rest. You could do this with
98 @kbd{C-v}, @kbd{M-v} and @kbd{M-<}, but in Rmail scrolling is so
99 frequent that it deserves to be easier.
100
101 @table @kbd
102 @item @key{SPC}
103 Scroll forward (@code{scroll-up-command}).
104 @item @key{DEL}
105 Scroll backward (@code{scroll-down-command}).
106 @item .
107 Scroll to start of message (@code{rmail-beginning-of-message}).
108 @item /
109 Scroll to end of message (@code{rmail-end-of-message}).
110 @end table
111
112 @kindex SPC @r{(Rmail)}
113 @kindex DEL @r{(Rmail)}
114 Since the most common thing to do while reading a message is to
115 scroll through it by screenfuls, Rmail makes @key{SPC} and @key{DEL}
116 do the same as @kbd{C-v} (@code{scroll-up-command}) and @kbd{M-v}
117 (@code{scroll-down-command}) respectively.
118
119 @kindex . @r{(Rmail)}
120 @kindex / @r{(Rmail)}
121 @findex rmail-beginning-of-message
122 @findex rmail-end-of-message
123 The command @kbd{.} (@code{rmail-beginning-of-message}) scrolls back to the
124 beginning of the selected message. This is not quite the same as @kbd{M-<}:
125 for one thing, it does not set the mark; for another, it resets the buffer
126 boundaries of the current message if you have changed them. Similarly,
127 the command @kbd{/} (@code{rmail-end-of-message}) scrolls forward to the end
128 of the selected message.
129 @c The comment about buffer boundaries is still true in mbox Rmail, if
130 @c less likely to be relevant.
131
132 @node Rmail Motion
133 @section Moving Among Messages
134
135 The most basic thing to do with a message is to read it. The way to
136 do this in Rmail is to make the message current. The usual practice is
137 to move sequentially through the file, since this is the order of
138 receipt of messages. When you enter Rmail, you are positioned at the
139 first message that you have not yet made current (that is, the first one
140 that has the @samp{unseen} attribute; @pxref{Rmail Attributes}). Move
141 forward to see the other new messages; move backward to re-examine old
142 messages.
143
144 @table @kbd
145 @item n
146 Move to the next nondeleted message, skipping any intervening deleted
147 messages (@code{rmail-next-undeleted-message}).
148 @item p
149 Move to the previous nondeleted message
150 (@code{rmail-previous-undeleted-message}).
151 @item M-n
152 Move to the next message, including deleted messages
153 (@code{rmail-next-message}).
154 @item M-p
155 Move to the previous message, including deleted messages
156 (@code{rmail-previous-message}).
157 @item C-c C-n
158 Move to the next message with the same subject as the current one
159 (@code{rmail-next-same-subject}).
160 @item C-c C-p
161 Move to the previous message with the same subject as the current one
162 (@code{rmail-previous-same-subject}).
163 @item j
164 Move to the first message. With argument @var{n}, move to
165 message number @var{n} (@code{rmail-show-message}).
166 @item >
167 Move to the last message (@code{rmail-last-message}).
168 @item <
169 Move to the first message (@code{rmail-first-message}).
170
171 @item M-s @var{regexp} @key{RET}
172 Move to the next message containing a match for @var{regexp}
173 (@code{rmail-search}).
174
175 @item - M-s @var{regexp} @key{RET}
176 Move to the previous message containing a match for @var{regexp}.
177 @end table
178
179 @kindex n @r{(Rmail)}
180 @kindex p @r{(Rmail)}
181 @kindex M-n @r{(Rmail)}
182 @kindex M-p @r{(Rmail)}
183 @findex rmail-next-undeleted-message
184 @findex rmail-previous-undeleted-message
185 @findex rmail-next-message
186 @findex rmail-previous-message
187 @kbd{n} and @kbd{p} are the usual way of moving among messages in
188 Rmail. They move through the messages sequentially, but skip over
189 deleted messages, which is usually what you want to do. Their command
190 definitions are named @code{rmail-next-undeleted-message} and
191 @code{rmail-previous-undeleted-message}. If you do not want to skip
192 deleted messages---for example, if you want to move to a message to
193 undelete it---use the variants @kbd{M-n} and @kbd{M-p}
194 (@code{rmail-next-message} and @code{rmail-previous-message}). A
195 numeric argument to any of these commands serves as a repeat
196 count.
197
198 In Rmail, you can specify a numeric argument by typing just the
199 digits. You don't need to type @kbd{C-u} first.
200
201 @kindex M-s @r{(Rmail)}
202 @findex rmail-search
203 @cindex searching in Rmail
204 The @kbd{M-s} (@code{rmail-search}) command is Rmail's version of
205 search. The usual incremental search command @kbd{C-s} works in Rmail,
206 but it searches only within the current message. The purpose of
207 @kbd{M-s} is to search for another message. It reads a regular
208 expression (@pxref{Regexps}) nonincrementally, then searches starting at
209 the beginning of the following message for a match. It then selects
210 that message. If @var{regexp} is empty, @kbd{M-s} reuses the regexp
211 used the previous time.
212
213 To search backward in the file for another message, give @kbd{M-s} a
214 negative argument. In Rmail you can do this with @kbd{- M-s}. This
215 begins searching from the end of the previous message.
216
217 It is also possible to search for a message based on labels.
218 @xref{Rmail Labels}.
219
220 @kindex C-c C-n @r{(Rmail)}
221 @kindex C-c C-p @r{(Rmail)}
222 @findex rmail-next-same-subject
223 @findex rmail-previous-same-subject
224 The @kbd{C-c C-n} (@code{rmail-next-same-subject}) command moves to
225 the next message with the same subject as the current one. A prefix
226 argument serves as a repeat count. With a negative argument, this
227 command moves backward, acting like @kbd{C-c C-p}
228 (@code{rmail-previous-same-subject}). When comparing subjects, these
229 commands ignore the prefixes typically added to the subjects of replies.
230
231 @kindex j @r{(Rmail)}
232 @kindex > @r{(Rmail)}
233 @kindex < @r{(Rmail)}
234 @findex rmail-show-message
235 @findex rmail-last-message
236 @findex rmail-first-message
237 To move to a message specified by absolute message number, use @kbd{j}
238 (@code{rmail-show-message}) with the message number as argument. With
239 no argument, @kbd{j} selects the first message. @kbd{<}
240 (@code{rmail-first-message}) also selects the first message. @kbd{>}
241 (@code{rmail-last-message}) selects the last message.
242
243 @node Rmail Deletion
244 @section Deleting Messages
245
246 @cindex deletion (Rmail)
247 When you no longer need to keep a message, you can @dfn{delete} it. This
248 flags it as ignorable, and some Rmail commands pretend it is no longer
249 present; but it still has its place in the Rmail file, and still has its
250 message number.
251
252 @cindex expunging (Rmail)
253 @dfn{Expunging} the Rmail file actually removes the deleted messages.
254 The remaining messages are renumbered consecutively.
255 @c The following is neither true (there is also unforward, sorting,
256 @c etc), nor especially interesting.
257 @c Expunging is the only action that changes the message number of any
258 @c message, except for undigestifying (@pxref{Rmail Digest}).
259
260 @table @kbd
261 @item d
262 Delete the current message, and move to the next nondeleted message
263 (@code{rmail-delete-forward}).
264 @item C-d
265 Delete the current message, and move to the previous nondeleted
266 message (@code{rmail-delete-backward}).
267 @item u
268 Undelete the current message, or move back to the previous deleted
269 message and undelete it (@code{rmail-undelete-previous-message}).
270 @item x
271 Expunge the Rmail file (@code{rmail-expunge}).
272 @end table
273
274 @kindex d @r{(Rmail)}
275 @kindex C-d @r{(Rmail)}
276 @findex rmail-delete-forward
277 @findex rmail-delete-backward
278 There are two Rmail commands for deleting messages. Both delete the
279 current message and select another message. @kbd{d}
280 (@code{rmail-delete-forward}) moves to the following message, skipping
281 messages already deleted, while @kbd{C-d} (@code{rmail-delete-backward})
282 moves to the previous nondeleted message. If there is no nondeleted
283 message to move to in the specified direction, the message that was just
284 deleted remains current. @kbd{d} with a prefix argument is equivalent
285 to @kbd{C-d}. Note that the Rmail summary versions of these commands
286 behave slightly differently (@pxref{Rmail Summary Edit}).
287
288 @c mention other hooks, eg show message hook?
289 @vindex rmail-delete-message-hook
290 Whenever Rmail deletes a message, it runs the hook
291 @code{rmail-delete-message-hook}. When the hook functions are invoked,
292 the message has been marked deleted, but it is still the current message
293 in the Rmail buffer.
294
295 @cindex undeletion (Rmail)
296 @kindex x @r{(Rmail)}
297 @findex rmail-expunge
298 @kindex u @r{(Rmail)}
299 @findex rmail-undelete-previous-message
300 To make all the deleted messages finally vanish from the Rmail file,
301 type @kbd{x} (@code{rmail-expunge}). Until you do this, you can still
302 @dfn{undelete} the deleted messages. The undeletion command, @kbd{u}
303 (@code{rmail-undelete-previous-message}), is designed to cancel the
304 effect of a @kbd{d} command in most cases. It undeletes the current
305 message if the current message is deleted. Otherwise it moves backward
306 to previous messages until a deleted message is found, and undeletes
307 that message.
308
309 You can usually undo a @kbd{d} with a @kbd{u} because the @kbd{u}
310 moves back to and undeletes the message that the @kbd{d} deleted. But
311 this does not work when the @kbd{d} skips a few already-deleted messages
312 that follow the message being deleted; then the @kbd{u} command
313 undeletes the last of the messages that were skipped. There is no clean
314 way to avoid this problem. However, by repeating the @kbd{u} command,
315 you can eventually get back to the message that you intend to
316 undelete. You can also select a particular deleted message with
317 the @kbd{M-p} command, then type @kbd{u} to undelete it.
318
319 A deleted message has the @samp{deleted} attribute, and as a result
320 @samp{deleted} appears in the mode line when the current message is
321 deleted. In fact, deleting or undeleting a message is nothing more than
322 adding or removing this attribute. @xref{Rmail Attributes}.
323
324 @node Rmail Inbox
325 @section Rmail Files and Inboxes
326 @cindex inbox file
327
328 When you receive mail locally, the operating system places incoming
329 mail for you in a file that we call your @dfn{inbox}. When you start
330 up Rmail, it runs a C program called @code{movemail} to copy the new
331 messages from your local inbox into your primary Rmail file, which
332 also contains other messages saved from previous Rmail sessions. It
333 is in this file that you actually read the mail with Rmail. This
334 operation is called @dfn{getting new mail}. You can get new mail at
335 any time in Rmail by typing @kbd{g}.
336
337 @vindex rmail-primary-inbox-list
338 @cindex @env{MAIL} environment variable
339 The variable @code{rmail-primary-inbox-list} contains a list of the
340 files which are inboxes for your primary Rmail file. If you don't set
341 this variable explicitly, Rmail uses the @env{MAIL} environment
342 variable, or, as a last resort, a default inbox based on
343 @code{rmail-spool-directory}. The default inbox file depends on your
344 operating system; often it is @file{/var/mail/@var{username}},
345 @file{/var/spool/mail/@var{username}}, or
346 @file{/usr/spool/mail/@var{username}}.
347
348 You can specify the inbox file(s) for any Rmail file for the current
349 session with the command @code{set-rmail-inbox-list}; see @ref{Rmail
350 Files}.
351
352 There are two reasons for having separate Rmail files and inboxes.
353
354 @enumerate
355 @item
356 The inbox file format varies between operating systems and according to
357 the other mail software in use. Only one part of Rmail needs to know
358 about the alternatives, and it need only understand how to convert all
359 of them to Rmail's own format.
360
361 @item
362 It is very cumbersome to access an inbox file without danger of losing
363 mail, because it is necessary to interlock with mail delivery.
364 Moreover, different operating systems use different interlocking
365 techniques. The strategy of moving mail out of the inbox once and for
366 all into a separate Rmail file avoids the need for interlocking in all
367 the rest of Rmail, since only Rmail operates on the Rmail file.
368 @end enumerate
369
370 Rmail was originally written to use the Babyl format as its internal
371 format. Since then, we have recognized that the usual inbox format
372 (@samp{mbox}) on Unix and GNU systems is adequate for the job, and so
373 since Emacs 23 Rmail uses that as its internal format. The Rmail file
374 is still separate from the inbox file, even though their format is the
375 same.
376
377 @vindex rmail-preserve-inbox
378 When getting new mail, Rmail first copies the new mail from the
379 inbox file to the Rmail file; then it saves the Rmail file; then it
380 clears out the inbox file. This way, a system crash may cause
381 duplication of mail between the inbox and the Rmail file, but cannot
382 lose mail. If @code{rmail-preserve-inbox} is non-@code{nil}, then
383 Rmail does not clear out the inbox file when it gets new mail. You
384 may wish to set this, for example, on a portable computer you use to
385 check your mail via POP while traveling, so that your mail will remain
386 on the server and you can save it later on your workstation.
387
388 In some cases, Rmail copies the new mail from the inbox file
389 indirectly. First it runs the @code{movemail} program to move the mail
390 from the inbox to an intermediate file called
391 @file{.newmail-@var{inboxname}}, in the same directory as the Rmail
392 file. Then Rmail merges the new mail from that file, saves the Rmail
393 file, and only then deletes the intermediate file. If there is a crash
394 at the wrong time, this file continues to exist, and Rmail will use it
395 again the next time it gets new mail from that inbox.
396
397 If Rmail is unable to convert the data in
398 @file{.newmail-@var{inboxname}} into mbox format, it renames the file to
399 @file{RMAILOSE.@var{n}} (@var{n} is an integer chosen to make the name
400 unique) so that Rmail will not have trouble with the data again. You
401 should look at the file, find whatever message confuses Rmail (probably
402 one that includes the control-underscore character, octal code 037), and
403 delete it. Then you can use @kbd{1 g} to get new mail from the
404 corrected file.
405
406 @node Rmail Files
407 @section Multiple Rmail Files
408
409 Rmail operates by default on your @dfn{primary Rmail file}, which is named
410 @file{~/RMAIL} and receives your incoming mail from your system inbox file.
411 But you can also have other Rmail files and edit them with Rmail. These
412 files can receive mail through their own inboxes, or you can move messages
413 into them with explicit Rmail commands (@pxref{Rmail Output}).
414
415 @table @kbd
416 @item i @var{file} @key{RET}
417 Read @var{file} into Emacs and run Rmail on it (@code{rmail-input}).
418
419 @item M-x set-rmail-inbox-list @key{RET} @var{files} @key{RET}
420 Specify inbox file names for current Rmail file to get mail from.
421
422 @item g
423 Merge new mail from current Rmail file's inboxes
424 (@code{rmail-get-new-mail}).
425
426 @item C-u g @var{file} @key{RET}
427 Merge new mail from inbox file @var{file}.
428 @end table
429
430 @kindex i @r{(Rmail)}
431 @findex rmail-input
432 To run Rmail on a file other than your primary Rmail file, you can use
433 the @kbd{i} (@code{rmail-input}) command in Rmail. This visits the file
434 in Rmail mode. You can use @kbd{M-x rmail-input} even when not in
435 Rmail, but it is easier to type @kbd{C-u M-x rmail}, which does the
436 same thing.
437
438 The file you read with @kbd{i} should normally be a valid mbox file.
439 If it is not, Rmail tries to convert its text to mbox format, and
440 visits the converted text in the buffer. If you save the buffer, that
441 converts the file.
442
443 If you specify a file name that doesn't exist, @kbd{i} initializes a
444 new buffer for creating a new Rmail file.
445
446 @vindex rmail-secondary-file-directory
447 @vindex rmail-secondary-file-regexp
448 You can also select an Rmail file from a menu. In the Classify menu,
449 choose the Input Rmail File item; then choose the Rmail file you want.
450 The variables @code{rmail-secondary-file-directory} and
451 @code{rmail-secondary-file-regexp} specify which files to offer in the
452 menu: the first variable says which directory to find them in; the
453 second says which files in that directory to offer (all those that match
454 the regular expression). If no files match, you cannot select this menu
455 item. These variables also apply to choosing a file for output
456 (@pxref{Rmail Output}).
457
458 @ignore
459 @findex set-rmail-inbox-list
460 Each Rmail file can contain a list of inbox file names; you can specify
461 this list with @kbd{M-x set-rmail-inbox-list @key{RET} @var{files}
462 @key{RET}}. The argument can contain any number of file names, separated
463 by commas. It can also be empty, which specifies that this file should
464 have no inboxes. Once you specify a list of inboxes in an Rmail file,
465 the Rmail file remembers it permanently until you specify a different list.
466 @end ignore
467
468 @vindex rmail-inbox-list
469 The inbox files to use are specified by the variable
470 @code{rmail-inbox-list}, which is buffer-local in Rmail mode. As a
471 special exception, if you have specified no inbox files for your primary
472 Rmail file, it uses the @env{MAIL} environment variable, or your
473 standard system inbox.
474
475 @kindex g @r{(Rmail)}
476 @findex rmail-get-new-mail
477 The @kbd{g} command (@code{rmail-get-new-mail}) merges mail into the
478 current Rmail file from its inboxes. If the Rmail file has no
479 inboxes, @kbd{g} does nothing. The command @kbd{M-x rmail} also
480 merges new mail into your primary Rmail file.
481
482 To merge mail from a file that is not the usual inbox, give the
483 @kbd{g} key a numeric argument, as in @kbd{C-u g}. Then it reads a file
484 name and merges mail from that file. The inbox file is not deleted or
485 changed in any way when @kbd{g} with an argument is used. This is,
486 therefore, a general way of merging one file of messages into another.
487
488 @node Rmail Output
489 @section Copying Messages Out to Files
490
491 These commands copy messages from an Rmail file into another file.
492
493 @table @kbd
494 @item o @var{file} @key{RET}
495 Append a full copy of the current message to the file @var{file}
496 (@code{rmail-output}).
497
498 @item C-o @var{file} @key{RET}
499 Append a copy of the current message, as displayed, to the file
500 @var{file} (@code{rmail-output-as-seen}).
501
502 @item w @var{file} @key{RET}
503 Output just the message body to the file @var{file}, taking the default
504 file name from the message @samp{Subject} header.
505 @end table
506
507 @kindex o @r{(Rmail)}
508 @findex rmail-output-as-seen
509 @kindex C-o @r{(Rmail)}
510 @findex rmail-output
511 The commands @kbd{o} and @kbd{C-o} copy the current message into a
512 specified file, adding it at the end. The two commands differ mainly
513 in how much to copy: @kbd{o} copies the full message headers, even if
514 they are not all visible, while @kbd{C-o} copies exactly the headers
515 currently displayed and no more. @xref{Rmail Display}. In addition,
516 @kbd{o} converts the message to Babyl format (used by Rmail in Emacs
517 version 22 and before) if the file is in Babyl format; @kbd{C-o}
518 cannot output to Babyl files at all.
519
520 If the output file is currently visited in an Emacs buffer, the
521 output commands append the message to that buffer. It is up to you to
522 save the buffer eventually in its file.
523
524 @kindex w @r{(Rmail)}
525 @findex rmail-output-body-to-file
526 Sometimes you may receive a message whose body holds the contents of a
527 file. You can save the body to a file (excluding the message header)
528 with the @kbd{w} command (@code{rmail-output-body-to-file}). Often
529 these messages contain the intended file name in the @samp{Subject}
530 field, so the @kbd{w} command uses the @samp{Subject} field as the
531 default for the output file name. However, the file name is read using
532 the minibuffer, so you can specify a different name if you wish.
533
534 You can also output a message to an Rmail file chosen with a menu.
535 In the Classify menu, choose the Output Rmail File menu item; then
536 choose the Rmail file you want. This outputs the current message to
537 that file, like the @kbd{o} command. The variables
538 @code{rmail-secondary-file-directory} and
539 @code{rmail-secondary-file-regexp} specify which files to offer in the
540 menu: the first variable says which directory to find them in; the
541 second says which files in that directory to offer (all those that
542 match the regular expression). If no files match, you cannot select
543 this menu item.
544
545 @vindex rmail-delete-after-output
546 Copying a message with @kbd{o} or @kbd{C-o} gives the original copy
547 of the message the @samp{filed} attribute, so that @samp{filed}
548 appears in the mode line when such a message is current.
549
550 If you like to keep just a single copy of every mail message, set
551 the variable @code{rmail-delete-after-output} to @code{t}; then the
552 @kbd{o}, @kbd{C-o} and @kbd{w} commands delete the original message
553 after copying it. (You can undelete it afterward if you wish.)
554
555 @vindex rmail-output-file-alist
556 The variable @code{rmail-output-file-alist} lets you specify
557 intelligent defaults for the output file, based on the contents of the
558 current message. The value should be a list whose elements have this
559 form:
560
561 @example
562 (@var{regexp} . @var{name-exp})
563 @end example
564
565 @noindent
566 If there's a match for @var{regexp} in the current message, then the
567 default file name for output is @var{name-exp}. If multiple elements
568 match the message, the first matching element decides the default file
569 name. The subexpression @var{name-exp} may be a string constant giving
570 the file name to use, or more generally it may be any Lisp expression
571 that returns a file name as a string. @code{rmail-output-file-alist}
572 applies to both @kbd{o} and @kbd{C-o}.
573
574 @vindex rmail-automatic-folder-directives
575 Rmail can automatically save messages from your primary Rmail file
576 (the one that @code{rmail-file-name} specifies) to other files, based
577 on the value of the variable @code{rmail-automatic-folder-directives}.
578 This variable is a list of elements (@samp{directives}) that say which
579 messages to save where. Each directive is a list consisting of an
580 output file, followed by one or more pairs of a header name and a regular
581 expression. If a message has a header matching the specified regular
582 expression, that message is saved to the given file. If the directive
583 has more than one header entry, all must match. Rmail checks directives
584 when it shows a message from the file @code{rmail-file-name}, and
585 applies the first that matches (if any). If the output file is
586 @code{nil}, the message is deleted, not saved. For example, you can use
587 this feature to save messages from a particular address, or with a
588 particular subject, to a dedicated file.
589
590 @node Rmail Labels
591 @section Labels
592 @cindex label (Rmail)
593 @cindex attribute (Rmail)
594
595 Each message can have various @dfn{labels} assigned to it as a means
596 of classification. Each label has a name; different names are different
597 labels. Any given label is either present or absent on a particular
598 message. A few label names have standard meanings and are given to
599 messages automatically by Rmail when appropriate; these special labels
600 are called @dfn{attributes}.
601 @ifnottex
602 (@xref{Rmail Attributes}.)
603 @end ifnottex
604 All other labels are assigned only by users.
605
606 @table @kbd
607 @item a @var{label} @key{RET}
608 Assign the label @var{label} to the current message (@code{rmail-add-label}).
609 @item k @var{label} @key{RET}
610 Remove the label @var{label} from the current message (@code{rmail-kill-label}).
611 @item C-M-n @var{labels} @key{RET}
612 Move to the next message that has one of the labels @var{labels}
613 (@code{rmail-next-labeled-message}).
614 @item C-M-p @var{labels} @key{RET}
615 Move to the previous message that has one of the labels @var{labels}
616 (@code{rmail-previous-labeled-message}).
617 @item l @var{labels} @key{RET}
618 @itemx C-M-l @var{labels} @key{RET}
619 Make a summary of all messages containing any of the labels @var{labels}
620 (@code{rmail-summary-by-labels}).
621 @end table
622
623 @kindex a @r{(Rmail)}
624 @kindex k @r{(Rmail)}
625 @findex rmail-add-label
626 @findex rmail-kill-label
627 The @kbd{a} (@code{rmail-add-label}) and @kbd{k}
628 (@code{rmail-kill-label}) commands allow you to assign or remove any
629 label on the current message. If the @var{label} argument is empty, it
630 means to assign or remove the same label most recently assigned or
631 removed.
632
633 Once you have given messages labels to classify them as you wish, there
634 are three ways to use the labels: in moving, in summaries, and in sorting.
635
636 @kindex C-M-n @r{(Rmail)}
637 @kindex C-M-p @r{(Rmail)}
638 @findex rmail-next-labeled-message
639 @findex rmail-previous-labeled-message
640 @kbd{C-M-n @var{labels} @key{RET}}
641 (@code{rmail-next-labeled-message}) moves to the next message that has
642 one of the labels @var{labels}. The argument @var{labels} specifies
643 one or more label names, separated by commas. @kbd{C-M-p}
644 (@code{rmail-previous-labeled-message}) is similar, but moves
645 backwards to previous messages. A numeric argument to either command
646 serves as a repeat count.
647
648 The command @kbd{C-M-l @var{labels} @key{RET}}
649 (@code{rmail-summary-by-labels}) displays a summary containing only the
650 messages that have at least one of a specified set of labels. The
651 argument @var{labels} is one or more label names, separated by commas.
652 @xref{Rmail Summary}, for information on summaries.
653
654 If the @var{labels} argument to @kbd{C-M-n}, @kbd{C-M-p} or
655 @kbd{C-M-l} is empty, it means to use the last set of labels specified
656 for any of these commands.
657
658 @xref{Rmail Sorting}, for information on sorting messages with labels.
659
660 @node Rmail Attributes
661 @section Rmail Attributes
662
663 Some labels such as @samp{deleted} and @samp{filed} have built-in
664 meanings, and Rmail assigns them to messages automatically at
665 appropriate times; these labels are called @dfn{attributes}. Here is
666 a list of Rmail attributes:
667
668 @table @samp
669 @item unseen
670 Means the message has never been current. Assigned to messages when
671 they come from an inbox file, and removed when a message is made
672 current. When you start Rmail, it initially shows the first message
673 that has this attribute.
674 @item deleted
675 Means the message is deleted. Assigned by deletion commands and
676 removed by undeletion commands (@pxref{Rmail Deletion}).
677 @item filed
678 Means the message has been copied to some other file. Assigned by the
679 @kbd{o} and @kbd{C-o} file output commands (@pxref{Rmail Output}).
680 @item answered
681 Means you have mailed an answer to the message. Assigned by the @kbd{r}
682 command (@code{rmail-reply}). @xref{Rmail Reply}.
683 @item forwarded
684 Means you have forwarded the message. Assigned by the @kbd{f} command
685 (@code{rmail-forward}). @xref{Rmail Reply}.
686 @item edited
687 Means you have edited the text of the message within Rmail.
688 @xref{Rmail Editing}.
689 @item resent
690 Means you have resent the message. Assigned by the command @kbd{M-x
691 rmail-resend}. @xref{Rmail Reply}.
692 @item retried
693 Means you have retried a failed outgoing message. Assigned by the
694 command @kbd{M-x rmail-retry-failure}. @xref{Rmail Reply}.
695 @end table
696
697 All other labels are assigned or removed only by users, and have no
698 standard meaning.
699
700 @node Rmail Reply
701 @section Sending Replies
702
703 Rmail has several commands to send outgoing mail. @xref{Sending
704 Mail}, for information on using Message mode, including certain
705 features meant to work with Rmail. What this section documents are
706 the special commands of Rmail for entering the mail buffer. Note that
707 the usual keys for sending mail---@kbd{C-x m}, @kbd{C-x 4 m}, and
708 @kbd{C-x 5 m}---also work normally in Rmail mode.
709
710 @table @kbd
711 @item m
712 Send a message (@code{rmail-mail}).
713 @item c
714 Continue editing the already started outgoing message (@code{rmail-continue}).
715 @item r
716 Send a reply to the current Rmail message (@code{rmail-reply}).
717 @item f
718 Forward the current message to other users (@code{rmail-forward}).
719 @item C-u f
720 Resend the current message to other users (@code{rmail-resend}).
721 @item M-m
722 Try sending a bounced message a second time (@code{rmail-retry-failure}).
723 @end table
724
725 @kindex r @r{(Rmail)}
726 @findex rmail-reply
727 @cindex reply to a message
728 The most common reason to send a message while in Rmail is to reply
729 to the message you are reading. To do this, type @kbd{r}
730 (@code{rmail-reply}). This displays the @samp{*mail*} buffer in
731 another window, much like @kbd{C-x 4 m}, but preinitializes the
732 @samp{Subject}, @samp{To}, @samp{CC}, @samp{In-reply-to} and
733 @samp{References} header fields based on the message you are replying
734 to. The @samp{To} field starts out as the address of the person who
735 sent the message you received, and the @samp{CC} field starts out with
736 all the other recipients of that message.
737
738 @vindex rmail-dont-reply-to-names
739 You can exclude certain recipients from being included automatically
740 in replies, using the variable @code{rmail-dont-reply-to-names}. Its
741 value should be a regular expression; any recipients that match are
742 excluded from the @samp{CC} field. They are also excluded from the
743 @samp{To} field, unless this would leave the field empty. If this
744 variable is nil, then the first time you compose a reply it is
745 initialized to a default value that matches your own address, and any
746 name starting with @samp{info-}. (Those names are excluded because
747 there is a convention of using them for large mailing lists to broadcast
748 announcements.)
749
750 To omit the @samp{CC} field completely for a particular reply, enter
751 the reply command with a numeric argument: @kbd{C-u r} or @kbd{1 r}.
752 This means to reply only to the sender of the original message.
753
754 Once the @samp{*mail*} buffer has been initialized, editing and
755 sending the mail goes as usual (@pxref{Sending Mail}). You can edit
756 the presupplied header fields if they are not what you want. You can
757 also use commands such as @kbd{C-c C-y}, which yanks in the message
758 that you are replying to (@pxref{Mail Commands}). You can also switch
759 to the Rmail buffer, select a different message there, switch back,
760 and yank the new current message.
761
762 @kindex M-m @r{(Rmail)}
763 @findex rmail-retry-failure
764 @cindex retrying a failed message
765 @vindex rmail-retry-ignored-headers
766 Sometimes a message does not reach its destination. Mailers usually
767 send the failed message back to you, enclosed in a @dfn{failure
768 message}. The Rmail command @kbd{M-m} (@code{rmail-retry-failure})
769 prepares to send the same message a second time: it sets up a
770 @samp{*mail*} buffer with the same text and header fields as before. If
771 you type @kbd{C-c C-c} right away, you send the message again exactly
772 the same as the first time. Alternatively, you can edit the text or
773 headers and then send it. The variable
774 @code{rmail-retry-ignored-headers}, in the same format as
775 @code{rmail-ignored-headers} (@pxref{Rmail Display}), controls which
776 headers are stripped from the failed message when retrying it.
777
778 @kindex f @r{(Rmail)}
779 @findex rmail-forward
780 @cindex forwarding a message
781 Another frequent reason to send mail in Rmail is to @dfn{forward} the
782 current message to other users. @kbd{f} (@code{rmail-forward}) makes
783 this easy by preinitializing the @samp{*mail*} buffer with the current
784 message as the text, and a subject designating a forwarded message. All
785 you have to do is fill in the recipients and send. When you forward a
786 message, recipients get a message which is ``from'' you, and which has
787 the original message in its contents.
788
789 @findex unforward-rmail-message
790 Forwarding a message encloses it between two delimiter lines. It also
791 modifies every line that starts with a dash, by inserting @w{@samp{- }}
792 at the start of the line. When you receive a forwarded message, if it
793 contains something besides ordinary text---for example, program source
794 code---you might find it useful to undo that transformation. You can do
795 this by selecting the forwarded message and typing @kbd{M-x
796 unforward-rmail-message}. This command extracts the original forwarded
797 message, deleting the inserted @w{@samp{- }} strings, and inserts it
798 into the Rmail file as a separate message immediately following the
799 current one.
800
801 @findex rmail-resend
802 @dfn{Resending} is an alternative similar to forwarding; the
803 difference is that resending sends a message that is ``from'' the
804 original sender, just as it reached you---with a few added header fields
805 (@samp{Resent-From} and @samp{Resent-To}) to indicate that it came via
806 you. To resend a message in Rmail, use @kbd{C-u f}. (@kbd{f} runs
807 @code{rmail-forward}, which invokes @code{rmail-resend} if you provide a
808 numeric argument.)
809
810 @kindex m @r{(Rmail)}
811 @findex rmail-mail
812 Use the @kbd{m} (@code{rmail-mail}) command to start editing an
813 outgoing message that is not a reply. It leaves the header fields empty.
814 Its only difference from @kbd{C-x 4 m} is that it makes the Rmail buffer
815 accessible for @kbd{C-c C-y}, just as @kbd{r} does. Thus, @kbd{m} can be
816 used to reply to or forward a message; it can do anything @kbd{r} or @kbd{f}
817 can do.
818
819 @kindex c @r{(Rmail)}
820 @findex rmail-continue
821 The @kbd{c} (@code{rmail-continue}) command resumes editing the
822 @samp{*mail*} buffer, to finish editing an outgoing message you were
823 already composing, or to alter a message you have sent.
824
825 @vindex rmail-mail-new-frame
826 If you set the variable @code{rmail-mail-new-frame} to a
827 non-@code{nil} value, then all the Rmail commands to start sending a
828 message create a new frame to edit it in. This frame is deleted when
829 you send the message, or when you use the @samp{Cancel} item in the
830 @samp{Mail} menu.
831
832 All the Rmail commands to send a message use the mail-composition
833 method that you have chosen (@pxref{Mail Methods}).
834
835 @node Rmail Summary
836 @section Summaries
837 @cindex summary (Rmail)
838
839 A @dfn{summary} is a buffer containing one line per message to give
840 you an overview of the mail in an Rmail file. Each line shows the
841 message number and date, the sender, the line count, the labels, and
842 the subject. Moving point in the summary buffer selects messages as
843 you move to their summary lines. Almost all Rmail commands are valid
844 in the summary buffer also; when used there, they apply to the message
845 described by the current line of the summary.
846
847 A summary buffer applies to a single Rmail file only; if you are
848 editing multiple Rmail files, each one can have its own summary buffer.
849 The summary buffer name is made by appending @samp{-summary} to the
850 Rmail buffer's name. Normally only one summary buffer is displayed at a
851 time.
852
853 @menu
854 * Rmail Make Summary:: Making various sorts of summaries.
855 * Rmail Summary Edit:: Manipulating messages from the summary.
856 @end menu
857
858 @node Rmail Make Summary
859 @subsection Making Summaries
860
861 Here are the commands to create a summary for the current Rmail
862 buffer. Once the Rmail buffer has a summary, changes in the Rmail
863 buffer (such as deleting or expunging messages, and getting new mail)
864 automatically update the summary.
865
866 @table @kbd
867 @item h
868 @itemx C-M-h
869 Summarize all messages (@code{rmail-summary}).
870 @item l @var{labels} @key{RET}
871 @itemx C-M-l @var{labels} @key{RET}
872 Summarize messages that have one or more of the specified labels
873 (@code{rmail-summary-by-labels}).
874 @item C-M-r @var{rcpts} @key{RET}
875 Summarize messages that match the specified recipients
876 (@code{rmail-summary-by-recipients}).
877 @item C-M-t @var{topic} @key{RET}
878 Summarize messages that have a match for the specified regexp
879 @var{topic} in their subjects (@code{rmail-summary-by-topic}).
880 @item C-M-s @var{regexp} @key{RET}
881 Summarize messages whose headers match the specified regular expression
882 @var{regexp} (@code{rmail-summary-by-regexp}).
883 @item C-M-f @var{senders} @key{RET}
884 Summarize messages that match the specified senders.
885 (@code{rmail-summary-by-senders}).
886 @end table
887
888 @kindex h @r{(Rmail)}
889 @findex rmail-summary
890 The @kbd{h} or @kbd{C-M-h} (@code{rmail-summary}) command fills the summary buffer
891 for the current Rmail buffer with a summary of all the messages in the buffer.
892 It then displays and selects the summary buffer in another window.
893
894 @kindex l @r{(Rmail)}
895 @kindex C-M-l @r{(Rmail)}
896 @findex rmail-summary-by-labels
897 @kbd{C-M-l @var{labels} @key{RET}} (@code{rmail-summary-by-labels}) makes
898 a partial summary mentioning only the messages that have one or more of the
899 labels @var{labels}. @var{labels} should contain label names separated by
900 commas.
901
902 @kindex C-M-r @r{(Rmail)}
903 @findex rmail-summary-by-recipients
904 @kbd{C-M-r @var{rcpts} @key{RET}} (@code{rmail-summary-by-recipients})
905 makes a partial summary mentioning only the messages that have one or
906 more recipients matching the regular expression @var{rcpts}. You can
907 use commas to separate multiple regular expressions. These are matched
908 against the @samp{To}, @samp{From}, and @samp{CC} headers (with a prefix
909 argument, this header is not included).
910
911 @kindex C-M-t @r{(Rmail)}
912 @findex rmail-summary-by-topic
913 @kbd{C-M-t @var{topic} @key{RET}} (@code{rmail-summary-by-topic})
914 makes a partial summary mentioning only the messages whose subjects have
915 a match for the regular expression @var{topic}. You can use commas to
916 separate multiple regular expressions. With a prefix argument, the
917 match is against the whole message, not just the subject.
918
919 @kindex C-M-s @r{(Rmail)}
920 @findex rmail-summary-by-regexp
921 @kbd{C-M-s @var{regexp} @key{RET}} (@code{rmail-summary-by-regexp})
922 makes a partial summary that mentions only the messages whose headers
923 (including the date and the subject lines) match the regular
924 expression @var{regexp}.
925
926 @kindex C-M-f @r{(Rmail)}
927 @findex rmail-summary-by-senders
928 @kbd{C-M-f @var{senders} @key{RET}} (@code{rmail-summary-by-senders})
929 makes a partial summary that mentions only the messages whose @samp{From}
930 fields match the regular expression @var{senders}. You can use commas to
931 separate multiple regular expressions.
932
933 Note that there is only one summary buffer for any Rmail buffer;
934 making any kind of summary discards any previous summary.
935
936 @vindex rmail-summary-window-size
937 @vindex rmail-summary-line-count-flag
938 The variable @code{rmail-summary-window-size} says how many lines to
939 use for the summary window. The variable
940 @code{rmail-summary-line-count-flag} controls whether the summary line
941 for a message should include the line count of the message. Setting
942 this option to nil might speed up the generation of summaries.
943
944 @node Rmail Summary Edit
945 @subsection Editing in Summaries
946
947 You can use the Rmail summary buffer to do almost anything you can do
948 in the Rmail buffer itself. In fact, once you have a summary buffer,
949 there's no need to switch back to the Rmail buffer.
950
951 You can select and display various messages in the Rmail buffer, from
952 the summary buffer, just by moving point in the summary buffer to
953 different lines. It doesn't matter what Emacs command you use to move
954 point; whichever line point is on at the end of the command, that
955 message is selected in the Rmail buffer.
956
957 Almost all Rmail commands work in the summary buffer as well as in the
958 Rmail buffer. Thus, @kbd{d} in the summary buffer deletes the current
959 message, @kbd{u} undeletes, and @kbd{x} expunges. (However, in the
960 summary buffer, a numeric argument to @kbd{d}, @kbd{C-d} and @kbd{u}
961 serves as a repeat count. A negative argument reverses the meaning of
962 @kbd{d} and @kbd{C-d}. Also, if there are no more undeleted messages in
963 the relevant direction, the delete commands go to the first or last
964 message, rather than staying on the current message.) @kbd{o} and
965 @kbd{C-o} output the current message to a FILE; @kbd{r} starts a reply
966 to it; etc. You can scroll the current message while remaining in the
967 summary buffer using @key{SPC} and @key{DEL}.
968 @c rmail-summary-scroll-between-messages not mentioned.
969
970 @findex rmail-summary-undelete-many
971 @kbd{M-u} (@code{rmail-summary-undelete-many}) undeletes all deleted
972 messages in the summary. A prefix argument means to undelete that many
973 of the previous deleted messages.
974
975 The Rmail commands to move between messages also work in the summary
976 buffer, but with a twist: they move through the set of messages included
977 in the summary. They also ensure the Rmail buffer appears on the screen
978 (unlike cursor motion commands, which update the contents of the Rmail
979 buffer but don't display it in a window unless it already appears).
980 Here is a list of these commands:
981
982 @table @kbd
983 @item n
984 Move to next line, skipping lines saying `deleted', and select its
985 message (@code{rmail-summary-next-msg}).
986 @item p
987 Move to previous line, skipping lines saying `deleted', and select
988 its message (@code{rmail-summary-previous-msg}).
989 @item M-n
990 Move to next line and select its message (@code{rmail-summary-next-all}).
991 @item M-p
992 Move to previous line and select its message
993 (@code{rmail-summary-previous-all}).
994 @item >
995 Move to the last line, and select its message
996 (@code{rmail-summary-last-message}).
997 @item <
998 Move to the first line, and select its message
999 (@code{rmail-summary-first-message}).
1000 @item j
1001 @itemx @key{RET}
1002 Select the message on the current line (ensuring that the Rmail buffer
1003 appears on the screen; @code{rmail-summary-goto-msg}). With argument
1004 @var{n}, select message number @var{n} and move to its line in the
1005 summary buffer; this signals an error if the message is not listed in
1006 the summary buffer.
1007 @item M-s @var{pattern} @key{RET}
1008 Search through messages for @var{pattern} starting with the current
1009 message; select the message found, and move point in the summary buffer
1010 to that message's line (@code{rmail-summary-search}). A prefix argument
1011 acts as a repeat count; a negative argument means search backward
1012 (equivalent to @code{rmail-summary-search-backward}.)
1013 @item C-M-n @var{labels} @key{RET}
1014 Move to the next message with at least one of the specified labels
1015 (@code{rmail-summary-next-labeled-message}). @var{labels} is a
1016 comma-separated list of labels. A prefix argument acts as a repeat
1017 count.
1018 @item C-M-p @var{labels} @key{RET}
1019 Move to the previous message with at least one of the specified labels
1020 (@code{rmail-summary-previous-labeled-message}).
1021 @item C-c C-n @key{RET}
1022 Move to the next message with the same subject as the current message
1023 (@code{rmail-summary-next-same-subject}). A prefix argument acts as a
1024 repeat count.
1025 @item C-c C-p @key{RET}
1026 Move to the previous message with the same subject as the current message
1027 (@code{rmail-summary-previous-same-subject}).
1028 @end table
1029
1030 @vindex rmail-redisplay-summary
1031 Deletion, undeletion, and getting new mail, and even selection of a
1032 different message all update the summary buffer when you do them in the
1033 Rmail buffer. If the variable @code{rmail-redisplay-summary} is
1034 non-@code{nil}, these actions also bring the summary buffer back onto
1035 the screen.
1036
1037 @kindex Q @r{(Rmail summary)}
1038 @findex rmail-summary-wipe
1039 @kindex q @r{(Rmail summary)}
1040 @findex rmail-summary-quit
1041 @kindex b @r{(Rmail summary)}
1042 @findex rmail-summary-bury
1043 When you are finished using the summary, type @kbd{Q}
1044 (@code{rmail-summary-wipe}) to delete the summary buffer's window. You
1045 can also exit Rmail while in the summary: @kbd{q}
1046 (@code{rmail-summary-quit}) deletes the summary window, then exits from
1047 Rmail by saving the Rmail file and switching to another buffer.
1048 Alternatively, @kbd{b} (@code{rmail-summary-bury}) simply buries the
1049 Rmail summary and buffer.
1050
1051 @node Rmail Sorting
1052 @section Sorting the Rmail File
1053 @cindex sorting Rmail file
1054 @cindex Rmail file sorting
1055
1056 @table @kbd
1057 @findex rmail-sort-by-date
1058 @item C-c C-s C-d
1059 @itemx M-x rmail-sort-by-date
1060 Sort messages of current Rmail buffer by date.
1061
1062 @findex rmail-sort-by-subject
1063 @item C-c C-s C-s
1064 @itemx M-x rmail-sort-by-subject
1065 Sort messages of current Rmail buffer by subject.
1066
1067 @findex rmail-sort-by-author
1068 @item C-c C-s C-a
1069 @itemx M-x rmail-sort-by-author
1070 Sort messages of current Rmail buffer by author's name.
1071
1072 @findex rmail-sort-by-recipient
1073 @item C-c C-s C-r
1074 @itemx M-x rmail-sort-by-recipient
1075 Sort messages of current Rmail buffer by recipient's names.
1076
1077 @findex rmail-sort-by-correspondent
1078 @item C-c C-s C-c
1079 @itemx M-x rmail-sort-by-correspondent
1080 Sort messages of current Rmail buffer by the name of the other
1081 correspondent.
1082
1083 @findex rmail-sort-by-lines
1084 @item C-c C-s C-l
1085 @itemx M-x rmail-sort-by-lines
1086 Sort messages of current Rmail buffer by number of lines.
1087
1088 @findex rmail-sort-by-labels
1089 @item C-c C-s C-k @key{RET} @var{labels} @key{RET}
1090 @itemx M-x rmail-sort-by-labels @key{RET} @var{labels} @key{RET}
1091 Sort messages of current Rmail buffer by labels. The argument
1092 @var{labels} should be a comma-separated list of labels. The order of
1093 these labels specifies the order of messages; messages with the first
1094 label come first, messages with the second label come second, and so on.
1095 Messages that have none of these labels come last.
1096 @end table
1097
1098 The Rmail sort commands perform a @emph{stable sort}: if there is no
1099 reason to prefer either one of two messages, their order remains
1100 unchanged. You can use this to sort by more than one criterion. For
1101 example, if you use @code{rmail-sort-by-date} and then
1102 @code{rmail-sort-by-author}, messages from the same author appear in
1103 order by date.
1104
1105 With a prefix argument, all these commands reverse the order of
1106 comparison. This means they sort messages from newest to oldest, from
1107 biggest to smallest, or in reverse alphabetical order.
1108
1109 The same keys in the summary buffer run similar functions; for
1110 example, @kbd{C-c C-s C-l} runs @code{rmail-summary-sort-by-lines}.
1111 Note that these commands always sort the whole Rmail buffer, even if the
1112 summary is only showing a subset of messages.
1113
1114 Note that you cannot undo a sort, so you may wish to save the Rmail
1115 buffer before sorting it.
1116
1117 @node Rmail Display
1118 @section Display of Messages
1119
1120 This section describes how Rmail displays mail headers,
1121 @acronym{MIME} sections and attachments, and URLs.
1122
1123 @table @kbd
1124 @item t
1125 Toggle display of complete header (@code{rmail-toggle-header}).
1126 @end table
1127
1128 @kindex t @r{(Rmail)}
1129 @findex rmail-toggle-header
1130 Before displaying each message for the first time, Rmail reformats
1131 its header, hiding uninteresting header fields to reduce clutter. The
1132 @kbd{t} (@code{rmail-toggle-header}) command toggles this, switching
1133 between showing the reformatted header fields and showing the
1134 complete, original header. With a positive prefix argument, the
1135 command shows the reformatted header; with a zero or negative prefix
1136 argument, it shows the full header. Selecting the message again also
1137 reformats it if necessary.
1138
1139 @vindex rmail-ignored-headers
1140 @vindex rmail-displayed-headers
1141 @vindex rmail-nonignored-headers
1142 The variable @code{rmail-ignored-headers} holds a regular expression
1143 specifying the header fields to hide; any matching header line will be
1144 hidden. The variable @code{rmail-nonignored-headers} overrides this:
1145 any header field matching that regular expression is shown even if it
1146 matches @code{rmail-ignored-headers} too. The variable
1147 @code{rmail-displayed-headers} is an alternative to these two
1148 variables; if non-@code{nil}, this should be a regular expression
1149 specifying which headers to display (the default is @code{nil}).
1150
1151 @vindex rmail-highlighted-headers
1152 Rmail highlights certain header fields that are especially
1153 interesting---by default, the @samp{From} and @samp{Subject} fields.
1154 This highlighting uses the @code{rmail-highlight} face. The variable
1155 @code{rmail-highlighted-headers} holds a regular expression specifying
1156 the header fields to highlight; if it matches the beginning of a
1157 header field, that whole field is highlighted. To disable this
1158 feature, set @code{rmail-highlighted-headers} to @code{nil}.
1159
1160 @cindex MIME messages (Rmail)
1161 @vindex rmail-enable-mime
1162 If a message is in @acronym{MIME} (Multipurpose Internet Mail
1163 Extensions) format and contains multiple parts (@acronym{MIME}
1164 entities), Rmail displays each part with a @dfn{tagline}. The tagline
1165 summarizes the part's index, size, and content type. Depending on the
1166 content type, it may also contain one or more buttons; these perform
1167 actions such as saving the part into a file.
1168
1169 @table @kbd
1170 @findex rmail-mime-toggle-hidden
1171 @item @key{RET}
1172 Hide or show the @acronym{MIME} part at point
1173 (@code{rmail-mime-toggle-hidden}).
1174
1175 @findex rmail-mime-next-item
1176 @item @key{TAB}
1177 Move point to the next @acronym{MIME} tagline button.
1178 (@code{rmail-mime-next-item}).
1179
1180 @findex rmail-mime-previous-item
1181 @item @key{BackTab}
1182 Move point to the previous @acronym{MIME} part
1183 (@code{rmail-mime-previous-item}).
1184
1185 @findex rmail-mime
1186 @item v
1187 @kindex v @r{(Rmail)}
1188 Toggle between @acronym{MIME} display and raw message
1189 (@code{rmail-mime}).
1190 @end table
1191
1192 Each plain-text @acronym{MIME} part is initially displayed
1193 immediately after its tagline, as part of the Rmail buffer, while
1194 @acronym{MIME} parts of other types are represented only by their
1195 taglines, with their actual contents hidden. In either case, you can
1196 toggle a @acronym{MIME} part between its ``displayed'' and ``hidden''
1197 states by typing @key{RET} anywhere in the part---or anywhere in its
1198 tagline, apart from a tagline button for some other action. Type
1199 @key{RET} (or click with the mouse) to activate a tagline button, and
1200 @key{TAB} to cycle point between tagline buttons.
1201
1202 The @kbd{v} (@code{rmail-mime}) command toggles between the default
1203 @acronym{MIME} display described above, and a ``raw'' display showing
1204 the undecoded @acronym{MIME} data. With a prefix argument, this
1205 command toggles the display of only an entity at point.
1206
1207 To prevent Rmail from handling MIME decoded messages, change the
1208 variable @code{rmail-enable-mime} to @code{nil}. When this is the
1209 case, the @kbd{v} (@code{rmail-mime}) command instead creates a
1210 temporary buffer to display the current @acronym{MIME} message.
1211
1212 You can highlight and activate URLs in the Rmail buffer using Goto
1213 Address mode:
1214
1215 @c FIXME goto-addr.el commentary says to use goto-address instead.
1216 @smallexample
1217 (add-hook 'rmail-show-message-hook 'goto-address-mode)
1218 @end smallexample
1219
1220 @noindent
1221 Then you can browse these URLs by clicking on them with @kbd{Mouse-2}
1222 (or @kbd{Mouse-1} quickly) or by moving to one and typing @kbd{C-c
1223 @key{RET}}. @xref{Goto Address mode, Activating URLs, Activating URLs}.
1224
1225 @node Rmail Coding
1226 @section Rmail and Coding Systems
1227
1228 @cindex decoding mail messages (Rmail)
1229 Rmail automatically decodes messages which contain non-@acronym{ASCII}
1230 characters, just as Emacs does with files you visit and with subprocess
1231 output. Rmail uses the standard @samp{charset=@var{charset}} header in
1232 the message, if any, to determine how the message was encoded by the
1233 sender. It maps @var{charset} into the corresponding Emacs coding
1234 system (@pxref{Coding Systems}), and uses that coding system to decode
1235 message text. If the message header doesn't have the @samp{charset}
1236 specification, or if @var{charset} is not recognized,
1237 Rmail chooses the coding system with the usual Emacs heuristics and
1238 defaults (@pxref{Recognize Coding}).
1239
1240 @cindex fixing incorrectly decoded mail messages
1241 Occasionally, a message is decoded incorrectly, either because Emacs
1242 guessed the wrong coding system in the absence of the @samp{charset}
1243 specification, or because the specification was inaccurate. For
1244 example, a misconfigured mailer could send a message with a
1245 @samp{charset=iso-8859-1} header when the message is actually encoded
1246 in @code{koi8-r}. When you see the message text garbled, or some of
1247 its characters displayed as hex codes or empty boxes, this may have
1248 happened.
1249
1250 @findex rmail-redecode-body
1251 You can correct the problem by decoding the message again using the
1252 right coding system, if you can figure out or guess which one is
1253 right. To do this, invoke the @kbd{M-x rmail-redecode-body} command.
1254 It reads the name of a coding system, and then redecodes the message
1255 using the coding system you specified. If you specified the right
1256 coding system, the result should be readable.
1257
1258 @node Rmail Editing
1259 @section Editing Within a Message
1260
1261 Most of the usual Emacs key bindings are available in Rmail mode,
1262 though a few, such as @kbd{C-M-n} and @kbd{C-M-h}, are redefined by
1263 Rmail for other purposes. However, the Rmail buffer is normally read
1264 only, and most of the letters are redefined as Rmail commands. If you
1265 want to edit the text of a message, you must use the Rmail command
1266 @kbd{e}.
1267
1268 @table @kbd
1269 @item e
1270 Edit the current message as ordinary text.
1271 @end table
1272
1273 @kindex e @r{(Rmail)}
1274 @findex rmail-edit-current-message
1275 The @kbd{e} command (@code{rmail-edit-current-message}) switches from
1276 Rmail mode into Rmail Edit mode, another major mode which is nearly the
1277 same as Text mode. The mode line indicates this change.
1278
1279 In Rmail Edit mode, letters insert themselves as usual and the Rmail
1280 commands are not available. You can edit the message body and header
1281 fields. When you are finished editing the message, type @kbd{C-c C-c}
1282 to switch back to Rmail mode. Alternatively, you can return to Rmail
1283 mode but cancel any editing that you have done, by typing @kbd{C-c C-]}.
1284
1285 @vindex rmail-edit-mode-hook
1286 Entering Rmail Edit mode runs the hook @code{text-mode-hook}; then
1287 it runs the hook @code{rmail-edit-mode-hook} (@pxref{Hooks}).
1288 Returning to ordinary Rmail mode adds the attribute @samp{edited} to
1289 the message, if you have made any changes in it.
1290
1291 @node Rmail Digest
1292 @section Digest Messages
1293 @cindex digest message
1294 @cindex undigestify
1295
1296 A @dfn{digest message} is a message which exists to contain and carry
1297 several other messages. Digests are used on some moderated mailing
1298 lists; all the messages that arrive for the list during a period of time
1299 such as one day are put inside a single digest which is then sent to the
1300 subscribers. Transmitting the single digest uses much less computer
1301 time than transmitting the individual messages even though the total
1302 size is the same, because the per-message overhead in network mail
1303 transmission is considerable.
1304
1305 @findex undigestify-rmail-message
1306 When you receive a digest message, the most convenient way to read it is
1307 to @dfn{undigestify} it: to turn it back into many individual messages.
1308 Then you can read and delete the individual messages as it suits you.
1309 To do this, select the digest message and type the command @kbd{M-x
1310 undigestify-rmail-message}. This extracts the submessages as separate
1311 Rmail messages, and inserts them following the digest. The digest
1312 message itself is flagged as deleted.
1313
1314 @node Rmail Rot13
1315 @section Reading Rot13 Messages
1316 @cindex rot13 code
1317
1318 Mailing list messages that might offend some readers are sometimes
1319 encoded in a simple code called @dfn{rot13}---so named because it
1320 rotates the alphabet by 13 letters. This code is not for secrecy, as it
1321 provides none; rather, it enables those who might be offended to avoid
1322 seeing the real text of the message.
1323
1324 @findex rot13-other-window
1325 To view a buffer which uses the rot13 code, use the command @kbd{M-x
1326 rot13-other-window}. This displays the current buffer in another window
1327 which applies the code when displaying the text.
1328
1329 @node Movemail
1330 @section @code{movemail} program
1331 @cindex @code{movemail} program
1332
1333 Rmail uses the @code{movemail} program to move mail from your inbox to
1334 your Rmail file (@pxref{Rmail Inbox}). When loaded for the first time,
1335 Rmail attempts to locate the @code{movemail} program and determine its
1336 version. There are two versions of the @code{movemail} program: the
1337 native one, shipped with GNU Emacs (the ``emacs version'') and the one
1338 included in GNU mailutils (the ``mailutils version,''
1339 @pxref{movemail,,,mailutils,GNU mailutils}). They support the same
1340 command line syntax and the same basic subset of options. However, the
1341 Mailutils version offers additional features.
1342
1343 The Emacs version of @code{movemail} is able to retrieve mail from
1344 the usual Unix mailbox formats and from remote mailboxes using the
1345 POP3 protocol.
1346
1347 The Mailutils version is able to handle a wide set of mailbox
1348 formats, such as plain Unix mailboxes, @code{maildir} and @code{MH}
1349 mailboxes, etc. It is able to access remote mailboxes using the POP3
1350 or IMAP4 protocol, and can retrieve mail from them using a TLS
1351 encrypted channel. It also accepts mailbox arguments in @acronym{URL}
1352 form. The detailed description of mailbox @acronym{URL}s can be found
1353 in @ref{URL,,,mailutils,Mailbox URL Formats}. In short, a
1354 @acronym{URL} is:
1355
1356 @smallexample
1357 @var{proto}://[@var{user}[:@var{password}]@@]@var{host-or-file-name}
1358 @end smallexample
1359
1360 @noindent
1361 where square brackets denote optional elements.
1362
1363 @table @var
1364 @item proto
1365 Specifies the @dfn{mailbox protocol}, or @dfn{format} to
1366 use. The exact semantics of the rest of @acronym{URL} elements depends
1367 on the actual value of @var{proto} (see below).
1368
1369 @item user
1370 User name to access the remote mailbox.
1371
1372 @item password
1373 User password to access the remote mailbox.
1374
1375 @item host-or-file-name
1376 Hostname of the remote server for remote mailboxes or file name of a
1377 local mailbox.
1378 @end table
1379
1380 @noindent
1381 @var{Proto} can be one of:
1382
1383 @table @code
1384 @item mbox
1385 Usual Unix mailbox format. In this case, neither @var{user} nor
1386 @var{pass} are used, and @var{host-or-file-name} denotes the file name
1387 of the mailbox file, e.g., @code{mbox://var/spool/mail/smith}.
1388
1389 @item mh
1390 A local mailbox in the @acronym{MH} format. @var{User} and
1391 @var{pass} are not used. @var{Host-or-file-name} denotes the name of
1392 @acronym{MH} folder, e.g., @code{mh://Mail/inbox}.
1393
1394 @item maildir
1395 A local mailbox in the @acronym{maildir} format. @var{User} and
1396 @var{pass} are not used, and @var{host-or-file-name} denotes the name of
1397 @code{maildir} mailbox, e.g., @code{maildir://mail/inbox}.
1398
1399 @item file
1400 Any local mailbox format. Its actual format is detected automatically
1401 by @code{movemail}.
1402
1403 @item pop
1404 A remote mailbox to be accessed via POP3 protocol. @var{User}
1405 specifies the remote user name to use, @var{pass} may be used to
1406 specify the user password, @var{host-or-file-name} is the name or IP
1407 address of the remote mail server to connect to; e.g.,
1408 @code{pop://smith:guessme@@remote.server.net}.
1409
1410 @item imap
1411 A remote mailbox to be accessed via IMAP4 protocol. @var{User}
1412 specifies the remote user name to use, @var{pass} may be used to
1413 specify the user password, @var{host-or-file-name} is the name or IP
1414 address of the remote mail server to connect to;
1415 e.g., @code{imap://smith:guessme@@remote.server.net}.
1416 @end table
1417
1418 Alternatively, you can specify the file name of the mailbox to use.
1419 This is equivalent to specifying the @samp{file} protocol:
1420
1421 @smallexample
1422 /var/spool/mail/@var{user} @equiv{} file://var/spool/mail/@var{user}
1423 @end smallexample
1424
1425 @vindex rmail-movemail-program
1426 @vindex rmail-movemail-search-path
1427 The variable @code{rmail-movemail-program} controls which version of
1428 @code{movemail} to use. If that is a string, it specifies the
1429 absolute file name of the @code{movemail} executable. If it is
1430 @code{nil}, Rmail searches for @code{movemail} in the directories
1431 listed in @code{rmail-movemail-search-path} and @code{exec-path}, then
1432 in @code{exec-directory}.
1433
1434 @node Remote Mailboxes
1435 @section Retrieving Mail from Remote Mailboxes
1436 @pindex movemail
1437
1438 Some sites use a method called POP for accessing users' inbox data
1439 instead of storing the data in inbox files. By default, the @code{Emacs
1440 movemail} can work with POP (unless the Emacs @code{configure} script
1441 was run with the option @samp{--without-pop}).
1442
1443 Similarly, the Mailutils @code{movemail} by default supports POP, unless
1444 it was configured with the @samp{--disable-pop} option.
1445
1446 Both versions of @code{movemail} only work with POP3, not with older
1447 versions of POP.
1448
1449 @cindex @env{MAILHOST} environment variable
1450 @cindex POP mailboxes
1451 No matter which flavor of @code{movemail} you use, you can specify
1452 a POP inbox by using a POP @dfn{URL} (@pxref{Movemail}). A POP
1453 @acronym{URL} is a ``file name'' of the form
1454 @samp{pop://@var{username}@@@var{hostname}}, where
1455 @var{hostname} is the host name or IP address of the remote mail
1456 server and @var{username} is the user name on that server.
1457 Additionally, you may specify the password in the mailbox @acronym{URL}:
1458 @samp{pop://@var{username}:@var{password}@@@var{hostname}}. In this
1459 case, @var{password} takes preference over the one set by
1460 @code{rmail-remote-password} (see below). This is especially useful
1461 if you have several remote mailboxes with different passwords.
1462
1463 For backward compatibility, Rmail also supports an alternative way of
1464 specifying remote POP mailboxes. Specifying an inbox name in the form
1465 @samp{po:@var{username}:@var{hostname}} is equivalent to
1466 @samp{pop://@var{username}@@@var{hostname}}. If you omit the
1467 @var{:hostname} part, the @env{MAILHOST} environment variable specifies
1468 the machine on which to look for the POP server.
1469
1470 @c FIXME mention --with-hesiod "support Hesiod to get the POP server host"?
1471
1472 @cindex IMAP mailboxes
1473 Another method for accessing remote mailboxes is IMAP. This method is
1474 supported only by the Mailutils @code{movemail}. To specify an IMAP
1475 mailbox in the inbox list, use the following mailbox @acronym{URL}:
1476 @samp{imap://@var{username}[:@var{password}]@@@var{hostname}}. The
1477 @var{password} part is optional, as described above.
1478
1479 @vindex rmail-remote-password
1480 @vindex rmail-remote-password-required
1481 Accessing a remote mailbox may require a password. Rmail uses the
1482 following algorithm to retrieve it:
1483
1484 @enumerate
1485 @item
1486 If a @var{password} is present in the mailbox URL (see above), it is
1487 used.
1488 @item
1489 If the variable @code{rmail-remote-password-required} is @code{nil},
1490 Rmail assumes no password is required.
1491 @item
1492 If the variable @code{rmail-remote-password} is non-@code{nil}, its
1493 value is used.
1494 @item
1495 Otherwise, Rmail will ask you for the password to use.
1496 @end enumerate
1497
1498 @vindex rmail-movemail-flags
1499 If you need to pass additional command-line flags to @code{movemail},
1500 set the variable @code{rmail-movemail-flags} a list of the flags you
1501 wish to use. Do not use this variable to pass the @samp{-p} flag to
1502 preserve your inbox contents; use @code{rmail-preserve-inbox} instead.
1503
1504 @cindex Kerberos POP authentication
1505 The @code{movemail} program installed at your site may support
1506 Kerberos authentication (the Emacs @code{movemail} does so if Emacs was
1507 configured with the option @code{--with-kerberos} or
1508 @code{--with-kerberos5}). If it is supported, it is used by default
1509 whenever you attempt to retrieve POP mail when
1510 @code{rmail-remote-password} and @code{rmail-remote-password-required}
1511 are unset.
1512
1513 @cindex reverse order in POP inboxes
1514 Some POP servers store messages in reverse order. If your server does
1515 this, and you would rather read your mail in the order in which it was
1516 received, you can tell @code{movemail} to reverse the order of
1517 downloaded messages by adding the @samp{-r} flag to
1518 @code{rmail-movemail-flags}.
1519
1520 @cindex TLS encryption (Rmail)
1521 Mailutils @code{movemail} supports TLS encryption. If you wish to
1522 use it, add the @samp{--tls} flag to @code{rmail-movemail-flags}.
1523
1524 @node Other Mailbox Formats
1525 @section Retrieving Mail from Local Mailboxes in Various Formats
1526
1527 If your incoming mail is stored on a local machine in a format other
1528 than Unix mailbox, you will need the Mailutils @code{movemail} to
1529 retrieve it. @xref{Movemail}, for the detailed description of
1530 @code{movemail} versions. For example, to access mail from a inbox in
1531 @code{maildir} format located in @file{/var/spool/mail/in}, you would
1532 include the following in the Rmail inbox list:
1533
1534 @smallexample
1535 maildir://var/spool/mail/in
1536 @end smallexample