# Edit Messages with show: mhedit

Edit messages with the show command? It sounds strange, but it works just fine. When you run show or a version of it, it first changes its current directory to your MH directory. Then show gets relative pathnames to the messages in the folders. Finally, it gives the pathnames to its showproc command. You can use any showproc command -- including a text editor, as long as the editor can handle more than one filename on its command line. In this example, I'll use vi.

> NOTE: In most cases, this doesn't work with MIME messages because show calls mhn or mhshow instead of its showproc. An easy way to edit MIME messages is by writing a short shell script. (There are directions in the Section Writing Shell Scripts for MH.)

>           #!/bin/sh
>           exec your-editor-here `mhpath ${*-cur}`

> If you name messages, the script will edit them. It defaults to the current message.

The time I usually edit messages is before I archive them in a folder: a message might include a long chunk of another message that I want to delete. When I get programs in the mail, in shar files, I start an editor on the message, write the program to a separate file, and save the rest in the message.

To make mhedit as a version of show, see the Section Making a New Command Version. To make an alias or function, see the Section Writing Command Versions as Aliases or Functions.

Add the following entry to your MH profile, or add the arguments to your alias or function. (Replace `vi` with another editor if you want to. But be sure that the editor can handle multiple files in case you give mhedit more than one message number. For instance, ed(1) won't do.)

        mhedit: -noheader -showproc vi