[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Nmh-workers] temporary files
From: |
Jerrad Pierce |
Subject: |
Re: [Nmh-workers] temporary files |
Date: |
Thu, 15 Mar 2012 18:54:22 -0400 |
>I guess that I avoid multiple concurrent compositions of all
>sorts because it's painful because of the shared draft file
>unless one uses long options.
That's what .mh_profile defaults are for, and Jerry Peek's recomp ;-)
http://rand-mh.sourceforge.net/book/examples/mh/bin/recomp
The patch inlined below is for a slightly modified version with some
added conveniences.
--- recomp 2006-05-07 19:31:15.000000000 -0400
+++ mycomp 2012-03-15 18:51:00.000000000 -0400
@@ -1,18 +1,21 @@
-#! /bin/sh
-# $Id: recomp,v 1.9 1993/04/22 08:33:46 jerry book3 $
-### recomp - re-compose a draft mesage in MH draft folder
-### Usage: recomp [msgnum]
+#!/bin/sh
+# $Id: mycomp,v 1.3 2005-07-24 belg4mit$
+# Based on Id: recomp,v 1.9 1993/04/22 08:33:46 jerry book3
+### mycomp - optionally re-compose a draft mesage in MH draft folder
+### Usage: mycomp [msg]
+## mycomp -new
+## mycomp [comp options]
##
## WHEN YOU TYPE q AT A What now? PROMPT, IT LEAVES THE DRAFT MESSAGE
## WITHOUT SENDING IT. IF YOU HAVE A DRAFT FOLDER, THE COMMAND LINE
## YOU'D TYPE TO RE-COMPOSE THE DRAFT IS LONG, LIKE:
-## comp -use -draftm 3 -draftf +drafts -editor vi.
+## comp -use -draftm 3 -draftf +drafts
## ALSO, IT CAN BE HARD TO REMEMBER THE DRAFT NUMBER--SO YOU HAVE TO
## scan THE DRAFT FOLDER, THEN REMEMBER TO CHANGE YOUR FOLDER BACK.
##
## THIS SCRIPT HELPS WITH THAT. IF YOU GIVE IT A MESSAGE NUMBER IN THE
## DRAFT FOLDER, IT STARTS comp -use ON THAT MESSAGE WITH YOUR FAVORITE
-## EDITOR PROGRAM. WITHOUT A MESSAGE NUMBER, recomp scanS THE DRAFT
+## EDITOR PROGRAM. WITHOUT A MESSAGE NUMBER, mycomp scanS THE DRAFT
## FOLDER, THEN LETS YOU ENTER THE NUMBER OF THE MESSAGE YOU WANT TO
## RE-COMPOSE AND STARTS comp -use.
##
@@ -40,10 +43,11 @@
# PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGES.
+# NOTE TO HACKERS: TABSTOPS ARE SET AT 4 IN THIS CODE
draftf=+drafts # NAME OF DRAFT FOLDER
folopts="-fast -norecurse -nolist -nototal -nopack"
-mh=/usr/local/mh # WHERE MH PROGRAMS LIVE
+mh=/usr/local/bin # WHERE MH PROGRAMS LIVE
# THIS SCRIPT CHANGES CURRENT FOLDER TO THE $draftf FOLDER.
# SET TEMPORARY CONTEXT FILE SO OTHER MH PROCESSES WON'T NOTICE CHANGE:
@@ -51,7 +55,7 @@
MHCONTEXT=$tempctx; export MHCONTEXT
stat=1 # DEFAULT EXIT STATUS; RESET TO 0 FOR NORMAL EXITS
trap '/bin/rm -f $tempctx; exit $stat' 0
-trap 'echo "`basename $0`: Interrupt! Cleaning up..." 1>&2' 1 2 15
+#trap 'echo "`basename $0`: Interrupt! Cleaning up..." 1>&2' 1 2 15
$mh/folder $folopts $draftf >/dev/null || {
echo "`basename $0`: quitting: problem with draft folder '$draftf'." 1>&2
exit 1
@@ -61,20 +65,37 @@
0) # THEY DIDN'T GIVE MESSAGE NUMBER; SHOW THEM FOLDER:
if $mh/scan
then
- echo -n "Which draft message number do you want to re-edit? "
+ printf "Which draft message to re-edit or cur [Enter] or (n)ew or
(q)uit? "
read msgnum
else
- echo "`basename $0`: quitting: no messages in your $draftf folder?"
1>&2
- exit
+ msgnum="new"
fi
;;
1) msgnum="$1" ;;
-*) echo "I don't understand '$*'.
- I need the draft message number, if you know it... otherwise, nothing.
- Usage: `basename $0` [msgnum]" 1>&2
- exit
+*)
+ $mh/comp $@
+ exit $?;
;;
esac
-$mh/comp -use -e ${VISUAL-${EDITOR-${EDIT-vi}}} -draftm $msgnum -draftf $draftf
+case "$msgnum" in
+0) echo "comp: no messages match specification" ;;
+q) exit;;
+n|ne|new|-n|-ne|-new)
+ $mh/comp -draftf $draftf -nouse ;;
+*[0-9]*|cur|last)
+ $mh/comp -draftf $draftf -use $msgnum;;
+?*)
+ $mh/comp $@ ;;
+*)
+ # Blank entry selects current message, or last
+ if [ -z $msgnum ]; then
+ msgnum=`pick cur`
+ if [ $msgnum -eq 0 ]; then
+ msgnum=`pick last`
+ fi
+ fi
+ $mh/comp -draftf $draftf -use -draftm $msgnum ;;
+esac
+
stat=$? # SAVE comp'S STATUS (IT'S USUALLY 0) FOR OUR exit
- Re: [Nmh-workers] temporary files, (continued)
- Re: [Nmh-workers] temporary files, paul vixie, 2012/03/15
- Re: [Nmh-workers] temporary files, Jon Steinhart, 2012/03/15
- Re: [Nmh-workers] temporary files, Lyndon Nerenberg, 2012/03/15
- Re: [Nmh-workers] temporary files, paul vixie, 2012/03/15
- Re: [Nmh-workers] temporary files, Paul Fox, 2012/03/15
- Re: [Nmh-workers] temporary files, Lyndon Nerenberg, 2012/03/15
- Re: [Nmh-workers] temporary files, Jon Steinhart, 2012/03/15
- Re: [Nmh-workers] temporary files, paul vixie, 2012/03/15
- Re: [Nmh-workers] temporary files, Jerrad Pierce, 2012/03/15
- Re: [Nmh-workers] temporary files, Jon Steinhart, 2012/03/15
- Re: [Nmh-workers] temporary files,
Jerrad Pierce <=
- Re: [Nmh-workers] temporary files, Ralph Corderoy, 2012/03/15
- Re: [Nmh-workers] temporary files, Paul Fox, 2012/03/15
- Re: [Nmh-workers] temporary files, Tethys, 2012/03/15
- Re: [Nmh-workers] temporary files, Valdis . Kletnieks, 2012/03/15
- Re: [Nmh-workers] temporary files, Ken Hornstein, 2012/03/15
- Re: [Nmh-workers] temporary files, Paul Fox, 2012/03/15
- Re: [Nmh-workers] temporary files, Jerrad Pierce, 2012/03/16
- Re: [Nmh-workers] temporary files, Ralph Corderoy, 2012/03/16
- Re: [Nmh-workers] temporary files, Ken Hornstein, 2012/03/16
- Re: [Nmh-workers] temporary files, Ken Hornstein, 2012/03/15