Organizing Messages with Folders

[previous] [next] [table of contents] [index]

When you first start xmh, you will have folders named inbox and drafts. Folders are like the folders you'd find in an office file cabinet: they group related messages. If you don't have many messages, you may not want new folders. People who get a lot of mail, though, will. Here's how to make new folders and move or copy messages into them.

Making a New Folder

The Create Folder command on the Folder menu will make a small window and prompt you for a folder name. After you type in the name, the folder and a new folder button will be created.

The folder name should be all one word -- don't use spaces. You can use a character like an underscore (_) to join two words into one. Long names are okay, but remember that they make the buttons bigger than short names. This is demonstrated in the Figure below. (Note that if you have a lot of buttons, or buttons with long names, you can always shorten the folder buttonbox so that it has a scrollbar -- and scroll through the folder buttons.)

Figure: Folder buttonbox with some long folder names


xmh Release 6 supports a single level of subfolders. (The Section Folders and Subfolders has more information.) Make a subfolder like a top-level folder -- but put a slash (/) and the subfolder name after the top-level folder name. For example, to make a cheese subfolder in the existing project folder, type project/cheese in the Create Folder box.

Folders and Subfolders

xmh Release 4 introduced limited support for MH subfolders. A subfolder is a folder within a folder, as the Figure below shows.

Figure: A folder with one subfolder


MH can have folders inside subfolders, many levels deep. xmh supports just one level -- but that's plenty for most users. (You can create a subfolder more than one level deep from within xmh. It will appear in the menu under the folder button. After you quit and restart xmh, though, the sub-subfolder won't appear on the folder menu anymore.)

If a folder has a subfolder, a list box will drop down when you select the button. The first entry in the list is always for the top-level folder. The other entries are for its subfolders. The next Figure shows how to select the system_b subfolder of the syserrs folder.

All xmh operations work as well on subfolders as they do on top-level folders.

Using Another Folder

To see another folder, you have two choices: either change the folder you're viewing now in the main window or open a new main window for the folder.

NOTE: If you make a new folder and you don't move or copy any messages into it -- then, when you open it for the first time, you'll get an error message like scan: no messages in folderpath.

This isn't really an error -- it's just the MH scan command telling you that the folder is empty. If you move or link a message into the folder before you open it for the first time, you won't see the error.

Moving Messages Between Folders

Here are the steps for moving messages to another folder, with and without an accelerator. First, make sure that the Table of Contents shows the folder you want to take messages from (the folder you want to move messages out of): Here are some miscellaneous facts about moving messages:

Figure: Two messages marked for moving


Linking (not Copying) Messages Between Folders

xmh Release 4 had a Copy command (on the Message menu) for "copying" messages between folders. This isn't really what xmh does with the messages -- instead, it links the messages to the new folder. In xmh Release 5, the command name was changed to Copy as Link -- but it does the same thing it did before. For more details about what linking means, see the Sections Using Links and Links. Basically, linking saves disk space.

CAUTION: If you edit one of the "copied" (linked) messages by displaying it in the view window and choosing Edit Message, all the "copies" of the messages in all folders will show the same edit!

A link isn't a true copy. In this book I'll call it a link, not a copy.

Linking a message to another folder takes the same steps as moving. The difference is that when the message is marked for copying, xmh puts a C in the Table of Contents next to the message number and -> foldername (Copy) in the titlebar above the message view. Be sure to use Commit Changes when you're ready.

The accelerator for marking to copy is META-C. The accelerator for committing the changes is META-SHIFT-C.

Deleting (and Restoring) Messages

To delete messages, use the steps in the Section Moving Messages Between Folders for selecting the messages, but use the Delete command on the Message menu. The accelerator for marking to delete is META-D. The accelerator for committing the changes is META-SHIFT-C.

If you accidentally delete a message, you can probably get it back (though you may have to exit xmh). See the Section Removing and Recovering Messages.

Also see the rmmer shell script, which makes it easy to recover your deleted messages. If you install rmmer on your account, you still use the Delete and Commit Changes commands (or the accelerators), as always. But rmmer puts your deleted messages into a subfolder named DELETE where it's easy to recover them if you need to. (A system program removes the "deleted" messages later.)

This is a real win for xmh users because you don't have to open an xterm window or use MH commands to recover deleted messages anymore. (Remember that because xmh can't deal with sub-subfolders, you'll need to use MH commands to recover messages you delete from subfolders -- see the Section Recovering a Removed Message for help. If you have to recover a deleted message with MH, you should use the xmh Rescan Folder command so xmh will update its folder list. This is a good thing to do any time after you use an MH command. Or use the rmmer_1.noask script instead -- it puts all deleted messages in one top-level folder (not a subfolder) named DELETE.)

The first time you delete a message in a folder, rmmer will create the DELETE subfolder for you. But the new subfolder won't appear on a menu until the next time you start xmh.

To recover a deleted message, go to the folder where it was deleted. Then go to the DELETE subfolder (see the Figure below) and move the message to its parent folder. (You can actually move the message to any folder, not just its parent.)

Figure: Recovering a message deleted by rmmer


Rescan Folder

Unlike MH, where you can always find out what's in your folder with scan, xmh only rescans your folder every so often (depending on the CheckFrequency setting -- see the resource summary in the Table xmh Resources).

If you think xmh doesn't have the latest view of the folder, use the Rescan Folder command on the Table of Contents menu. (The accelerator is META-SHIFT-R.) This is good to do after you've used some MH commands from, say, an xterm window.

Viewed Message vs. Viewed Folder

The viewed message area of the main window will hold a view of one message. It can even be a message from a different folder than the viewed folder. The Figure below is viewing a message from the drafts folder, but with a different folder and sequence selected in the Table of Contents. You might want to do this if your screen is already full of windows and you don't want to open a separate window on a separate folder.

Figure: Message and Table of Contents from different folders


Packing a Folder

If you use the Pack Folder command on the Table of Contents menu, messages in the folder will be renumbered as 1, 2, 3, and so on. This closes gaps caused by removing messages (if you don't pack the folder, the messages aren't renumbered). MH and xmh don't care much what numbers your messages have, although xmh isn't happy with message numbers larger than 9999. Packing a folder also avoids errors in the sequence file if the folder gets too fragmented; the NOTE in the Section Previous-Sequence, Sequence-Negation explains what to do if this happens to you.

Sorting a Folder

To sort the messages by date from oldest to newest use the Sort Folder command. (Depending on the version of MH you're running, this may also renumber the messages starting from 1 (like packing the folder). Check your online sortm(1) manual page.)

The first Figure below is an example of a folder before sorting. The next Figure below shows the same folder after sorting.

Figure: Folder before sorting


Figure: Folder after sorting


Notice that one of the messages has an asterisk (*) by the number. This means that there's no acceptable Date: field in the header -- so xmh shows the date that the message file itself was modified. The message from the MH sortm command pops up in a dialog box.

After sorting, the messages don't seem to be in date order (message 3 was sent on November 23, but message 4 was sent on February 9?). But the dates are in order -- the date sort pays attention to the year. For instance, message 3 was sent in 1989. If a message doesn't have an acceptable date, the sort tries to keep the message in about the same relative position it was before -- but, as you can see, this doesn't always work.

If you have the MH 6.7 or later version of sortm, you can change it to sort by other fields. For instance, it can sort by subject. The Section Sorting Messages: sortm explains sorting switches.

You can set default sortm switches in your MH profile, so you always get one kind of sort. You can also set up xmh buttons that run the edprofile shell script -- to change the sorting order at any time while you're running xmh.

Deleting a Folder

The Delete Folder command on the Folder menu deletes the selected folder and all messages in it. Before it deletes the folder, xmh will list it in the Table of Contents. Then, it will will ask for confirmation in a dialog box.

NOTE: Delete Folder deletes the selected folder, not the viewed folder.

Even though the dialog box is up, you should be able to browse through the Table of Contents, view messages, and so on. When you're sure, click Yes.

CAUTION: When you delete a folder, there's no going back. Be careful...

[Table of Contents] [Index] [Previous: Printing Your Mail] [Next: Introduction to Sequences]

Last change $Date: 1996/06/06 15:12:02 $

This file is from the third edition of the book MH & xmh: Email for Users & Programmers, ISBN 1-56592-093-7, by Jerry Peek. Copyright © 1991, 1992, 1995 by O'Reilly & Associates, Inc. This file is freely-available; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation. For more information, see the file copying.htm.

Suggestions are welcome: Jerry Peek <>