whatnow2 save metainformation in the draft itself
authorPhilipp Takacs <philipp@bureaucracy.de>
Mon, 31 Dec 2018 01:54:23 +0000 (02:54 +0100)
committerPhilipp Takacs <philipp@bureaucracy.de>
Mon, 31 Dec 2018 01:54:23 +0000 (02:54 +0100)
by default meta information like last editor or altmsg is stored in
the draft ifself. This can be overritten by the profile entry
Metafile-Extension.

etc/Makefile.in
etc/mhl.whatnow2 [new file with mode: 0644]
man/mh-profile.man5
man/whatnow2.man1
test/tests/whatnow2/default-workflow [new file with mode: 0644]
test/tests/whatnow2/metafile [new file with mode: 0644]
uip/Makefile.in
uip/whatnow2.sh

index 7b2934e..b4aea9e 100644 (file)
@@ -28,7 +28,7 @@ SED = sed
 # static configuration, format, and components files
 STATIC_FILES = components digestcomps distcomps forwcomps \
                mhl.body mhl.format mhl.forward mhl.headers \
 # static configuration, format, and components files
 STATIC_FILES = components digestcomps distcomps forwcomps \
                mhl.body mhl.format mhl.forward mhl.headers \
-               mhl.reply rcvdistcomps rcvdistcomps.outbox \
+               mhl.reply mhl.whatnow2 rcvdistcomps rcvdistcomps.outbox \
                replcomps replgroupcomps scan.MMDDYY scan.YYYYMMDD \
                scan.nmh scan.mailx scan.nomime scan.size scan.time \
                scan.timely scan.unseen scan.meillo scan.default \
                replcomps replgroupcomps scan.MMDDYY scan.YYYYMMDD \
                scan.nmh scan.mailx scan.nomime scan.size scan.time \
                scan.timely scan.unseen scan.meillo scan.default \
diff --git a/etc/mhl.whatnow2 b/etc/mhl.whatnow2
new file mode 100644 (file)
index 0000000..188634d
--- /dev/null
@@ -0,0 +1,4 @@
+ignores=mmh-*
+extras:raw
+:
+body:nocomponent,overflowoffset=0,raw
index dd8196f..3b692ee 100644 (file)
@@ -388,6 +388,13 @@ Your signature will be added to the address
 puts in the `From:' header; do not include an address in the
 signature text.  (profile, no default)
 .RE
 puts in the `From:' header; do not include an address in the
 signature text.  (profile, no default)
 .RE
+.PP
+.BR Metafile-Extention :
+\&.meta
+.RS 5
+This extions will be used to store meta information about a mail or a draft.
+Currently only implemented by whatnow2.  (profile, no default)
+.RE
 
 .SS "Process Profile Entries"
 The following profile elements are used whenever an
 
 .SS "Process Profile Entries"
 The following profile elements are used whenever an
index f66bfe7..4ba5674 100644 (file)
@@ -122,6 +122,7 @@ information.
 ^Path:~^To determine the user's mail storage
 ^Draft\-Folder:~^To set the default draft\-folder
 ^Editor:~^To override the default editor
 ^Path:~^To determine the user's mail storage
 ^Draft\-Folder:~^To set the default draft\-folder
 ^Editor:~^To override the default editor
+^Metafile\-Extension:~^The optional extion for meta information like lasteditor
 ^<lasteditor>\-next:~^To name an editor to be used after exit
 ^~^from <lasteditor>
 ^listproc:~^Program to list the contents of a message
 ^<lasteditor>\-next:~^To name an editor to be used after exit
 ^~^from <lasteditor>
 ^listproc:~^Program to list the contents of a message
diff --git a/test/tests/whatnow2/default-workflow b/test/tests/whatnow2/default-workflow
new file mode 100644 (file)
index 0000000..bd4cf88
--- /dev/null
@@ -0,0 +1,53 @@
+#test whatnow2 workflow
+
+. "$MH_TEST_COMMON"
+profile="$MMH/profile-send"
+cd "$MMH"
+cat "`mhparam profile`" - >"$profile" <<!
+default-from: Bob <bob@example.org>
+!
+cd - >/dev/null
+export MMHP="$profile"
+
+runandcheck "comp -editor cat -whatnowproc whatnow2" <<!
+mmh-last-editor: cat
+mmh-mhdist: 0
+To:
+Cc:
+Fcc: +sent
+Subject:
+--------
+!
+
+runandcheck "whatnow2 edit" <<!
+mmh-last-editor: cat
+mmh-mhdist: 0
+To:
+Cc:
+Fcc: +sent
+Subject:
+--------
+!
+
+cat >`mhpath l +drafts` <<!
+From: Bob <bob@example.org>
+To: alice
+Date: Sun, 25 Oct 2015 18:59:56 +0100
+Subject: Test
+----------------
+foo
+!
+
+runandcheck 'whatnow2 send -debug | replace_contentid' <<!
+From: Bob <bob@example.org>
+To: alice
+Date: Sun, 25 Oct 2015 18:59:56 +0100
+Subject: Test
+MIME-Version: 1.0
+Content-Type: text/plain; charset="us-ascii"
+Content-ID: <TESTID>
+
+foo
+----EOM----
+alice
+!
diff --git a/test/tests/whatnow2/metafile b/test/tests/whatnow2/metafile
new file mode 100644 (file)
index 0000000..e91cc79
--- /dev/null
@@ -0,0 +1,60 @@
+#test whatnow2 workflow
+
+. "$MH_TEST_COMMON"
+profile="$MMH/profile-send"
+cd "$MMH"
+cat "`mhparam profile`" - >"$profile" <<!
+default-from: Bob <bob@example.org>
+Metafile-Extension: .meta
+!
+cd - >/dev/null
+export MMHP="$profile"
+
+runandcheck "comp -editor cat -whatnowproc whatnow2" <<!
+To:
+Cc:
+Fcc: +sent
+Subject:
+--------
+!
+
+runandcheck "cat `mhpath l +drafts`.meta" <<!
+mmh-last-editor: cat
+mmh-mhdist: 0
+!
+
+runandcheck "whatnow2 edit" <<!
+To:
+Cc:
+Fcc: +sent
+Subject:
+--------
+!
+
+runandcheck "cat `mhpath l +drafts`.meta" <<!
+mmh-last-editor: cat
+mmh-mhdist: 0
+!
+
+cat >`mhpath l +drafts` <<!
+From: Bob <bob@example.org>
+To: alice
+Date: Sun, 25 Oct 2015 18:59:56 +0100
+Subject: Test
+----------------
+foo
+!
+
+runandcheck 'whatnow2 send -debug | replace_contentid' <<!
+From: Bob <bob@example.org>
+To: alice
+Date: Sun, 25 Oct 2015 18:59:56 +0100
+Subject: Test
+MIME-Version: 1.0
+Content-Type: text/plain; charset="us-ascii"
+Content-ID: <TESTID>
+
+foo
+----EOM----
+alice
+!
index f037ec1..fcab14d 100644 (file)
@@ -54,13 +54,13 @@ CMDS = ali anno burst comp dist flist folder forw mmh mark \
        mhbuild mhl mhsign mhpgp \
        mhlist mhmail mhparam mhpath mhstore new packf pick \
        print-mimetype prompter rcvdist rcvpack rcvstore refile repl rmf \
        mhbuild mhl mhsign mhpgp \
        mhlist mhmail mhparam mhpath mhstore new packf pick \
        print-mimetype prompter rcvdist rcvpack rcvstore refile repl rmf \
-       rmm send sendfiles show slocal sortm spost whatnow whom
+       rmm send sendfiles show slocal sortm spost whatnow whatnow2 whom
 
 # commands that are links to other commands
 LCMDS = flists folders next prev fnext fprev unseen scan
 
 # misc support binaries
 
 # commands that are links to other commands
 LCMDS = flists folders next prev fnext fprev unseen scan
 
 # misc support binaries
-MISC = ap dp fmtdump mhtest mmhwrap whatnow2
+MISC = ap dp fmtdump mhtest mmhwrap
 
 # commands with 'S'pecial installation needs
 SCMDS = inc
 
 # commands with 'S'pecial installation needs
 SCMDS = inc
index 91ff5a5..f9cf255 100755 (executable)
@@ -45,7 +45,7 @@ get_editor()
 {
        if [ -f "$mhmetafile" ]
        then
 {
        if [ -f "$mhmetafile" ]
        then
-               lasteditor=`anno -list -component 'last-editor' $mhmetafile`
+               lasteditor=`anno -list -component 'mmh-last-editor' "$mhmetafile"`
                if [ -n "$lasteditor" ]
                then
                        editor=`echo $lasteditor | cut -d ' ' -f 1`
                if [ -n "$lasteditor" ]
                then
                        editor=`echo $lasteditor | cut -d ' ' -f 1`
@@ -63,6 +63,14 @@ get_editor()
        mheditor=`mhparam 'Editor'`
 }
 
        mheditor=`mhparam 'Editor'`
 }
 
+save_config()
+{
+       component="$1"
+       newtext="$2"
+       anno -delete -number all -component "$component" "$mhmetafile"
+       anno -nodate -component "$component" -text "$newtext" "$mhmetafile"
+}
+
 get_showproc()
 {
        mhshowproc=`mhparam 'listproc'`
 get_showproc()
 {
        mhshowproc=`mhparam 'listproc'`
@@ -78,50 +86,31 @@ get_realpath()
        cd "$OLDPWD"
 }
 
        cd "$OLDPWD"
 }
 
-set_lasteditor()
-{
-       anno -delete -number all -component 'last-editor' $mhmetafile
-       anno -nodate -component 'last-editor' -text "$1" $mhmetafile
-}
-
 create()
 {
        if [ -z "$mhdraft" ]
        then
                usage 1
        fi
 create()
 {
        if [ -z "$mhdraft" ]
        then
                usage 1
        fi
-       mhmetafile=$mhdraft.meta
-       touch $mhmetafile
+       mhext=`mhparam Metafile-Extension`
+       mhmetafile="$mhdraft""$mhext"
+       touch "$mhmetafile"
        if [ -z "$mheditor" ]
        then
                get_editor
        fi
        if [ "$mhuse" -eq 1 ]
        then
        if [ -z "$mheditor" ]
        then
                get_editor
        fi
        if [ "$mhuse" -eq 1 ]
        then
+               exec $mheditor $mhdraft
                return
        fi
                return
        fi
-       if [ -n "$mhaltmsg" ]
-       then
-               anno -nodate -component 'mhaltmsg' -text "$mhaltmsg" $mhmetafile
-       fi
-       if [ -n "$mhdist" ]
-       then
-               anno -nodate -component 'mhdist' -text "$mhdist" $mhmetafile
-       fi
-       if [ -n "$mhfolder" ]
-       then
-               anno -nodate -component 'mhfolder' -text "$mhfolder" $mhmetafile
-       fi
-       if [ -n "$mhmessages" ]
-       then
-               anno -nodate -component 'mhmessages' -text "$mhmessages" $mhmetafile
-       fi
-       if [ -n "$mhannotate" ]
-       then
-               anno -nodate -component 'mhannotate' -text "$mhannotate" $mhmetafile
-       fi
-       set_lasteditor "$mheditor"
-       exec $mheditor $mhdraft
+       save_config mmh-mhaltmsg "$mhaltmsg"
+       save_config mmh-mhdist "$mhdist"
+       save_config mmh-mhfolder "$mhfolder"
+       save_config mmh-mhmessages "$mhmessages"
+       save_config mmh-mhannotate "$mhannotate"
+       save_config mmh-last-editor "$mheditor"
+       exec $mheditor "$mhdraft"
 }
 
 edit()
 }
 
 edit()
@@ -133,8 +122,8 @@ edit()
                mheditor="$@"
        fi
 
                mheditor="$@"
        fi
 
-       set_lasteditor "$mheditor"
-       exec $mheditor $mhdraft
+       save_config mmh-last-editor "$mheditor"
+       exec $mheditor "$mhdraft"
 }
 
 list()
 }
 
 list()
@@ -145,13 +134,23 @@ list()
 
 sendfunktion()
 {
 
 sendfunktion()
 {
-       export mhaltmsg=`anno -list -component 'mhaltmsg' "$mhmetafile"`
-       export mhdist=`anno -list -component 'mhdist' "$mhmetafile"`
-       export mhfolder=`anno -list -component 'mhfolder' "$mhmetafile"`
-       export mhmessages=`anno -list -component 'mhmessages' "$mhmetafile"`
-       export mhannotate=`anno -list -component 'mhannotate' "$mhmetafile"`
+       export mhaltmsg=`anno -list -component 'mmh-mhaltmsg' "$mhmetafile"`
+       export mhdist=`anno -list -component 'mmh-mhdist' "$mhmetafile"`
+       export mhfolder=`anno -list -component 'mmh-mhfolder' "$mhmetafile"`
+       export mhmessages=`anno -list -component 'mmh-mhmessages' "$mhmetafile"`
+       export mhannotate=`anno -list -component 'mmh-mhannotate' "$mhmetafile"`
+       tmp=`mktemp`
+       cp "$mhdraft" "$tmp"
+       mhl -form mhl.whatnow2 "$tmp" > "$mhdraft"
+       mhle="$?"
+       if [ "$mhle" -ne 0 ]
+       then
+               mv "$tmp" "$mhdraft"
+               exit "$mhle"
+       fi
        send "$@" "$mhdraft" || exit $?
        rm -f "$mhmetafile"
        send "$@" "$mhdraft" || exit $?
        rm -f "$mhmetafile"
+       rm -f "$tmp"
        exit 0
 }
 
        exit 0
 }
 
@@ -206,7 +205,7 @@ detach()
 
 display()
 {
 
 display()
 {
-       mhaltmsg=`anno -list -component 'mhaltmsg' "$mhmetafile"`
+       mhaltmsg=`anno -list -component 'mmh-mhaltmsg' "$mhmetafile"`
        get_showproc
        if [ -z "$mhaltmsg" ]
        then
        get_showproc
        if [ -z "$mhaltmsg" ]
        then
@@ -243,7 +242,8 @@ then
                ;;
        esac
 fi
                ;;
        esac
 fi
-mhmetafile="$mhdraft".meta
+mhext=`mhparam Metafile-Extension`
+mhmetafile="$mhdraft""$mhext"
 touch "$mhmetafile"
 
 
 touch "$mhmetafile"