[comp.mail.mh] A hacked XMH to emacs interface

key@cs.utk.edu (Ken Key) (04/20/91)

Greetings Folks,

  I don't normally read this list, but a friend at Dartmouth, Tim Irvin,
mentioned that folks have been asking for an emacs interface to XMH.
I don't claim to have the real thing, but it does get faculty members
off my back.

What I've done is to modify R4 XMH to have a user extensiblity feature
(can you say "system()").  For those into .Xdefaults hacking for xmh,
you'll remember that you can add lines like:

Xmh*CommandButtonCount: 25
Xmh*commandBox.button1.label:   Inc
Xmh*commandBox.button1.translations:    #override        <Btn1Down>,<Btn1Up>: Xm
hIncorporateNewMail()unset()

That create button 1 and tie the XmhIncorporateNewMail function to it.

I've created two new Xmh functions:  XmhUserComm() and XmhUserMhComm().
The XmhUserComm just gives whatever argument you have straight to system.
An example is:

Xmh*commandBox.button18.label:  xpert
Xmh*commandBox.button18.translations:   #override\n\
        <Btn1Down>,<Btn1Up>:XmhUserComm(ref xpert > /dev/null 2>&1;
sync)XmhForceRescan()unset()
where "ref" is a shell script I have to sort my inbox into folders based on
the mailing list I'm on.  This particular button takes all the XPERT mail out
and then forces a rescan so I can look for more important mail (like the
homebrew digest :-) without the clutter of the 100 or so xpert mailings a day.


Now, what does this have to do with using EMACS.  The primary problem with
mixing MH and XMH is the fact that XMH maintains it's state internally while
the MH commands rely on the context file.  That's where XmhUserMhComm()
function comes in.  It appends the XMH current folder and current
message list to whatever command is tied to the button function.  For example:

Xmh*commandBox.button23.label:  mh-repl
Xmh*commandBox.button23.translations:   #override\n\
        <Btn1Down>,<Btn1Up>:XmhUserMhComm(xterm -e repl )unset()

will fire up an emacs window waiting for your MH reply, provided that
your editor is set to emacs in your ~/.mh_profile (or what have you). Note
you wind up having to place an xterm and then an emacs window.  The xterm is
around to run prompter in.  If you are just using vi, it puts you
in composition inside the xterm.  The reply will have the message number
corrisponding to the first in the message list.  Forward also works:

Xmh*commandBox.button25.label:  mh-forw
Xmh*commandBox.button25.translations:   #override\n\
        <Btn1Down>,<Btn1Up>:XmhUserMhComm(xterm -e forw )unset()

will set up a forward composition window containing all of the messages you
had highlighted in your XMH.

OK. I'll be the first to admit that it's not a real emacs interface.  But
then I use the X text widget for E-mail and don't mind.  What I really did it
for was to interface my mh shell script(s) to the xmh button boxes, the rest
was gravy.  It could use lots of extentions, but it does what I want.  If
someone does have a real emacs interface to the text widgets, blow this stuff
off and let me have a copy, too!!!

If anyone wants to try it out themselves, the xmh is available via anonymous
FTP from cs.utk.edu in /pub/xmh.shar.Z or E-mail me for copies (this may
be a mistake on my part... :-)  It's the full R4 XMH directory, except for
the icons/ subdirectory (my shar doesn't have a -R option :-(
My "ref" shell script is in /pub/ref.shar.Z on cs.utk.edu as well.  

Cheers,
Ken Key   (key@cs.utk.edu)