home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / epmsmp.zip / NR2POST.E < prev    next >
Text File  |  1996-05-21  |  8KB  |  188 lines

  1. ; I use NR/2 as my newsreader.  I have it set up to invoke EPM
  2. ; (select Configure / Editor, deselect "Use NewsReader/2 Editor",
  3. ; for Editor Name enter EPM.EXE, and for parameters enter
  4. ;    /m % 'nr2post'
  5. ; ).  The latter part of the line passes the NR2POST command to EPM
  6. ; whenever NR/2 opens an editor session.  That's the command defined
  7. ; below.  It checks for some common problems and warns you about them.
  8. ;  - You get a warning if the Newsgroups: line contains a test group.
  9. ;    (If it does, a line is added to the header to cut down on replies
  10. ;     in case you don't remove the test group(s).)
  11. ;  - You get a warning if the Newsgroups line contains both a comp.
  12. ;    group and a .sex group.
  13. ;  - You optionally get a warning if there are more than a certain number
  14. ;    of newsgroups being posted to at once.  Set NEWSGROUPS_LIMIT to the
  15. ;    limit if this feature is desired; leave it undefined if it is not.
  16. ;  - You optionally get a warning if the subject line contains any "bad words".
  17. ;    This is a reminder for you to change the subject line if you're
  18. ;    replying to the thread.  Set BAD_SUBJECT_WORDS to the list of words
  19. ;    you want to check for if this feature is desired; leave it undefined
  20. ;    if it is not.  The list below is silly, in order to avoid offending
  21. ;    anyone; instead use any curse words, swear words, and racist epithets
  22. ;    which you don't want to accidentally be associated with your name.
  23.  
  24. ; This command also sets the tabs to 8 (mine are normally 3), sets the
  25. ; margins, and adds '/o' to the default save options, so the file will
  26. ; be saved in OS/2 format.  (NR/2 might otherwise have problems if you
  27. ; import some text that has abnormal line terminators.)
  28.  
  29. ; This is NR/2 specific in that it assumes the post header is stored
  30. ; separately with the same path and filename as the current file, but
  31. ; with an extension of .hdr.  This could easily be changed to work
  32. ; with other newsreaders, as long as they let you configure the editor
  33. ; and its parameters.
  34.  
  35. ; This can be included by your MYSTUFF.E, or compiled as a separate
  36. ; command.
  37.  
  38. ; Power EPM user notes:  I keep a number of versions of EPM around; my
  39. ; actual NR/2 setup fully-qualifies the editor:  F:\EPM\603\EPM.EXE
  40. ; and the parameters field uses the /e option so EPM will load the
  41. ; EPM.EX file in my \epm\603 directory:  /ef:\epm\603\epm.ex /m % 'nr2post'
  42. ; My MYCNF.E sets a number of machine-specific constants at the beginning
  43. ; so that my other MY*.EX files can be shared on all machines without
  44. ; modification.  That's what the below EPM_VER_DIR is for - I prefer to
  45. ; switch to my EPM working directory.  The relevant parts of my MYCNF.E
  46. ; are:
  47. ; const
  48. ;    EPM_DRIVE =      'f:'            -- The drive containing \epm, \epm\551, \epm\603, ...
  49. ; compile if EVERSION >= 6.04
  50. ;    -- EPM version directory unknown (yet) - hope it's first in path.
  51. ; compile elseif EVERSION >= 6.03
  52. ;    EPM_VER_DIR = EPM_DRIVE'\epm\603'
  53. ; compile elseif EVERSION >= 5.51
  54. ;    EPM_VER_DIR = EPM_DRIVE'\epm\551'
  55. ; compile endif                 -- (Lots of other versions omitted for this example)
  56.  
  57. define
  58.    EDIT_NR2POST_HEADER__MSG = \10\10'Execute:  e =.hdr'\10'to edit header and correct the problem.'
  59.    NEWSGROUPS_LIMIT = 8
  60.    BAD_SUBJECT_WORDS = 'TUSHY POOPHEAD HOSER'  -- Use only upper case!
  61. ;         Uncomment the following & modify appropriately if a disclaimer is desired in the header.
  62. ;  POST_DISCLAIMER = "Disclaimer: This posting represents the poster's views, not necessarily those of their employer."
  63.  
  64. compile if not defined(SMALL)   -- Allow for separate compilation
  65.    include 'stdconst.e'
  66.    tryinclude 'MYCNF.E'            -- Include user's config
  67.  
  68.    defmain
  69.       'nr2post' arg(1)
  70. compile endif -- not defined(SMALL)
  71.  
  72. defc nr2post =
  73.    universal default_save_options
  74.    'postme tabs 8'         -- Set the tabs to 8, so quoted stuff looks right.
  75.    'postme ma 1 65 1'      -- Set the margins narrow, so post can be quoted a
  76.                            -- few times without growing beyond 80 columns.
  77. compile if defined(EPM_VER_DIR)
  78.    call directory(EPM_VER_DIR)
  79. compile endif
  80. compile if EPM32
  81.    default_save_options = default_save_options '/o'  -- Save in OS/2 format.
  82. compile endif
  83. compile if 1        -- Want to turn on dynamic spell-checking for posts?
  84.    if .keyset<>'SPELL_KEYS' then  -- Not already on?
  85.    'postme dynaspell'
  86.    endif
  87. compile endif
  88.    'e =.hdr'
  89.    if rc then return; endif
  90.    0
  91.    wng = ''
  92.    edit_hdr_msg = ''
  93. compile if 0  -- Include this section if you have problems with long lines in the header
  94.    l = longestline()
  95.    if l>255 then
  96.       wng = 'Caution:  Longest line in header is' l 'characters.'
  97.       edit_hdr_msg = EDIT_NR2POST_HEADER__MSG
  98.    endif
  99. compile endif
  100. compile if defined(BAD_SUBJECT_WORDS)
  101.  compile if EPM32
  102.    'xcom l /^Subject\:/cx'
  103.  compile else
  104.    'xcom l /^Subject:/cg'
  105.  compile endif
  106.    if rc then
  107.       subject = ''
  108.    else
  109.       getline subject
  110.  compile if 1 -- Fix for bug in "NeoLogic News for OS/2 [version: 4.5 999]"
  111.       if leftstr(subject, 16) = 'Subject: Re: Re:' then
  112.          replaceline 'Subject: Re:' strip(substr(subject, 17), 'L')
  113.          'save /q'
  114.       endif
  115.  compile endif
  116.       subject = upcase(subject)
  117.       0
  118.    endif
  119. compile endif -- defined(BAD_SUBJECT_WORDS)
  120. compile if EPM32
  121.    'xcom l /^Newsgroups\:/cx'
  122. compile else
  123.    'xcom l /^Newsgroups:/cg'
  124. compile endif
  125. ;  if rc then sayerror '"Newsgroups:" missing!'; return; endif
  126.    if rc then 'quit'; return; endif  -- Could be missing because it's a note, not a post...
  127.    newsgroups = lowcase(textline(.line))
  128. compile if defined(POST_DISCLAIMER)
  129.    insertline POST_DISCLAIMER, .last+1
  130. compile endif
  131.    if pos('test', newsgroups) then
  132.       if wng <> '' then wng = wng\10\10; endif
  133.       wng = wng || 'Newsgroups line contains a test group!'
  134.       edit_hdr_msg = EDIT_NR2POST_HEADER__MSG
  135.       insertline 'X-test-avoider: No Reply', .line+1
  136. compile if not defined(POST_DISCLAIMER)  -- If no disclaimer added,
  137.       'file /q'                          --   File it if test avoider added,
  138.    else                                  --   otherwise
  139.       'quit'                             --   just Quit.
  140.    endif
  141. compile else                             -- If disclaimer added,
  142.    endif
  143.    'file /q'                             -- always File it.
  144. compile endif
  145.    if pos('comp.', newsgroups) & pos('.sex', newsgroups) then
  146.       if wng <> '' then wng = wng\10\10; endif
  147.       wng = wng || 'Newsgroups: line cross-posted to both a comp and a sex group!'
  148.       edit_hdr_msg = EDIT_NR2POST_HEADER__MSG
  149.    endif
  150.    if pos('amiga', newsgroups) & pos('os2', newsgroups) then
  151.       if wng <> '' then wng = wng\10\10; endif
  152.       wng = wng || 'Newsgroups: line cross-posted between an Amiga & an OS/2 group!'
  153.       edit_hdr_msg = EDIT_NR2POST_HEADER__MSG
  154.    endif
  155.    if pos('alt.org.team-os2', newsgroups) & pos(',', newsgroups) then
  156.       if wng <> '' then wng = wng\10\10; endif
  157.       wng = wng || 'Newsgroups: line cross-posted to alt.org.team-os2'
  158.       edit_hdr_msg = EDIT_NR2POST_HEADER__MSG
  159.    endif
  160. compile if defined(BAD_SUBJECT_WORDS)
  161.    do i = 1 to words(BAD_SUBJECT_WORDS)
  162.       if pos(word(BAD_SUBJECT_WORDS, i), subject) then
  163.          if wng <> '' then wng = wng\10\10; endif
  164.          wng = wng || 'Subject: line contains something undesirable.'
  165.          edit_hdr_msg = EDIT_NR2POST_HEADER__MSG
  166.          leave
  167.       endif
  168.    enddo
  169. compile endif -- defined(BAD_SUBJECT_WORDS)
  170. compile if defined(NEWSGROUPS_LIMIT)
  171.    c = count(',', newsgroups)
  172.    if c >= NEWSGROUPS_LIMIT then
  173.       if wng <> '' then wng = wng\10\10; endif
  174.       wng = wng || 'Newsgroups: line contains' c+1 'newsgroups.'
  175.       edit_hdr_msg = EDIT_NR2POST_HEADER__MSG
  176.    endif
  177. compile endif -- defined(NEWSGROUPS_LIMIT)
  178. compile if 0  -- Include this section if you have problems with long lines in the post body
  179.    l = longestline()
  180.    if l>255 then
  181.       if wng <> '' then wng = wng\10\10; endif
  182.       wng = wng || 'Caution:  Longest line is' l 'characters.'
  183.    endif
  184. compile endif
  185.    if wng <> '' then
  186.       call winmessagebox('Newsgroup warning', wng || edit_hdr_msg, MB_OK + MB_MOVEABLE)
  187.    endif
  188.