|
|
1.1 root 1: Date: 30 Jan 86 23:07:34 -0800 (Thu)
2: Subject: Repl nifty
3: From: Bob Desinger <[email protected]>
4: To: [email protected]
5: cc: [email protected]
6:
7: I've long wanted a way to get someone's original message into my
8: replies, prepended with those nice "> " netnews-style borders like so:
9:
10: > This is the original text that the person wrote.
11: > My reply, of course, prepends the original body with the angle-brackets,
12: > often called brokets, and skips the headers.
13:
14: The most obvious way would be to use a repl filter. Alas, there is no
15: mechanism to specify a prepended-text-string for the body, except a
16: number of spaces to indent. I didn't want to use awk because that was
17: too easy---uh, too slow on a timeshared machine. I wound up editing
18: the replies anyway, most of the time, but I wanted some mechanism to
19: invoke simply by name. Ideally it would be some kind of "repl:"
20: mh_profile entry, but I haven't progressed that far. (I'm open to
21: suggestions.) I got an idea from a sed script of Peter Honeyman's,
22: which used the extremely rapid sed "b" (branch) instruction to churn
23: through its input.
24:
25: How to use this script:
26:
27: 1. Install it in your bin/ directory, or some other place where you'll
28: be able to easily execute it, under the name "cur". Csh users may need
29: to type "rehash" to get it into their $path right after installation.
30:
31: 2. Change the script's definition of LINK if you don't use "@" for
32: your links when replying.
33:
34: 3. Now you're ready to try it. Type `repl' and get into your favorite
35: editor. (Yes, I realize this is a hack, but most of the time you wind
36: up getting into the editor anyway, to trim down the quoted [original]
37: message.) Go to the last line of the header, on the dashes. Run the
38: program `cur' from the editor, reading its input. In vi, the command
39: is:
40:
41: :r ! cur
42:
43: and voila! You have the message body, sans headers, prepended with the
44: brokets. Type your response and push it off.
45:
46: I chose the name cur because of its similarity to the mh message "cur".
47: Hopefully, users will think of the editor-invoked command as "read cur".
48:
49: How it works:
50:
51: Mh does the setup for you when you type `repl' by installing a link
52: named "@" in the current directory. This "@" is really a link to the
53: current message, the one you're trying to reply to.
54:
55: The first part of the sed script, after the ":header" label, spins
56: through the message discarding the first set of lines (the header)
57: until it comes to a blank line. Then it branches to the label ":eohdr"
58: with the blank line held in sed's pattern space (== current input
59: line). If you wanted to include parts of the header (like "From:" or
60: "Subject:"), put lines like, say,
61:
62: /^From:/s/^From:/> From:/p
63: /^Subject:/s/^Subject:/> Subject:/p
64:
65: just after the "/^$/b eohdr" line which branches to the next section
66: when the first empty line is found.
67:
68: The ":eohdr" part simply discards the blank line and branches to the
69: section labeled ":body." If you want to put in any leading lines
70: introducing the quoted part of the original message (like "In Reply
71: To:" or whatever), the place to do it is right after the ":eohdr"
72: line.
73:
74: The last section, after the ":body" label, inserts the broket-and-space
75: before each line.
76:
77: Enjoy,
78: Bob Desinger
79:
80:
81: # This is a shell archive. Remove anything before this line,
82: # then unpack it by saving it in a file and typing "sh file".
83: #
84: # Wrapped by hpitg!bd on Thu Jan 30 22:21:38 PST 1986
85: # Contents: cur
86:
87: echo x - cur
88: sed 's/^@//' > "cur" <<'@//E*O*F cur//'
89: #! /bin/sh
90: : read in the current message, rn-style
91: LINK="@"
92:
93: # Skip headers, then print out the body lines prepended with "> "
94: sed -n '
95: :header
96: /^$/b eohdr
97: n
98: b header
99: :eohdr
100: n
101: b body
102: :body
103: s/^/> /p
104: n
105: b body' $LINK
106: @//E*O*F cur//
107: chmod u=rwx,g=rx,o=rx cur
108:
109: echo Inspecting for damage in transit...
110: temp=/tmp/shar$$; dtemp=/tmp/.shar$$
111: trap "rm -f $temp $dtemp; exit" 0 1 2 3 15
112: cat > $temp <<\!!!
113: 17 43 214 cur
114: !!!
115: wc cur | sed 's=[^ ]*/==' | diff -b $temp - >$dtemp
116: if [ -s $dtemp ]
117: then echo "Ouch [diff of wc output]:" ; cat $dtemp
118: else echo "No problems found."
119: fi
120: exit 0
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.