home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / elisp / misc / maillist.el < prev    next >
Encoding:
Text File  |  1992-11-25  |  5.7 KB  |  170 lines

  1. ;;  maillist.el
  2. ;;  mailing list utilities for GNU Emacs.
  3. ;;
  4. ;;  written by Lee Short (short@asf.com)
  5. ;;  Copyright (C) 1992 Lee Short.
  6. ;;  last mod: 20 November, 1992
  7.  
  8. ;; LCD Archive Entry:
  9. ;; maillist|Lee Short|short@asf.com|
  10. ;; Mailing list utilities.|
  11. ;; 92-11-20||~/misc/maillist.el.Z|
  12.  
  13. ;; This is free software; you can redistribute it and/or modify
  14. ;; it under the terms of the GNU General Public License as published by
  15. ;; the Free Software Foundation.  
  16.  
  17. ;; This software is distributed in the hope that it will be useful,
  18. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. ;; GNU General Public License for more details.
  21.  
  22. ;; For a copy of the GNU General Public License write to
  23. ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  24.  
  25.  
  26. (defvar  auto-cc-on-maillist-reply nil
  27. "This variable determines if the user will be automatically CCed on replies
  28. to the author of a mailing list message.  This will not work properly unless 
  29. you also have rmail-reply-cc.el" )
  30.  
  31. (defvar  auto-cc-on-maillist-followup nil
  32. "This variable determines if the user will be automatically CCed on followups
  33. to a mailing list message.  This will not work properly unless 
  34. you also have rmail-reply-cc.el" )
  35.  
  36. (defvar  auto-cc-on-nonlist-reply nil
  37. "This variable determines if the user will be automatically CCed on replies
  38. to a mail message.  This will not work properly unless 
  39. you also have rmail-reply-cc.el" )
  40.  
  41. ; the following defvar should be uncommented if rmail-reply-cc.el is not used
  42. ;
  43. ; (defvar  my-mail-address "foo@bar.com" 
  44. ; "The user's email address as it will be automaticlly inserted on CC: 
  45. ; lines.")
  46.  
  47. ; the following defvar should be uncommented if rmail-reply-cc.el is not used
  48. ;
  49. ; (defvar  auto-cc nil 
  50. ; "The value of this variable determines if the user will be automatically 
  51. ; CC'd on mail messages.  )
  52.  
  53.  
  54. (defconst maillists 
  55.        '( ( "Reply-to: DRS@utxvm.cc.utexas.edu" "~/drs.rmail" ) 
  56.           ( "Reply-To: Dead Runners Mind <DRM@DARTCMS1.BITNET>" "~/drs.rmail" )
  57.         )
  58.  "A list which describes the user's mailing lists in a format usable by 
  59. maillist.el.  Each entry in the list is itself a list.  The first entry in 
  60. each sublist is an identifying string in the text of messages from the 
  61. mailing list, the second is the name of the rmail file in which to save 
  62. messages from the mailing list.  Any message in which the identifying 
  63. string is found is assumed to be a message from the mailing list.  Thus, 
  64. a forwarded message from the mailing list is likely to be flagged as 
  65. coming from the list."
  66. )
  67.  
  68.  
  69. (defun file-to-maillist ()
  70. "Saves the current rmail message to the rmail file for its mailing list, as 
  71. specified in the constant maillists."
  72. ;;  searches the message for a match with any of the identifying strings 
  73. ;;  given in maillists.  As soon as it finds a match, it outputs the message
  74. ;;  to the mailing list's rmail file and deletes it from the current rmail
  75. ;;  file
  76.    (interactive)
  77.    (rmail-output-to-rmail-file 
  78.       (let  ( (current-list maillists) 
  79.               (rmail-filename nil)  )
  80.           (while  (and (car current-list) (not rmail-filename) )
  81.               (if (my-string-find (car (car current-list) ) )
  82.                   (setq rmail-filename (car (cdr ( car current-list) ) ) )  )
  83.               (setq current-list (cdr current-list) )
  84.           )
  85.           rmail-filename
  86.       )
  87.    )
  88.    (rmail-delete-forward)
  89. )
  90.  
  91.  
  92. (defun reply-to-maillist-message ()
  93. "Initiates a reply to the author of a mailing list article."
  94.    (let  ( (from nil) )
  95.       (interactive)
  96.       (delete-other-windows)
  97.       (setq auto-cc auto-cc-on-maillist-reply)
  98.       (rmail-reply t)        ;; you are now in the mail buffer
  99.  
  100.       (beginning-of-buffer)
  101.       (word-search-forward "To: " nil t)
  102.       (kill-line)               ;; waste the old "to" field
  103.       (insert ": ")
  104.  
  105.       (other-window 1)          ;; you are now in the rmail buffer
  106.       (setq from (mail-fetch-field "from") )      ;; find the author's name
  107.  
  108.       (other-window 1)        ;; you are now in the mail buffer
  109.       (insert from)          ;; insert the name of the author
  110.  
  111.       (end-of-buffer)
  112.       (newline)
  113.    )
  114. )
  115.  
  116.  
  117. (defun my-rmail-followup  ()
  118. "Initiates a followup to the mailing list in reply to a mailing list article."
  119.    (interactive)
  120.    (delete-other-windows)
  121.    (setq auto-cc auto-cc-on-maillist-followup)
  122.    (rmail-reply t)
  123. )
  124.  
  125. (defun my-string-find  (string-arg)
  126. "Searches for a string in the current buffer.  Returns t if it is found, 
  127. nil otherwise."
  128.    (set-mark-command nil)          ;;  store point
  129.    (beginning-of-buffer)
  130.    (if  (word-search-forward string-arg nil t)
  131.        (progn
  132.           (set-mark-command t)          ;;  restore point
  133.           t
  134.        )
  135.        (progn
  136.           (set-mark-command t)          ;;  restore point
  137.           nil
  138.        )
  139.    )
  140. )
  141.  
  142. (defun maillist-p ()
  143. "Determines if the current rmail message is in one of the mailing lists as 
  144. defined by the constant maillists."
  145.    (let  ( (current-list maillists) 
  146.            (found nil)  )
  147.        (while  (and (car current-list) (not found) )
  148.            (if (my-string-find (car (car current-list) ) )
  149.                (setq found t)  )
  150.            (setq current-list (cdr current-list) )
  151.        )
  152.        found
  153.    )
  154. )
  155.  
  156. (defun my-rmail-reply  ()
  157. "Sends a reply to the author of an rmail message, if the message is either a 
  158. regular message, or a message from one of the mailing lists defined by the 
  159. variable maillists.  Any other mailing list message will likely result in 
  160. a reply to the mailing list, rather than the author."  
  161.     (interactive)
  162.     (if (maillist-p)
  163.         (reply-to-maillist-message)
  164.         (progn
  165.            (setq auto-cc auto-cc-on-nonlist-reply)
  166.            (rmail-reply nil)
  167.         )
  168.     )
  169. )
  170.