hide-ifdef-mode documented; mark some entries as not needed doc updates.
[bpt/emacs.git] / lisp / mail / uce.el
index 722ef28..283608c 100644 (file)
@@ -1,6 +1,7 @@
 ;;; uce.el --- facilitate reply to unsolicited commercial email
 
-;; Copyright (C) 1996, 1998, 2000 Free Software Foundation, Inc.
+;; Copyright (C) 1996, 1998, 2000, 2001, 2002, 2003, 2004,
+;;   2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Author: stanislav shalunov <shalunov@mccme.ru>
 ;; Created: 10 Dec 1996
@@ -8,10 +9,10 @@
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -19,9 +20,7 @@
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
 
 ;;; Code:
 
+(defvar gnus-original-article-buffer)
+(defvar mail-reply-buffer)
+(defvar rmail-current-message)
+
 (require 'sendmail)
 ;; Those sections of code which are dependent upon
 ;; RMAIL are only evaluated if we have received a message with RMAIL...
-;;(require 'rmail) 
+;;(require 'rmail)
 
 (defgroup uce nil
   "Facilitate reply to unsolicited commercial email."
@@ -137,7 +140,7 @@ This hook is run after `mail-setup-hook', which is run as well."
   :type 'hook
   :group 'uce)
 
-(defcustom uce-message-text 
+(defcustom uce-message-text
   "Recently, I have received an Unsolicited Commercial E-mail from you.
 I do not like UCE's and I would like to inform you that sending
 unsolicited messages to someone while he or she may have to pay for
@@ -148,8 +151,8 @@ If you think that this is a good way to advertise your products or
 services you are mistaken.  Spamming will only make people hate you, not
 buy from you.
 
-If you have any list of people you send unsolicited commercial emails to, 
-REMOVE me from such list immediately.  I suggest that you make this list 
+If you have any list of people you send unsolicited commercial emails to,
+REMOVE me from such list immediately.  I suggest that you make this list
 just empty.
 
        ----------------------------------------------------
@@ -192,7 +195,7 @@ Value nil means use no separator."
   :group 'uce)
 
 (defcustom uce-signature mail-signature
-"Text to put as your signature after the note to UCE sender.  
+"Text to put as your signature after the note to UCE sender.
 Value nil means none, t means insert `~/.signature' file (if it happens
 to exist), if this variable is a string this string will be inserted
 as your signature."
@@ -212,6 +215,14 @@ These are mostly meant for headers that prevent delivery errors reporting."
   :type 'string
   :group 'uce)
 
+(declare-function mail-strip-quoted-names "mail-utils" (address))
+(declare-function rmail-msg-is-pruned "rmail" ())
+(declare-function rmail-maybe-set-message-counters "rmail" ())
+(declare-function rmail-msgbeg "rmail" (n))
+(declare-function rmail-msgend "rmail" (n))
+(declare-function rmail-toggle-header "rmail" (&optional arg))
+
+
 (defun uce-reply-to-uce (&optional ignored)
   "Send reply to UCE in Rmail.
 UCE stands for unsolicited commercial email.  Function will set up reply
@@ -221,12 +232,12 @@ address, and postmaster of the mail relay used."
   (let ((message-buffer
         (cond ((eq uce-mail-reader 'gnus) gnus-original-article-buffer)
               ((eq uce-mail-reader 'rmail) "RMAIL")
-              (t (error 
+              (t (error
                   "Variable uce-mail-reader set to unrecognized value"))))
        (full-header-p (and (eq uce-mail-reader 'rmail)
                            (not (rmail-msg-is-pruned)))))
     (or (get-buffer message-buffer)
-       (error (concat "No buffer " message-buffer ", cannot find UCE")))
+       (error "No buffer %s, cannot find UCE" message-buffer))
     (switch-to-buffer message-buffer)
     ;; We need the message with headers pruned.
     (if full-header-p
@@ -246,7 +257,7 @@ address, and postmaster of the mail relay used."
              end-of-hostname (string-match "[ ,>]" to first-at-sign)
              sender-host (substring to first-at-sign end-of-hostname))
        (if (string-match "\\." sender-host)
-           (setq to (format "%s, postmaster%s, abuse%s" 
+           (setq to (format "%s, postmaster%s, abuse%s"
                             to sender-host sender-host))))
       (setq mail-send-actions nil)
       (setq mail-reply-buffer nil)
@@ -258,7 +269,7 @@ address, and postmaster of the mail relay used."
                 (rmail-toggle-header 1)
                 (widen)
                 (rmail-maybe-set-message-counters)
-                (copy-region-as-kill (rmail-msgbeg rmail-current-message) 
+                (copy-region-as-kill (rmail-msgbeg rmail-current-message)
                                      (rmail-msgend rmail-current-message))))))
       ;; Restore the pruned header state we found.
       (if full-header-p
@@ -283,10 +294,10 @@ address, and postmaster of the mail relay used."
             (re-search-forward "^Lines:")
             (beginning-of-line))
            ((eq uce-mail-reader 'rmail)
-            (beginning-of-buffer)
+            (goto-char (point-min))
             (search-forward "*** EOOH ***\n")
             (beginning-of-line)
-            (forward-line -1)))      
+            (forward-line -1)))
       (re-search-backward "^Received:")
       (beginning-of-line)
       ;; Is this always good?  It's the only thing I saw when I checked
@@ -304,7 +315,7 @@ address, and postmaster of the mail relay used."
       (forward-char -1)
       ;; And add its postmaster to the list of addresses.
       (if (string-match "\\." (buffer-substring temp (point)))
-         (setq to (format "%s, postmaster@%s" 
+         (setq to (format "%s, postmaster@%s"
                           to (buffer-substring temp (point)))))
       ;; Also look at the message-id, it helps *very* often.
       (if (and (search-forward "\nMessage-Id: " nil t)
@@ -320,7 +331,7 @@ address, and postmaster of the mail relay used."
            (search-forward ">")
            (forward-char -1)
            (if (string-match "\\." (buffer-substring temp (point)))
-               (setq to (format "%s, postmaster@%s" 
+               (setq to (format "%s, postmaster@%s"
                                 to (buffer-substring temp (point)))))))
       (cond ((eq uce-mail-reader 'gnus)
             ;; Does Gnus always have Lines: in the end?
@@ -364,11 +375,7 @@ address, and postmaster of the mail relay used."
               (if (file-exists-p "~/.signature")
                   (progn
                     (insert "\n\n-- \n")
-                    (insert-file "~/.signature")
-                    ;; Function insert-file leaves point where it was,
-                    ;; while we want to place signature in the ``middle''
-                    ;; of the message.
-                    (exchange-point-and-mark))))
+                    (forward-char (cadr (insert-file-contents "~/.signature"))))))
              (uce-signature
               (insert "\n\n-- \n" uce-signature)))
        ;; And text of the original message.
@@ -384,7 +391,7 @@ address, and postmaster of the mail relay used."
       ;; might be to set up special key bindings, replace standart
       ;; functions in mail-mode, etc.
       (run-hooks 'mail-setup-hook 'uce-setup-hook))))
-  
+
 (defun uce-insert-ranting (&optional ignored)
   "Insert text of the usual reply to UCE into current buffer."
   (interactive "P")
@@ -392,4 +399,5 @@ address, and postmaster of the mail relay used."
 
 (provide 'uce)
 
+;; arch-tag: 44b68c87-9b29-47bd-822c-3feee3883221
 ;;; uce.el ends here