NAME
mha-mhedit - MH/nmh reply editor for multipart, non-text/plain messages
SYNOPSIS
repl -editor mha-mhedit
DESCRIPTION
mha-mhedit nicely formats MIME messages for use with MH/nmh's repl(1) command.
A big deficiency with MH/nmh's repl
is that it is not MIME aware, or more technically, repl filters are not MIME aware. Consequently, if replying to a multipart, non-plain text message, and your repl filter includes the body of the message being replied to, all the MIME formatting is included, which can be messing for binary data, like images, and for quoted-printable text.
mha-mhedit is designed to be used as the repl
editor:
repl -editor mha-mhedit
mha-mhedit is designed to functional transparently. mha-mhedit formats and quotes the reply-to message body for editing in the message draft. After the formatting is complete, mha-mhedit invokes your regular editor for final composition.
mha-mhedit does its job by using MHonArc, <http://www.mhonarc.org>, with a specially crafted MHonArc resource file, and by using a text-based HTML viewer, like w3m, <http://w3m.sourceforge.net/>. Of course, a tool can be developed that does not depend on these types of tools, but I did not feel like developing one and these work well for what I wanted.
mha-mhedit can be invoke by default when using repl
by having the following in your .mh_profile
:
repl: -editor mha-mhedit
However, since using mha-mhedit adds some extra initial overhead before your regular editor is invoked, you may choose to define a shell alias instead:
(t)csh:
alias mrepl repl -editor mha-mhedit
bash:
alias mrepl="repl -editor mha-mhedit"
Therefore, if replying to a MIME messages, you enter mrepl
at your shell prompt and continue to use repl
for plain text messages.
Note: It is recommended to have something like the following in your .mh_profile
:
mha-mhedit-next: <your-editor>
This way, at the What now?
prompt, if you enter edit
, it will invoke your regular editor again instead of calling mha-mhedit, which will cause all your edits to be lost.
OPTIONS
Options can be defined in your .mh_profile
like any other MH/nmh component. For example:
mha-mhedit: -editor vim
The following options are available:
- -editor editor
-
Text editor to invoke at the end. If not specified, the value of the Editor profile component, the EDITOR environment variable, or
vi
is used.Arguments to the editor can be defined by setting the
mha-mhedit-editor
profile component. For example, if your editor is set tovim
, the following can be added to your.mh_profile
to have vim start at the end of your reply:mha-mhedit-vim: +
- -htmlconv command
-
Command that converts HTML to plain text. The command must be able to take HTML from stdin and dump plain text to stdout. If the command requires arguments. If not specified, then
w3m
is used.You can define arguments to give the specified converter by defining the
mha-mhedit-htmlconv
profile component in your.mh_profile
. For example, the following represents the default arguments used if-htmlconv
isw3m
:mha-mhedit-w3m: -dump -cols 76 -T text/html
The following works well if
-htmlconv
is set tolynx
:mha-mhedit-lynx: -stdin -dump -force_html -nolist -width=76
- -linelen number
-
Maxium line length of formated reply text. If the orginal message contains lines longer then
-linelen
, the lines will be wrapped. Default value is 76. - -mharc pathname
-
Pathname to mhonarc resource file. If not specified, the file
mha-repl.mrc
in your MH/nmh directory.Note: If a resource file is not found, mha-mhedit aborts execution. If using a custom resource file, be careful of settings that could create extra files during mail-to-html conversion.
- -mhonarc pathname
-
Pathname to mhonarc program. If not specified,
mhonarc
is used.You can define extra arguments to give
mhonarc
by defining themha-mhedit-mhonarc
profile component in your.mh_profile
. However, I'm unsure if you will ever need to. - -quotechars chars
-
List of characters denoting the start of a quoted line in a message. This option affects is used during line wrapping when detecting for quoted lines.
The default value is
>
. - -quoteprefix string
-
String to prepend to each line of text being responded to. The default value is "
>
" (greater-than sign followed by a space). - -tmpdir pathname
-
Pathname to directory to use for temporary files. If not specified, then the TMPDIR environment variable is used or the path location of Draft-Folder profile component.
- -help
-
Display help information.
- -man
-
Display entire manpage.
INSTALLATION
Copy the mha-mhedit program to somewhere in your search path. Copy mha-repl.mrc into your MH/nmh directory.
NOTES
mha-mhedit is designed to work friendly with your normal replcomps and repl filter. mha-mhedit reads the head of the draft created by repl in order to preserve it after formatting the initial message body. mha-mhedit preserves the replcomps message header and up-to the next 5 lines afterwards that does not look like quoted reply text generated from the repl filter (mha-mhedit assumes that the a line starting with a '>' denotes the begining of quoted reply text).
If I have lost you, here is the replcomps I have:
%(lit)%(formataddr %<{reply-to}%?{from}%?{sender}%?{return-path}%>)\ %<(nonnull)%(void(width))%(putaddr To: )\n%>\ %(lit)%(formataddr{to})%(formataddr{cc})%(formataddr(me))\ %<(nonnull)%(void(width))%(putaddr cc: )\n%>\ %<{fcc}Fcc: %{fcc}\n%>\ %<{subject}Subject: Re: %(putstr(trim{subject}))\n%>\ From: Earl Hood \<earl@earlhood.com\> Reply-To: Earl Hood \<earl@earlhood.com\> %<{date}In-reply-to: %<{message-id}%{message-id}%>\n%>\ %<{message-id}References: %<{references}%(void{references})%(trim)%(putstr) %> %(void{message-id})%(trim)%(putstr)\n%>\ -------- On %(lmonth{date}) %(mday{date}), %(year{date}) at \ %02(putnumf(hour{date})):%02(putnumf(min{date})), \ %<{from}%(friendly{from})%|you%> wrote:
And the repl filter (repl.filter) I use for quoting the body of the reply-to message:
leftadjust,compwidth=14 body:component=> ,overflowtext=> ,noleftadjust
The replcomps file includes a preamble in the message body providing the date and person who wrote the message I am replying to.
My repl.filter causes the reply-to message body to be included in the composition draft quoted with "> " before each line.
mha-mhedit automatically reads the initial draft header (everything up to the
--------
). After that, mha-mhedit reads up-to the next 5 lines for potential inclusion. The body preamble in my replcomps takes up 2 lines (there is a trailing blank line that may not be easily noticed above). Therefore, mha-mhedit will preserve it. The third line will be the start of quoted text. mha-mhedit sees this, and stops reading the draft.Now, if I plan to make mha-mhedit my default repl editor, it will be more efficient if I remove the message body quoting since mha-mhedit will ignore and overwrite anyway.
Currently, no temporary files should be generated. However, this depends on the version of mhonarc you are using, the type of message being replied to, and any edits you may make to the mhonarc resource file.
It may be possible that by-product files, like attachments, could be created. If so, manual deletion of the files in
-tmpdir
will be required.
FILES
$HOME/.mh_profile
-
Profile definitions.
<mh-dir>/mha-repl.mrc
-
MHonArc resource file. The resource file can be explicitly defined via the
-mharc
command-line option.
MH/nmh PROFILE COMPONENTS
mha-mhedit
-
Arguments to mha-mhedit.
mha-mhedit-editor
-
Arguments to pass to editor invoked by mha-mhedit, where editor is the name of the editor.
mha-mhedit-htmlconv
-
Arguments to pass to html-to-text converter, where htmlconv is the name of the html-to-text converter program.
mha-mhedit-mhonarc
-
Extra arguments to pass to mhonarc.
Editor
-
Text editor.
ENVIRONMENT
EDITOR
-
Default editor.
TMPDIR
-
Location of temporary files.
DEPENDENCIES
- MHonArc
-
MHonArc, <http://www.mhonarc.org/>, is used to translate the raw message into HTML. MHonArc is used since it conveniently combines multipart, non-plain text, messages into a singe HTML document.
- w3m
-
w3m, <http://w3m.sourceforge.net/>, is used to translate HTML generated by mhonarc into format plain text.
An alternate converter program can be used via the
-htmlconv
option. It must be able to take HTML as standard input and dump formated text to standard out.
VERSION
$Id: mha-mhedit,v 1.2 2003/01/04 21:11:26 ehood Exp $
AUTHOR
Earl Hood, earl@earlhood.com
Copyright (C), 2002. This program comes with ABSOLUTELY NO WARRANTY and may be copied only under the terms of the GNU General Public License.