# Replying to Mail with repl

The repl command is flexible -- there are a lot of great features that weren't covered in the introduction.

You don't have to reply to everyone who got the original message, and repl -query makes it easy to choose who gets your reply. The -nocc and -cc switches give you another way to choose. This section covers several different ways to include the original message in your reply. The original message can be marked automatically when you reply to it. And there's more.

## Selective Replies with -query

By default, when you reply to a message, repl will send a copy of your reply to everyone who got the original message -- that includes the author, you, and all addresses in the `To:` and `cc:` fields. If you don't want that to happen all the time, repl can ask you. Just start repl with its -query switch. You can type it on the command line, just for particular messages:

        % repl -query

Or, if you like -query enough to use it most of the time, you can add it to your MH profile -- then, whenever you don't want -query, you can use -noquery on the command line:

        % repl -noquery

Now, for a demonstration of -query. First, show part of the message. Then, start `repl -query` and send copies of the reply only to a couple of people. Compare the addresses in the original message with the header of the reply:

        % show last
        (Message mh-users:8)
        Date:  13 Nov 89 00:28:18 GMT
        From:  Al Bok <al@phlabs.ph.com>
        To:  mh-users@ics.uci.edu
        cc: auser@quack.phlabs.ph.com, aguru@mt.top.ph.com
        Subject:  Query about "repl -query"

        I have a question about repl -query...
            ...
        % repl -query
        Reply to Al Bok <al@phlabs.ph.com>? y
        Reply to mh-users@ics.uci.edu? n
        Reply to auser@quack.phlabs.ph.com? n
        Reply to aguru@mt.top.ph.com? y
        Reply to auser? n

        To: Al Bok <al@phlabs.ph.com>
        cc: aguru@mt.top.ph.com
        Subject: Re: Query about "repl -query"
        In-reply-to: Your message of "13 Nov 89 00:28:18 +0000."
        --------
        Al, I think this is the answer.  Guru, am I right?
            ...

If you hadn't used -query, your reply would have been addressed to all the original recipients.

(Notice the last query `Reply to auser?`. This happened because repl will automatically send a copy to you (auser) at your local address if your replcomps file tells it to. Even though auser's complete address (auser@quack.phlabs.ph.com) was already in the header, repl couldn't tell the difference, so it asked again. There are ways around these problems besides -query. See the Sections Selective Replies with -nocc and -cc and Defining Alternate Mailboxes.)

If you press your interrupt key (like CTRL-C) while -query is asking for addresses, repl will leave an empty draft message file. If you aren't using a draft folder, you'll get the prompt "Draft exists: disposition?" when you try again; just replace the empty draft. If you use a draft folder, it will fill up with empty drafts; a cron job that runs `find -size 0 -name '[1-9]*'` in the draft folder can remove those empty files.

A quick note to programmers: -query works with the (formataddr) function escape in your repl components file (like replcomps). If the format string doesn't use (formataddr), then the -query switch won't work.

## Selective Replies with -nocc and -cc

You can also tell repl to ignore certain fields in the message you're replying to -- that is, not to send copies to anyone in those field(s). Here are examples:

1. If you started with message 8 in the previous section again, the command:

             % repl -nocc to -nocc cc

   would have sent the reply only to Al Bok and you. You might ask: why you? (Let's assume you're auser.) Didn't you use `-nocc cc` to ignore the `cc:` field? Yes, but repl always sends a copy to you, by default -- unless, that is, you use the -nocc me switch.
2. To send a reply to only the `From:` field, you could type:

             % repl -nocc to -nocc cc -nocc me

   That's getting pretty long. Using -nocc all or -cc all lets you exclude or include `cc:`'s to everyone listed in the original message. You could do the same thing as the command above with:

             % repl -nocc all

3. You can use the -nocc and -cc switches together. The order of the switches on the command line matters. The last switch on the command line takes precedence. So to send a reply to only the `To:` addresses (not `cc:` or `me`), the first command below would work -- but the second one would not work:

             % repl -nocc all -cc to
             % repl -cc to -nocc all

   The first one works (sends a copy to the `To:` addresses) because `-cc to` comes last on the command line and thus undoes part of the `-nocc all`.
4. You can also put your -nocc switches in your MH profile like this:

             repl: -nocc cc -nocc me

   Then, for example, you can use the -cc switch when you want to include one of the header fields (overriding the -nocc switches in your MH profile):

             % repl -cc cc

## Changing the Message Header with replcomps

As you've seen, comp has a components file to control the header, and repl has its replcomps file. The replcomps file is different, though, because it not only controls which lines are included in the header of the reply but also controls what is filled into each field and how it's formatted. This is good to understand because the default replcomps ignores some of the addresses that you might want to reply to!

For more information, see the Section The replcomps File.

## Reading Original Message with an Editor

When you reply to a message, you may want to include parts of the original message in your reply. That's especially true if someone besides the original readers gets a copy of your reply or if there's something controversial or important that should be seen exactly as written.

One way to do that is by editing your reply with a text editor like vi which can read other files. repl lets you read the original message file through a link named @ (at sign). (On systems that use an at sign (`@`) as the line-delete character, type `\@`.) For example, with vi, just move to the bottom of the draft reply and type:

        :read @

If it doesn't work, check to see whether you started repl from a read-only directory or if your current directory is on a different filesystem than the original message. In those cases, UNIX can't make a link to the original message. This Section has an alias for repl that pops you back to the filesystem where the links can be made. Also, many versions of Emacs change their current directory to the directory where the draft is; if your editor does that, reading @ will be a pain.

Depending on your editor, you may also be able to read the original message by using the editalt environment variable. In vi, for instance, type:

        :read $editalt

If neither of those works, the mhpath command can find the pathname for you. For example, you can always read the original message by typing the command in backquotes (```). For example, in vi, enter:

        :read `mhpath cur`

The Section Shell Command Substitution covers backquoting. You'll also want to know about The mhpath Command.

Another way to add the original message is with a program like append -- you use it at the `What now?` prompt.

Finally, the Section Including the Original Message with -filter has what might be the best way of all.

## Including the Original Message with -filter

Another way to include the original message in your reply is by using a filter file and the repl -filter command. A filter file uses mhl message-formatting instructions to control which lines of the original message are included in the reply and how they're formatted.

This isn't the place to explain mhl in depth. If you're interested, look at the Section mhl. Otherwise, here's some "cookbook" help.

For instance, to make a filter file that includes the original message in your reply, indented by eight characters, put the following two lines into a file named something like replfilt (the exact name doesn't matter) in your MH Mail directory:

        :
        body:nocomponent,compwidth=9,offset=9

Be sure that there's no space between `body:` and `nocomponent`. Then, reply to the message this way (use the original message number and other switches, as well, if you need to):

        % repl -filter replfilt

A lot of people like to include the original message with the right angle bracket (`>`) and a space before every line of the original, like this:

        % repl -filter replfilt
        To: Al Bok <al@phlabs.ph.com>
        cc: aguru@mt.top.ph.com
        Subject: Re: Query about "repl -query"
        In-reply-to: Your message of "13 Nov 89 00:28:18 +0000."
        --------
        > I have a question about repl -query.
        > Why does it ask twice if I want a copy of my reply?

        Al, that's because repl automatically sends a copy
            ...

To do that, make your replfilt file look like this:

        body:component="> ",compwidth=0

Note that the right angle bracket has a space (blank) after it (`>` ). The blank(s) are optional; depending on how you want the original message indented, you can use no, one, or several blanks. Also note that some earlier versions of MH would either put the right angle bracket (`>`) only before the first line of the included reply or insert a > in the middle of some lines of text. If your version of MH does either of these, you'll need a newer version of MH, such as MH 6.7.

You can make that the default by adding -filter replfilt to a `repl:` entry in your MH profile. There's a problem with adding that entry to your MH profile, though: after you do that, it will be hard to reply to a message without that replfilt formatting. (repl doesn't have a -nofilter switch.) The Section Versions of repl shows some ways to make all of this easier. For instance, you can fix your own mail environment so that you can type replx to use your filter file or repl to reply without including the original message. To add text to the end of each reply, see the Section Automatic Signature on End of Messages.

## Displaying the Original Message

At a `What now?` prompt, you can type `display` or just `d` to show the original message on your screen. (This is different than `list`, which shows the draft reply.)

## Annotating the Original Message

If you use the -annotate switch -- on the repl command line or in your MH profile -- the message you reply to will have fields like these added to its header:

        Replied: Mon, 09 Jan 1995 18:28:46 -0500 Replied: Al Bok
        <al@phlabs.ph.com> Replied: aguru@mt.top.ph.com

This lets you know that you've sent a reply -- a useful feature for busy or absent-minded people.

By default, scan looks for these `Replied:` fields in messages. It marks these messages with a dash (`-`) in the listing. For example, here are two messages; you've replied to the second one:

           5  01/09 Al Bok             The next project...<<...is going to be
          11 -01/10 Donna Lewis        About the next project...<<Al, I'm won

## Replying to Messages with MIME

If you get a single-part message and you want to send a multipart MIME reply, this section shows an easy way: Add a `#forw` directive that includes the original message. If you want to edit the included message, edit the draft with mhn or mhbuild, then start a text editor to clean up the included part.

        % repl 86
        Reply to "Emma H. User" <ehuser@x.y.com>? y
        From: Jerry Peek <jpeek@jpeek.com>
        X-Mailer: MH 6.8.3
        To: "Emma H. User" <ehuser@x.y.com>
        Fcc: inbox
        Subject: Re: Reviewers needed for book chapters about MIME under MH
        In-reply-to: Message from "Emma H. User" <ehuser@x.y.com>
           of "Mon, 09 Jan 1995 12:22:47 -0800." <1995Jan09.122251pst.7395@x.y.com>
        --------
        #forw
        #<text/enriched [my reply]
        Emma, it would be <bold>great</bold> if you have time to
        ...omitted...
        #text/x-sgml [X User Tools article] /u/jerry/mh-book/xpt_article/2021.sgm
        #image/x-xwd [overall view] /u/jerry/mh-book/xpt_article/exmh.allwin.xwd
        #image/x-xwd [folders] /u/jerry/mh-book/xpt_article/exmh.folders.xwd
        #text/plain [Xhibition article] /u/jerry/mh-book/exmh.Xhibition/article

        CTRL-D
        --------
        What now? e mhn    (...or, in nmh, mime...)

        What now? e vi
            ...edit first part (original message excerpt)...
        What now? p
        %

MH 6.8.4 and nmh-0.09 added a new repl switch: -mime. It does what example above did: adds a `#forw` directive to include the message(s) you're replying to.

Unfortunately, using the `#forw` directive doesn't let you select one part of a multipart message. It also doesn't undo quoted-printable or base64 encodings so that you can include (and edit) the original message text. One workaround is to use the mimecat script to pull in the original draft, unencoded. For instance, to read part 2 of the original (current) message into your draft, add an appropriate directive:

        #text/plain [your message] |mimecat -part 2

If you want to edit the included text, use a `#<` directive instead:

        #<text/plain [your message]

Then, as you're editing the draft, read in the original message part. For example, to read message 23 from the mimecat output with vi:

        :r !mimecat 23

As I write this, I hadn't found a replacement for repl that automates the job. If you hear of something good, please send me email. I'll update the archive and the book.