By default, the show command puts all of your message, including "boring" header fields like Received:, onto your screen.
You can change the way that your message is shown by deleting these header fields, folding lines that are too long for your terminal, and so on. You can print your messages with neat margins and a header line at the top of the page. Here's how MH displays non-MIME messages. This is good background for the Section Reading MIME Messages, which explains how MIME messages are displayed.
% show 1 3 5 ...the last message (5) becomes the current message.
To set this up, pick a name for the unseen sequence (I call mine unseen).
(Note that MH will keep more than one unseen sequence, if you need that. Add other sequence names to the Unseen-Sequence: entry, separated with spaces. All the unseen sequences will have the same message lists in them. You can use the mark program to modify one or more of them, though.)
Put an entry in your MH profile:
Unseen-Sequence: unseenRemember that in MH, you can use a sequence name any place you can use message numbers. For example, to get a list of the messages you haven't read, you can use:
% scan unseenIf you have MH 6.7.2 or later, you can tack on a range specification like :first or :last. For instance, to read the first unseen message, remove it, then read the rest of the unseen messages one-by-one:
% show unseen:first
...
% rmm
% show unseen:next
...
% rmm
% !s C shell history: repeats previous show command
...
If you've already read some of the messages -- that is, there are "gaps" in the unseen messages, show unseen:next will step through the unseen messages. When you've seen all the messages, you'll get "show: no unseen:next message."
Would you like an automatic list of your unread messages as you log in? Use lines like those in the Example below to your .login or .profile file. If there are messages in your unseen sequence, you'll get a scan listing.
Examples: Automatic scan of unread messages
C shell
mhpath unseen +inbox >& /dev/null if ($status == 0) then echo "Unseen mail in inbox:" scan +inbox unseen endifBourne and Korn shells:
if mhpath unseen +inbox >/dev/null 2>&1 then echo "Unseen mail in inbox:" scan +inbox unseen fiEach folder keeps its own unseen sequence, but it's mostly useful in the inbox. As of this writing, no version of xmh supports the unseen sequence.
Our system manager and I get status reports from uucp. I ignore them unless he's out of the office. This Example shows how I delete them quickly:
Example: Finding and handling a group of messages quickly
% inc Incorporating new mail into inbox... 155+ 01/09 uucp uu-status<<LCK..cuZ2: 23283 LCK..cuZ3 ... 189 01/09 Tim O'Reilly New edition of MH & xmh<<How are the % pick -from uucp -seq temp cur-last 12 hits % scan temp 155+ 01/09 uucp uu-status<<LCK..cuZ2: 23283 LCK..cuZ3 ... more messages from uucp... % rmm tempFirst I find the messages with pick and store them in the temp sequence. (I use pick cur-last because that'll be all the messages inc brought in. As the Section Messages You Haven't Read explains, pick unseen would check the same messages -- though it might also include older messages I hadn't read yet.) A quick review with scan (and maybe show on a few) makes sure there's nothing I need to see. So, I remove the messages. There's more about this in the Sections Find and Specify with scan, pick, Ranges, Sequences and Storing Message Numbers in MH Sequences.
What if I decide not to remove one of the messages in that temp sequence? I can use mark -delete to take the message out of the sequence before I run rmm.
% show cur:1In MH, cur has the current message number, even if it's been deleted. The :1 is a range with one message in it -- your online mh-sequence(5) manual page has details. Of course, ranges usually have more than one message -- such as first:10, the first ten message numbers in the folder. But there's nothing wrong with cur:1 -- it means "up to one message in the range beginning with the current message." If the current message doesn't exist, MH automatically finds the next message number in the folder.
If that command is too cryptic to remember, you might want to stick it in a shell alias or function named something like nx. Then you can use nx to read the current or next message, whichever.
% show -showproc lessIf you like the less viewer or any other file viewer, you can make that viewer the default for all messages you read. Put an entry like this in your MH profile:
showproc: lessBefore show starts the showproc, it prints a header line with the folder name and message number:
(Message inbox:24)Usually, that's convenient. Sometimes it isn't. For example, when you're printing a message that fits onto a page exactly, the extra header line can make the page too long. The UNIX pr(1) program does that kind of message formatting. It formats a file for printing, with a header and page number, one message per page. By default, pr output goes to the terminal, not the printer. But you can use a standard UNIX pipe to send output to your printer program (often called lp or lpr). For example, here's how to print the last three messages, formatted with pr, on the lpr printer:
% show -noheader -showproc pr last:3 | lprThe -noheader switch tells show not to output (Message folder:Number). Of course, that command line is pretty long. A shell alias or function can shorten it to something like:
% msgpr last:3The Section Custom Printing: showpr shows a shell program that does even more.
If you need to edit a message you've received from someone else, the show command can do that too! Just set your showproc to be...a text editor. The mhedit command version makes this convenient.
Setting the showproc doesn't work the same way for multipart MIME messages. The showproc may be run several times, once for each part, on temporary copies of the parts. (There are details in the Section How mhn Shows a Message.) Even a single-part MIME message may still need to be decoded before you can print it. There are two fairly simple ways to print MIME messages:
% mimecat 26 | lpr -PlaserYou could also adapt mimecat to send contents directly to a printer; the details in the explanation of mimecat should help.
CAUTION: Some graphic file formats may contain commands that can be dangerous security holes. For instance, PostScript files can hold commands that can change printer settings -- or even delete other files! If you get a PostScript or other interpreted file from someone you don't trust, be careful.
Example: Showing a message without mhl
% show (Message inbox:14) Received: by mysun.xyz.edu (5.54/ACS) id AA22457; Mon, 09 Jan 1995 10:32:37 EST Received: from cliff.xyz.edu by asun.xyz.edu (4.1/CNS) id AA00488; Mon, 09 Jan 1995 10:24:44 EST Message-Id: <9501091524.AA00488@asun.xyz.edu> Received: by cliff.xyz.edu (4.1/SMI-4.0) id AA00220; Mon, 09 Jan 1995 10:24:42 EST To: jdpeek@mysun.xyz.edu, nancyp@hersun.xyz.edu To: ed@hissun.xyz.edu Subject: X Terminal Presentation/Demonstration next week; be there, please Date: Mon, 09 Jan 1995 10:24:39 -0500 From: "Wilbur, Orville" <owilbur@asun.xyz.edu> Vince Molino from NAC Corp. will give a short presentation ...Example: Showing a message with default mhl formatting
% show -showproc mhl (Message inbox:14) -- using template mhl.format -- Date: Mon, 09 Jan 1995 10:24:39 EST To: jdpeek@mysun.xyz.edu, nancyp@hersun.xyz.edu, ed@hissun.xyz.edu From: "Wilbur, Orville" <owilbur@asun.xyz.edu> Subject: X Terminal Presentation/Demonstration next week; be ***there, please ...Unless your system has a different default or you customize it, mhl does what you saw in the second Example:
NOTE: When mhn shows MIME messages with mhl, it splits the message into header and body parts; the parts are shown separately. The techniques in this section don't apply directly to MIME mail. There's more information in the Section How mhn Shows a Message.
To use mhl on a single message, give it as the showproc on a command line:
% show -showproc mhlIf you like mhl, you can use it to show all messages by putting this entry in your MH profile:
showproc: mhlOr you can add separate entries for individual mail-showing programs:
show: -showproc mhl next: -showproc mhl prev: -showproc mhlIf you've set mhl as the default, you can override that default temporarily by typing the name of a different showproc on the command line:
% show -showproc more % show -showproc pr 3-7 | lprmhl reads a format file that sets the appearance of your messages. The default format file is called mhl.format and is in the system MH library directory. You can copy the system mhl.format file into your MH directory and customize it. For example, to copy it and edit it with vi:
% cd Mail % cp /usr/local/lib/mh/mhl.format . % vi mhl.formatThe next example shows the message above with my customized mhl.format file and showproc: mhl in my MH profile:
Example: Showing a message with customized mhl formatting
% show (Message inbox:14) -- using Jerry's mhl.format template -- Date: Mon, 09 Jan 1995 10:24:39 EST From: "Wilbur, Orville" <owilbur@asun.xyz.edu> To: jdpeek@mysun.xyz.edu, nancyp@hersun.xyz.edu, ed@hissun.xyz.edu Subject: X Terminal Presentation/Demonstration next week; be ***there, please Vince Molino from NAC Corp. will be giving a short presentation ...To make your own mhl.format file, see the Section Default mhl Format File for show.
Of course, you can pipe the output of show -noshowproc to another program -- for instance, a separate pager like less(1), or a program like od -c or (on some systems) cat -v that displays "unprintable" characters. (The C shell alias showv, sends output to a pager.) You can also use the shell's > and >> operators to redirect show output into a file.
That may not always be what you want! And it's a real surprise to people who have used monolithic user agents. If you don't want information to be shared between MH sessions, or kept after you log out, you can make separate context, sequence or MH profile files. The MH sessions that use separate copies of some or all of those files will be independent. Then you can do things like browsing through the messages in one folder while you remove messages from another folder; you don't need to constantly type folder-changing commands. This is also a way to stop accidental interactions between a standard MH session and a session with an MH front-end like xmh; otherwise, changing the current folder or message from MH without telling the front-end about the change can cause some real problems.
The Figure Important parts of a UNIX filesystem shows the parts of a UNIX filesystem that MH uses. Three files control the MH session:
Example: Separate MH sessions with different current folders
projects/beta folder summaries folder % scan +projects/beta % setenv MHCONTEXT /tmp/myctx$$ ...scan listing... % folder +summaries % show 27 summaries+ has 1540 messages ( 1-1826) (Message projects/beta:27) % show last ...message appears... (Message summaries:1826) % ... ...message appears... ... % unsetenv MHCONTEXT % rm /tmp/myctx$$The context filename can be any absolute pathname. I picked a temporary file, in /tmp, with a unique name that includes the shell's process ID number (from the $$ shell variable). That name will be different in every shell running on a system. If you want to keep the same context, session-to-session, you should choose a filename somewhere else -- in your MH directory, for instance. If several people share the same account, you could make context files named context.carol, context.jake, and so on.
Changing the context file doesn't affect public sequences in a folder. If two people are working in the same folder, or you have two windows open on a folder, changing the current message in one session may cause grief in the other session. So, if the account isn't already set up to use private sequences, you can make one or both sessions use them. To do this, make an empty mh-sequences: entry (with no filename after it) in the MH profile. If you want one session to use public sequences, and another to use private sequences, make a copy of the MH profile and put an empty mh-sequences: entry in the copy. The next example shows that for the Bourne shell (and Korn shell, bash, etc.):
Example: A second session with different current folder and sequences
$ cd $ cp .mh_profile /tmp/profile$$ $ MH=/tmp/profile$$ MHCONTEXT=/tmp/context$$ $ export MH MHCONTEXT $ emacs $MH ...edit temporary profile, add empty mh-sequences: entry $ show some-message +some-folderIn the Example above, the new context file won't have any sequences defined when you start. (Remember, the empty mh-sequences: entry means that sequences are stored in the context file.) If you have public sequences defined that you'd like to copy to the second session, you can copy the .mh_sequences file from the folder into your new context file. But the two file formats are different. A sequence in the .mh_sequences (public sequences) file looks like this:
urgent: 2 4 9 16-19A private sequence in the context file contains the folder pathname. Here's an example of the urgent sequence for the project folder:
atr-urgent-/home/andy/Mail/project: 2 4 9 16-19As you copy the sequences, you need to change the label at the beginning of each entry. Be careful not to break or truncate long entries. Worse, the format of public and private sequence files isn't documented (as far as I can tell), so it could change. If you do this often, you'll want a little Perl script to do the conversion automatically. And, when you're done in the private session, do you want to copy the sequences back to the folder's public sequence file? Maybe you should have defined a different public sequence filename in the temporary MH profile:
mh-sequences: sequences.tempAs you can see, there are lots of possibilities. We're getting beyond the scope of this chapter. By understanding the principles in this section, though, you can do almost anything you need to do in multiple MH sessions.
% show 23 24 29 | lprOr, as the Section Changing Showproc for Viewing, Printing, and Editing shows, you can use pr(1) to make simple headers (with the folder and message number), to make page numbers, and to start each message on a new page:
% show -showproc pr 23 24 29 | lprThe showpr program, in this book's online archive, lets you do more. It can use mhl to clean up each message before printing. You can customize the page heading -- to include the message subject, for instance. And you can pass options to pr to tell it how to format your message. You can store default showpr options in your MH profile.
You can use mh-format strings on the showpr command line -- like the ones you'd give to the scan command.
Here are some examples. Some of these might look pretty complicated to type just for printing a message. But remember that you can store any set of options as defaults in your MH profile:
% showpr | lpr
% showpr -mhl -pr '-f -l50' last:3(You can shorten the options to -m and -p, if you want.)
Dec 17 08:49 1995 From: Al Bok Date: 01/09/1995 Page 2Use a command line like this (split onto two lines here for readability):
showpr -mhl -format 'From: %(friendly{from}) \ Date: %(mon{date})/%(mday{date})/%(year{date})' last:3 | lprTo make that easier, you could put the following entry in your MH profile:
showpr: -m -f 'From: %(friendly{from}) Date: %(mon{date})/%(mday{date})/%(year{date})'Then get that formatting and print your messages with:
% showpr last:3 | lpr
Here's how to set up showpr.
% show 1-5 ...By default -- except with MIME messages -- show hands each message separately to your pager program. When your showproc is a pager like more or less, your pager's "next file" command (like :n) will skip to the next message, Of course, you can also quit in the middle of the messages with your pager's "quit" command -- like q in more and less.
When you show more than one message at a time with mhl as your showproc, the messages will be shown in a stream:
% show 1825 1826 >>> inbox:1825 -- using template mhl.format -- Date: Tue, 10 Jan 1995 15:24:39 EST ... >>> inbox:1826 -- using template mhl.format -- Date: Wed, 11 Jan 1995 02:29:03 PST ...This surprises people who've just started using mhl because the "next file" command in their pager program (like :n in more and less) doesn't skip to the next message anymore. You can work around the problem by using your pager's search command to find the message-number marker at the top of the next message. Searching for >>> may be enough. If messages contain that string, though, you can be more exact. For instance, if you're reading mail from the inbox folder -- as in the example above -- use the search command:
/^>>> inbox:and repeat it, using the pager's n command, to go to each following message.
[Table of Contents] [Index] [Previous: Chapter Introduction] [Next: Reading MIME Messages]
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 <jerry@ora.com>
HIVE: All information for read only. Please respect copyright! |