Synch to No Gnus 200510042243.
[elisp/gnus.git-] / lisp / gnus-msg.el
index 6904bb4..40610bf 100644 (file)
@@ -1,6 +1,7 @@
 ;;; gnus-msg.el --- mail and post interface for Semi-gnus
-;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
-;;        Free Software Foundation, Inc.
+
+;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
+;;   2004, 2005 Free Software Foundation, Inc.
 
 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
 ;;     Lars Magne Ingebrigtsen <larsi@gnus.org>
@@ -24,8 +25,8 @@
 
 ;; 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.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 ;;; Commentary:
 
@@ -71,8 +72,10 @@ message in, you can set this variable to a function that checks the
 current newsgroup name and then returns a suitable group name (or list
 of names)."
   :group 'gnus-message
-  :type '(choice (string :tag "Group")
-                (function)))
+  :type '(choice (const nil)
+                (function)
+                (string :tag "Group")
+                (repeat :tag "List of groups" (string :tag "Group"))))
 
 (defcustom gnus-mailing-list-groups nil
   "*If non-nil a regexp matching groups that are really mailing lists.
@@ -168,7 +171,7 @@ See Info node `(gnus)Posting Styles'."
 
 (defcustom gnus-gcc-mark-as-read nil
   "If non-nil, automatically mark Gcc articles as read."
-  :version "21.4"
+  :version "22.1"
   :group 'gnus-message
   :type 'boolean)
 
@@ -180,7 +183,7 @@ See Info node `(gnus)Posting Styles'."
 If it is `all', attach files as external parts;
 if a regexp and matches the Gcc group name, attach files as external parts;
 if nil, attach files as normal parts."
-  :version "21.4"
+  :version "22.1"
   :group 'gnus-message
   :type '(choice (const nil :tag "None")
                 (const all :tag "Any")
@@ -238,7 +241,7 @@ List of charsets that are permitted to be unencoded.")
     "gnus-agent.el" "gnus-cache.el" "gnus-srvr.el"
     "mm-util.el" "mm-decode.el" "nnmail.el" "nntp.el" "message.el")
   "Files whose variables will be reported in `gnus-bug'."
-  :version "21.4"
+  :version "22.1"
   :group 'gnus-message
   :type '(repeat (string :tag "File")))
 
@@ -246,7 +249,7 @@ List of charsets that are permitted to be unencoded.")
   '(mm-mime-mule-charset-alist
     nnmail-split-fancy message-minibuffer-local-map)
   "Variables that should not be reported in `gnus-bug'."
-  :version "21.4"
+  :version "22.1"
   :group 'gnus-message
   :type '(repeat (symbol :tag "Variable")))
 
@@ -254,7 +257,7 @@ List of charsets that are permitted to be unencoded.")
   '(nndraft nnml nnimap nnmaildir nnmh nnfolder nndir)
   "A list of back ends that are not used in \"real\" newsgroups.
 This variable is used only when `gnus-post-method' is `current'."
-  :version "21.4"
+  :version "22.1"
   :group 'gnus-group-foreign
   :type '(repeat (symbol :tag "Back end")))
 
@@ -278,7 +281,8 @@ See also the `mml-default-encrypt-method' variable."
   :group 'gnus-message
   :type 'boolean)
 
-(defcustom gnus-confirm-mail-reply-to-news nil
+(defcustom gnus-confirm-mail-reply-to-news (and gnus-novice-user
+                                               (not gnus-expert-user))
   "If non-nil, Gnus requests confirmation when replying to news.
 This is done because new users often reply by mistake when reading
 news.
@@ -286,7 +290,7 @@ This can also be a function receiving the group name as the only
 parameter which should return non-nil iff a confirmation is needed, or
 a regexp, in which case a confirmation is asked for iff the group name
 matches the regexp."
-  :version "21.4"
+  :version "22.1"
   :group 'gnus-message
   :type '(choice (const :tag "No" nil)
                 (const :tag "Yes" t)
@@ -299,7 +303,7 @@ matches the regexp."
 when replying by mail.  See the `gnus-confirm-mail-reply-to-news' variable
 for fine-tuning this.
 If nil, Gnus will never ask for confirmation if replying to mail."
-  :version "21.4"
+  :version "22.1"
   :group 'gnus-message
   :type 'boolean)
 
@@ -307,7 +311,7 @@ If nil, Gnus will never ask for confirmation if replying to mail."
   "If non-nil, Gnus tries to suggest a default address to resend to.
 If nil, the address field will always be empty after invoking
 `gnus-summary-resend-message'."
-  :version "21.4"
+  :version "22.1"
   :group 'gnus-message
   :type 'boolean)
 
@@ -500,27 +504,19 @@ Gcc: header for archiving purposes."
   ;; COMPOSEFUNC should return t if succeed.  Undocumented ???
   t)
 
-(defvar save-selected-window-window)
-
 ;;;###autoload
 (defun gnus-button-mailto (address)
   "Mail to ADDRESS."
   (set-buffer (gnus-copy-article-buffer))
   (gnus-setup-message 'message
-    (message-reply address))
-  (and (boundp 'save-selected-window-window)
-       (not (window-live-p save-selected-window-window))
-       (setq save-selected-window-window (selected-window))))
+    (message-reply address)))
 
 ;;;###autoload
 (defun gnus-button-reply (&optional to-address wide)
   "Like `message-reply'."
   (interactive)
   (gnus-setup-message 'message
-    (message-reply to-address wide))
-  (and (boundp 'save-selected-window-window)
-       (not (window-live-p save-selected-window-window))
-       (setq save-selected-window-window (selected-window))))
+    (message-reply to-address wide)))
 
 ;;;###autoload
 (define-mail-user-agent 'gnus-user-agent
@@ -551,7 +547,7 @@ Gcc: header for archiving purposes."
     (gnus-make-local-hook 'message-header-hook)
     (add-hook 'message-header-hook 'gnus-agent-possibly-save-gcc nil t))
   (setq message-post-method
-       `(lambda (arg)
+       `(lambda (&optional arg)
           (gnus-post-method arg ,gnus-newsgroup-name)))
   (setq message-user-agent (gnus-message-make-user-agent))
   (unless message-use-multi-frames
@@ -837,8 +833,7 @@ active, the entire article will be yanked."
         (list (or (assq 'References message-header-format-alist)
                   '(References . message-shorten-references)))
         (list (cons 'References
-                    (mapconcat 'identity (nreverse refs) " "))))
-       (backward-delete-char 1))
+                    (mapconcat 'identity (nreverse refs) " ")))))
       (setq beg (mark t))
       (pop-mark))
 
@@ -930,7 +925,6 @@ header line with the old Message-ID."
            (gnus-remove-text-with-property 'gnus-prev)
            (gnus-remove-text-with-property 'gnus-next)
            (gnus-remove-text-with-property 'gnus-decoration)
-           (gnus-remove-text-with-property 'x-face-mule-bitmap-image)
            (insert
             (prog1
                 (static-if (featurep 'xemacs)
@@ -1119,52 +1113,14 @@ If SILENT, don't prompt the user."
      (t gnus-select-method))))
 
 \f
-;; Dummies to avoid byte-compile warning.
-(eval-when-compile
-  (defvar xemacs-codename))
-
-(defun gnus-message-make-user-agent (&optional include-mime-info max-column
-                                                newline-product)
-  "Return a user-agent info.  If INCLUDE-MIME-INFO is non-nil and the
-variable `mime-edit-user-agent-value' is bound, the value will be
-included in the return value, and `gnus-user-agent' is ignored.  If
-MAX-COLUMN is specified, the return value will be folded up as it were
-filled.  NEWLINE-PRODUCT specifies whether a newline should be
-inserted in front of each product-token.  If the value is t or `hard',
-it works strictly.  Otherwise, if it is non-nil (e.g. `soft'), it
-works semi-strictly.
-
-Here is an odd example, which inserts a User-Agent: header when you
-begin to compose a message:
-
-\(add-hook 'gnus-message-setup-hook
-         (lambda nil
-           (setq message-user-agent nil)
-           (save-excursion
-             (save-restriction
-               (message-narrow-to-headers)
-               (goto-char (point-max))
-               (insert \"User-Agent: \"
-                       (gnus-message-make-user-agent t 76 'soft)
-                       \"\\n\")))))
-"
-  (let ((gnus-v (gnus-extended-version))
-       user-agent)
-    (cond ((and include-mime-info
-               (boundp 'mime-edit-user-agent-value))
-          (setq user-agent (concat gnus-v " " mime-edit-user-agent-value)))
-         ((eq gnus-user-agent 'gnus-mime-edit)
-          (setq user-agent
-                (if (boundp 'mime-edit-user-agent-value)
-                    (concat gnus-v " " mime-edit-user-agent-value)
-                  gnus-v)))
-         (t
-          (setq user-agent (if (stringp gnus-user-agent)
-                               gnus-user-agent
-                             (concat gnus-v
-                                     (let ((emacs-v (gnus-emacs-version)))
-                                       (when emacs-v
-                                         (concat " " emacs-v))))))))
+(defun gnus-message-make-user-agent (&optional dummy max-column
+                                              newline-product)
+  "Return a user-agent info.  If MAX-COLUMN is specified, the return
+value will be folded up as it were filled.  NEWLINE-PRODUCT specifies
+whether a newline should be inserted in front of each product-token;
+if the value is t or `hard', it works strictly.  Otherwise, if it is
+non-nil (e.g. `soft'), it works semi-strictly."
+  (let ((user-agent (gnus-extended-version)))
     (when max-column
       (unless (natnump max-column)
        (setq max-column 76))
@@ -1896,7 +1852,7 @@ this is a reply."
             (gcc (cond
                   ((functionp group)
                    (funcall group))
-                  ((or (stringp group) (list group))
+                  ((or (stringp group) (listp group))
                    group))))
        (when gcc
          (insert "Gcc: "
@@ -2165,10 +2121,12 @@ this is a reply."
       (when (and filep v)
        (setq v (with-temp-buffer
                  (insert-file-contents v)
-                 (goto-char (point-max))
-                 (skip-chars-backward "\n")
-                 (delete-region (+ (point) (if (bolp) 0 1)) (point-max))
-                 (buffer-string))))
+                 (buffer-substring (point-min)
+                                   (progn
+                                     (goto-char (point-max))
+                                     (if (zerop (skip-chars-backward "\n"))
+                                         (point)
+                                       (1+ (point))))))))
       (if (eq element 'import)
          (progn
            (if (member v stack)