home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 3 / 3392 < prev    next >
Internet Message Format  |  1991-05-20  |  2KB

  1. From: sahayman@iuvax.cs.indiana.edu (Steve Hayman)
  2. Newsgroups: alt.sources
  3. Subject: handy "rn" macro for editing/reposting news articles with corrections
  4. Message-ID: <1991May20.220707.16985@news.cs.indiana.edu>
  5. Date: 20 May 91 22:06:55 GMT
  6.  
  7.  
  8. Here is a handy shell script and rn macro definition that lets you
  9. edit and repost news articles.  I like to use this when I've posted
  10. something and notice a typo or want to make some other small correction.
  11.  
  12. Go to the article with rn, type 'E' .  You're placed in the editor looking
  13. at a copy of your article.  Make the change you want, write it out.
  14. The script says "Post it? [y/n]" and then "Cancel the original? [y/n]".
  15. and will take care of posting and cancellation for you.
  16.  
  17. No warranties, etc etc.  I like it, it works for me.  Your mileage may vary.
  18.  
  19. put this in your .rnmac file
  20.  
  21. # Edit.  Edit the current article, repost, cancel the original.
  22. E    !/u/sahayman/scripts/EditArticle %A '%i' ^M
  23.  
  24.  
  25. and here is the EditArticle script.  You may need to change the
  26. definition of 'inews' if yours isn't in /usr/lib/news/inews.
  27.  
  28.  
  29. #!/bin/sh
  30. # EditArticle
  31. # Edit and re-post the current news message; cancel the original.
  32. # I have an rn macro, "E", that runs this program.
  33. # Based on an idea by ksbooth
  34. #
  35. # Put this in your .rnmac file:
  36. # E    !/pathname/of/this/program %A '%i' ^M
  37. #
  38. # steve hayman
  39. # sahayman@cs.indiana.edu
  40. # 1991 05 20
  41.  
  42. # don't export PATH, we want the original PATH inside the 'vi', for instance
  43. PATH=/usr/local/bin:/usr/ucb:/bin:/usr/bin 
  44.  
  45. TMP=/tmp/Edit.$$
  46. trap exit 1 2 3 15
  47. trap 'rm -f $TMP' 0
  48.  
  49. Usage="Usage: $0 article-path message-id"
  50.  
  51. inews="/usr/lib/news/inews -h"
  52.  
  53. Orig=${1?"$Usage"}
  54. MessageID=${2?"$Usage"}
  55.  
  56. # Delete header lines that will not be relevant any more
  57. egrep -v '^(Lines|Message-ID|Path|From|Sender|Date): ' $Orig >$TMP
  58.  
  59. ${EDITOR-vi} $TMP
  60.  
  61. echo -n 'Post it? [y/n] '
  62. read postit
  63. case "$postit" in
  64. ""|y*|Y*)        $inews  <$TMP
  65.         rm $TMP ;;
  66. esac
  67.  
  68.  
  69. echo -n 'Cancel the original? [y/n] '
  70. read cancel
  71. case "$cancel" in
  72. ""|y*|Y*)        
  73.     
  74.     sed -n -e '/^Newsgroups: /p' -e '/^References: /p' \
  75.         -e '/^Distribution: /p' \
  76.         -e "/^Subject: /s/.*/Subject: cmsg cancel $MessageID/p" <$Orig |
  77.         $inews 
  78.     ;;
  79. esac
  80.