1 ;;; gnus-msg.el --- mail and post interface for Semi-gnus
2 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
3 ;; Free Software Foundation, Inc.
5 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
6 ;; Lars Magne Ingebrigtsen <larsi@gnus.org>
7 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
8 ;; Shuhei KOBAYASHI <shuhei-k@jaist.ac.jp>
9 ;; Katsumi Yamaoka <yamaoka@jpl.org>
10 ;; Kiyokazu SUTO <suto@merry.xmath.ous.ac.jp>
11 ;; Keywords: mail, news, MIME
13 ;; This file is part of GNU Emacs.
15 ;; GNU Emacs is free software; you can redistribute it and/or modify
16 ;; it under the terms of the GNU General Public License as published by
17 ;; the Free Software Foundation; either version 2, or (at your option)
20 ;; GNU Emacs is distributed in the hope that it will be useful,
21 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
22 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 ;; GNU General Public License for more details.
25 ;; You should have received a copy of the GNU General Public License
26 ;; along with GNU Emacs; see the file COPYING. If not, write to the
27 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
28 ;; Boston, MA 02111-1307, USA.
34 (eval-when-compile (require 'cl))
35 (eval-when-compile (require 'static))
42 (defcustom gnus-post-method 'current
43 "*Preferred method for posting USENET news.
45 If this variable is `current' (which is the default), Gnus will use
46 the \"current\" select method when posting. If it is `native', Gnus
47 will use the native select method when posting.
49 This method will not be used in mail groups and the like, only in
52 If not `native' nor `current', the value must be a valid method as discussed
53 in the documentation of `gnus-select-method'. It can also be a list of
54 methods. If that is the case, the user will be queried for what select
55 method to use when posting."
56 :group 'gnus-group-foreign
57 :link '(custom-manual "(gnus)Posting Server")
58 :type `(choice (const native)
60 (sexp :tag "Methods" ,gnus-select-method)))
62 (defcustom gnus-outgoing-message-group nil
63 "*All outgoing messages will be put in this group.
64 If you want to store all your outgoing mail and articles in the group
65 \"nnml:archive\", you set this variable to that value. This variable
66 can also be a list of group names.
68 If you want to have greater control over what group to put each
69 message in, you can set this variable to a function that checks the
70 current newsgroup name and then returns a suitable group name (or list
73 :type '(choice (string :tag "Group")
76 (defcustom gnus-mailing-list-groups nil
77 "*Regexp matching groups that are really mailing lists.
78 This is useful when you're reading a mailing list that has been
79 gatewayed to a newsgroup, and you want to followup to an article in
84 (defcustom gnus-add-to-list nil
85 "*If non-nil, add a `to-list' parameter automatically."
89 (defcustom gnus-crosspost-complaint
92 You posted the article below with the following Newsgroups header:
96 The %s group, at least, was an inappropriate recipient
97 of this message. Please trim your Newsgroups header to exclude this
98 group before posting in the future.
103 "Format string to be inserted when complaining about crossposts.
104 The first %s will be replaced by the Newsgroups header;
105 the second with the current group name."
109 (defcustom gnus-message-setup-hook '(gnus-maybe-setup-default-charset)
110 "Hook run after setting up a message buffer."
114 (defcustom gnus-bug-create-help-buffer t
115 "*Should we create the *Gnus Help Bug* buffer?"
119 (defcustom gnus-posting-styles nil
120 "*Alist of styles to use when posting.
121 See Info node `(gnus)Posting Styles'."
123 :type '(repeat (cons (choice (regexp)
128 (choice (const signature)
129 (const signature-file)
134 (string :tag "Header"))
140 (defcustom gnus-gcc-mark-as-read nil
141 "If non-nil, automatically mark Gcc articles as read."
145 (defvar gnus-inews-mark-gcc-as-read nil
146 "Obsolete variable. Use `gnus-gcc-mark-as-read' instead.")
148 (make-obsolete-variable 'gnus-inews-mark-gcc-as-read
149 'gnus-gcc-mark-as-read)
151 (defcustom gnus-gcc-externalize-attachments nil
152 "Should local-file attachments be included as external parts in Gcc copies?
153 If it is `all', attach files as external parts;
154 if a regexp and matches the Gcc group name, attach files as external parts;
155 If nil, attach files as normal parts."
157 :type '(choice (const nil :tag "None")
158 (const all :tag "Any")
159 (string :tag "Regexp")))
161 (defcustom gnus-group-posting-charset-alist
162 '(("^\\(no\\|fr\\)\\.[^,]*\\(,[ \t\n]*\\(no\\|fr\\)\\.[^,]*\\)*$" iso-8859-1 (iso-8859-1))
163 ("^\\(fido7\\|relcom\\)\\.[^,]*\\(,[ \t\n]*\\(fido7\\|relcom\\)\\.[^,]*\\)*$" koi8-r (koi8-r))
164 (message-this-is-mail nil nil)
165 (message-this-is-news nil t))
166 "Alist of regexps and permitted unencoded charsets for posting.
167 Each element of the alist has the form (TEST HEADER BODY-LIST), where
168 TEST is either a regular expression matching the newsgroup header or a
170 HEADER is the charset which may be left unencoded in the header (nil
171 means encode all charsets),
172 BODY-LIST is a list of charsets which may be encoded using 8bit
173 content-transfer encoding in the body, or one of the special values
174 nil (always encode using quoted-printable) or t (always use 8bit).
176 Note that any value other than nil for HEADER infringes some RFCs, so
177 use this option with care."
178 :type '(repeat (list :tag "Permitted unencoded charsets"
180 (regexp :tag "Group")
181 (const :tag "Mail message"
182 :value message-this-is-mail)
183 (const :tag "News article"
184 :value message-this-is-news))
185 (choice :tag "Header"
186 (const :tag "None" nil)
187 (symbol :tag "Charset"))
189 (const :tag "Any" :value t)
190 (const :tag "None" :value nil)
191 (repeat :tag "Charsets"
192 (symbol :tag "Charset")))))
193 :group 'gnus-charset)
195 ;;; Internal variables.
197 (defvar gnus-inhibit-posting-styles nil
198 "Inhibit the use of posting styles.")
200 (defvar gnus-message-buffer "*Mail Gnus*")
201 (defvar gnus-article-copy nil)
202 (defvar gnus-check-before-posting nil)
203 (defvar gnus-last-posting-server nil)
204 (defvar gnus-message-group-art nil)
206 (defvar gnus-msg-force-broken-reply-to nil)
208 (defconst gnus-bug-message
209 (format "Sending a bug report to the Gnus Towers.
210 ========================================
212 This gnus is the %s%s.
213 If you think the bug is a Semi-gnus bug, send a bug report to Semi-gnus
214 Developers. (the addresses below are mailing list addresses)
216 ========================================
218 The buffer below is a mail buffer. When you press `C-c C-c', it will
219 be sent to the Gnus Bug Exterminators.
221 The thing near the bottom of the buffer is how the environment
222 settings will be included in the mail. Please do not delete that.
223 They will tell the Bug People what your environment is, so that it
224 will be easier to locate the bugs.
226 If you have found a bug that makes Emacs go \"beep\", set
227 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
228 and include the backtrace in your bug report.
230 Please describe the bug in annoying, painstaking detail.
232 Thank you for your help in stamping out bugs.
235 (if (string= gnus-product-name "Semi-gnus")
237 ", a modified version of Semi-gnus")))
240 (autoload 'gnus-uu-post-news "gnus-uu" nil t)
241 (autoload 'news-setup "rnewspost")
242 (autoload 'news-reply-mode "rnewspost")
243 (autoload 'rmail-dont-reply-to "mail-utils")
244 (autoload 'rmail-output "rmailout"))
248 ;;; Gnus Posting Functions
251 (gnus-define-keys (gnus-summary-send-map "S" gnus-summary-mode-map)
252 "p" gnus-summary-post-news
253 "i" gnus-summary-news-other-window
254 "f" gnus-summary-followup
255 "F" gnus-summary-followup-with-original
256 "c" gnus-summary-cancel-article
257 "s" gnus-summary-supersede-article
258 "r" gnus-summary-reply
259 "y" gnus-summary-yank-message
260 "R" gnus-summary-reply-with-original
261 "w" gnus-summary-wide-reply
262 "W" gnus-summary-wide-reply-with-original
263 "v" gnus-summary-very-wide-reply
264 "V" gnus-summary-very-wide-reply-with-original
265 "n" gnus-summary-followup-to-mail
266 "N" gnus-summary-followup-to-mail-with-original
267 "m" gnus-summary-mail-other-window
268 "u" gnus-uu-post-news
269 "\M-c" gnus-summary-mail-crosspost-complaint
270 "Br" gnus-summary-reply-broken-reply-to
271 "BR" gnus-summary-reply-broken-reply-to-with-original
272 "om" gnus-summary-mail-forward
273 "op" gnus-summary-post-forward
274 "Om" gnus-summary-digest-mail-forward
275 "Op" gnus-summary-digest-post-forward)
277 (gnus-define-keys (gnus-send-bounce-map "D" gnus-summary-send-map)
278 "b" gnus-summary-resend-bounced-mail
279 ;; "c" gnus-summary-send-draft
280 "r" gnus-summary-resend-message)
282 ;;; Internal functions.
284 (defvar gnus-article-reply nil)
285 (defmacro gnus-setup-message (config &rest forms)
286 (let ((winconf (make-symbol "gnus-setup-message-winconf"))
287 (buffer (make-symbol "gnus-setup-message-buffer"))
288 (article (make-symbol "gnus-setup-message-article"))
289 (group (make-symbol "gnus-setup-message-group")))
290 `(let ((,winconf (current-window-configuration))
291 (,buffer (buffer-name (current-buffer)))
292 (,article gnus-article-reply)
293 (,group gnus-newsgroup-name)
294 (message-header-setup-hook
295 (copy-sequence message-header-setup-hook))
296 (message-mode-hook (copy-sequence message-mode-hook))
297 (message-startup-parameter-alist
298 '((reply-buffer . gnus-copy-article-buffer)
299 (original-buffer . gnus-original-article-buffer)
300 (user-agent . Gnus))))
301 (add-hook 'message-header-setup-hook 'gnus-inews-insert-gcc)
302 (add-hook 'message-header-setup-hook 'gnus-inews-insert-archive-gcc)
303 ;; #### FIXME: for a reason that I did not manage to identify yet,
304 ;; the variable `gnus-newsgroup-name' does not honor a dynamically
305 ;; scoped or setq'ed value from a caller like `C-u gnus-summary-mail'.
306 ;; After evaluation of @forms below, it gets the value we actually want
307 ;; to override, and the posting styles are used. For that reason, I've
308 ;; added an optional argument to `gnus-configure-posting-styles' to
309 ;; make sure that the correct value for the group name is used. -- drv
310 (add-hook 'message-mode-hook
312 (gnus-configure-posting-styles ,group)))
316 (gnus-inews-add-send-actions ,winconf ,buffer ,article ,config)
317 (gnus-inews-insert-draft-meta-information ,group ,article)
318 (setq gnus-message-buffer (current-buffer))
319 (set (make-local-variable 'gnus-message-group-art)
320 (cons ,group ,article))
321 (set (make-local-variable 'gnus-newsgroup-name) ,group)
322 (gnus-run-hooks 'gnus-message-setup-hook))
324 (gnus-configure-windows ,config t)
325 (run-hooks 'post-command-hook)
326 (set-buffer-modified-p nil))))
328 (defun gnus-inews-insert-draft-meta-information (group article)
331 (not (string= group ""))
332 (not (message-fetch-field gnus-draft-meta-information-header)))
333 (goto-char (point-min))
334 (insert gnus-draft-meta-information-header ": (\"" group "\" "
335 (if article (number-to-string
342 (defun gnus-msg-mail (&optional to subject other-headers continue
343 switch-action yank-action send-actions)
344 "Start editing a mail message to be sent.
345 Like `message-mail', but with Gnus paraphernalia, particularly the
346 Gcc: header for archiving purposes."
348 (let ((buf (current-buffer))
350 (gnus-setup-message 'message
351 (message-mail to subject other-headers continue
352 nil yank-action send-actions))
354 (setq mail-buf (current-buffer))
355 (switch-to-buffer buf)
356 (apply switch-action mail-buf nil)))
357 ;; COMPOSEFUNC should return t if succeed. Undocumented ???
360 (defvar save-selected-window-window)
363 (defun gnus-button-mailto (address)
365 (set-buffer (gnus-copy-article-buffer))
366 (gnus-setup-message 'message
367 (message-reply address))
368 (and (boundp 'save-selected-window-window)
369 (not (window-live-p save-selected-window-window))
370 (setq save-selected-window-window (selected-window))))
373 (defun gnus-button-reply (&optional to-address wide)
374 "Like `message-reply'."
376 (gnus-setup-message 'message
377 (message-reply to-address wide))
378 (and (boundp 'save-selected-window-window)
379 (not (window-live-p save-selected-window-window))
380 (setq save-selected-window-window (selected-window))))
383 (define-mail-user-agent 'gnus-user-agent
384 'gnus-msg-mail 'message-send-and-exit
385 'message-kill-buffer 'message-send-hook)
387 (defun gnus-setup-posting-charset (group)
388 (let ((alist gnus-group-posting-charset-alist)
389 (group (or group ""))
393 (while (setq elem (pop alist))
394 (when (or (and (stringp (car elem))
395 (string-match (car elem) group))
396 (and (gnus-functionp (car elem))
397 (funcall (car elem) group))
398 (and (symbolp (car elem))
399 (symbol-value (car elem))))
400 (throw 'found (cons (cadr elem) (caddr elem)))))))))
402 (defun gnus-inews-add-send-actions (winconf buffer article &optional config)
403 (make-local-hook 'message-sent-hook)
404 (add-hook 'message-sent-hook (if gnus-agent 'gnus-agent-possibly-do-gcc
405 'gnus-inews-do-gcc) nil t)
407 (make-local-hook 'message-header-hook)
408 (add-hook 'message-header-hook 'gnus-agent-possibly-save-gcc nil t))
409 (setq message-post-method
411 (gnus-post-method arg ,gnus-newsgroup-name)))
412 (setq message-user-agent (gnus-extended-version))
413 (when (not message-use-multi-frames)
415 `(set-window-configuration ,winconf) 'exit 'postpone 'kill))
417 `(when (gnus-buffer-exists-p ,buffer)
421 (if (eq config 'forward)
422 `(gnus-summary-mark-article-as-forwarded ',article)
423 `(gnus-summary-mark-article-as-replied ',article)))))
426 (put 'gnus-setup-message 'lisp-indent-function 1)
427 (put 'gnus-setup-message 'edebug-form-spec '(form body))
429 ;;; Post news commands of Gnus group mode and summary mode
431 (defun gnus-group-mail (&optional arg)
432 "Start composing a mail.
433 If ARG, use the group under the point to find a posting style.
434 If ARG is 1, prompt for a group name to find the posting style."
436 ;; We can't `let' gnus-newsgroup-name here, since that leads
437 ;; to local variables leaking.
438 (let ((group gnus-newsgroup-name)
439 (buffer (current-buffer)))
442 (setq gnus-newsgroup-name
444 (if (= 1 (prefix-numeric-value arg))
445 (completing-read "Use posting style of group: "
446 gnus-active-hashtb nil
447 (gnus-read-active-file-p))
448 (gnus-group-group-name))
450 ;; #### see comment in gnus-setup-message -- drv
451 (gnus-setup-message 'message (message-mail)))
454 (setq gnus-newsgroup-name group)))))
456 (defun gnus-group-news (&optional arg)
457 "Start composing a news.
458 If ARG, post to group under point.
459 If ARG is 1, prompt for group name to post to.
461 This function prepares a news even when using mail groups. This is useful
462 for posting messages to mail groups without actually sending them over the
463 network. The corresponding backend must have a 'request-post method."
465 ;; We can't `let' gnus-newsgroup-name here, since that leads
466 ;; to local variables leaking.
467 (let ((group gnus-newsgroup-name)
468 (buffer (current-buffer)))
471 (setq gnus-newsgroup-name
473 (if (= 1 (prefix-numeric-value arg))
474 (completing-read "Use group: "
475 gnus-active-hashtb nil
476 (gnus-read-active-file-p))
477 (gnus-group-group-name))
479 ;; #### see comment in gnus-setup-message -- drv
480 (gnus-setup-message 'message
481 (message-news (gnus-group-real-name gnus-newsgroup-name))))
484 (setq gnus-newsgroup-name group)))))
486 (defun gnus-group-post-news (&optional arg)
487 "Start composing a message (a news by default).
488 If ARG, post to group under point. If ARG is 1, prompt for group name.
489 Depending on the selected group, the message might be either a mail or
492 ;; Bind this variable here to make message mode hooks work ok.
493 (let ((gnus-newsgroup-name
495 (if (= 1 (prefix-numeric-value arg))
496 (completing-read "Newsgroup: " gnus-active-hashtb nil
497 (gnus-read-active-file-p))
498 (gnus-group-group-name))
500 (gnus-post-news 'post gnus-newsgroup-name)))
502 (defun gnus-summary-mail-other-window (&optional arg)
503 "Start composing a mail in another window.
504 Use the posting of the current group by default.
505 If ARG, don't do that. If ARG is 1, prompt for group name to find the
508 ;; We can't `let' gnus-newsgroup-name here, since that leads
509 ;; to local variables leaking.
510 (let ((group gnus-newsgroup-name)
511 (buffer (current-buffer)))
514 (setq gnus-newsgroup-name
516 (if (= 1 (prefix-numeric-value arg))
517 (completing-read "Use group: "
518 gnus-active-hashtb nil
519 (gnus-read-active-file-p))
521 gnus-newsgroup-name))
522 ;; #### see comment in gnus-setup-message -- drv
523 (gnus-setup-message 'message (message-mail)))
526 (setq gnus-newsgroup-name group)))))
528 (defun gnus-summary-news-other-window (&optional arg)
529 "Start composing a news in another window.
530 Post to the current group by default.
531 If ARG, don't do that. If ARG is 1, prompt for group name to post to.
533 This function prepares a news even when using mail groups. This is useful
534 for posting messages to mail groups without actually sending them over the
535 network. The corresponding backend must have a 'request-post method."
537 ;; We can't `let' gnus-newsgroup-name here, since that leads
538 ;; to local variables leaking.
539 (let ((group gnus-newsgroup-name)
540 (buffer (current-buffer)))
543 (setq gnus-newsgroup-name
545 (if (= 1 (prefix-numeric-value arg))
546 (completing-read "Use group: "
547 gnus-active-hashtb nil
548 (gnus-read-active-file-p))
550 gnus-newsgroup-name))
551 ;; #### see comment in gnus-setup-message -- drv
552 (gnus-setup-message 'message
553 (message-news (gnus-group-real-name gnus-newsgroup-name))))
556 (setq gnus-newsgroup-name group)))))
558 (defun gnus-summary-post-news (&optional arg)
559 "Start composing a message. Post to the current group by default.
560 If ARG, don't do that. If ARG is 1, prompt for a group name to post to.
561 Depending on the selected group, the message might be either a mail or
564 ;; Bind this variable here to make message mode hooks work ok.
565 (let ((gnus-newsgroup-name
567 (if (= 1 (prefix-numeric-value arg))
568 (completing-read "Newsgroup: " gnus-active-hashtb nil
569 (gnus-read-active-file-p))
571 gnus-newsgroup-name)))
572 (gnus-post-news 'post gnus-newsgroup-name)))
575 (defun gnus-summary-followup (yank &optional force-news)
576 "Compose a followup to an article.
577 If prefix argument YANK is non-nil, the original article is yanked
579 YANK is a list of elements, where the car of each element is the
580 article number, and the two following numbers is the region to be
583 (list (and current-prefix-arg
584 (gnus-summary-work-articles 1))))
586 (gnus-summary-goto-subject
587 (if (listp (car yank))
590 (save-window-excursion
591 (gnus-summary-select-article))
592 (let ((headers (gnus-summary-article-header (gnus-summary-article-number)))
593 (gnus-newsgroup-name gnus-newsgroup-name))
595 (gnus-post-news nil gnus-newsgroup-name
596 headers gnus-article-buffer
597 yank nil force-news)))
599 (defun gnus-summary-followup-with-original (n &optional force-news)
600 "Compose a followup to an article and include the original article."
602 (gnus-summary-followup (gnus-summary-work-articles n) force-news))
604 (defun gnus-summary-followup-to-mail (&optional arg)
605 "Followup to the current mail message via news."
607 (list (and current-prefix-arg
608 (gnus-summary-work-articles 1))))
609 (gnus-summary-followup arg t))
611 (defun gnus-summary-followup-to-mail-with-original (&optional arg)
612 "Followup to the current mail message via news."
614 (gnus-summary-followup (gnus-summary-work-articles arg) t))
616 (defun gnus-inews-yank-articles (articles)
617 (let (beg article yank-string
618 (more-than-one (cdr articles))
619 (cur (current-buffer))
622 (while (setq article (pop articles))
623 (when (listp article)
624 (setq yank-string (nth 1 article)
625 article (nth 0 article)))
626 (save-window-excursion
627 (set-buffer gnus-summary-buffer)
628 (gnus-summary-select-article nil nil nil article)
629 (gnus-summary-remove-process-mark article))
631 ;; Gathering references.
633 (setq refs (message-list-references
635 (mail-header-references gnus-current-headers)
636 (mail-header-message-id gnus-current-headers)))
637 (when message-use-multi-frames
638 (when (setq window (get-buffer-window cur t))
639 (select-frame (window-frame window)))))
641 (gnus-copy-article-buffer nil yank-string)
642 (let ((message-reply-buffer gnus-article-copy)
643 (message-reply-headers
644 ;; The headers are decoded.
645 (with-current-buffer gnus-article-copy
646 (nnheader-parse-head t))))
647 (message-yank-original)
648 (setq beg (or beg (mark t))))
653 ;; Replace with the gathered references.
657 (message-narrow-to-headers)
658 (let ((case-fold-search t))
659 (if (re-search-forward "^References:\\([\t ]+.+\n\\)+" nil t)
661 (goto-char (point-max))))
663 (list (or (assq 'References message-header-format-alist)
664 '(References . message-shorten-references)))
665 (list (cons 'References
666 (mapconcat 'identity (nreverse refs) " "))))
667 (backward-delete-char 1))
673 (defun gnus-summary-cancel-article (&optional n symp)
674 "Cancel an article you posted.
675 Uses the process-prefix convention. If given the symbolic
676 prefix `a', cancel using the standard posting method; if not
677 post using the current select method."
678 (interactive (gnus-interactive "P\ny"))
679 (let ((articles (gnus-summary-work-articles n))
682 (gnus-post-method (not (eq symp 'a)) ,gnus-newsgroup-name)))
684 (while (setq article (pop articles))
685 (when (gnus-summary-select-article t nil nil article)
686 (when (gnus-eval-in-buffer-window gnus-article-buffer
688 (set-buffer gnus-original-article-buffer)
689 (message-cancel-news)))
690 (gnus-summary-mark-as-read article gnus-canceled-mark)
691 (gnus-cache-remove-article 1))
692 (gnus-article-hide-headers-if-wanted))
693 (gnus-summary-remove-process-mark article))))
695 (defun gnus-summary-supersede-article ()
696 "Compose an article that will supersede a previous article.
697 This is done simply by taking the old article and adding a Supersedes
698 header line with the old Message-ID."
700 (let ((article (gnus-summary-article-number))
701 (gnus-message-setup-hook '(gnus-maybe-setup-default-charset)))
702 (gnus-setup-message 'reply-yank
703 (gnus-summary-select-article t)
704 (set-buffer gnus-original-article-buffer)
708 (when (gnus-buffer-exists-p ,gnus-summary-buffer)
710 (set-buffer ,gnus-summary-buffer)
711 (gnus-cache-possibly-remove-article ,article nil nil nil t)
712 (gnus-summary-mark-as-read ,article gnus-canceled-mark)))))
713 message-send-actions))))
717 (defun gnus-copy-article-buffer (&optional article-buffer yank-string)
718 ;; make a copy of the article buffer with all text properties removed
719 ;; this copy is in the buffer gnus-article-copy.
720 ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
721 ;; this buffer should be passed to all mail/news reply/post routines.
722 (setq gnus-article-copy (gnus-get-buffer-create " *gnus article copy*"))
723 (let ((article-buffer (or article-buffer gnus-article-buffer))
725 (if (not (and (get-buffer article-buffer)
726 (gnus-buffer-exists-p article-buffer)))
727 (error "Can't find any article buffer")
729 (set-buffer article-buffer)
730 (let ((gnus-newsgroup-charset (or gnus-article-charset
731 gnus-newsgroup-charset))
732 (gnus-newsgroup-ignored-charsets
733 (or gnus-article-ignored-charsets
734 gnus-newsgroup-ignored-charsets)))
736 ;; Copy over the (displayed) article buffer, delete
737 ;; hidden text and remove text properties.
739 (let ((inhibit-read-only t))
740 (copy-to-buffer gnus-article-copy (point-min) (point-max))
741 (set-buffer gnus-article-copy)
744 (delete-region (point) (point-max))
745 (insert yank-string))
746 ;; Encode bitmap smileys to ordinary text.
747 ;; Possibly, the original text might be restored.
748 (static-unless (featurep 'xemacs)
749 (when (featurep 'smiley-mule)
750 (smiley-encode-buffer)))
751 (gnus-article-delete-text-of-type 'annotation)
752 (gnus-remove-text-with-property 'gnus-prev)
753 (gnus-remove-text-with-property 'gnus-next)
754 (gnus-remove-text-with-property 'x-face-mule-bitmap-image)
757 (static-if (featurep 'xemacs)
758 ;; Revome smiley extents for (possibly) XEmacs 21.1.
760 (buffer-substring-no-properties (point-min)
762 (buffer-substring-no-properties (point-min) (point-max)))
764 ;; Find the original headers.
765 (set-buffer gnus-original-article-buffer)
766 (goto-char (point-min))
767 (while (looking-at message-unix-mail-delimiter)
770 end (or (message-goto-body) beg))
771 ;; Delete the headers from the displayed articles.
772 (set-buffer gnus-article-copy)
773 (delete-region (goto-char (point-min))
774 (or (message-goto-body) (point-max)))
775 ;; Insert the original article headers.
776 (insert-buffer-substring gnus-original-article-buffer beg end)
778 (let ((gnus-article-decode-hook
779 (delq 'article-decode-charset
780 (copy-sequence gnus-article-decode-hook))))
781 ;; Needed for T-gnus.
782 (add-hook 'gnus-article-decode-hook
783 'article-decode-encoded-words)
784 (run-hooks 'gnus-article-decode-hook)))))
787 (defun gnus-post-news (post &optional group header article-buffer yank subject
790 (gnus-copy-article-buffer))
791 (let ((gnus-article-reply (and article-buffer (gnus-summary-article-number)))
792 (add-to-list gnus-add-to-list))
793 (gnus-setup-message (cond (yank 'reply-yank)
794 (article-buffer 'reply)
796 (let* ((group (or group gnus-newsgroup-name))
797 (charset (gnus-group-name-charset nil group))
799 to-address to-group mailing-list to-list
802 (setq to-address (gnus-parameter-to-address group)
803 to-group (gnus-group-find-parameter group 'to-group)
804 to-list (gnus-parameter-to-list group)
805 newsgroup-p (gnus-group-find-parameter group 'newsgroup)
806 mailing-list (when gnus-mailing-list-groups
807 (string-match gnus-mailing-list-groups group))
808 group (gnus-group-name-decode (gnus-group-real-name group)
810 (if (or (and to-group
811 (gnus-news-group-p to-group))
814 (and (gnus-news-group-p
815 (or pgroup gnus-newsgroup-name)
816 (or header gnus-current-article))
822 (message-news (or to-group group))
823 (set-buffer gnus-article-copy)
824 (gnus-msg-treat-broken-reply-to)
825 (message-followup (if (or newsgroup-p force-news)
826 (if (save-restriction
827 (article-narrow-to-head)
828 (message-fetch-field "newsgroups"))
835 (message-mail (or to-address to-list))
836 ;; Arrange for mail groups that have no `to-address' to
837 ;; get that when the user sends off the mail.
838 (when (and (not to-list)
841 (push (list 'gnus-inews-add-to-address pgroup)
842 message-send-actions)))
843 (set-buffer gnus-article-copy)
844 (gnus-msg-treat-broken-reply-to)
845 (message-wide-reply to-address)))
847 (gnus-inews-yank-articles yank))))))
849 (defun gnus-msg-treat-broken-reply-to (&optional force)
850 "Remove the Reply-to header iff broken-reply-to."
852 (gnus-group-find-parameter
853 gnus-newsgroup-name 'broken-reply-to))
855 (message-narrow-to-head)
856 (message-remove-header "reply-to"))))
858 (defun gnus-post-method (arg group &optional silent)
859 "Return the posting method based on GROUP and ARG.
860 If SILENT, don't prompt the user."
861 (let ((gnus-post-method (or (gnus-parameter-post-method group)
863 (group-method (gnus-find-method-for-group group)))
865 ;; If the group-method is nil (which shouldn't happen) we use
866 ;; the default method.
868 (or (and (listp gnus-post-method) ;If not current/native/nil
869 (not (listp (car gnus-post-method))) ; and not a list of methods
870 gnus-post-method) ;then use it.
872 message-post-method))
873 ;; We want the inverse of the default
874 ((and arg (not (eq arg 0)))
875 (if (eq gnus-post-method 'current)
878 ;; We query the user for a post method.
880 (and (listp gnus-post-method)
881 (listp (car gnus-post-method))))
883 ;; Collect all methods we know about.
885 (when (listp gnus-post-method)
886 (if (listp (car gnus-post-method))
888 (list gnus-post-method)))
889 gnus-secondary-select-methods
890 (mapcar 'cdr gnus-server-alist)
891 (mapcar 'car gnus-opened-servers)
892 (list gnus-select-method)
893 (list group-method)))
894 method-alist post-methods method)
895 ;; Weed out all mail methods.
897 (setq method (gnus-server-get-method "" (pop methods)))
898 (when (and (or (gnus-method-option-p method 'post)
899 (gnus-method-option-p method 'post-mail))
900 (not (member method post-methods)))
901 (push method post-methods)))
902 ;; Create a name-method alist.
906 (if (equal (cadr m) "")
907 (list (symbol-name (car m)) m)
908 (list (concat (cadr m) " (" (symbol-name (car m)) ")") m)))
913 (setq gnus-last-posting-server
915 gnus-last-posting-server)
916 ;; Just use the last value.
917 gnus-last-posting-server
919 "Posting method: " method-alist nil t
920 (cons (or gnus-last-posting-server "") 0))))
922 ;; Override normal method.
923 ((and (eq gnus-post-method 'current)
924 (not (eq (car group-method) 'nndraft))
925 (gnus-get-function group-method 'request-post t))
928 ;; Use gnus-post-method.
929 ((listp gnus-post-method) ;A method...
930 (assert (not (listp (car gnus-post-method)))) ;... not a list of methods.
932 ;; Use the normal select method (nil or native).
933 (t gnus-select-method))))
936 (defun gnus-message-make-user-agent (&optional include-mime-info max-column
938 "Return a user-agent info. If INCLUDE-MIME-INFO is non-nil and the
939 variable `mime-edit-user-agent-value' is bound, the value will be
940 included in the return value. If MAX-COLUMN is specified, the return
941 value will be folded up as it were filled. NEWLINE-PRODUCT specifies
942 whether a newline should be inserted in front of each product-token.
943 If the value is t or `hard', it works strictly. Otherwise, if it is
944 non-nil (e.g. `soft'), it works semi-strictly.
946 Here is an example of how to use this function:
948 \(add-hook 'gnus-message-setup-hook
950 (setq message-user-agent nil)
953 (message-narrow-to-headers)
954 (goto-char (point-max))
955 (insert \"User-Agent: \"
956 (gnus-message-make-user-agent t 76 'soft)
959 (let ((user-agent (if (and include-mime-info
960 (boundp 'mime-edit-user-agent-value))
961 (concat (gnus-extended-version)
963 mime-edit-user-agent-value)
964 (gnus-extended-version))))
966 (unless (natnump max-column)
967 (setq max-column 76))
969 (set-buffer-multibyte t)
970 (insert (mapconcat 'identity (split-string user-agent) " "))
971 (goto-char (point-min))
973 start agent agents width element swidth)
974 (while (re-search-forward "\\([^ ]+\\) ?" nil t)
975 (setq start (match-beginning 0))
976 (if (eq (char-after start) ?\()
980 (push (buffer-substring start (point)) agent))
982 (push (nreverse agent) agents))
983 (setq agent (list (match-string 1)))))
985 (push (nreverse agent) agents))
986 (setq agents (nreverse agents))
987 (if (> (+ 12 (string-width (caar agents))) max-column)
988 (setq user-agent "\n"
993 (setq agent (car agents)
996 (or (memq newline-product '(t hard))
999 (string-width (mapconcat 'identity
1002 (setq user-agent (concat user-agent "\n")
1006 (setq element (car agent)
1007 swidth (string-width element)
1010 (setq user-agent (if (member user-agent '("" "\n"))
1011 (concat user-agent element)
1012 (concat user-agent " " element))
1013 width (+ width 1 swidth)
1015 (if (> (+ width 1 swidth) max-column)
1016 (setq user-agent (concat user-agent "\n " element)
1018 (setq user-agent (concat user-agent " " element)
1019 width (+ width 1 swidth)))))))))
1024 ;;; Gnus Mail Functions
1027 ;;; Mail reply commands of Gnus summary mode
1029 (defun gnus-summary-reply (&optional yank wide very-wide)
1030 "Start composing a mail reply to the current message.
1031 If prefix argument YANK is non-nil, the original article is yanked
1033 If WIDE, make a wide reply.
1034 If VERY-WIDE, make a very wide reply."
1036 (list (and current-prefix-arg
1037 (gnus-summary-work-articles 1))))
1039 (if (listp (car yank))
1042 (gnus-article-reply (or article (gnus-summary-article-number)))
1044 ;; Stripping headers should be specified with mail-yank-ignored-headers.
1046 (gnus-summary-goto-subject article))
1047 (gnus-setup-message (if yank 'reply-yank 'reply)
1049 (gnus-summary-select-article)
1050 (dolist (article very-wide)
1051 (gnus-summary-select-article nil nil nil article)
1053 (set-buffer (gnus-copy-article-buffer))
1054 (gnus-msg-treat-broken-reply-to)
1056 (message-narrow-to-head)
1057 (setq headers (concat headers (buffer-string)))))))
1058 (set-buffer (gnus-copy-article-buffer))
1059 (gnus-msg-treat-broken-reply-to gnus-msg-force-broken-reply-to)
1061 (message-narrow-to-head)
1065 (goto-char (point-max)))
1066 (message-reply nil wide)
1068 (gnus-inews-yank-articles yank)))))
1070 (defun gnus-summary-reply-with-original (n &optional wide)
1071 "Start composing a reply mail to the current message.
1072 The original article will be yanked."
1074 (gnus-summary-reply (gnus-summary-work-articles n) wide))
1076 (defun gnus-summary-reply-broken-reply-to (&optional yank wide very-wide)
1077 "Like `gnus-summary-reply' except removing reply-to field.
1078 If prefix argument YANK is non-nil, the original article is yanked
1080 If WIDE, make a wide reply.
1081 If VERY-WIDE, make a very wide reply."
1083 (list (and current-prefix-arg
1084 (gnus-summary-work-articles 1))))
1085 (let ((gnus-msg-force-broken-reply-to t))
1086 (gnus-summary-reply yank wide very-wide)))
1088 (defun gnus-summary-reply-broken-reply-to-with-original (n &optional wide)
1089 "Like `gnus-summary-reply-with-original' except removing reply-to field.
1090 The original article will be yanked."
1092 (gnus-summary-reply-broken-reply-to (gnus-summary-work-articles n) wide))
1094 (defun gnus-summary-wide-reply (&optional yank)
1095 "Start composing a wide reply mail to the current message.
1096 If prefix argument YANK is non-nil, the original article is yanked
1099 (list (and current-prefix-arg
1100 (gnus-summary-work-articles 1))))
1101 (gnus-summary-reply yank t))
1103 (defun gnus-summary-wide-reply-with-original (n)
1104 "Start composing a wide reply mail to the current message.
1105 The original article will be yanked."
1107 (gnus-summary-reply-with-original n t))
1109 (defun gnus-summary-very-wide-reply (&optional yank)
1110 "Start composing a very wide reply mail to the current message.
1111 If prefix argument YANK is non-nil, the original article is yanked
1114 (list (and current-prefix-arg
1115 (gnus-summary-work-articles 1))))
1116 (gnus-summary-reply yank t (gnus-summary-work-articles yank)))
1118 (defun gnus-summary-very-wide-reply-with-original (n)
1119 "Start composing a very wide reply mail to the current message.
1120 The original article will be yanked."
1123 (gnus-summary-work-articles n) t (gnus-summary-work-articles n)))
1125 (defun gnus-summary-mail-forward (&optional full-headers post)
1126 "Forward the current message(s) to another user.
1127 If process marks exist, forward all marked messages;
1128 If FULL-HEADERS (the prefix), include full headers when forwarding."
1130 (if (null (cdr (gnus-summary-work-articles nil)))
1131 (gnus-setup-message 'forward
1132 (gnus-summary-select-article)
1133 (let ((charset default-mime-charset))
1134 (set-buffer gnus-original-article-buffer)
1135 (make-local-variable 'default-mime-charset)
1136 (setq default-mime-charset charset))
1137 (let ((message-included-forward-headers
1138 (if full-headers "" message-included-forward-headers)))
1139 (message-forward post)))
1140 (gnus-summary-digest-mail-forward nil post)))
1142 (defun gnus-summary-digest-mail-forward (&optional n post)
1143 "Digests and forwards all articles in this series.
1144 If N is a positive number, forward the N next articles.
1145 If N is a negative number, forward the N previous articles.
1146 If N is nil and any articles have been marked with the process mark,
1147 forward those articles instead.
1148 Optional POST will use news to forward instead of mail."
1150 (let ((articles (gnus-summary-work-articles n))
1151 (topics "Topics:\n")
1152 subject article frame)
1153 (when (car articles)
1154 (gnus-setup-message 'forward
1155 (gnus-summary-select-article)
1157 (setq articles (sort articles '<)
1158 subject "Digested Articles")
1159 (with-current-buffer gnus-original-article-buffer
1160 (setq subject (message-make-forward-subject))))
1162 (message-news nil subject)
1163 (message-mail nil subject))
1164 (when (and message-use-multi-frames (cdr articles))
1165 (setq frame (window-frame (get-buffer-window (current-buffer)))))
1167 (while (setq article (pop articles))
1168 (save-window-excursion
1169 (set-buffer gnus-summary-buffer)
1170 (gnus-summary-select-article nil nil nil article)
1171 (setq topics (concat topics " "
1172 (mail-header-subject gnus-current-headers)
1174 (gnus-summary-remove-process-mark article))
1176 (select-frame frame))
1177 (insert (mime-make-tag "message" "rfc822") "\n")
1178 (narrow-to-region (point) (point))
1179 (insert-buffer-substring gnus-original-article-buffer)
1181 (article-narrow-to-head)
1182 (message-remove-header message-included-forward-headers t nil t))
1183 (goto-char (point-max))
1189 (mime-edit-enclose-digest-region (point)(mark t))))))
1191 (defun gnus-summary-digest-post-forward (&optional n)
1192 "Digest and forwards all articles in this series to a newsgroup.
1193 If N is a positive number, forward the N next articles.
1194 If N is a negative number, forward the N previous articles.
1195 If N is nil and any articles have been marked with the process mark,
1196 forward those articles instead."
1198 (gnus-summary-digest-mail-forward n t))
1200 (defun gnus-summary-resend-message (address n)
1201 "Resend the current article to ADDRESS."
1203 (list (message-read-from-minibuffer
1204 "Resend message(s) to: "
1205 (when (gnus-buffer-live-p gnus-original-article-buffer)
1206 ;; If some other article is currently selected, the
1207 ;; initial-contents is wrong. Whatever, it is just the
1208 ;; initial-contents.
1209 (with-current-buffer gnus-original-article-buffer
1210 (nnmail-fetch-field "to"))))
1211 current-prefix-arg))
1212 (let ((articles (gnus-summary-work-articles n))
1214 (while (setq article (pop articles))
1215 (gnus-summary-select-article nil nil nil article)
1217 (set-buffer gnus-original-article-buffer)
1218 (message-resend address))
1219 (gnus-summary-mark-article-as-forwarded article))))
1221 (defun gnus-summary-post-forward (&optional full-headers)
1222 "Forward the current article to a newsgroup.
1223 If FULL-HEADERS (the prefix), include full headers when forwarding."
1225 (gnus-summary-mail-forward full-headers t))
1227 (defvar gnus-nastygram-message
1228 "The following article was inappropriately posted to %s.\n\n"
1229 "Format string to insert in nastygrams.
1230 The current group name will be inserted at \"%s\".")
1232 (defun gnus-summary-mail-nastygram (n)
1233 "Send a nastygram to the author of the current article."
1235 (when (or gnus-expert-user
1237 "Really send a nastygram to the author of the current article? "))
1238 (let ((group gnus-newsgroup-name))
1239 (gnus-summary-reply-with-original n)
1240 (set-buffer gnus-message-buffer)
1242 (insert (format gnus-nastygram-message group))
1243 (message-send-and-exit))))
1245 (defun gnus-summary-mail-crosspost-complaint (n)
1246 "Send a complaint about crossposting to the current article(s)."
1248 (let ((articles (gnus-summary-work-articles n))
1250 (while (setq article (pop articles))
1251 (set-buffer gnus-summary-buffer)
1252 (gnus-summary-goto-subject article)
1253 (let ((group (gnus-group-real-name gnus-newsgroup-name))
1254 newsgroups followup-to)
1255 (gnus-summary-select-article)
1256 (set-buffer gnus-original-article-buffer)
1257 (if (and (<= (length (message-tokenize-header
1259 (mail-fetch-field "newsgroups"))
1262 (or (not (setq followup-to (mail-fetch-field "followup-to")))
1263 (not (member group (message-tokenize-header
1264 followup-to ", ")))))
1266 (gnus-message 1 "Followup-to restricted")
1267 (gnus-message 1 "Not a crossposted article"))
1268 (set-buffer gnus-summary-buffer)
1269 (gnus-summary-reply-with-original 1)
1270 (set-buffer gnus-message-buffer)
1272 (insert (format gnus-crosspost-complaint newsgroups group))
1273 (message-goto-subject)
1274 (re-search-forward " *$")
1275 (replace-match " (crosspost notification)" t t)
1276 (gnus-deactivate-mark)
1277 (when (gnus-y-or-n-p "Send this complaint? ")
1278 (message-send-and-exit)))))))
1280 (defun gnus-mail-parse-comma-list ()
1283 (skip-chars-forward " ")
1286 (skip-chars-forward "^,")
1291 (narrow-to-region beg (point))
1294 (while (search-forward "\"" nil t)
1298 (skip-chars-forward ",")
1299 (skip-chars-forward "^,"))
1300 (skip-chars-backward " ")
1301 (push (buffer-substring beg (point))
1303 (skip-chars-forward "^,")
1304 (skip-chars-forward ", "))
1307 (defun gnus-inews-add-to-address (group)
1308 (let ((to-address (mail-fetch-field "to")))
1309 (when (and to-address
1311 ;; This mail group doesn't have a `to-list', so we add one
1313 (when (gnus-y-or-n-p
1314 (format "Do you want to add this as `to-list': %s " to-address))
1315 (gnus-group-add-parameter group (cons 'to-list to-address))))))
1317 (defun gnus-put-message ()
1318 "Put the current message in some group and return to Gnus."
1320 (let ((reply gnus-article-reply)
1321 (winconf gnus-prev-winconf)
1322 (group gnus-newsgroup-name))
1324 (not (gnus-group-read-only-p group)))
1325 (setq group (read-string "Put in group: " nil (gnus-writable-groups))))
1327 (when (gnus-gethash group gnus-newsrc-hashtb)
1328 (error "No such group: %s" group))
1332 (message-narrow-to-headers)
1333 (let ((gnus-deletable-headers nil))
1334 (message-generate-headers
1335 (if (message-news-p)
1336 message-required-news-headers
1337 message-required-mail-headers)))
1338 (goto-char (point-max))
1339 (insert "Gcc: " group "\n")
1342 (when (and (get-buffer gnus-group-buffer)
1343 (gnus-buffer-exists-p (car-safe reply))
1345 (set-buffer (car reply))
1346 (gnus-summary-mark-article-as-replied (cdr reply)))
1348 (set-window-configuration winconf))))
1350 (defun gnus-article-mail (yank)
1351 "Send a reply to the address near point.
1352 If YANK is non-nil, include the original article."
1356 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
1357 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
1359 (message-reply address)
1361 (gnus-inews-yank-articles (list (cdr gnus-article-current)))))))
1363 (defvar nntp-server-type)
1365 "Send a bug report to the Gnus maintainers."
1367 (unless (gnus-alive-p)
1368 (error "Gnus has been shut down"))
1369 (gnus-setup-message (if (message-mail-user-agent) 'message 'bug)
1370 (unless (message-mail-user-agent)
1371 (message-pop-to-buffer "*Gnus Bug*")
1372 (delete-other-windows)
1373 (when gnus-bug-create-help-buffer
1374 (switch-to-buffer "*Gnus Help Bug*")
1376 (insert gnus-bug-message)
1377 (goto-char (point-min))
1379 (set-buffer "*Gnus Bug*")))
1380 (let ((message-this-is-mail t))
1381 (message-setup `((To . ,gnus-maintainer) (Subject . ""))))
1382 (when gnus-bug-create-help-buffer
1383 (push `(gnus-bug-kill-buffer) message-send-actions))
1384 (goto-char (point-min))
1385 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
1387 (insert gnus-product-name " " gnus-version-number
1388 " (r" gnus-revision-number ") "
1389 "based on " gnus-original-product-name " v"
1390 gnus-original-version-number "\n"
1391 (emacs-version) "\n")
1392 (when (and (boundp 'nntp-server-type)
1393 (stringp nntp-server-type))
1394 (insert nntp-server-type))
1395 (insert "\n\n\n\n\n")
1396 (let (mime-content-types)
1397 (mime-edit-insert-tag
1398 "application" "emacs-lisp"
1399 "\nContent-Disposition: inline\nContent-Description: User settings"))
1400 (insert (with-temp-buffer
1403 (let (mime-content-types)
1404 (mime-edit-insert-tag "text" "plain"))
1405 (goto-char (point-min))
1406 (search-forward "Subject: " nil t)
1409 (defun gnus-bug-kill-buffer ()
1410 (when (get-buffer "*Gnus Help Bug*")
1411 (kill-buffer "*Gnus Help Bug*")))
1413 (defun gnus-summary-yank-message (buffer n)
1414 "Yank the current article into a composed message."
1416 (list (completing-read "Buffer: " (mapcar 'list (message-buffers)) nil t)
1417 current-prefix-arg))
1418 (when (gnus-buffer-live-p buffer)
1419 (let ((summary-frame (selected-frame))
1420 (message-frame (when (static-if (featurep 'xemacs)
1421 (device-on-window-system-p)
1423 (let ((window (get-buffer-window buffer t)))
1425 (window-frame window)))))
1426 (separator (concat "^" (regexp-quote mail-header-separator)
1428 (gnus-summary-iterate n
1429 (gnus-summary-select-article)
1430 (gnus-copy-article-buffer)
1431 (when (frame-live-p message-frame)
1432 (raise-frame message-frame)
1433 (select-frame message-frame))
1434 (with-current-buffer buffer
1435 (when (save-excursion
1437 (let (case-fold-search)
1438 (and (not (re-search-backward separator nil t))
1439 (re-search-forward separator nil t))))
1440 (goto-char (match-end 0)))
1441 (message-yank-buffer gnus-article-copy))
1442 (select-frame summary-frame))
1443 (when (frame-live-p message-frame)
1444 (select-frame message-frame)))))
1446 (defun gnus-debug ()
1447 "Attempts to go through the Gnus source file and report what variables have been changed.
1448 The source file has to be in the Emacs load path."
1450 (let ((files '("gnus.el" "gnus-sum.el" "gnus-group.el"
1451 "gnus-art.el" "gnus-start.el" "gnus-async.el"
1452 "gnus-msg.el" "gnus-score.el" "gnus-win.el" "gnus-topic.el"
1453 "nnmail.el" "nntp.el" "message.el"))
1455 file expr olist sym)
1456 (gnus-message 4 "Please wait while we snoop your variables...")
1457 ;; Go through all the files looking for non-default values for variables.
1460 (set-buffer (gnus-get-buffer-create " *gnus bug info*"))
1463 (when (and (setq file (locate-library (pop files)))
1464 (file-exists-p file))
1465 (insert-file-contents file)
1466 (goto-char (point-min))
1467 (if (not (re-search-forward "^;;* *Internal variables" nil t))
1468 (gnus-message 4 "Malformed sources in file %s" file)
1469 (narrow-to-region (point-min) (point))
1470 (goto-char (point-min))
1471 (while (setq expr (ignore-errors (read (current-buffer))))
1473 (and (memq (car expr) '(defvar defcustom defvoo))
1474 (stringp (nth 3 expr))
1475 (or (not (boundp (nth 1 expr)))
1476 (not (equal (eval (nth 2 expr))
1477 (symbol-value (nth 1 expr)))))
1478 (push (nth 1 expr) olist)))))))
1479 (kill-buffer (current-buffer)))
1480 (when (setq olist (nreverse olist))
1481 (insert ";----------------- Environment follows ------------------\n\n"))
1483 (if (boundp (car olist))
1485 (pp `(setq ,(car olist)
1486 ,(if (or (consp (setq sym (symbol-value (car olist))))
1488 (not (or (eq sym nil)
1490 (list 'quote (symbol-value (car olist)))
1491 (symbol-value (car olist))))
1494 (format "(setq %s 'whatever)\n" (car olist))))
1495 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
1496 (setq olist (cdr olist)))
1497 ;; Remove any control chars - they seem to cause trouble for some
1498 ;; mailers. (Byte-compiled output from the stuff above.)
1500 (while (re-search-forward "[\000-\010\013-\037\200-\237]" nil t)
1501 (replace-match (format "\\%03o" (string-to-char (match-string 0)))
1503 ;; Break MIME tags purposely.
1505 (while (re-search-forward mime-edit-tag-regexp nil t)
1506 (goto-char (1+ (match-beginning 0)))
1509 ;;; Treatment of rejected articles.
1512 (defun gnus-summary-resend-bounced-mail (&optional fetch)
1513 "Re-mail the current message.
1514 This only makes sense if the current message is a bounce message than
1515 contains some mail you have written which has been bounced back to
1517 If FETCH, try to fetch the article that this is a reply to, if indeed
1520 (gnus-summary-select-article t)
1521 (set-buffer gnus-original-article-buffer)
1522 (let ((gnus-message-setup-hook '(gnus-maybe-setup-default-charset)))
1523 (gnus-setup-message 'compose-bounce
1524 (let* ((references (mail-fetch-field "references"))
1525 (parent (and references (gnus-parent-id references))))
1527 ;; If there are references, we fetch the article we answered to.
1529 (gnus-summary-refer-article parent)
1530 (gnus-summary-show-all-headers))))))
1534 (defun gnus-inews-group-method (group)
1536 ;; If the group doesn't exist, we assume
1537 ;; it's an archive group...
1538 ((and (null (gnus-get-info group))
1539 (eq (car (gnus-server-to-method gnus-message-archive-method))
1540 (car (gnus-server-to-method (gnus-group-method group)))))
1541 gnus-message-archive-method)
1543 ((gnus-info-method (gnus-get-info group))
1544 (gnus-info-method (gnus-get-info group)))
1546 (t (gnus-server-to-method (gnus-group-method group)))))
1548 ;; Do Gcc handling, which copied the message over to some group.
1549 (defun gnus-inews-do-gcc (&optional gcc)
1553 (message-narrow-to-headers)
1554 (let ((gcc (or gcc (mail-fetch-field "gcc" nil t)))
1555 (coding-system-for-write 'raw-text)
1556 (output-coding-system 'raw-text)
1557 groups group method group-art
1558 mml-externalize-attachments)
1560 (message-remove-header "gcc")
1562 (setq groups (message-unquote-tokens
1563 (message-tokenize-header gcc " ,")))
1564 ;; Copy the article over to some group(s).
1565 (while (setq group (pop groups))
1566 (unless (gnus-check-server
1567 (setq method (gnus-inews-group-method group)))
1568 (error "Can't open server %s" (if (stringp method) method
1570 (unless (gnus-request-group group nil method)
1571 (gnus-request-create-group group method))
1572 (setq mml-externalize-attachments
1573 (if (stringp gnus-gcc-externalize-attachments)
1574 (string-match gnus-gcc-externalize-attachments group)
1575 gnus-gcc-externalize-attachments))
1577 (nnheader-set-temp-buffer " *acc*")
1578 (insert-buffer-substring message-encoding-buffer)
1579 (gnus-run-hooks 'gnus-before-do-gcc-hook)
1580 (goto-char (point-min))
1581 (when (re-search-forward
1582 (concat "^" (regexp-quote mail-header-separator) "$")
1584 (replace-match "" t t ))
1585 (unless (setq group-art
1586 (gnus-request-accept-article group method t t))
1587 (gnus-message 1 "Couldn't store article in group %s: %s"
1588 group (gnus-status-message method))
1590 (when (and group-art
1591 (or gnus-gcc-mark-as-read
1592 gnus-inews-mark-gcc-as-read))
1593 (gnus-group-mark-article-read group (cdr group-art)))
1594 (kill-buffer (current-buffer)))))))))
1596 (defun gnus-inews-insert-gcc ()
1597 "Insert Gcc headers based on `gnus-outgoing-message-group'."
1600 (message-narrow-to-headers)
1601 (let* ((group gnus-outgoing-message-group)
1603 ((gnus-functionp group)
1605 ((or (stringp group) (list group))
1609 (if (stringp gcc) gcc
1610 (mapconcat 'identity gcc " "))
1613 (defun gnus-inews-insert-archive-gcc (&optional group)
1614 "Insert the Gcc to say where the article is to be archived."
1615 (let* ((var gnus-message-archive-group)
1616 (group (or group gnus-newsgroup-name ""))
1618 (and gnus-newsgroup-name
1619 (not (equal gnus-newsgroup-name ""))
1620 (gnus-group-find-parameter
1621 gnus-newsgroup-name 'gcc-self)))
1625 ((null gnus-message-archive-method)
1629 ;; Just a single group.
1632 ;; We don't want this.
1634 ((and (listp var) (stringp (car var)))
1635 ;; A list of groups.
1637 ((gnus-functionp var)
1639 (funcall var group))
1641 ;; An alist of regexps/functions/forms.
1646 ((stringp (caar var))
1648 (when (string-match (caar var) group)
1650 ((gnus-functionp (car var))
1652 (funcall (car var) group))
1654 (eval (car var)))))))
1655 (setq var (cdr var)))
1658 (when (or groups gcc-self-val)
1659 (when (stringp groups)
1660 (setq groups (list groups)))
1663 (message-narrow-to-headers)
1664 (goto-char (point-max))
1667 ;; Use the `gcc-self' param value instead.
1670 (if (stringp gcc-self-val)
1673 (if (not (eq gcc-self-val 'none))
1678 ;; Use the list of groups.
1679 (while (setq name (pop groups))
1680 (insert (if (string-match ":" name)
1682 (gnus-group-prefixed-name
1683 name gnus-message-archive-method)))
1690 (defun gnus-configure-posting-styles (&optional group-name)
1691 "Configure posting styles according to `gnus-posting-styles'."
1692 (unless gnus-inhibit-posting-styles
1693 (let ((group (or group-name gnus-newsgroup-name ""))
1694 (styles gnus-posting-styles)
1695 style match variable attribute value v results
1696 filep name address element)
1697 ;; If the group has a posting-style parameter, add it at the end with a
1698 ;; regexp matching everything, to be sure it takes precedence over all
1700 (when gnus-newsgroup-name
1701 (let ((tmp-style (gnus-group-find-parameter group 'posting-style t)))
1703 (setq styles (append styles (list (cons ".*" tmp-style)))))))
1704 ;; Go through all styles and look for matches.
1705 (dolist (style styles)
1706 (setq match (pop style))
1707 (goto-char (point-min))
1710 ;; Regexp string match on the group name.
1711 (string-match match group))
1713 (and (gnus-buffer-live-p gnus-article-copy)
1714 (with-current-buffer gnus-article-copy
1715 (let ((header (message-fetch-field (pop style))))
1717 (string-match (pop style) header))))))
1718 ((or (symbolp match)
1719 (gnus-functionp match))
1721 ((gnus-functionp match)
1722 ;; Function to be called.
1725 ;; Variable to be checked.
1726 (symbol-value match))))
1728 ;; This is a form to be evaled.
1730 ;; We have a match, so we set the variables.
1731 (dolist (attribute style)
1732 (setq element (pop attribute)
1737 ((eq (car attribute) ':file)
1740 ((eq (car attribute) :value)
1744 ;; We get the value.
1749 ((or (symbolp value)
1750 (gnus-functionp value))
1751 (cond ((gnus-functionp value)
1754 (symbol-value value))))
1757 ;; Translate obsolescent value.
1758 (when (eq element 'signature-file)
1759 (setq element 'signature
1761 ;; Get the contents of file elems.
1763 (setq v (with-temp-buffer
1764 (insert-file-contents v)
1766 (setq results (delq (assoc element results) results))
1767 (push (cons element v) results))))
1768 ;; Now we have all the styles, so we insert them.
1769 (setq name (assq 'name results)
1770 address (assq 'address results))
1771 (setq results (delq name (delq address results)))
1772 ;; make-local-hook is not obsolete in Emacs 20 or XEmacs.
1773 (make-local-hook 'message-setup-hook)
1774 (dolist (result results)
1775 (add-hook 'message-setup-hook
1777 ((eq 'eval (car result))
1779 ((eq 'body (car result))
1783 (insert ,(cdr result)))))
1784 ((eq 'signature (car result))
1785 (set (make-local-variable 'message-signature) nil)
1786 (set (make-local-variable 'message-signature-file) nil)
1787 (if (not (cdr result))
1791 (let ((message-signature ,(cdr result)))
1792 (when message-signature
1793 (message-insert-signature)))))))
1796 (if (symbolp (car result))
1797 (capitalize (symbol-name (car result)))
1801 (message-remove-header ,header)
1802 (let ((value ,(cdr result)))
1805 (insert ,header ": " value "\n"))))))))
1807 (when (or name address)
1808 (add-hook 'message-setup-hook
1810 (set (make-local-variable 'user-mail-address)
1811 ,(or (cdr address) user-mail-address))
1812 (let ((user-full-name ,(or (cdr name) (user-full-name)))
1814 ,(or (cdr address) user-mail-address)))
1816 (message-remove-header "From")
1818 (insert "From: " (message-make-from) "\n"))))
1822 ;;; @ for MIME Edit mode
1825 (defun gnus-maybe-setup-default-charset ()
1827 (and (boundp 'gnus-summary-buffer)
1828 (buffer-live-p gnus-summary-buffer)
1830 (set-buffer gnus-summary-buffer)
1831 default-mime-charset))))
1834 (make-local-variable 'default-mime-charset)
1835 (setq default-mime-charset charset)
1839 ;;; @ for MIME view mode
1842 (defun gnus-following-method (buf)
1843 (gnus-setup-message 'reply-yank
1845 (if (message-news-p)
1847 (message-reply nil 'wide))
1848 (let ((message-reply-buffer buf))
1849 (message-yank-original))
1850 (message-goto-body))
1854 ;;; Allow redefinition of functions.
1860 ;;; gnus-msg.el ends here