[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Nmh-workers] De-MIMEing

From: Ken Hornstein
Subject: Re: [Nmh-workers] De-MIMEing
Date: Mon, 15 Jul 2013 15:28:26 -0400

>Specifically, I need to understand the steps, and the ordering of the
>steps that the "repl" command undertakes, and also I need to understand,
>for whatever thing is named as the -editor in the repl options within
>the .mh_pfofile file, where does it get its input from and where must
>it place its output?

I'll try to explain that, as it's not very well documented (various
pieces are, but there's no "big picture" that explains how it all
works).  I'll try to explain the differences between Earl's approach
and what I did.  I think both are valid; Earl had his reasons for his
approach, and I had my own.

>So, for example, I currently have the following within my .mh_profile file:
>repl: -cc all -nocc me -query -annotate -inplace -filter Repl.mhl -form 
>It could be just because I did not get enough sleep last night, but I don't
>even remember at the moment what most of this stuff even does, exactly.

There is a man page for repl that explains most of that, but let's break
down the things you care about.

The ones that concern us are the "-filter" and "-form" options.  "-form"
means use the specified form file instead of the default of replcomps.
That's used to build the reply draft.  If you specify -format, then
mhl is used to format the body of the draft message (you specify "-filter",
which tells mhl to use the specified template for formatting; that implies

So, the flow of execution is basically something like:

1) repl uses mh-format(5) routines to write out our message draft
2) Assuming -format, mhn is run on the original message and the result is
   appended to the message draft.  mhl takes the original message on standard
   input and writes the result to standard output.
3) The editor is invoked with one argument, the name of the draft message
4) After the editor is run, you're generally at a WhatNow? prompt and you
   then send the message.

mha-mhedit and replyfilter use two different types of magic.

What mha-mhedit does is run as a replacement editor for step 3) above.
But the magic here is that when repl invokes the editor, the special
environment variable "editalt" is set to point to the filename of the
ORIGINAL message (the one you're replying to).  So mha-mhedit parses the
message draft, snips out everything at the point where it starts seeing
the quoted text in the message draft, and then uses the original message
to construct a new, replacement body for the message draft.  It then
arranges to run your "real" editor.

replyfilter gets hooked into mhl as part of step 2) above. replyfilter's
magic is new functionality in mhl that allows the "body" component of a
message (basically, the whole body as one big piece) to be processed via
an external program.  So replyfilter receives the body of the message
on standard input, processes it, and sends the de-MIMEified message to
standard output. mhl is reading the output from replyfilter (or any
program you specify) and writing it to _mhl's_ standard output, where it
is eventually being read by repl and ends up in the message draft.  You
edit the resulting draft with your standard editor.  The wrinkle here
is that replyfilter only has access to the body of the message, due to
complications with mhl; the extra MIME headers it needs are passed as
command line arguments (see replyfilter for details; exactly how this
works is specified in the comments at the top).

I have nothing against mha-mhedit's approach; my motivation was to have
a solution that could work with third-party programs; you can't easily
use mha-mhedit with something like exmh, for example (or at least it
wasn't obvious to me).

Confused? :-)  Now you know how the sausage is made.  If you have
further questions, please don't hesitate to ask.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]