]> diplodocus.org Git - nmh/blobdiff - docs/contrib/replaliases
Removed redundant initialization of local variable tls.
[nmh] / docs / contrib / replaliases
index 6848dc23a893c0410ca593f7e8aa092273511671..077965c1d323c1db772a7d600bff06f8228a701a 100644 (file)
@@ -1,7 +1,13 @@
 #### replaliases
 ####
 #### convenience functions for various repl(1) commands
 #### replaliases
 ####
 #### convenience functions for various repl(1) commands
-#### They're functions instead of aliases for portability.
+####
+#### They're functions instead of aliases for portability.  This file
+#### is intended to be sourced from a Bourne-compatible shell, e.g.,
+####     source `mhparam docdir`/contrib/replaliases
+#### to declare the functions.
+####
+#### Author: David Levine <levinedl@acm.org>
 
 #### If using par (see mhn.defaults), it helps to have its PARINIT
 #### environment variable set.  If you really want it to be null,
 
 #### If using par (see mhn.defaults), it helps to have its PARINIT
 #### environment variable set.  If you really want it to be null,
@@ -13,6 +19,7 @@ if [ -z "$PARINIT" ]; then
     export PARINIT
 fi
 
     export PARINIT
 fi
 
+
 #### Reply, including text/html (converted to text/plain) and
 #### text/plain parts.
 ####
 #### Reply, including text/html (converted to text/plain) and
 #### text/plain parts.
 ####
@@ -26,12 +33,12 @@ fi
 rt() {
     if [ "$1" = -h ]; then
         shift
 rt() {
     if [ "$1" = -h ]; then
         shift
-        repl -filter mhl.replywithoutbody -convertargs text/plain '' "$@"
+        \repl -filter mhl.replywithoutbody -convertargs text/plain '' "$@"
     elif [ "$1" = -p ]; then
         shift
     elif [ "$1" = -p ]; then
         shift
-        repl -filter mhl.replywithoutbody -convertargs text/html '' "$@"
+        \repl -filter mhl.replywithoutbody -convertargs text/html '' "$@"
     else
     else
-        repl -filter mhl.replywithoutbody \
+        \repl -filter mhl.replywithoutbody \
              -convertargs text/html '' -convertargs text/plain '' "$@"
     fi
 }
              -convertargs text/html '' -convertargs text/plain '' "$@"
     fi
 }
@@ -51,27 +58,78 @@ rtm() {
 }
 
 
 }
 
 
+#### Internal function for use by calendar response functions below.
+#### Pulls "-a address" out of command line arguments.
+mhical_attendee() {
+    mhical_prev=
+    mhical_attendee=
+    for arg in "$@"; do
+        test "$mhical_prev" = -a  &&  mhical_attendee="$arg"
+        mhical_prev="$arg"
+    done
+    unset arg
+    unset mhical_prev
+    echo "$mhical_attendee"
+}
+
+
 #### accept a calendar request
 #### accept a calendar request
+#### usage: calaccept [-a address] [repl switches]
+####   -a specifies attendee, see mhical(1)
+#### Other arguments passed to repl(1).
 calaccept() {
 calaccept() {
-    repl -noformat -editor mhbuild \
-         -convertargs text/calendar '-reply accept -contenttype' "$@"
+    if [ "$1" = -a ]; then
+        attendee=' -attendee '`mhical_attendee "$@"`
+        shift; shift
+    else
+        attendee=
+    fi
+    \repl -noformat -editor mhbuild \
+          -convertargs text/calendar "-reply accept -contenttype${attendee}" \
+          "$@"
+    unset attendee
 }
 
 }
 
+
 #### decline a calendar request
 #### decline a calendar request
+#### usage: caldecline [-a address] [repl switches]
+####   -a specifies attendee, see mhical(1)
+#### Other arguments passed to repl(1).
 caldecline() {
 caldecline() {
-    repl -noformat -editor mhbuild \
-         -convertargs text/calendar '-reply decline -contenttype' "$@"
+    if [ "$1" = -a ]; then
+        attendee=' -attendee '`mhical_attendee "$@"`
+        shift; shift
+    else
+        attendee=
+    fi
+    \repl -noformat -editor mhbuild \
+          -convertargs text/calendar "-reply decline -contenttype${attendee}" \
+          "$@"
+    unset attendee
 }
 
 }
 
+
 #### reply as tentative to a calendar request
 #### reply as tentative to a calendar request
+#### usage: caltentative [-a address] [repl switches]
+####   -a specifies attendee, see mhical(1)
+#### Other arguments passed to repl(1).
 caltentative() {
 caltentative() {
-    repl -noformat -editor mhbuild \
-         -convertargs text/calendar '-reply tentative -contenttype' "$@"
+    if [ "$1" = -a ]; then
+        attendee=' -attendee '`mhical_attendee "$@"`
+        shift; shift
+    else
+        attendee=
+    fi
+    \repl -noformat -editor mhbuild \
+          -convertargs text/calendar "-reply tentative -contenttype${attendee}" \
+          "$@"
+    unset attendee
 }
 
 }
 
+
 #### cancel a calendar request
 calcancel() {
 #### cancel a calendar request
 calcancel() {
-    repl -noformat -editor mhbuild \
+    \repl -noformat -editor mhbuild \
          -convertargs text/calendar '-cancel -contenttype' "$@"
 }
 
          -convertargs text/calendar '-cancel -contenttype' "$@"
 }