Edit Messages with show: mhedit

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

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 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

[Table of Contents] [Index] [Previous: Versions of forw] [Next: Show MIME Message Parts with showpart]


Last change $Date: 1996/06/06 15:10:05 $

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 <jpeek@jpeek.com>