home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / mail / elm / 2172 < prev    next >
Encoding:
Text File  |  1992-08-19  |  5.2 KB  |  153 lines

  1. Newsgroups: comp.mail.elm
  2. Path: sparky!uunet!kithrup!stanford.edu!ames!haven.umd.edu!darwin.sura.net!jvnc.net!princeton!phoenix.Princeton.EDU!spencer
  3. From: spencer@phoenix.Princeton.EDU (S. Spencer Sun)
  4. Subject: Re: Attribution enhancement, maybe?
  5. Message-ID: <1992Aug19.195059.4309@Princeton.EDU>
  6. Sender: news@Princeton.EDU (USENET News System)
  7. Nntp-Posting-Host: phoenix.princeton.edu
  8. Reply-To: spencer@phoenix.princeton.edu (S. Spencer Sun)
  9. Organization: Live Organ Transplants
  10. References: <1992Aug19.151729.29784@DSI.COM> <1992Aug19.182721.25194@das.harvard.edu> <Bt8wAo.74J@cs.dal.ca>
  11. Date: Wed, 19 Aug 1992 19:50:59 GMT
  12. Lines: 139
  13.  
  14. In article <Bt8wAo.74J@cs.dal.ca>, dinn@ug.cs.dal.ca (Michael 'Moose' Dinn) writes:
  15. >In article <1992Aug19.182721.25194@das.harvard.edu> adam@flicker.uucp (Adam Shostack) writes:
  16. >>Ok, heres an idea for an enhancement for the next version. Currently,
  17. >>.elm/elmrc has a single line controlling attribution.  Since most of
  18. >>my replies are done with r(eply) not g(roup reply), I leave this set
  19. >>to "You wrote."  But when I send a group reply, I'd like this to
  20. >>automatically change to "%s wrote:"
  21. >
  22. >Good idea.
  23. >Could we also add something like %w for when the message was sent, %z for
  24. >the subject of the message, etc., to these fields?
  25. >
  26. >That would make the attribution feature mich more interesting.
  27.  
  28. Here's how I get my attributions.  It includes the date and full From:
  29. field of the original sender.  It could easily be adapted to do more than
  30. it currently does though.  NOte that this works with /usr/ucb/mail also
  31. if you set your EDITOR variable to point to mq and then ~e instead of ~v
  32. (so that you don't have to set your VISUAL to point to mq, because
  33. things besides mail use VISUAL)
  34.  
  35. 1. Set your indent prefix in your elmrc.  ELM does the attribution, this
  36. does the rest.
  37. 2. Set your editor variable in your elmrc to point to this script (I
  38. call it mq which stands for m)ail q)uoter because it used to do the
  39. quoting too, even though it no longer does)
  40. 3. Change the #! path to point to perl.
  41. 4. You'll have to modify the signature part unless you want it set up
  42. the way I have it set up.  I have a directory called ~/.sigdir, which
  43. contains numerous files, any one of which can be randomly selected and
  44. used as my .signature file.  There is a file called INDEX which is a
  45. list of all the files, create with "ls -1 > INDEX" and then delete the
  46. line that contains INDEX on it (notice ls -1, not ls -l).  The signature
  47. stuff is way at the bottom of the file.
  48. 5. You may want/have to change the definition of $tempfile.
  49.  
  50. #!/usr/princeton/bin/perl
  51.  
  52. $prefix="-> ";
  53. $sigdir="$ENV{HOME}/.sigdir";
  54. $sigindex="INDEX";
  55.  
  56. #
  57. # Copy the file over to temporary file, because we're going to copy it
  58. # back and write over the original file.  Note that since 0 = false
  59. # and 1 = true, that's a && after the system() and not a || like you'd
  60. # expect.
  61. #
  62. $ARGV[0] || die("No filename specified on command line");
  63. $tempfile="/tmp/mq$$";
  64. system("cp $ARGV[0] $tempfile") && die("Couldn't copy $ARGV[0] to $tempfile");
  65.  
  66. open(TEMPFILE, "$tempfile");
  67. open(OUTFILE, ">$ARGV[0]");
  68.  
  69. #
  70. # First we copy all the lines up to the first indent prefix (in case
  71. # we're using Berkeley mail with the 'editheaders' option set)
  72. #
  73. while (<TEMPFILE>)
  74. {
  75.   last if /^${prefix}From /o;
  76.   print OUTFILE;
  77. }
  78.  
  79. #
  80. # Now skip until the first line consisting of just an indent prefix.
  81. # This deletes all the mail header lines.  Meanwhile, extract the
  82. # name of the sender, and the date the mail was sent.
  83. #
  84. while (<TEMPFILE>)
  85. {
  86.   chop;
  87.   last if /^${prefix}$/o;
  88.   s/^${prefix}From: //o && ($from = $_);
  89.   s/^${prefix}Date: //o && ($date = $_);
  90. }
  91.  
  92. #
  93. # Create the attribution line and print it out, breaking lines at the
  94. # 75th column for nice output.  Then print the rest of the mail.
  95. #
  96.  
  97. if ($from)
  98. {
  99.   if ($date)
  100.   { $foo = "On $date, $from may or may not have written:"; }
  101.   else
  102.   { $foo = "$from may or may not have written:"; }
  103.   @attrib = split(/[ \t\n]+/, $foo);
  104.   $length = 0;
  105.   do
  106.   {
  107.     $length += (length($attrib[0]) + 1);
  108.     if ($length > 75)
  109.     {
  110.       print OUTFILE "\n";
  111.       $length = 0;
  112.     }
  113.     print OUTFILE "$attrib[0] ";
  114.   } while (shift(@attrib));
  115.   print OUTFILE "\n$prefix \n";
  116.   print OUTFILE while (<TEMPFILE>);
  117. }
  118.  
  119. #
  120. # Now print out the constant stuff in the sig.
  121. #
  122. print OUTFILE "\n-----\n";
  123. print OUTFILE "sss/PU'94 Dept of CS (spencer@phoenix.princeton.edu/JvNCnet(spencer@jvnc.net)\n";
  124.   
  125. close(TEMPFILE);
  126. unlink($tempfile) || print STDERR "Couldn't remove temporary file $tempfile\n";
  127.  
  128. #
  129. # open the index file, select a random sig, and print it out
  130. #
  131. open(SIGS, "${sigdir}/${sigindex}");
  132. @lines = <SIGS>;
  133. close(SIGS);
  134. srand(time^$$);
  135. open(SIGFILE, "${sigdir}/$lines[rand @lines]");
  136. print OUTFILE while (<SIGFILE>);
  137. close(SIGFILE);
  138.  
  139. close (OUTFILE);
  140.  
  141. $ENV{VISUAL} && exec "/usr/ucb/vi", $ARGV[0];
  142. print STDERR "No visual editor!  Using vi...\n";
  143. (-x "/usr/ucb/vi") && exec "/usr/ucb/vi", $ARGV[0];
  144. (-x "/usr/bin/vi") && exec "/usr/bin/vi", $ARGV[0];
  145. print STDERR "Couldn't find /usr/ucb/vi or /usr/bin/vi.  Giving up\n";
  146.  
  147.  
  148. ----------- The opinions expressed in this article are solely mine. -----------
  149. <Insert lame attempt at disclaimer humor>
  150. sss/PU'94 Dept of CS (spencer@phoenix.princeton.edu)/JvNCnet (spencer@jvnc.net)
  151. "'Rue the day'?  Who talks like that?"
  152.  
  153.