File: replaliases

package info (click to toggle)
nmh 1.8-3
  • links: PTS
  • area: main
  • in suites: trixie
  • size: 7,860 kB
  • sloc: ansic: 50,445; sh: 22,697; makefile: 1,138; lex: 740; perl: 509; yacc: 265
file content (139 lines) | stat: -rw-r--r-- 4,037 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#### replaliases
####
#### convenience functions for various repl(1) commands
####
#### 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, it helps to have its PARINIT environment variable
#### set.  If you really want it to be null, either comment this out
#### or set it to, e.g., ' '.  Removed "R" from PARINIT recommendation
#### in par(1) man page so that it doesn't consider words that are too
#### long to be an error.
if [ -z "$PARINIT" ]; then
    PARINIT='rTbgq B=.,?_A_a Q=_s>|'
    export PARINIT
fi


#### Reply, including text/html (converted to text/plain) and
#### text/plain parts.
####
#### Optional arguments:
####   -h to disable conversion of text/html parts
####   -p to disable conversion of text/plain parts
#### All other arguments are passed to repl.
#### The -p argument can be useful with improperly structured
#### messages, such as those that use multipart/related when they
#### should have used multipart/alternative.
rt() {
    if [ "$1" = -h ]; then
        shift
        \repl -filter mhl.replywithoutbody -convertargs text/plain '' "$@"
    elif [ "$1" = -p ]; then
        shift
        \repl -filter mhl.replywithoutbody -convertargs text/html '' "$@"
    else
        \repl -filter mhl.replywithoutbody \
             -convertargs text/html '' -convertargs text/plain '' "$@"
    fi
}


#### Add -editor mhbuild to above.  Useful only when attachments
#### won't be added to the message.
####
#### To ease editing at the What now? prompt, add a line like this to
#### your .mh_profile:
####     mhbuild-next: $EDITOR
#### assuming that your EDTIOR environment variable is set; if not,
#### replace $EDITOR above with the name of your editor.  Without that
#### profile entry, enter "e[dit] $EDITOR" at the What now? prompt.
rtm() {
    rt "$@" -editor mhbuild
}


#### 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
#### usage: calaccept [-a address] [repl switches]
####   -a specifies attendee, see mhical(1)
#### Other arguments passed to repl(1).
calaccept() {
    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
#### usage: caldecline [-a address] [repl switches]
####   -a specifies attendee, see mhical(1)
#### Other arguments passed to repl(1).
caldecline() {
    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
#### usage: caltentative [-a address] [repl switches]
####   -a specifies attendee, see mhical(1)
#### Other arguments passed to repl(1).
caltentative() {
    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() {
    \repl -noformat -editor mhbuild \
         -convertargs text/calendar '-cancel -contenttype' "$@"
}


# Local Variables:
# mode: sh
# End: