1 ;;; gnus-msg.el --- mail and post interface for Gnus
2 ;; Copyright (C) 1995,96 Free Software Foundation, Inc.
4 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
5 ;; Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
35 ;; Added by Sudish Joseph <joseph@cis.ohio-state.edu>.
36 (defvar gnus-post-method nil
37 "*Preferred method for posting USENET news.
38 If this variable is nil, Gnus will use the current method to decide
39 which method to use when posting. If it is non-nil, it will override
40 the current method. This method will not be used in mail groups and
41 the like, only in \"real\" newsgroups.
43 The value must be a valid method as discussed in the documentation of
44 `gnus-select-method'. It can also be a list of methods. If that is
45 the case, the user will be queried for what select method to use when
48 (defvar gnus-outgoing-message-group nil
49 "*All outgoing messages will be put in this group.
50 If you want to store all your outgoing mail and articles in the group
51 \"nnml:archive\", you set this variable to that value. This variable
52 can also be a list of group names.
54 If you want to have greater control over what group to put each
55 message in, you can set this variable to a function that checks the
56 current newsgroup name and then returns a suitable group name (or list
59 (defvar gnus-mailing-list-groups nil
60 "*Regexp matching groups that are really mailing lists.
61 This is useful when you're reading a mailing list that has been
62 gatewayed to a newsgroup, and you want to followup to an article in
65 (defvar gnus-sent-message-ids-file
66 (nnheader-concat gnus-directory "Sent-Message-IDs")
67 "File where Gnus saves a cache of sent message ids.")
69 (defvar gnus-sent-message-ids-length 1000
70 "The number of sent Message-IDs to save.")
72 (defvar gnus-crosspost-complaint
75 You posted the article below with the following Newsgroups header:
79 The %s group, at least, was an inappropriate recipient
80 of this message. Please trim your Newsgroups header to exclude this
81 group before posting in the future.
85 "Format string to be inserted when complaining about crossposts.
86 The first %s will be replaced by the Newsgroups header;
87 the second with the current group name.")
89 ;;; Internal variables.
91 (defvar gnus-message-buffer "*Mail Gnus*")
92 (defvar gnus-article-copy nil)
93 (defvar gnus-last-posting-server nil)
95 (defconst gnus-bug-message
96 "Sending a bug report to the Gnus Towers.
97 ========================================
99 The buffer below is a mail buffer. When you press `C-c C-c', it will
100 be sent to the Gnus Bug Exterminators.
102 At the bottom of the buffer you'll see lots of variable settings.
103 Please do not delete those. They will tell the Bug People what your
104 environment is, so that it will be easier to locate the bugs.
106 If you have found a bug that makes Emacs go \"beep\", set
107 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
108 and include the backtrace in your bug report.
110 Please describe the bug in annoying, painstaking detail.
112 Thank you for your help in stamping out bugs.
116 (autoload 'gnus-uu-post-news "gnus-uu" nil t)
117 (autoload 'news-setup "rnewspost")
118 (autoload 'news-reply-mode "rnewspost")
119 (autoload 'rmail-dont-reply-to "mail-utils")
120 (autoload 'rmail-output "rmailout"))
124 ;;; Gnus Posting Functions
127 (gnus-define-keys (gnus-summary-send-map "S" gnus-summary-mode-map)
128 "p" gnus-summary-post-news
129 "f" gnus-summary-followup
130 "F" gnus-summary-followup-with-original
131 "c" gnus-summary-cancel-article
132 "s" gnus-summary-supersede-article
133 "r" gnus-summary-reply
134 "R" gnus-summary-reply-with-original
135 "m" gnus-summary-mail-other-window
136 "u" gnus-uu-post-news
137 "\M-c" gnus-summary-mail-crosspost-complaint
138 "om" gnus-summary-mail-forward
139 "op" gnus-summary-post-forward
140 "Om" gnus-uu-digest-mail-forward
141 "Op" gnus-uu-digest-post-forward)
143 (gnus-define-keys (gnus-send-bounce-map "D" gnus-summary-send-map)
144 "b" gnus-summary-resend-bounced-mail
145 ;; "c" gnus-summary-send-draft
146 "r" gnus-summary-resend-message)
148 ;;; Internal functions.
150 (defvar gnus-article-reply nil)
151 (defmacro gnus-setup-message (config &rest forms)
152 (let ((winconf (make-symbol "winconf"))
153 (buffer (make-symbol "buffer"))
154 (article (make-symbol "article")))
155 `(let ((,winconf (current-window-configuration))
156 (,buffer (current-buffer))
157 (,article (and gnus-article-reply (gnus-summary-article-number)))
158 (message-header-setup-hook
159 (copy-sequence message-header-setup-hook)))
160 (add-hook 'message-header-setup-hook 'gnus-inews-insert-gcc)
161 (add-hook 'message-header-setup-hook 'gnus-inews-insert-archive-gcc)
163 (gnus-inews-add-send-actions ,winconf ,buffer ,article)
164 (setq gnus-message-buffer (current-buffer))
165 (make-local-variable 'gnus-newsgroup-name)
166 (gnus-configure-windows ,config t))))
168 (defun gnus-inews-add-send-actions (winconf buffer article)
169 (gnus-make-local-hook 'message-sent-hook)
170 (gnus-add-hook 'message-sent-hook 'gnus-inews-do-gcc nil t)
171 (setq message-post-method
173 (gnus-post-method arg ,gnus-newsgroup-name)))
174 (setq message-newsreader (setq message-mailer (gnus-extended-version)))
176 `(set-window-configuration ,winconf) 'exit 'postpone 'kill)
178 `(when (buffer-name ,buffer)
182 `(gnus-summary-mark-article-as-replied ,article))))
185 (put 'gnus-setup-message 'lisp-indent-function 1)
186 (put 'gnus-setup-message 'lisp-indent-hook 1)
187 (put 'gnus-setup-message 'edebug-form-spec '(form body))
189 ;;; Post news commands of Gnus group mode and summary mode
191 (defun gnus-group-mail ()
192 "Start composing a mail."
194 (gnus-setup-message 'message
197 (defun gnus-group-post-news (&optional arg)
198 "Start composing a news message.
199 If ARG, post to the group under point.
200 If ARG is 1, prompt for a group name."
202 ;; Bind this variable here to make message mode hooks
204 (let ((gnus-newsgroup-name
206 (if (= 1 (prefix-numeric-value arg))
207 (completing-read "Newsgroup: " gnus-active-hashtb nil
208 (gnus-read-active-file-p))
209 (gnus-group-group-name))
211 (gnus-post-news 'post gnus-newsgroup-name)))
213 (defun gnus-summary-post-news ()
214 "Start composing a news message."
216 (gnus-set-global-variables)
217 (gnus-post-news 'post gnus-newsgroup-name))
219 (defun gnus-summary-followup (yank &optional force-news)
220 "Compose a followup to an article.
221 If prefix argument YANK is non-nil, original article is yanked automatically."
223 (list (and current-prefix-arg
224 (gnus-summary-work-articles 1))))
225 (gnus-set-global-variables)
227 (gnus-summary-goto-subject (car yank)))
228 (save-window-excursion
229 (gnus-summary-select-article))
230 (let ((headers (gnus-summary-article-header (gnus-summary-article-number)))
231 (gnus-newsgroup-name gnus-newsgroup-name))
233 (gnus-post-news nil gnus-newsgroup-name
234 headers gnus-article-buffer
235 yank nil force-news)))
237 (defun gnus-summary-followup-with-original (n &optional force-news)
238 "Compose a followup to an article and include the original article."
240 (gnus-summary-followup (gnus-summary-work-articles n) force-news))
242 (defun gnus-inews-yank-articles (articles)
244 (while (setq article (pop articles))
245 (save-window-excursion
246 (set-buffer gnus-summary-buffer)
247 (gnus-summary-select-article nil nil nil article)
248 (gnus-summary-remove-process-mark article))
249 (gnus-copy-article-buffer)
250 (let ((message-reply-buffer gnus-article-copy)
251 (message-reply-headers gnus-current-headers))
252 (message-yank-original)
253 (setq beg (or beg (mark t))))
254 (when articles (insert "\n")))
259 (defun gnus-summary-cancel-article (n)
260 "Cancel an article you posted."
262 (gnus-set-global-variables)
263 (let ((articles (gnus-summary-work-articles n))
266 (gnus-post-method nil ,gnus-newsgroup-name)))
268 (while (setq article (pop articles))
269 (when (gnus-summary-select-article t nil nil article)
270 (when (gnus-eval-in-buffer-window gnus-original-article-buffer
271 (message-cancel-news))
272 (gnus-summary-mark-as-read article gnus-canceled-mark)
273 (gnus-cache-remove-article 1))
274 (gnus-article-hide-headers-if-wanted))
275 (gnus-summary-remove-process-mark article))))
277 (defun gnus-summary-supersede-article ()
278 "Compose an article that will supersede a previous article.
279 This is done simply by taking the old article and adding a Supersedes
280 header line with the old Message-ID."
282 (gnus-set-global-variables)
283 (let ((article (gnus-summary-article-number)))
284 (gnus-setup-message 'reply-yank
285 (gnus-summary-select-article t)
286 (set-buffer gnus-original-article-buffer)
290 (gnus-cache-possibly-remove-article ,article nil nil nil t)))
291 message-send-actions))))
295 (defun gnus-copy-article-buffer (&optional article-buffer)
296 ;; make a copy of the article buffer with all text properties removed
297 ;; this copy is in the buffer gnus-article-copy.
298 ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
299 ;; this buffer should be passed to all mail/news reply/post routines.
300 (setq gnus-article-copy (get-buffer-create " *gnus article copy*"))
301 (buffer-disable-undo gnus-article-copy)
302 (or (memq gnus-article-copy gnus-buffer-list)
303 (setq gnus-buffer-list (cons gnus-article-copy gnus-buffer-list)))
304 (let ((article-buffer (or article-buffer gnus-article-buffer))
306 (when (and (get-buffer article-buffer)
307 (buffer-name (get-buffer article-buffer)))
309 (set-buffer article-buffer)
312 (article-delete-text-of-type 'annotation)
313 (setq contents (format "%s" (buffer-string)))
314 (set-buffer gnus-original-article-buffer)
315 (goto-char (point-min))
316 (while (looking-at message-unix-mail-delimiter)
319 (setq end (or (search-forward "\n\n" nil t) (point)))
320 (set-buffer gnus-article-copy)
323 (delete-region (goto-char (point-min))
324 (or (search-forward "\n\n" nil t) (point)))
325 (insert-buffer-substring gnus-original-article-buffer beg end)))
328 (defun gnus-post-news (post &optional group header article-buffer yank subject
331 (gnus-copy-article-buffer))
332 (let ((gnus-article-reply article-buffer))
333 (gnus-setup-message (cond (yank 'reply-yank)
334 (article-buffer 'reply)
336 (let* ((group (or group gnus-newsgroup-name))
338 to-address to-group mailing-list to-list)
340 (setq to-address (gnus-group-find-parameter group 'to-address)
341 to-group (gnus-group-find-parameter group 'to-group)
342 to-list (gnus-group-find-parameter group 'to-list)
343 mailing-list (when gnus-mailing-list-groups
344 (string-match gnus-mailing-list-groups group))
345 group (gnus-group-real-name group)))
346 (if (or (and to-group
347 (gnus-news-group-p to-group))
349 (and (gnus-news-group-p
350 (or pgroup gnus-newsgroup-name)
351 (if header (mail-header-number header)
352 gnus-current-article))
358 (message-news (or to-group group))
359 (set-buffer gnus-article-copy)
360 (message-followup to-group))
364 (message-mail (or to-address to-list))
365 ;; Arrange for mail groups that have no `to-address' to
366 ;; get that when the user sends off the mail.
367 (push (list 'gnus-inews-add-to-address group)
368 message-send-actions))
369 (set-buffer gnus-article-copy)
370 (message-wide-reply to-address)))
372 (gnus-inews-yank-articles yank))))))
374 (defun gnus-post-method (arg group &optional silent)
375 "Return the posting method based on GROUP and ARG.
376 If SILENT, don't prompt the user."
377 (let ((group-method (gnus-find-method-for-group group)))
379 ;; If the group-method is nil (which shouldn't happen) we use
380 ;; the default method.
382 (or gnus-post-method gnus-select-method message-post-method))
383 ;; We want this group's method.
384 ((and arg (not (eq arg 0)))
386 ;; We query the user for a post method.
388 (and gnus-post-method
389 (listp (car gnus-post-method))))
391 ;; Collect all methods we know about.
393 (when gnus-post-method
394 (if (listp (car gnus-post-method))
396 (list gnus-post-method)))
397 gnus-secondary-select-methods
398 (list gnus-select-method)
399 (list group-method)))
400 method-alist post-methods method)
401 ;; Weed out all mail methods.
403 (setq method (gnus-server-get-method "" (pop methods)))
404 (when (or (gnus-method-option-p method 'post)
405 (gnus-method-option-p method 'post-mail))
406 (push method post-methods)))
407 ;; Create a name-method alist.
411 (list (concat (cadr m) " (" (symbol-name (car m)) ")") m))
416 (setq gnus-last-posting-server
418 gnus-last-posting-server)
419 ;; Just use the last value.
420 gnus-last-posting-server
422 "Posting method: " method-alist nil t
423 (cons (or gnus-last-posting-server "") 0))))
425 ;; Override normal method.
426 ((and gnus-post-method
427 (or (gnus-method-option-p group-method 'post)
428 (gnus-method-option-p group-method 'post-mail)))
430 ;; Perhaps this is a mail group?
431 ((and (not (gnus-member-of-valid 'post group))
432 (not (gnus-method-option-p group-method 'post-mail)))
434 ;; Use the normal select method.
435 (t gnus-select-method))))
437 (defun gnus-inews-narrow-to-headers ()
440 (goto-char (point-min))
441 (or (and (re-search-forward
442 (concat "^" (regexp-quote mail-header-separator) "$") nil t)
445 (goto-char (point-min)))
448 ;;; Check whether the message has been sent already.
451 (defvar gnus-inews-sent-ids nil)
453 (defun gnus-inews-reject-message ()
454 "Check whether this message has already been sent."
455 (when gnus-sent-message-ids-file
456 (let ((message-id (save-restriction (gnus-inews-narrow-to-headers)
457 (mail-fetch-field "message-id")))
460 (unless gnus-inews-sent-ids
464 (if (member message-id gnus-inews-sent-ids)
465 ;; Reject this message.
466 (not (gnus-yes-or-no-p
467 (format "Message %s already sent. Send anyway? "
469 (push message-id gnus-inews-sent-ids)
470 ;; Chop off the last Message-IDs.
471 (when (setq end (nthcdr gnus-sent-message-ids-length
472 gnus-inews-sent-ids))
474 (nnheader-temp-write gnus-sent-message-ids-file
475 (gnus-prin1 `(setq gnus-inews-sent-ids ',gnus-inews-sent-ids)))
480 ;; Dummy to avoid byte-compile warning.
481 (defvar nnspool-rejected-article-hook)
483 ;;; Since the X-Newsreader/X-Mailer are ``vanity'' headers, they might
484 ;;; as well include the Emacs version as well.
485 ;;; The following function works with later GNU Emacs, and XEmacs.
486 (defun gnus-extended-version ()
487 "Stringified Gnus version and Emacs version"
493 ((string-match "^\\([0-9]+\\.[0-9]+\\)\\.[.0-9]+$" emacs-version)
494 (concat "Emacs " (substring emacs-version
497 ((string-match "\\([A-Z]*[Mm][Aa][Cc][Ss]\\)" emacs-version)
498 (concat (substring emacs-version
501 (format " %d.%d" emacs-major-version emacs-minor-version)))
504 ;; Written by "Mr. Per Persson" <pp@gnu.ai.mit.edu>.
505 (defun gnus-inews-insert-mime-headers ()
506 (goto-char (point-min))
507 (let ((mail-header-separator
509 (goto-char (point-min))
510 (if (and (search-forward (concat "\n" mail-header-separator "\n")
512 (not (search-backward "\n\n" nil t)))
513 mail-header-separator
515 (or (mail-position-on-field "Mime-Version")
517 (cond ((save-restriction
519 (goto-char (point-min))
520 (re-search-forward "[\200-\377]" nil t))
521 (or (mail-position-on-field "Content-Type")
522 (insert "text/plain; charset=ISO-8859-1"))
523 (or (mail-position-on-field "Content-Transfer-Encoding")
525 (t (or (mail-position-on-field "Content-Type")
526 (insert "text/plain; charset=US-ASCII"))
527 (or (mail-position-on-field "Content-Transfer-Encoding")
528 (insert "7bit")))))))
532 ;;; Gnus Mail Functions
535 ;;; Mail reply commands of Gnus summary mode
537 (defun gnus-summary-reply (&optional yank)
538 "Reply mail to news author.
539 If prefix argument YANK is non-nil, original article is yanked automatically."
541 (list (and current-prefix-arg
542 (gnus-summary-work-articles 1))))
543 ;; Bug fix by jbw@bigbird.bu.edu (Joe Wells)
544 ;; Stripping headers should be specified with mail-yank-ignored-headers.
545 (gnus-set-global-variables)
547 (gnus-summary-goto-subject (car yank)))
548 (let ((gnus-article-reply t))
549 (gnus-setup-message (if yank 'reply-yank 'reply)
550 (gnus-summary-select-article)
551 (set-buffer (gnus-copy-article-buffer))
552 (message-reply nil nil (gnus-group-find-parameter
553 gnus-newsgroup-name 'broken-reply-to))
555 (gnus-inews-yank-articles yank)))))
557 (defun gnus-summary-reply-with-original (n)
558 "Reply mail to news author with original article."
560 (gnus-summary-reply (gnus-summary-work-articles n)))
562 (defun gnus-summary-mail-forward (&optional post)
563 "Forward the current message to another user."
565 (gnus-set-global-variables)
566 (gnus-setup-message 'forward
567 (gnus-summary-select-article)
568 (set-buffer gnus-original-article-buffer)
569 (message-forward post)))
571 (defun gnus-summary-resend-message (address)
572 "Resend the current article to ADDRESS."
573 (interactive "sResend message to: ")
574 (gnus-summary-select-article)
576 (set-buffer gnus-original-article-buffer)
577 (message-resend address)))
579 (defun gnus-summary-post-forward ()
580 "Forward the current article to a newsgroup."
582 (gnus-summary-mail-forward t))
584 (defvar gnus-nastygram-message
585 "The following article was inappropriately posted to %s.\n"
586 "Format string to insert in nastygrams.
587 The current group name will be inserted at \"%s\".")
589 (defun gnus-summary-mail-nastygram (n)
590 "Send a nastygram to the author of the current article."
592 (if (or gnus-expert-user
594 "Really send a nastygram to the author of the current article? "))
595 (let ((group gnus-newsgroup-name))
596 (gnus-summary-reply-with-original n)
597 (set-buffer gnus-message-buffer)
598 (insert (format gnus-nastygram-message group))
599 (message-send-and-exit))))
601 (defun gnus-summary-mail-crosspost-complaint (n)
602 "Send a complaint about crossposting to the current article(s)."
604 (let ((articles (gnus-summary-work-articles n))
606 (while (setq article (pop articles))
607 (set-buffer gnus-summary-buffer)
608 (gnus-summary-goto-subject article)
609 (let ((group (gnus-group-real-name gnus-newsgroup-name))
610 newsgroups followup-to)
611 (gnus-summary-select-article)
612 (set-buffer gnus-original-article-buffer)
613 (if (and (<= (length (message-tokenize-header
614 (setq newsgroups (mail-fetch-field "newsgroups"))
617 (or (not (setq followup-to (mail-fetch-field "followup-to")))
618 (not (member group (message-tokenize-header
619 followup-to ", ")))))
621 (gnus-message 1 "Followup-to restricted")
622 (gnus-message 1 "Not a crossposted article"))
623 (set-buffer gnus-summary-buffer)
624 (gnus-summary-reply-with-original 1)
625 (set-buffer gnus-message-buffer)
626 (insert (format gnus-crosspost-complaint newsgroups group))
627 (when (gnus-y-or-n-p "Send this complaint? ")
628 (message-send-and-exit)))))))
630 (defun gnus-summary-mail-other-window ()
631 "Compose mail in other window."
633 (gnus-setup-message 'message
636 (defun gnus-mail-parse-comma-list ()
639 (skip-chars-forward " ")
642 (skip-chars-forward "^,")
647 (narrow-to-region beg (point))
650 (while (search-forward "\"" nil t)
652 (if (zerop i) 2 i)) 2)))))
653 (skip-chars-forward ",")
654 (skip-chars-forward "^,"))
655 (skip-chars-backward " ")
657 (cons (buffer-substring beg (point))
659 (skip-chars-forward "^,")
660 (skip-chars-forward ", "))
663 (defun gnus-mail-yank-original ()
666 (mail-yank-original nil))
667 (or mail-yank-hooks mail-citation-hook
668 (run-hooks 'news-reply-header-hook)))
670 (defun gnus-inews-add-to-address (group)
671 (let ((to-address (mail-fetch-field "to")))
672 (when (and to-address
674 ;; This mail group doesn't have a `to-list', so we add one
676 (gnus-group-add-parameter group (cons 'to-list to-address)))))
678 (defun gnus-put-message ()
679 "Put the current message in some group and return to Gnus."
681 (let ((reply gnus-article-reply)
682 (winconf gnus-prev-winconf)
683 (group gnus-newsgroup-name))
685 (or (and group (not (gnus-group-read-only-p group)))
686 (setq group (read-string "Put in group: " nil
687 (gnus-writable-groups))))
688 (and (gnus-gethash group gnus-newsrc-hashtb)
689 (error "No such group: %s" group))
694 (gnus-inews-narrow-to-headers)
695 (let (gnus-deletable-headers)
697 (message-generate-headers message-required-news-headers)
698 (message-generate-headers message-required-mail-headers)))
699 (goto-char (point-max))
700 (insert "Gcc: " group "\n")
705 (if (get-buffer gnus-group-buffer)
707 (if (gnus-buffer-exists-p (car-safe reply))
709 (set-buffer (car reply))
711 (gnus-summary-mark-article-as-replied
713 (and winconf (set-window-configuration winconf))))))
715 (defun gnus-article-mail (yank)
716 "Send a reply to the address near point.
717 If YANK is non-nil, include the original article."
721 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
722 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
724 (message-reply address)
726 (gnus-inews-yank-articles (list (cdr gnus-article-current)))))))
729 "Send a bug report to the Gnus maintainers."
731 (unless (gnus-alive-p)
732 (error "Gnus has been shut down"))
733 (gnus-setup-message 'bug
734 (delete-other-windows)
735 (switch-to-buffer "*Gnus Help Bug*")
737 (insert gnus-bug-message)
738 (goto-char (point-min))
739 (message-pop-to-buffer "*Gnus Bug*")
740 (message-setup `((To . ,gnus-maintainer) (Subject . "")))
741 (push `(gnus-bug-kill-buffer) message-send-actions)
742 (goto-char (point-min))
743 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
745 (insert (gnus-version) "\n")
746 (insert (emacs-version))
747 (insert "\n\n\n\n\n")
749 (goto-char (point-min))
750 (search-forward "Subject: " nil t)
753 (defun gnus-bug-kill-buffer ()
754 (and (get-buffer "*Gnus Help Bug*")
755 (kill-buffer "*Gnus Help Bug*")))
758 "Attemps to go through the Gnus source file and report what variables have been changed.
759 The source file has to be in the Emacs load path."
761 (let ((files '("gnus-load.el" "gnus-sum.el" "gnus-group.el"
762 "gnus-art.el" "gnus-start.el"
763 "gnus-msg.el" "gnus-score.el" "gnus-win.el"
764 "nnmail.el" "message.el"))
766 (gnus-message 4 "Please wait while we snoop your variables...")
768 ;; Go through all the files looking for non-default values for variables.
770 (set-buffer (get-buffer-create " *gnus bug info*"))
771 (buffer-disable-undo (current-buffer))
774 (when (file-exists-p (setq file (locate-library (pop files))))
775 (insert-file-contents file)
776 (goto-char (point-min))
777 (if (not (re-search-forward "^;;* *Internal variables" nil t))
778 (gnus-message 4 "Malformed sources in file %s" file)
779 (narrow-to-region (point-min) (point))
780 (goto-char (point-min))
781 (while (setq expr (condition-case ()
782 (read (current-buffer)) (error nil)))
784 (and (eq (car expr) 'defvar)
785 (stringp (nth 3 expr))
786 (or (not (boundp (nth 1 expr)))
787 (not (equal (eval (nth 2 expr))
788 (symbol-value (nth 1 expr)))))
789 (push (nth 1 expr) olist))
791 (kill-buffer (current-buffer)))
792 (when (setq olist (nreverse olist))
793 (insert "------------------ Environment follows ------------------\n\n"))
795 (if (boundp (car olist))
797 (pp `(setq ,(car olist)
798 ,(if (or (consp (setq sym (symbol-value (car olist))))
800 (not (or (eq sym nil)
802 (list 'quote (symbol-value (car olist)))
803 (symbol-value (car olist))))
806 (format "(setq %s 'whatever)\n" (car olist))))
807 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
808 (setq olist (cdr olist)))
810 ;; Remove any null chars - they seem to cause trouble for some
811 ;; mailers. (Byte-compiled output from the stuff above.)
812 (goto-char (point-min))
813 (while (re-search-forward "[\000\200]" nil t)
814 (replace-match "" t t))))
816 ;;; Treatment of rejected articles.
819 (defun gnus-summary-resend-bounced-mail (&optional fetch)
820 "Re-mail the current message.
821 This only makes sense if the current message is a bounce message than
822 contains some mail you have written which has been bounced back to
824 If FETCH, try to fetch the article that this is a reply to, if indeed
827 (gnus-summary-select-article t)
828 (set-buffer gnus-original-article-buffer)
829 (gnus-setup-message 'compose-bounce
830 (let* ((references (mail-fetch-field "references"))
831 (parent (and references (gnus-parent-id references))))
833 ;; If there are references, we fetch the article we answered to.
835 (gnus-summary-refer-article parent)
836 (gnus-summary-show-all-headers)))))
840 ;; Do Gcc handling, which copied the message over to some group.
841 (defun gnus-inews-do-gcc (&optional gcc)
845 (message-narrow-to-headers)
846 (let ((gcc (or gcc (mail-fetch-field "gcc" nil t)))
847 (cur (current-buffer))
850 (message-remove-header "gcc")
852 (setq groups (message-tokenize-header gcc " ,"))
853 ;; Copy the article over to some group(s).
854 (while (setq group (pop groups))
857 (cond ((and (null (gnus-get-info group))
858 (eq (car gnus-message-archive-method)
860 (gnus-server-to-method
861 (gnus-group-method group)))))
862 ;; If the group doesn't exist, we assume
863 ;; it's an archive group...
864 gnus-message-archive-method)
866 ((gnus-info-method (gnus-get-info group))
867 (gnus-info-method (gnus-get-info group)))
869 (t (gnus-group-method group)))))
870 (gnus-check-server method)
871 (unless (gnus-request-group group t method)
872 (gnus-request-create-group group method))
874 (nnheader-set-temp-buffer " *acc*")
875 (insert-buffer-substring cur)
876 (goto-char (point-min))
877 (when (re-search-forward
878 (concat "^" (regexp-quote mail-header-separator) "$")
880 (replace-match "" t t ))
881 (unless (gnus-request-accept-article group method t)
882 (gnus-message 1 "Couldn't store article in group %s: %s"
883 group (gnus-status-message method))
885 (kill-buffer (current-buffer))))))))))
887 (defun gnus-inews-insert-gcc ()
888 "Insert Gcc headers based on `gnus-outgoing-message-group'."
891 (gnus-inews-narrow-to-headers)
892 (let* ((group gnus-outgoing-message-group)
894 ((gnus-functionp group)
896 ((or (stringp group) (list group))
900 (if (stringp gcc) gcc
901 (mapconcat 'identity gcc " "))
904 (defun gnus-inews-insert-archive-gcc (&optional group)
905 "Insert the Gcc to say where the article is to be archived."
906 (let* ((var gnus-message-archive-group)
907 (group (or group gnus-newsgroup-name ""))
912 ((null gnus-message-archive-method)
916 ;; Just a single group.
919 ;; We don't want this.
921 ((and (listp var) (stringp (car var)))
924 ((gnus-functionp var)
928 ;; An alist of regexps/functions/forms.
933 ((stringp (caar var))
935 (when (string-match (caar var) group)
937 ((gnus-functionp (car var))
939 (funcall (car var) group))
941 (eval (car var)))))))
942 (setq var (cdr var)))
946 (when (stringp groups)
947 (setq groups (list groups)))
950 (gnus-inews-narrow-to-headers)
951 (goto-char (point-max))
953 (if (and gnus-newsgroup-name
955 (gnus-group-find-parameter
956 gnus-newsgroup-name 'gcc-self)))
959 (if (stringp gcc-self-val)
962 (if (not (eq gcc-self-val 'none))
967 (while (setq name (pop groups))
968 (insert (if (string-match ":" name)
970 (gnus-group-prefixed-name
971 name gnus-message-archive-method)))
972 (if groups (insert " ")))
975 (defun gnus-summary-send-draft ()
976 "Enter a mail/post buffer to edit and send the draft."
978 (gnus-set-global-variables)
980 (if (not (setq buf (gnus-request-restore-buffer
981 (gnus-summary-article-number) gnus-newsgroup-name)))
982 (error "Couldn't restore the article")
983 (switch-to-buffer buf)
984 (when (eq major-mode 'news-reply-mode)
985 (local-set-key "\C-c\C-c" 'gnus-inews-news))
986 ;; Insert the separator.
987 (goto-char (point-min))
988 (search-forward "\n\n")
990 (insert mail-header-separator)
991 ;; Configure windows.
992 (let ((gnus-draft-buffer (current-buffer)))
993 (gnus-configure-windows 'draft t)
994 (goto-char (point))))))
996 (gnus-add-shutdown 'gnus-inews-close 'gnus)
998 (defun gnus-inews-close ()
999 (setq gnus-inews-sent-ids nil))
1001 ;;; Allow redefinition of functions.
1007 ;;; gnus-msg.el ends here