*** empty log message ***
[gnus] / lisp / gnus-msg.el
index 295d84b..dbf2722 100644 (file)
@@ -26,6 +26,8 @@
 
 ;;; Code:
 
+(eval-when-compile (require 'cl))
+
 (require 'gnus)
 (require 'gnus-ems)
 (require 'message)
@@ -97,6 +99,7 @@ the second with the current group name.")
 (defvar gnus-message-buffer "*Mail Gnus*")
 (defvar gnus-article-copy nil)
 (defvar gnus-last-posting-server nil)
+(defvar gnus-message-group-art nil)
 
 (defconst gnus-bug-message
   "Sending a bug report to the Gnus Towers.
@@ -159,9 +162,9 @@ Thank you for your help in stamping out bugs.
 
 (defvar gnus-article-reply nil)
 (defmacro gnus-setup-message (config &rest forms)
-  (let ((winconf (make-symbol "winconf"))
-       (buffer (make-symbol "buffer"))
-       (article (make-symbol "article")))
+  (let ((winconf (make-symbol "gnus-setup-message-winconf"))
+       (buffer (make-symbol "gnus-setup-message-buffer"))
+       (article (make-symbol "gnus-setup-message-article")))
     `(let ((,winconf (current-window-configuration))
           (,buffer (buffer-name (current-buffer)))
           (,article (and gnus-article-reply (gnus-summary-article-number)))
@@ -170,9 +173,12 @@ Thank you for your help in stamping out bugs.
        (add-hook 'message-header-setup-hook 'gnus-inews-insert-gcc)
        (add-hook 'message-header-setup-hook 'gnus-inews-insert-archive-gcc)
        (unwind-protect
-          ,@forms
+          (progn
+            ,@forms)
         (gnus-inews-add-send-actions ,winconf ,buffer ,article)
         (setq gnus-message-buffer (current-buffer))
+        (set (make-local-variable 'gnus-message-group-art)
+             (cons ,gnus-newsgroup-name ,article))
         (make-local-variable 'gnus-newsgroup-name)
         (run-hooks 'gnus-message-setup-hook))
        (gnus-configure-windows ,config t)
@@ -180,7 +186,7 @@ Thank you for your help in stamping out bugs.
 
 (defun gnus-inews-add-send-actions (winconf buffer article)
   (make-local-hook 'message-sent-hook)
-  (gnus-add-hook 'message-sent-hook 'gnus-inews-do-gcc nil t)
+  (add-hook 'message-sent-hook 'gnus-inews-do-gcc nil t)
   (setq message-post-method
        `(lambda (arg)
           (gnus-post-method arg ,gnus-newsgroup-name)))
@@ -211,8 +217,7 @@ Thank you for your help in stamping out bugs.
 If ARG, post to the group under point.
 If ARG is 1, prompt for a group name."
   (interactive "P")
-  ;; Bind this variable here to make message mode hooks
-  ;; work ok.
+  ;; Bind this variable here to make message mode hooks work ok.
   (let ((gnus-newsgroup-name
         (if arg
             (if (= 1 (prefix-numeric-value arg))
@@ -225,7 +230,6 @@ If ARG is 1, prompt for a group name."
 (defun gnus-summary-post-news ()
   "Start composing a news message."
   (interactive)
-  (gnus-set-global-variables)
   (gnus-post-news 'post gnus-newsgroup-name))
 
 (defun gnus-summary-followup (yank &optional force-news)
@@ -234,7 +238,6 @@ If prefix argument YANK is non-nil, original article is yanked automatically."
   (interactive
    (list (and current-prefix-arg
              (gnus-summary-work-articles 1))))
-  (gnus-set-global-variables)
   (when yank
     (gnus-summary-goto-subject (car yank)))
   (save-window-excursion
@@ -281,14 +284,16 @@ If prefix argument YANK is non-nil, original article is yanked automatically."
     (push-mark)
     (goto-char beg)))
 
-(defun gnus-summary-cancel-article (n)
-  "Cancel an article you posted."
-  (interactive "P")
-  (gnus-set-global-variables)
+(defun gnus-summary-cancel-article (&optional n symp)
+  "Cancel an article you posted.
+Uses the process-prefix convention.  If given the symbolic
+prefix `a', cancel using the standard posting method; if not
+post using the current select method."
+  (interactive (gnus-interactive "P\ny"))
   (let ((articles (gnus-summary-work-articles n))
        (message-post-method
         `(lambda (arg)
-           (gnus-post-method nil ,gnus-newsgroup-name)))
+           (gnus-post-method (not (eq symp 'a)) ,gnus-newsgroup-name)))
        article)
     (while (setq article (pop articles))
       (when (gnus-summary-select-article t nil nil article)
@@ -304,7 +309,6 @@ If prefix argument YANK is non-nil, original article is yanked automatically."
 This is done simply by taking the old article and adding a Supersedes
 header line with the old Message-ID."
   (interactive)
-  (gnus-set-global-variables)
   (let ((article (gnus-summary-article-number)))
     (gnus-setup-message 'reply-yank
       (gnus-summary-select-article t)
@@ -415,7 +419,9 @@ header line with the old Message-ID."
                  (push (list 'gnus-inews-add-to-address pgroup)
                        message-send-actions)))
            (set-buffer gnus-article-copy)
-           (message-wide-reply to-address)))
+           (message-wide-reply to-address
+                               (gnus-group-find-parameter
+                                gnus-newsgroup-name 'broken-reply-to))))
        (when yank
          (gnus-inews-yank-articles yank))))))
 
@@ -510,6 +516,7 @@ If SILENT, don't prompt the user."
 
 ;; Dummy to avoid byte-compile warning.
 (defvar nnspool-rejected-article-hook)
+(defvar xemacs-codename)
 
 ;;; Since the X-Newsreader/X-Mailer are ``vanity'' headers, they might
 ;;; as well include the Emacs version as well.
@@ -535,7 +542,9 @@ If SILENT, don't prompt the user."
                 (substring emacs-version
                            (match-beginning 3)
                            (match-end 3))
-              "")))
+              "")
+            (if (boundp 'xemacs-codename)
+                (concat " - \"" xemacs-codename "\""))))
     (t emacs-version))))
 
 ;; Written by "Mr. Per Persson" <pp@gnu.ai.mit.edu>.
@@ -579,7 +588,6 @@ automatically."
    (list (and current-prefix-arg
              (gnus-summary-work-articles 1))))
   ;; Stripping headers should be specified with mail-yank-ignored-headers.
-  (gnus-set-global-variables)
   (when yank
     (gnus-summary-goto-subject (car yank)))
   (let ((gnus-article-reply t))
@@ -616,7 +624,6 @@ The original article will be yanked."
   "Forward the current message to another user.
 If FULL-HEADERS (the prefix), include full headers when forwarding."
   (interactive "P")
-  (gnus-set-global-variables)
   (gnus-setup-message 'forward
     (gnus-summary-select-article)
     (set-buffer gnus-original-article-buffer)
@@ -689,6 +696,7 @@ The current group name will be inserted at \"%s\".")
          (message-goto-subject)
          (re-search-forward " *$")
          (replace-match " (crosspost notification)" t t)
+         (gnus-deactivate-mark)
          (when (gnus-y-or-n-p "Send this complaint? ")
            (message-send-and-exit)))))))
 
@@ -792,7 +800,7 @@ If YANK is non-nil, include the original article."
     (error "Gnus has been shut down"))
   (gnus-setup-message 'bug
     (delete-other-windows)
-    (switch-to-buffer "*Gnus Help Bug*")
+    (switch-to-buffer (get-buffer-create "*Gnus Help Bug*"))
     (erase-buffer)
     (insert gnus-bug-message)
     (goto-char (point-min))
@@ -825,6 +833,7 @@ The source file has to be in the Emacs load path."
                 "gnus-art.el" "gnus-start.el" "gnus-async.el"
                 "gnus-msg.el" "gnus-score.el" "gnus-win.el" "gnus-topic.el"
                 "nnmail.el" "message.el"))
+       (point (point))
        file expr olist sym)
     (gnus-message 4 "Please wait while we snoop your variables...")
     (sit-for 0)
@@ -870,11 +879,12 @@ The source file has to be in the Emacs load path."
        (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
       (setq olist (cdr olist)))
     (insert "\n\n")
-    ;; Remove any null chars - they seem to cause trouble for some
+    ;; Remove any control chars - they seem to cause trouble for some
     ;; mailers.  (Byte-compiled output from the stuff above.)
-    (goto-char (point-min))
-    (while (re-search-forward "[\000\200]" nil t)
-      (replace-match "" t t))))
+    (goto-char point)
+    (while (re-search-forward "[\000-\010\013-\037\200-\237]" nil t)
+      (replace-match (format "\\%03o" (string-to-char (match-string 0)))
+                    t t))))
 
 ;;; Treatment of rejected articles.
 ;;; Bounced mail.
@@ -969,8 +979,11 @@ this is a reply."
   "Insert the Gcc to say where the article is to be archived."
   (let* ((var gnus-message-archive-group)
         (group (or group gnus-newsgroup-name ""))
-        result
-        gcc-self-val
+        (gcc-self-val
+         (and gnus-newsgroup-name
+              (gnus-group-find-parameter
+               gnus-newsgroup-name 'gcc-self)))
+        result 
         (groups
          (cond
           ((null gnus-message-archive-method)
@@ -1006,7 +1019,7 @@ this is a reply."
              (setq var (cdr var)))
            result)))
         name)
-    (when groups
+    (when (or groups gcc-self-val)
       (when (stringp groups)
        (setq groups (list groups)))
       (save-excursion
@@ -1014,10 +1027,8 @@ this is a reply."
          (message-narrow-to-headers)
          (goto-char (point-max))
          (insert "Gcc: ")
-         (if (and gnus-newsgroup-name
-                  (setq gcc-self-val
-                        (gnus-group-find-parameter
-                         gnus-newsgroup-name 'gcc-self)))
+         (if gcc-self-val
+             ;; Use the `gcc-self' param value instead.
              (progn
                (insert
                 (if (stringp gcc-self-val)
@@ -1028,6 +1039,7 @@ this is a reply."
                  (progn
                    (beginning-of-line)
                    (kill-line))))
+           ;; Use the list of groups.
            (while (setq name (pop groups))
              (insert (if (string-match ":" name)
                          name
@@ -1037,27 +1049,6 @@ this is a reply."
                (insert " ")))
            (insert "\n")))))))
 
-(defun gnus-summary-send-draft ()
-  "Enter a mail/post buffer to edit and send the draft."
-  (interactive)
-  (gnus-set-global-variables)
-  (let (buf)
-    (if (not (setq buf (gnus-request-restore-buffer
-                       (gnus-summary-article-number) gnus-newsgroup-name)))
-       (error "Couldn't restore the article")
-      (switch-to-buffer buf)
-      (when (eq major-mode 'news-reply-mode)
-       (local-set-key "\C-c\C-c" 'gnus-inews-news))
-      ;; Insert the separator.
-      (goto-char (point-min))
-      (search-forward "\n\n")
-      (forward-char -1)
-      (insert mail-header-separator)
-      ;; Configure windows.
-      (let ((gnus-draft-buffer (current-buffer)))
-       (gnus-configure-windows 'draft t)
-       (goto-char (point))))))
-
 (gnus-add-shutdown 'gnus-inews-close 'gnus)
 
 (defun gnus-inews-close ()