Merge from emacs--devo--0, gnus--rel--5.10
[gnus] / lisp / message.el
index 8bc7f20..0a38ec0 100644 (file)
@@ -8,20 +8,18 @@
 
 ;; 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 3, 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
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         See the
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 ;; 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., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
@@ -1794,33 +1792,32 @@ You must have the \"hashcash\" binary installed, see `hashcash-path'."
   :group 'message-headers
   :type 'regexp)
 
-(eval-and-compile
-  (autoload 'gnus-alive-p "gnus-util")
-  (autoload 'gnus-delay-article "gnus-delay")
-  (autoload 'gnus-extract-address-components "gnus-util")
-  (autoload 'gnus-find-method-for-group "gnus")
-  (autoload 'gnus-group-decoded-name "gnus-group")
-  (autoload 'gnus-group-name-charset "gnus-group")
-  (autoload 'gnus-group-name-decode "gnus-group")
-  (autoload 'gnus-groups-from-server "gnus")
-  (autoload 'gnus-make-local-hook "gnus-util")
-  (autoload 'gnus-open-server "gnus-int")
-  (autoload 'gnus-output-to-mail "gnus-util")
-  (autoload 'gnus-output-to-rmail "gnus-util")
-  (autoload 'gnus-request-post "gnus-int")
-  (autoload 'gnus-select-frame-set-input-focus "gnus-util")
-  (autoload 'gnus-server-string "gnus")
-  (autoload 'idna-to-ascii "idna")
-  (autoload 'message-setup-toolbar "messagexmas")
-  (autoload 'mh-new-draft-name "mh-comp")
-  (autoload 'mh-send-letter "mh-comp")
-  (autoload 'nndraft-request-associate-buffer "nndraft")
-  (autoload 'nndraft-request-expire-articles "nndraft")
-  (autoload 'nnvirtual-find-group-art "nnvirtual")
-  (autoload 'rmail-dont-reply-to "mail-utils")
-  (autoload 'rmail-msg-is-pruned "rmail")
-  (autoload 'rmail-msg-restore-non-pruned-header "rmail")
-  (autoload 'rmail-output "rmailout"))
+(autoload 'gnus-alive-p "gnus-util")
+(autoload 'gnus-delay-article "gnus-delay")
+(autoload 'gnus-extract-address-components "gnus-util")
+(autoload 'gnus-find-method-for-group "gnus")
+(autoload 'gnus-group-decoded-name "gnus-group")
+(autoload 'gnus-group-name-charset "gnus-group")
+(autoload 'gnus-group-name-decode "gnus-group")
+(autoload 'gnus-groups-from-server "gnus")
+(autoload 'gnus-make-local-hook "gnus-util")
+(autoload 'gnus-open-server "gnus-int")
+(autoload 'gnus-output-to-mail "gnus-util")
+(autoload 'gnus-output-to-rmail "gnus-util")
+(autoload 'gnus-request-post "gnus-int")
+(autoload 'gnus-select-frame-set-input-focus "gnus-util")
+(autoload 'gnus-server-string "gnus")
+(autoload 'idna-to-ascii "idna")
+(autoload 'message-setup-toolbar "messagexmas")
+(autoload 'mh-new-draft-name "mh-comp")
+(autoload 'mh-send-letter "mh-comp")
+(autoload 'nndraft-request-associate-buffer "nndraft")
+(autoload 'nndraft-request-expire-articles "nndraft")
+(autoload 'nnvirtual-find-group-art "nnvirtual")
+(autoload 'rmail-dont-reply-to "mail-utils")
+(autoload 'rmail-msg-is-pruned "rmail")
+(autoload 'rmail-msg-restore-non-pruned-header "rmail")
+(autoload 'rmail-output "rmailout")
 
 \f
 
@@ -4062,11 +4059,32 @@ not have PROP."
        (setq start next)))
     (nreverse regions)))
 
-(defcustom message-bogus-address-regexp nil ;; "noreply\\|nospam\\|invalid"
-  "Regexp of potentially bogus mail addresses."
+(defcustom message-bogus-addresses
+  ;; '("noreply" "nospam" "invalid")
+  '("noreply" "nospam" "invalid" "@@" "[^[:ascii:]].*@" "[ \t]")
+  "List of regexps of potentially bogus mail addresses.
+See `message-check-recipients' how to setup checking.
+
+This list should make it possible to catch typos or warn about
+spam-trap addresses.  It doesn't aim to verify strict RFC
+conformance."
   :version "23.1" ;; No Gnus
   :group 'message-headers
-  :type 'regexp)
+  :type '(choice
+         (const :tag "None" nil)
+         (list
+          (set :inline t
+               (const "noreply")
+               (const "nospam")
+               (const "invalid")
+               (const :tag "duplicate @" "@@")
+               (const :tag "non-ascii local part" "[^[:ascii:]].*@")
+               ;; Already caught by `message-valid-fqdn-regexp'
+               ;; (const :tag "`_' in domain part" "@.*_")
+               (const :tag "whitespace" "[ \t]"))
+          (repeat :inline t
+                  :tag "Other"
+                  (regexp)))))
 
 (defun message-fix-before-sending ()
   "Do various things to make the message nice before sending it."
@@ -4152,7 +4170,7 @@ not have PROP."
          (forward-char)
          (skip-chars-forward mm-7bit-chars)))))
   (message-check 'bogus-recipient
-    ;; Warn before composing or sending a mail to an invalid address.
+    ;; Warn before sending a mail to an invalid address.
     (message-check-recipients)))
 
 (defun message-bogus-recipient-p (recipients)
@@ -4161,9 +4179,9 @@ not have PROP."
 RECIPIENTS is a mail header.  Return a list of potentially bogus
 addresses.  If none is found, return nil.
 
-An addresses might be bogus if the domain part is not fully
-qualified, see `message-valid-fqdn-regexp', or if it matches
-`message-bogus-address-regexp'."
+An address might be bogus if the domain part is not fully
+qualified, see `message-valid-fqdn-regexp', or if there's a
+matching entry in `message-bogus-addresses'."
   ;; FIXME: How about "foo@subdomain", when the MTA adds ".domain.tld"?
   (let (found)
     (mapc (lambda (address)
@@ -4175,9 +4193,15 @@ qualified, see `message-valid-fqdn-regexp', or if it matches
                      (string-match
                       (concat ".@.*\\("
                               message-valid-fqdn-regexp "\\)\\'") address)))
-                   (and (stringp message-bogus-address-regexp)
-                        (string-match message-bogus-address-regexp address)))
-             (push address found)))
+                   (and message-bogus-addresses
+                        (let ((re
+                               (if (listp message-bogus-addresses)
+                                   (mapconcat 'identity
+                                              message-bogus-addresses
+                                              "\\|")
+                                 message-bogus-addresses)))
+                          (string-match re address))))
+                        (push address found)))
          ;;
          (mail-extract-address-components recipients t))
     found))
@@ -4199,6 +4223,8 @@ This function could be useful in `message-setup-hook'."
                        "Address `%s' might be bogus.  Continue? " bog)))
                 (error "Bogus address."))))))))
 
+(custom-add-option 'message-setup-hook 'message-check-recipients)
+
 (defun message-add-action (action &rest types)
   "Add ACTION to be performed when doing an exit of type TYPES."
   (while types
@@ -4517,7 +4543,7 @@ to find out how to use this."
        (apply
         'call-process-region (point-min) (point-max)
         message-qmail-inject-program nil nil nil
-        ;; qmail-inject's default behaviour is to look for addresses on the
+        ;; qmail-inject's default behavior is to look for addresses on the
         ;; command line; if there're none, it scans the headers.
         ;; yes, it does The Right Thing w.r.t. Resent-To and it's kin.
         ;;
@@ -6275,7 +6301,7 @@ are not included."
   "Disassociate the message buffer from the drafts directory."
   (when message-draft-article
     (nndraft-request-expire-articles
-     (list message-draft-article) "nndraft:drafts" nil t)))
+     (list message-draft-article) "drafts" nil t)))
 
 (defun message-insert-headers ()
   "Generate the headers for the article."
@@ -7080,9 +7106,8 @@ Optional DIGEST will use digest to forward."
       (message-forward-make-body-digest-mime forward-buffer)
     (message-forward-make-body-digest-plain forward-buffer)))
 
-(eval-and-compile
-  (autoload 'mm-uu-dissect-text-parts "mm-uu")
-  (autoload 'mm-uu-dissect "mm-uu"))
+(autoload 'mm-uu-dissect-text-parts "mm-uu")
+(autoload 'mm-uu-dissect "mm-uu")
 
 (defun message-signed-or-encrypted-p (&optional dont-emulate-mime handles)
   "Say whether the current buffer contains signed or encrypted message.