1 ;;; gnus-msg.el --- mail and post interface for Gnus
3 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
4 ;; 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
6 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
7 ;; Lars Magne Ingebrigtsen <larsi@gnus.org>
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 3, or (at your option)
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25 ;; Boston, MA 02110-1301, USA.
31 (eval-when-compile (require 'cl
))
39 (defcustom gnus-post-method
'current
40 "*Preferred method for posting USENET news.
42 If this variable is `current' (which is the default), Gnus will use
43 the \"current\" select method when posting. If it is `native', Gnus
44 will use the native select method when posting.
46 This method will not be used in mail groups and the like, only in
49 If not `native' nor `current', the value must be a valid method as discussed
50 in the documentation of `gnus-select-method'. It can also be a list of
51 methods. If that is the case, the user will be queried for what select
52 method to use when posting."
53 :group
'gnus-group-foreign
54 :link
'(custom-manual "(gnus)Posting Server")
55 :type
`(choice (const native
)
57 (sexp :tag
"Methods" ,gnus-select-method
)))
59 (defcustom gnus-outgoing-message-group nil
60 "*All outgoing messages will be put in this group.
61 If you want to store all your outgoing mail and articles in the group
62 \"nnml:archive\", you set this variable to that value. This variable
63 can also be a list of group names.
65 If you want to have greater control over what group to put each
66 message in, you can set this variable to a function that checks the
67 current newsgroup name and then returns a suitable group name (or list
70 :type
'(choice (const nil
)
73 (repeat :tag
"List of groups" (string :tag
"Group"))))
75 (defcustom gnus-mailing-list-groups nil
76 "*If non-nil a regexp matching groups that are really mailing lists.
77 This is useful when you're reading a mailing list that has been
78 gatewayed to a newsgroup, and you want to followup to an article in
81 :type
'(choice (regexp)
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 nil
110 "Hook run after setting up a message buffer."
112 :options
'(message-remove-blank-cited-lines)
115 (defcustom gnus-bug-create-help-buffer t
116 "*Should we create the *Gnus Help Bug* buffer?"
120 (defcustom gnus-posting-styles nil
121 "*Alist of styles to use when posting.
122 See Info node `(gnus)Posting Styles'."
124 :link
'(custom-manual "(gnus)Posting Styles")
125 :type
'(repeat (cons (choice (regexp)
128 (string :tag
"Header")
129 (regexp :tag
"Regexp"))
133 (choice (const signature
)
134 (const signature-file
)
141 (string :tag
"Header"))
147 (defcustom gnus-gcc-mark-as-read nil
148 "If non-nil, automatically mark Gcc articles as read."
153 (make-obsolete-variable 'gnus-inews-mark-gcc-as-read
154 'gnus-gcc-mark-as-read
)
156 (defcustom gnus-gcc-externalize-attachments nil
157 "Should local-file attachments be included as external parts in Gcc copies?
158 If it is `all', attach files as external parts;
159 if a regexp and matches the Gcc group name, attach files as external parts;
160 if nil, attach files as normal parts."
163 :type
'(choice (const nil
:tag
"None")
164 (const all
:tag
"Any")
165 (string :tag
"Regexp")))
167 (gnus-define-group-parameter
168 posting-charset-alist
171 "Return the permitted unencoded charsets for posting of GROUP."
172 :variable gnus-group-posting-charset-alist
174 '(("^\\(no\\|fr\\)\\.[^,]*\\(,[ \t\n]*\\(no\\|fr\\)\\.[^,]*\\)*$" iso-8859-1
(iso-8859-1))
175 ("^\\(fido7\\|relcom\\)\\.[^,]*\\(,[ \t\n]*\\(fido7\\|relcom\\)\\.[^,]*\\)*$" koi8-r
(koi8-r))
176 (message-this-is-mail nil nil
)
177 (message-this-is-news nil t
))
179 "Alist of regexps and permitted unencoded charsets for posting.
180 Each element of the alist has the form (TEST HEADER BODY-LIST), where
181 TEST is either a regular expression matching the newsgroup header or a
183 HEADER is the charset which may be left unencoded in the header (nil
184 means encode all charsets),
185 BODY-LIST is a list of charsets which may be encoded using 8bit
186 content-transfer encoding in the body, or one of the special values
187 nil (always encode using quoted-printable) or t (always use 8bit).
189 Note that any value other than nil for HEADER infringes some RFCs, so
190 use this option with care."
191 :variable-group gnus-charset
193 '(repeat (list :tag
"Permitted unencoded charsets"
195 (regexp :tag
"Group")
196 (const :tag
"Mail message" :value message-this-is-mail
)
197 (const :tag
"News article" :value message-this-is-news
))
198 (choice :tag
"Header"
199 (const :tag
"None" nil
)
200 (symbol :tag
"Charset"))
202 (const :tag
"Any" :value t
)
203 (const :tag
"None" :value nil
)
204 (repeat :tag
"Charsets"
205 (symbol :tag
"Charset")))))
206 :parameter-type
'(choice :tag
"Permitted unencoded charsets"
209 :parameter-document
"\
210 List of charsets that are permitted to be unencoded.")
212 (defcustom gnus-debug-files
213 '("gnus.el" "gnus-sum.el" "gnus-group.el"
214 "gnus-art.el" "gnus-start.el" "gnus-async.el"
215 "gnus-msg.el" "gnus-score.el" "gnus-win.el" "gnus-topic.el"
216 "gnus-agent.el" "gnus-cache.el" "gnus-srvr.el"
217 "mm-util.el" "mm-decode.el" "nnmail.el" "message.el")
218 "Files whose variables will be reported in `gnus-bug'."
221 :type
'(repeat (string :tag
"File")))
223 (defcustom gnus-debug-exclude-variables
224 '(mm-mime-mule-charset-alist
225 nnmail-split-fancy message-minibuffer-local-map
)
226 "Variables that should not be reported in `gnus-bug'."
229 :type
'(repeat (symbol :tag
"Variable")))
231 (defcustom gnus-discouraged-post-methods
232 '(nndraft nnml nnimap nnmaildir nnmh nnfolder nndir
)
233 "A list of back ends that are not used in \"real\" newsgroups.
234 This variable is used only when `gnus-post-method' is `current'."
236 :group
'gnus-group-foreign
237 :type
'(repeat (symbol :tag
"Back end")))
239 (defcustom gnus-message-replysign
241 "Automatically sign replies to signed messages.
242 See also the `mml-default-sign-method' variable."
246 (defcustom gnus-message-replyencrypt
248 "Automatically encrypt replies to encrypted messages.
249 See also the `mml-default-encrypt-method' variable."
253 (defcustom gnus-message-replysignencrypted
255 "Setting this causes automatically encrypted messages to also be signed."
259 (defcustom gnus-confirm-mail-reply-to-news
(and gnus-novice-user
260 (not gnus-expert-user
))
261 "If non-nil, Gnus requests confirmation when replying to news.
262 This is done because new users often reply by mistake when reading
264 This can also be a function receiving the group name as the only
265 parameter, which should return non-nil if a confirmation is needed; or
266 a regexp, in which case a confirmation is asked for if the group name
268 :version
"23.1" ;; No Gnus (default changed)
270 :type
'(choice (const :tag
"No" nil
)
272 (regexp :tag
"If group matches regexp")
273 (function :tag
"If function evaluates to non-nil")))
275 (defcustom gnus-confirm-treat-mail-like-news
277 "If non-nil, Gnus will treat mail like news with regard to confirmation
278 when replying by mail. See the `gnus-confirm-mail-reply-to-news' variable
279 for fine-tuning this.
280 If nil, Gnus will never ask for confirmation if replying to mail."
285 (defcustom gnus-summary-resend-default-address t
286 "If non-nil, Gnus tries to suggest a default address to resend to.
287 If nil, the address field will always be empty after invoking
288 `gnus-summary-resend-message'."
293 (defcustom gnus-message-highlight-citation
294 t
;; gnus-treat-highlight-citation ;; gnus-cite dependency
295 "Enable highlighting of different citation levels in message-mode."
296 :version
"23.1" ;; No Gnus
301 (autoload 'gnus-message-citation-mode
"gnus-cite" nil t
)
303 ;;; Internal variables.
305 (defvar gnus-inhibit-posting-styles nil
306 "Inhibit the use of posting styles.")
308 (defvar gnus-article-yanked-articles nil
)
309 (defvar gnus-message-buffer
"*Mail Gnus*")
310 (defvar gnus-article-copy nil
)
311 (defvar gnus-check-before-posting nil
)
312 (defvar gnus-last-posting-server nil
)
313 (defvar gnus-message-group-art nil
)
315 (defvar gnus-msg-force-broken-reply-to nil
)
317 (defconst gnus-bug-message
318 "Sending a bug report to the Gnus Towers.
319 ========================================
321 The buffer below is a mail buffer. When you press `C-c C-c', it will
322 be sent to the Gnus Bug Exterminators.
324 The thing near the bottom of the buffer is how the environment
325 settings will be included in the mail. Please do not delete that.
326 They will tell the Bug People what your environment is, so that it
327 will be easier to locate the bugs.
329 If you have found a bug that makes Emacs go \"beep\", set
330 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
331 and include the backtrace in your bug report.
333 Please describe the bug in annoying, painstaking detail.
335 Thank you for your help in stamping out bugs.
339 (autoload 'gnus-uu-post-news
"gnus-uu" nil t
))
343 ;;; Gnus Posting Functions
346 (gnus-define-keys (gnus-summary-send-map "S" gnus-summary-mode-map
)
347 "p" gnus-summary-post-news
348 "i" gnus-summary-news-other-window
349 "f" gnus-summary-followup
350 "F" gnus-summary-followup-with-original
351 "c" gnus-summary-cancel-article
352 "s" gnus-summary-supersede-article
353 "r" gnus-summary-reply
354 "y" gnus-summary-yank-message
355 "R" gnus-summary-reply-with-original
356 "w" gnus-summary-wide-reply
357 "W" gnus-summary-wide-reply-with-original
358 "v" gnus-summary-very-wide-reply
359 "V" gnus-summary-very-wide-reply-with-original
360 "n" gnus-summary-followup-to-mail
361 "N" gnus-summary-followup-to-mail-with-original
362 "m" gnus-summary-mail-other-window
363 "u" gnus-uu-post-news
364 "\M-c" gnus-summary-mail-crosspost-complaint
365 "Br" gnus-summary-reply-broken-reply-to
366 "BR" gnus-summary-reply-broken-reply-to-with-original
367 "om" gnus-summary-mail-forward
368 "op" gnus-summary-post-forward
369 "Om" gnus-uu-digest-mail-forward
370 "Op" gnus-uu-digest-post-forward
)
372 (gnus-define-keys (gnus-send-bounce-map "D" gnus-summary-send-map
)
373 "b" gnus-summary-resend-bounced-mail
374 ;; "c" gnus-summary-send-draft
375 "r" gnus-summary-resend-message
376 "e" gnus-summary-resend-message-edit
)
378 ;;; Internal functions.
380 (defun gnus-inews-make-draft (articles)
382 (gnus-inews-make-draft-meta-information
383 ,(gnus-group-decoded-name gnus-newsgroup-name
) ',articles
)))
385 (defvar gnus-article-reply nil
)
386 (defmacro gnus-setup-message
(config &rest forms
)
387 (let ((winconf (make-symbol "gnus-setup-message-winconf"))
388 (buffer (make-symbol "gnus-setup-message-buffer"))
389 (article (make-symbol "gnus-setup-message-article"))
390 (yanked (make-symbol "gnus-setup-yanked-articles"))
391 (group (make-symbol "gnus-setup-message-group")))
392 `(let ((,winconf
(current-window-configuration))
393 (,buffer
(buffer-name (current-buffer)))
394 (,article gnus-article-reply
)
395 (,yanked gnus-article-yanked-articles
)
396 (,group gnus-newsgroup-name
)
397 (message-header-setup-hook
398 (copy-sequence message-header-setup-hook
))
399 (mbl mml-buffer-list
)
400 (message-mode-hook (copy-sequence message-mode-hook
)))
401 (setq mml-buffer-list nil
)
402 (add-hook 'message-header-setup-hook
'gnus-inews-insert-gcc
)
403 (add-hook 'message-header-setup-hook
'gnus-inews-insert-archive-gcc
)
404 ;; message-newsreader and message-mailer were formerly set in
405 ;; gnus-inews-add-send-actions, but this is too late when
406 ;; message-generate-headers-first is used. --ansel
407 (add-hook 'message-mode-hook
409 (setq message-newsreader
410 (setq message-mailer
(gnus-extended-version)))))
411 ;; #### FIXME: for a reason that I did not manage to identify yet,
412 ;; the variable `gnus-newsgroup-name' does not honor a dynamically
413 ;; scoped or setq'ed value from a caller like `C-u gnus-summary-mail'.
414 ;; After evaluation of @forms below, it gets the value we actually want
415 ;; to override, and the posting styles are used. For that reason, I've
416 ;; added an optional argument to `gnus-configure-posting-styles' to
417 ;; make sure that the correct value for the group name is used. -- drv
418 (add-hook 'message-mode-hook
419 (if (memq ,config
'(reply-yank reply
))
421 (gnus-configure-posting-styles ,group
))
423 ;; There may be an old " *gnus article copy*" buffer.
424 (let (gnus-article-copy)
425 (gnus-configure-posting-styles ,group
)))))
426 (gnus-pull ',(intern gnus-draft-meta-information-header
)
427 message-required-headers
)
429 (not (string= ,group
"")))
431 (intern gnus-draft-meta-information-header
)
432 (gnus-inews-make-draft (or ,yanked
,article
)))
433 message-required-headers
))
437 (gnus-inews-add-send-actions ,winconf
,buffer
,article
,config
439 (setq gnus-message-buffer
(current-buffer))
440 (set (make-local-variable 'gnus-message-group-art
)
441 (cons ,group
,article
))
442 (set (make-local-variable 'gnus-newsgroup-name
) ,group
)
443 ;; Enable highlighting of different citation levels
444 (when gnus-message-highlight-citation
445 (gnus-message-citation-mode 1))
446 (gnus-run-hooks 'gnus-message-setup-hook
)
447 (if (eq major-mode
'message-mode
)
448 (let ((mbl1 mml-buffer-list
))
449 (setq mml-buffer-list mbl
) ;; Global value
450 (set (make-local-variable 'mml-buffer-list
) mbl1
);; Local value
451 (gnus-make-local-hook 'kill-buffer-hook
)
452 (gnus-make-local-hook 'change-major-mode-hook
)
453 (add-hook 'change-major-mode-hook
'mml-destroy-buffers nil t
)
454 (add-hook 'kill-buffer-hook
'mml-destroy-buffers t t
))
455 (mml-destroy-buffers)
456 (setq mml-buffer-list mbl
)))
457 (message-hide-headers)
459 (gnus-configure-windows ,config t
)
460 (run-hooks 'post-command-hook
)
461 (set-buffer-modified-p nil
))))
463 (defun gnus-inews-make-draft-meta-information (group articles
)
464 (when (numberp articles
)
465 (setq articles
(list articles
)))
466 (concat "(\"" group
"\""
480 (defun gnus-msg-mail (&optional to subject other-headers continue
481 switch-action yank-action send-actions
)
482 "Start editing a mail message to be sent.
483 Like `message-mail', but with Gnus paraphernalia, particularly the
484 Gcc: header for archiving purposes."
486 (let ((buf (current-buffer))
488 (gnus-setup-message 'message
489 (message-mail to subject other-headers continue
490 nil yank-action send-actions
))
492 (setq mail-buf
(current-buffer))
493 (switch-to-buffer buf
)
494 (apply switch-action mail-buf nil
)))
495 ;; COMPOSEFUNC should return t if succeed. Undocumented ???
499 (defun gnus-button-mailto (address)
501 (set-buffer (gnus-copy-article-buffer))
502 (gnus-setup-message 'message
503 (message-reply address
)))
506 (defun gnus-button-reply (&optional to-address wide
)
507 "Like `message-reply'."
509 (gnus-setup-message 'message
510 (message-reply to-address wide
)))
513 (define-mail-user-agent 'gnus-user-agent
514 'gnus-msg-mail
'message-send-and-exit
515 'message-kill-buffer
'message-send-hook
)
517 (defun gnus-setup-posting-charset (group)
518 (let ((alist gnus-group-posting-charset-alist
)
519 (group (or group
""))
523 (while (setq elem
(pop alist
))
524 (when (or (and (stringp (car elem
))
525 (string-match (car elem
) group
))
526 (and (functionp (car elem
))
527 (funcall (car elem
) group
))
528 (and (symbolp (car elem
))
529 (symbol-value (car elem
))))
530 (throw 'found
(cons (cadr elem
) (caddr elem
)))))))))
532 (defun gnus-inews-add-send-actions (winconf buffer article
533 &optional config yanked
)
534 (gnus-make-local-hook 'message-sent-hook
)
535 (add-hook 'message-sent-hook
(if gnus-agent
'gnus-agent-possibly-do-gcc
536 'gnus-inews-do-gcc
) nil t
)
538 (gnus-make-local-hook 'message-header-hook
)
539 (add-hook 'message-header-hook
'gnus-agent-possibly-save-gcc nil t
))
540 (setq message-post-method
541 `(lambda (&optional arg
)
542 (gnus-post-method arg
,gnus-newsgroup-name
)))
544 `(when (gnus-buffer-exists-p ,buffer
)
545 (set-window-configuration ,winconf
))
546 'exit
'postpone
'kill
)
547 (let ((to-be-marked (cond
550 (lambda (x) (if (listp x
) (car x
) x
)) yanked
))
551 (article (if (listp article
) article
(list article
)))
554 `(when (gnus-buffer-exists-p ,buffer
)
555 (with-current-buffer ,buffer
557 (if (eq config
'forward
)
558 `(gnus-summary-mark-article-as-forwarded ',to-be-marked
)
559 `(gnus-summary-mark-article-as-replied ',to-be-marked
)))))
562 (put 'gnus-setup-message
'lisp-indent-function
1)
563 (put 'gnus-setup-message
'edebug-form-spec
'(form body
))
565 ;;; Post news commands of Gnus group mode and summary mode
567 (defun gnus-group-mail (&optional arg
)
568 "Start composing a mail.
569 If ARG, use the group under the point to find a posting style.
570 If ARG is 1, prompt for a group name to find the posting style."
572 ;; We can't `let' gnus-newsgroup-name here, since that leads
573 ;; to local variables leaking.
574 (let ((group gnus-newsgroup-name
)
575 ;; make sure last viewed article doesn't affect posting styles:
577 (buffer (current-buffer)))
580 (setq gnus-newsgroup-name
582 (if (= 1 (prefix-numeric-value arg
))
583 (gnus-group-completing-read
584 "Use posting style of group: "
585 nil nil
(gnus-read-active-file-p))
586 (gnus-group-group-name))
588 ;; #### see comment in gnus-setup-message -- drv
589 (gnus-setup-message 'message
(message-mail)))
590 (with-current-buffer buffer
591 (setq gnus-newsgroup-name group
)))))
593 (defun gnus-group-news (&optional arg
)
594 "Start composing a news.
595 If ARG, post to group under point.
596 If ARG is 1, prompt for group name to post to.
598 This function prepares a news even when using mail groups. This is useful
599 for posting messages to mail groups without actually sending them over the
600 network. The corresponding back end must have a 'request-post method."
602 ;; We can't `let' gnus-newsgroup-name here, since that leads
603 ;; to local variables leaking.
604 (let ((group gnus-newsgroup-name
)
605 ;; make sure last viewed article doesn't affect posting styles:
607 (buffer (current-buffer)))
610 (setq gnus-newsgroup-name
612 (if (= 1 (prefix-numeric-value arg
))
613 (gnus-group-completing-read "Use group: "
615 (gnus-read-active-file-p))
616 (gnus-group-group-name))
618 ;; #### see comment in gnus-setup-message -- drv
619 (gnus-setup-message 'message
620 (message-news (gnus-group-real-name gnus-newsgroup-name
))))
621 (with-current-buffer buffer
622 (setq gnus-newsgroup-name group
)))))
624 (defun gnus-group-post-news (&optional arg
)
625 "Start composing a message (a news by default).
626 If ARG, post to group under point. If ARG is 1, prompt for group name.
627 Depending on the selected group, the message might be either a mail or
630 ;; Bind this variable here to make message mode hooks work ok.
631 (let ((gnus-newsgroup-name
633 (if (= 1 (prefix-numeric-value arg
))
634 (gnus-group-completing-read "Newsgroup: " nil nil
635 (gnus-read-active-file-p))
636 (gnus-group-group-name))
638 ;; make sure last viewed article doesn't affect posting styles:
640 (gnus-post-news 'post gnus-newsgroup-name nil nil nil nil
641 (string= gnus-newsgroup-name
""))))
643 (defun gnus-summary-mail-other-window (&optional arg
)
644 "Start composing a mail in another window.
645 Use the posting of the current group by default.
646 If ARG, don't do that. If ARG is 1, prompt for group name to find the
649 ;; We can't `let' gnus-newsgroup-name here, since that leads
650 ;; to local variables leaking.
651 (let ((group gnus-newsgroup-name
)
652 ;; make sure last viewed article doesn't affect posting styles:
654 (buffer (current-buffer)))
657 (setq gnus-newsgroup-name
659 (if (= 1 (prefix-numeric-value arg
))
660 (gnus-group-completing-read "Use group: "
662 (gnus-read-active-file-p))
664 gnus-newsgroup-name
))
665 ;; #### see comment in gnus-setup-message -- drv
666 (gnus-setup-message 'message
(message-mail)))
667 (with-current-buffer buffer
668 (setq gnus-newsgroup-name group
)))))
670 (defun gnus-summary-news-other-window (&optional arg
)
671 "Start composing a news in another window.
672 Post to the current group by default.
673 If ARG, don't do that. If ARG is 1, prompt for group name to post to.
675 This function prepares a news even when using mail groups. This is useful
676 for posting messages to mail groups without actually sending them over the
677 network. The corresponding back end must have a 'request-post method."
679 ;; We can't `let' gnus-newsgroup-name here, since that leads
680 ;; to local variables leaking.
681 (let ((group gnus-newsgroup-name
)
682 ;; make sure last viewed article doesn't affect posting styles:
684 (buffer (current-buffer)))
687 (setq gnus-newsgroup-name
689 (if (= 1 (prefix-numeric-value arg
))
690 (gnus-group-completing-read "Use group: "
692 (gnus-read-active-file-p))
694 gnus-newsgroup-name
))
695 ;; #### see comment in gnus-setup-message -- drv
696 (gnus-setup-message 'message
698 (message-news (gnus-group-real-name gnus-newsgroup-name
))
699 (set (make-local-variable 'gnus-discouraged-post-methods
)
701 (car (gnus-find-method-for-group gnus-newsgroup-name
))
702 gnus-discouraged-post-methods
)))))
703 (with-current-buffer buffer
704 (setq gnus-newsgroup-name group
)))))
706 (defun gnus-summary-post-news (&optional arg
)
707 "Start composing a message. Post to the current group by default.
708 If ARG, don't do that. If ARG is 1, prompt for a group name to post to.
709 Depending on the selected group, the message might be either a mail or
712 ;; Bind this variable here to make message mode hooks work ok.
713 (let ((gnus-newsgroup-name
715 (if (= 1 (prefix-numeric-value arg
))
716 (gnus-group-completing-read "Newsgroup: " nil nil
717 (gnus-read-active-file-p))
719 gnus-newsgroup-name
))
720 ;; make sure last viewed article doesn't affect posting styles:
722 (gnus-post-news 'post gnus-newsgroup-name
)))
725 (defun gnus-summary-followup (yank &optional force-news
)
726 "Compose a followup to an article.
727 If prefix argument YANK is non-nil, the original article is yanked
729 YANK is a list of elements, where the car of each element is the
730 article number, and the cdr is the string to be yanked."
732 (list (and current-prefix-arg
733 (gnus-summary-work-articles 1))))
735 (gnus-summary-goto-subject
736 (if (listp (car yank
))
739 (save-window-excursion
740 (gnus-summary-select-article))
741 (let ((headers (gnus-summary-article-header (gnus-summary-article-number)))
742 (gnus-newsgroup-name gnus-newsgroup-name
))
744 (gnus-post-news nil gnus-newsgroup-name
745 headers gnus-article-buffer
747 (gnus-summary-handle-replysign)))
749 (defun gnus-summary-followup-with-original (n &optional force-news
)
750 "Compose a followup to an article and include the original article.
751 The text in the region will be yanked. If the region isn't
752 active, the entire article will be yanked."
754 (gnus-summary-followup (gnus-summary-work-articles n
) force-news
))
756 (defun gnus-summary-followup-to-mail (&optional arg
)
757 "Followup to the current mail message via news."
759 (list (and current-prefix-arg
760 (gnus-summary-work-articles 1))))
761 (gnus-summary-followup arg t
))
763 (defun gnus-summary-followup-to-mail-with-original (&optional arg
)
764 "Followup to the current mail message via news."
766 (gnus-summary-followup (gnus-summary-work-articles arg
) t
))
768 (defun gnus-inews-yank-articles (articles)
769 (let (beg article yank-string
)
771 (while (setq article
(pop articles
))
772 (when (listp article
)
773 (setq yank-string
(nth 1 article
)
774 article
(nth 0 article
)))
775 (save-window-excursion
776 (set-buffer gnus-summary-buffer
)
777 (gnus-summary-select-article nil nil nil article
)
778 (gnus-summary-remove-process-mark article
))
779 (gnus-copy-article-buffer nil yank-string
)
780 (let ((message-reply-buffer gnus-article-copy
)
781 (message-reply-headers
782 ;; The headers are decoded.
783 (with-current-buffer gnus-article-copy
785 (nnheader-narrow-to-headers)
786 (nnheader-parse-naked-head)))))
787 (message-yank-original)
788 (message-exchange-point-and-mark)
789 (setq beg
(or beg
(mark t
))))
795 (defun gnus-summary-cancel-article (&optional n symp
)
796 "Cancel an article you posted.
797 Uses the process-prefix convention. If given the symbolic
798 prefix `a', cancel using the standard posting method; if not
799 post using the current select method."
800 (interactive (gnus-interactive "P\ny"))
801 (let ((message-post-method
803 (gnus-post-method (eq ',symp
'a
) ,gnus-newsgroup-name
))))
804 (dolist (article (gnus-summary-work-articles n
))
805 (when (gnus-summary-select-article t nil nil article
)
806 (when (gnus-eval-in-buffer-window gnus-original-article-buffer
807 (message-cancel-news))
808 (gnus-summary-mark-as-read article gnus-canceled-mark
)
809 (gnus-cache-remove-article 1))
810 (gnus-article-hide-headers-if-wanted))
811 (gnus-summary-remove-process-mark article
))))
813 (defun gnus-summary-supersede-article ()
814 "Compose an article that will supersede a previous article.
815 This is done simply by taking the old article and adding a Supersedes
816 header line with the old Message-ID."
818 (let ((article (gnus-summary-article-number)))
819 (gnus-setup-message 'reply-yank
820 (gnus-summary-select-article t
)
821 (set-buffer gnus-original-article-buffer
)
825 (when (gnus-buffer-exists-p ,gnus-summary-buffer
)
826 (with-current-buffer ,gnus-summary-buffer
827 (gnus-cache-possibly-remove-article ,article nil nil nil t
)
828 (gnus-summary-mark-as-read ,article gnus-canceled-mark
)))))
829 message-send-actions
)
831 (gnus-inews-insert-archive-gcc)
832 (gnus-inews-insert-gcc))))
836 (defun gnus-copy-article-buffer (&optional article-buffer yank-string
)
837 ;; make a copy of the article buffer with all text properties removed
838 ;; this copy is in the buffer gnus-article-copy.
839 ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
840 ;; this buffer should be passed to all mail/news reply/post routines.
841 (setq gnus-article-copy
(gnus-get-buffer-create " *gnus article copy*"))
842 (with-current-buffer gnus-article-copy
843 (mm-enable-multibyte))
844 (let ((article-buffer (or article-buffer gnus-article-buffer
))
846 (if (not (and (get-buffer article-buffer
)
847 (gnus-buffer-exists-p article-buffer
)))
848 (error "Can't find any article buffer")
849 (with-current-buffer article-buffer
850 (let ((gnus-newsgroup-charset (or gnus-article-charset
851 gnus-newsgroup-charset
))
852 (gnus-newsgroup-ignored-charsets
853 (or gnus-article-ignored-charsets
854 gnus-newsgroup-ignored-charsets
)))
856 ;; Copy over the (displayed) article buffer, delete
857 ;; hidden text and remove text properties.
859 (copy-to-buffer gnus-article-copy
(point-min) (point-max))
860 (set-buffer gnus-article-copy
)
863 (delete-region (point) (point-max))
864 (insert yank-string
))
865 (gnus-article-delete-text-of-type 'annotation
)
866 (gnus-article-delete-text-of-type 'multipart
)
867 (gnus-remove-text-with-property 'gnus-prev
)
868 (gnus-remove-text-with-property 'gnus-next
)
869 (gnus-remove-text-with-property 'gnus-decoration
)
872 (buffer-substring-no-properties (point-min) (point-max))
874 ;; Find the original headers.
875 (set-buffer gnus-original-article-buffer
)
876 (goto-char (point-min))
877 (while (looking-at message-unix-mail-delimiter
)
879 (let ((mail-header-separator ""))
881 end
(or (message-goto-body)
882 ;; There may be just a header.
884 ;; Delete the headers from the displayed articles.
885 (set-buffer gnus-article-copy
)
886 (let ((mail-header-separator ""))
887 (delete-region (goto-char (point-min))
888 (or (message-goto-body) (point-max))))
889 ;; Insert the original article headers.
890 (insert-buffer-substring gnus-original-article-buffer beg end
)
892 (let ((gnus-article-decode-hook
893 (delq 'article-decode-charset
894 (copy-sequence gnus-article-decode-hook
)))
895 (rfc2047-quote-decoded-words-containing-tspecials t
))
896 (run-hooks 'gnus-article-decode-hook
)))))
899 (defun gnus-post-news (post &optional group header article-buffer yank subject
902 (gnus-copy-article-buffer))
903 (let ((gnus-article-reply (and article-buffer
(gnus-summary-article-number)))
904 (gnus-article-yanked-articles yank
)
905 (add-to-list gnus-add-to-list
))
906 (gnus-setup-message (cond (yank 'reply-yank
)
907 (article-buffer 'reply
)
909 (let* ((group (or group gnus-newsgroup-name
))
910 (charset (gnus-group-name-charset nil group
))
912 to-address to-group mailing-list to-list
915 (setq to-address
(gnus-parameter-to-address group
)
916 to-group
(gnus-group-find-parameter group
'to-group
)
917 to-list
(gnus-parameter-to-list group
)
918 newsgroup-p
(gnus-group-find-parameter group
'newsgroup
)
919 mailing-list
(when gnus-mailing-list-groups
920 (string-match gnus-mailing-list-groups group
))
921 group
(gnus-group-name-decode (gnus-group-real-name group
)
923 (if (or (and to-group
924 (gnus-news-group-p to-group
))
927 (and (gnus-news-group-p
928 (or pgroup gnus-newsgroup-name
)
929 (or header gnus-current-article
))
937 (and (not (gnus-virtual-group-p pgroup
)) group
)))
938 (set-buffer gnus-article-copy
)
939 (gnus-msg-treat-broken-reply-to)
940 (message-followup (if (or newsgroup-p force-news
)
941 (if (save-restriction
942 (article-narrow-to-head)
943 (message-fetch-field "newsgroups"))
950 (message-mail (or to-address to-list
))
951 ;; Arrange for mail groups that have no `to-address' to
952 ;; get that when the user sends off the mail.
953 (when (and (not to-list
)
956 (push (list 'gnus-inews-add-to-address pgroup
)
957 message-send-actions
)))
958 (set-buffer gnus-article-copy
)
959 (gnus-msg-treat-broken-reply-to)
960 (message-wide-reply to-address
)))
962 (gnus-inews-yank-articles yank
))))))
964 (defun gnus-msg-treat-broken-reply-to (&optional force
)
965 "Remove the Reply-to header if broken-reply-to."
967 (gnus-group-find-parameter
968 gnus-newsgroup-name
'broken-reply-to
))
970 (message-narrow-to-head)
971 (message-remove-header "reply-to"))))
973 (defun gnus-post-method (arg group
&optional silent
)
974 "Return the posting method based on GROUP and ARG.
975 If SILENT, don't prompt the user."
976 (let ((gnus-post-method (or (gnus-parameter-post-method group
)
978 (group-method (gnus-find-method-for-group group
)))
980 ;; If the group-method is nil (which shouldn't happen) we use
981 ;; the default method.
983 (or (and (listp gnus-post-method
) ;If not current/native/nil
984 (not (listp (car gnus-post-method
))) ; and not a list of methods
985 gnus-post-method
) ;then use it.
987 message-post-method
))
988 ;; We want the inverse of the default
989 ((and arg
(not (eq arg
0)))
990 (if (eq gnus-post-method
'current
)
993 ;; We query the user for a post method.
995 (and (listp gnus-post-method
)
996 (listp (car gnus-post-method
))))
998 ;; Collect all methods we know about.
1000 (when (listp gnus-post-method
)
1001 (if (listp (car gnus-post-method
))
1003 (list gnus-post-method
)))
1004 gnus-secondary-select-methods
1005 (mapcar 'cdr gnus-server-alist
)
1006 (mapcar 'car gnus-opened-servers
)
1007 (list gnus-select-method
)
1008 (list group-method
)))
1009 method-alist post-methods method
)
1010 ;; Weed out all mail methods.
1012 (setq method
(gnus-server-get-method "" (pop methods
)))
1013 (when (and (or (gnus-method-option-p method
'post
)
1014 (gnus-method-option-p method
'post-mail
))
1015 (not (member method post-methods
)))
1016 (push method post-methods
)))
1017 ;; Create a name-method alist.
1021 (if (equal (cadr m
) "")
1022 (list (symbol-name (car m
)) m
)
1023 (list (concat (cadr m
) " (" (symbol-name (car m
)) ")") m
)))
1028 (setq gnus-last-posting-server
1030 gnus-last-posting-server
)
1031 ;; Just use the last value.
1032 gnus-last-posting-server
1034 "Posting method: " method-alist nil t
1035 (cons (or gnus-last-posting-server
"") 0))))
1037 ;; Override normal method.
1038 ((and (eq gnus-post-method
'current
)
1039 (not (memq (car group-method
) gnus-discouraged-post-methods
))
1040 (gnus-get-function group-method
'request-post t
))
1043 ;; Use gnus-post-method.
1044 ((listp gnus-post-method
) ;A method...
1045 (assert (not (listp (car gnus-post-method
)))) ;... not a list of methods.
1047 ;; Use the normal select method (nil or native).
1048 (t gnus-select-method
))))
1052 (defun gnus-extended-version ()
1053 "Stringified Gnus version and Emacs version.
1054 See the variable `gnus-user-agent'."
1056 (if (stringp gnus-user-agent
)
1058 ;; `gnus-user-agent' is a list:
1059 (let* ((float-output-format nil
)
1061 (when (memq 'gnus gnus-user-agent
)
1063 (prin1-to-string (gnus-continuum-version gnus-version
) t
)
1064 " (" gnus-version
")")))
1065 (emacs-v (gnus-emacs-version)))
1066 (concat gnus-v
(when (and gnus-v emacs-v
) " ")
1071 ;;; Gnus Mail Functions
1074 ;;; Mail reply commands of Gnus summary mode
1076 (defun gnus-summary-reply (&optional yank wide very-wide
)
1077 "Start composing a mail reply to the current message.
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 ;; Allow user to require confirmation before replying by mail to the
1086 ;; author of a news article (or mail message).
1088 (not (or (gnus-news-group-p gnus-newsgroup-name
)
1089 gnus-confirm-treat-mail-like-news
))
1090 (not (cond ((stringp gnus-confirm-mail-reply-to-news
)
1091 (string-match gnus-confirm-mail-reply-to-news
1092 gnus-newsgroup-name
))
1093 ((functionp gnus-confirm-mail-reply-to-news
)
1094 (funcall gnus-confirm-mail-reply-to-news gnus-newsgroup-name
))
1095 (t gnus-confirm-mail-reply-to-news
)))
1096 (if (or wide very-wide
)
1097 t
;; Ignore gnus-confirm-mail-reply-to-news for wide and very
1099 (y-or-n-p "Really reply by mail to article author? ")))
1101 (if (listp (car yank
))
1104 (gnus-article-reply (or article
(gnus-summary-article-number)))
1105 (gnus-article-yanked-articles yank
)
1107 ;; Stripping headers should be specified with mail-yank-ignored-headers.
1109 (gnus-summary-goto-subject article
))
1110 (gnus-setup-message (if yank
'reply-yank
'reply
)
1112 (gnus-summary-select-article)
1113 (dolist (article very-wide
)
1114 (gnus-summary-select-article nil nil nil article
)
1115 (with-current-buffer (gnus-copy-article-buffer)
1116 (gnus-msg-treat-broken-reply-to)
1118 (message-narrow-to-head)
1119 (setq headers
(concat headers
(buffer-string)))))))
1120 (set-buffer (gnus-copy-article-buffer))
1121 (gnus-msg-treat-broken-reply-to gnus-msg-force-broken-reply-to
)
1123 (message-narrow-to-head)
1127 (goto-char (point-max)))
1128 (mml-quote-region (point) (point-max))
1129 (message-reply nil wide
)
1131 (gnus-inews-yank-articles yank
))
1132 (gnus-summary-handle-replysign)))))
1134 (defun gnus-summary-handle-replysign ()
1135 "Check the various replysign variables and take action accordingly."
1136 (when (or gnus-message-replysign gnus-message-replyencrypt
)
1137 (let (signed encrypted
)
1138 (with-current-buffer gnus-article-buffer
1139 (setq signed
(memq 'signed gnus-article-wash-types
))
1140 (setq encrypted
(memq 'encrypted gnus-article-wash-types
)))
1141 (cond ((and gnus-message-replyencrypt encrypted
)
1142 (mml-secure-message mml-default-encrypt-method
1143 (if gnus-message-replysignencrypted
1146 ((and gnus-message-replysign signed
)
1147 (mml-secure-message mml-default-sign-method
'sign
))))))
1149 (defun gnus-summary-reply-with-original (n &optional wide
)
1150 "Start composing a reply mail to the current message.
1151 The original article will be yanked."
1153 (gnus-summary-reply (gnus-summary-work-articles n
) wide
))
1155 (defun gnus-summary-reply-broken-reply-to (&optional yank wide very-wide
)
1156 "Like `gnus-summary-reply' except removing reply-to field.
1157 If prefix argument YANK is non-nil, the original article is yanked
1159 If WIDE, make a wide reply.
1160 If VERY-WIDE, make a very wide reply."
1162 (list (and current-prefix-arg
1163 (gnus-summary-work-articles 1))))
1164 (let ((gnus-msg-force-broken-reply-to t
))
1165 (gnus-summary-reply yank wide very-wide
)))
1167 (defun gnus-summary-reply-broken-reply-to-with-original (n &optional wide
)
1168 "Like `gnus-summary-reply-with-original' except removing reply-to field.
1169 The original article will be yanked."
1171 (gnus-summary-reply-broken-reply-to (gnus-summary-work-articles n
) wide
))
1173 (defun gnus-summary-wide-reply (&optional yank
)
1174 "Start composing a wide reply mail to the current message.
1175 If prefix argument YANK is non-nil, the original article is yanked
1178 (list (and current-prefix-arg
1179 (gnus-summary-work-articles 1))))
1180 (gnus-summary-reply yank t
))
1182 (defun gnus-summary-wide-reply-with-original (n)
1183 "Start composing a wide reply mail to the current message.
1184 The original article will be yanked.
1185 Uses the process/prefix convention."
1187 (gnus-summary-reply-with-original n t
))
1189 (defun gnus-summary-very-wide-reply (&optional yank
)
1190 "Start composing a very wide reply mail to the current message.
1191 If prefix argument YANK is non-nil, the original article is yanked
1194 (list (and current-prefix-arg
1195 (gnus-summary-work-articles 1))))
1196 (gnus-summary-reply yank t
(gnus-summary-work-articles yank
)))
1198 (defun gnus-summary-very-wide-reply-with-original (n)
1199 "Start composing a very wide reply mail to the current message.
1200 The original article will be yanked."
1203 (gnus-summary-work-articles n
) t
(gnus-summary-work-articles n
)))
1205 (defun gnus-summary-mail-forward (&optional arg post
)
1206 "Forward the current message(s) to another user.
1207 If process marks exist, forward all marked messages;
1208 if ARG is nil, see `message-forward-as-mime' and `message-forward-show-mml';
1209 if ARG is 1, decode the message and forward directly inline;
1210 if ARG is 2, forward message as an rfc822 MIME section;
1211 if ARG is 3, decode message and forward as an rfc822 MIME section;
1212 if ARG is 4, forward message directly inline;
1213 otherwise, use flipped `message-forward-as-mime'.
1214 If POST, post instead of mail.
1215 For the `inline' alternatives, also see the variable
1216 `message-forward-ignored-headers'."
1218 (if (cdr (gnus-summary-work-articles nil
))
1219 ;; Process marks are given.
1220 (gnus-uu-digest-mail-forward arg post
)
1221 ;; No process marks.
1222 (let ((message-forward-as-mime message-forward-as-mime
)
1223 (message-forward-show-mml message-forward-show-mml
))
1227 (setq message-forward-as-mime nil
1228 message-forward-show-mml t
))
1230 (setq message-forward-as-mime t
1231 message-forward-show-mml nil
))
1233 (setq message-forward-as-mime t
1234 message-forward-show-mml t
))
1236 (setq message-forward-as-mime nil
1237 message-forward-show-mml nil
))
1239 (setq message-forward-as-mime
(not message-forward-as-mime
))))
1240 (let* ((gnus-article-reply (gnus-summary-article-number))
1241 (gnus-article-yanked-articles (list gnus-article-reply
)))
1242 (gnus-setup-message 'forward
1243 (gnus-summary-select-article)
1244 (let ((mail-parse-charset
1245 (or (and (gnus-buffer-live-p gnus-article-buffer
)
1246 (with-current-buffer gnus-article-buffer
1247 gnus-article-charset
))
1248 gnus-newsgroup-charset
))
1249 (mail-parse-ignored-charsets
1250 gnus-newsgroup-ignored-charsets
))
1251 (set-buffer gnus-original-article-buffer
)
1252 (message-forward post
)))))))
1254 (defun gnus-summary-resend-message (address n
)
1255 "Resend the current article to ADDRESS."
1257 (list (message-read-from-minibuffer
1258 "Resend message(s) to: "
1259 (when (and gnus-summary-resend-default-address
1260 (gnus-buffer-live-p gnus-original-article-buffer
))
1261 ;; If some other article is currently selected, the
1262 ;; initial-contents is wrong. Whatever, it is just the
1263 ;; initial-contents.
1264 (with-current-buffer gnus-original-article-buffer
1265 (nnmail-fetch-field "to"))))
1266 current-prefix-arg
))
1267 (dolist (article (gnus-summary-work-articles n
))
1268 (gnus-summary-select-article nil nil nil article
)
1269 (with-current-buffer gnus-original-article-buffer
1270 (message-resend address
))
1271 (gnus-summary-mark-article-as-forwarded article
)))
1273 ;; From: Matthieu Moy <Matthieu.Moy@imag.fr>
1274 (defun gnus-summary-resend-message-edit ()
1275 "Resend an article that has already been sent.
1276 A new buffer will be created to allow the user to modify body and
1277 contents of the message, and then, everything will happen as when
1278 composing a new message."
1280 (let ((article (gnus-summary-article-number)))
1281 (gnus-setup-message 'reply-yank
1282 (gnus-summary-select-article t
)
1283 (set-buffer gnus-original-article-buffer
)
1284 (let ((cur (current-buffer))
1285 (to (message-fetch-field "to")))
1286 ;; Get a normal message buffer.
1287 (message-pop-to-buffer (message-buffer-name "Resend" to
))
1288 (insert-buffer-substring cur
)
1290 (message-narrow-to-head-1)
1291 ;; Gnus will generate a new one when sending.
1292 (message-remove-header "Message-ID")
1293 ;; Remove unwanted headers.
1294 (message-remove-header message-ignored-resent-headers t
)
1295 (goto-char (point-max))
1296 (insert mail-header-separator
)
1298 (gnus-inews-insert-archive-gcc)
1299 (gnus-inews-insert-gcc)
1300 (goto-char (point-min))
1301 (when (re-search-forward "^To:\\|^Newsgroups:" nil
'move
)
1305 (defun gnus-summary-post-forward (&optional arg
)
1306 "Forward the current article to a newsgroup.
1307 See `gnus-summary-mail-forward' for ARG."
1309 (gnus-summary-mail-forward arg t
))
1311 (defvar gnus-nastygram-message
1312 "The following article was inappropriately posted to %s.\n\n"
1313 "Format string to insert in nastygrams.
1314 The current group name will be inserted at \"%s\".")
1316 (defun gnus-summary-mail-nastygram (n)
1317 "Send a nastygram to the author of the current article."
1319 (when (or gnus-expert-user
1321 "Really send a nastygram to the author of the current article? "))
1322 (let ((group gnus-newsgroup-name
))
1323 (gnus-summary-reply-with-original n
)
1324 (set-buffer gnus-message-buffer
)
1326 (insert (format gnus-nastygram-message group
))
1327 (message-send-and-exit))))
1329 (defun gnus-summary-mail-crosspost-complaint (n)
1330 "Send a complaint about crossposting to the current article(s)."
1332 (dolist (article (gnus-summary-work-articles n
))
1333 (set-buffer gnus-summary-buffer
)
1334 (gnus-summary-goto-subject article
)
1335 (let ((group (gnus-group-real-name gnus-newsgroup-name
))
1336 newsgroups followup-to
)
1337 (gnus-summary-select-article)
1338 (set-buffer gnus-original-article-buffer
)
1339 (if (and (<= (length (message-tokenize-header
1341 (mail-fetch-field "newsgroups"))
1344 (or (not (setq followup-to
(mail-fetch-field "followup-to")))
1345 (not (member group
(message-tokenize-header
1346 followup-to
", ")))))
1348 (gnus-message 1 "Followup-to restricted")
1349 (gnus-message 1 "Not a crossposted article"))
1350 (set-buffer gnus-summary-buffer
)
1351 (gnus-summary-reply-with-original 1)
1352 (set-buffer gnus-message-buffer
)
1354 (insert (format gnus-crosspost-complaint newsgroups group
))
1355 (message-goto-subject)
1356 (re-search-forward " *$")
1357 (replace-match " (crosspost notification)" t t
)
1358 (gnus-deactivate-mark)
1359 (when (gnus-y-or-n-p "Send this complaint? ")
1360 (message-send-and-exit))))))
1362 (defun gnus-mail-parse-comma-list ()
1365 (skip-chars-forward " ")
1368 (skip-chars-forward "^,")
1373 (narrow-to-region beg
(point))
1376 (while (search-forward "\"" nil t
)
1380 (skip-chars-forward ",")
1381 (skip-chars-forward "^,"))
1382 (skip-chars-backward " ")
1383 (push (buffer-substring beg
(point))
1385 (skip-chars-forward "^,")
1386 (skip-chars-forward ", "))
1389 (defun gnus-inews-add-to-address (group)
1390 (let ((to-address (mail-fetch-field "to")))
1391 (when (and to-address
1393 ;; This mail group doesn't have a `to-list', so we add one
1395 (when (gnus-y-or-n-p
1396 (format "Do you want to add this as `to-list': %s? " to-address
))
1397 (gnus-group-add-parameter group
(cons 'to-list to-address
))))))
1399 (defun gnus-put-message ()
1400 "Put the current message in some group and return to Gnus."
1402 (let ((reply gnus-article-reply
)
1403 (winconf gnus-prev-winconf
)
1404 (group gnus-newsgroup-name
))
1406 (not (gnus-group-read-only-p group
)))
1407 (setq group
(read-string "Put in group: " nil
(gnus-writable-groups))))
1409 (when (gnus-group-entry group
)
1410 (error "No such group: %s" group
))
1414 (message-narrow-to-headers)
1415 (let ((gnus-deletable-headers nil
))
1416 (message-generate-headers
1417 (if (message-news-p)
1418 message-required-news-headers
1419 message-required-mail-headers
)))
1420 (goto-char (point-max))
1421 (if (string-match " " group
)
1422 (insert "Gcc: \"" group
"\"\n")
1423 (insert "Gcc: " group
"\n"))
1426 (when (and (get-buffer gnus-group-buffer
)
1427 (gnus-buffer-exists-p (car-safe reply
))
1429 (set-buffer (car reply
))
1430 (gnus-summary-mark-article-as-replied (cdr reply
)))
1432 (set-window-configuration winconf
))))
1434 (defun gnus-article-mail (yank)
1435 "Send a reply to the address near point.
1436 If YANK is non-nil, include the original article."
1440 (save-excursion (re-search-backward "[ \t\n]" nil t
) (1+ (point)))
1441 (save-excursion (re-search-forward "[ \t\n]" nil t
) (1- (point))))))
1443 (gnus-msg-mail address
)
1445 (gnus-inews-yank-articles (list (cdr gnus-article-current
)))))))
1447 (defvar nntp-server-type
)
1449 "Send a bug report to the Gnus maintainers."
1451 (unless (gnus-alive-p)
1452 (error "Gnus has been shut down"))
1453 (gnus-setup-message (if (message-mail-user-agent) 'message
'bug
)
1454 (unless (message-mail-user-agent)
1455 (delete-other-windows)
1456 (when gnus-bug-create-help-buffer
1457 (switch-to-buffer "*Gnus Help Bug*")
1459 (insert gnus-bug-message
)
1460 (goto-char (point-min)))
1461 (message-pop-to-buffer "*Gnus Bug*"))
1462 (let ((message-this-is-mail t
))
1463 (message-setup `((To .
,gnus-maintainer
) (Subject .
""))))
1464 (when gnus-bug-create-help-buffer
1465 (push `(gnus-bug-kill-buffer) message-send-actions
))
1466 (goto-char (point-min))
1467 (re-search-forward (concat "^" (regexp-quote mail-header-separator
) "$"))
1469 (insert (gnus-version) "\n"
1470 (emacs-version) "\n")
1471 (when (and (boundp 'nntp-server-type
)
1472 (stringp nntp-server-type
))
1473 (insert nntp-server-type
))
1474 (insert "\n\n\n\n\n")
1476 (with-current-buffer (gnus-get-buffer-create " *gnus environment info*")
1479 (setq text
(buffer-string)))
1480 (insert "<#part type=application/emacs-lisp disposition=inline description=\"User settings\">\n" text
"\n<#/part>"))
1481 (goto-char (point-min))
1482 (search-forward "Subject: " nil t
)
1485 (defun gnus-bug-kill-buffer ()
1486 (when (get-buffer "*Gnus Help Bug*")
1487 (kill-buffer "*Gnus Help Bug*")))
1489 (defun gnus-summary-yank-message (buffer n
)
1490 "Yank the current article into a composed message."
1492 (list (completing-read "Buffer: " (mapcar 'list
(message-buffers)) nil t
)
1493 current-prefix-arg
))
1494 (gnus-summary-iterate n
1495 (let ((gnus-inhibit-treatment t
))
1496 (gnus-summary-select-article))
1497 (with-current-buffer buffer
1498 (message-yank-buffer gnus-article-buffer
))))
1500 (defun gnus-debug ()
1501 "Attempts to go through the Gnus source file and report what variables have been changed.
1502 The source file has to be in the Emacs load path."
1504 (let ((files gnus-debug-files
)
1506 file expr olist sym
)
1507 (gnus-message 4 "Please wait while we snoop your variables...")
1509 ;; Go through all the files looking for non-default values for variables.
1510 (with-current-buffer (gnus-get-buffer-create " *gnus bug info*")
1513 (when (and (setq file
(locate-library (pop files
)))
1514 (file-exists-p file
))
1515 (insert-file-contents file
)
1516 (goto-char (point-min))
1517 (if (not (re-search-forward "^;;* *Internal variables" nil t
))
1518 (gnus-message 4 "Malformed sources in file %s" file
)
1519 (narrow-to-region (point-min) (point))
1520 (goto-char (point-min))
1521 (while (setq expr
(ignore-errors (read (current-buffer))))
1523 (and (or (eq (car expr
) 'defvar
)
1524 (eq (car expr
) 'defcustom
))
1525 (stringp (nth 3 expr
))
1526 (not (memq (nth 1 expr
) gnus-debug-exclude-variables
))
1527 (or (not (boundp (nth 1 expr
)))
1528 (not (equal (eval (nth 2 expr
))
1529 (symbol-value (nth 1 expr
)))))
1530 (push (nth 1 expr
) olist
)))))))
1531 (kill-buffer (current-buffer)))
1532 (when (setq olist
(nreverse olist
))
1533 (insert "------------------ Environment follows ------------------\n\n"))
1535 (if (boundp (car olist
))
1539 ,(if (or (consp (setq sym
(symbol-value (car olist
))))
1541 (not (or (eq sym nil
)
1543 (list 'quote
(symbol-value (car olist
)))
1544 (symbol-value (car olist
))))))
1545 (insert ";; (makeunbound '" (symbol-name (car olist
)) ")\n"))
1546 (setq olist
(cdr olist
)))
1548 ;; Remove any control chars - they seem to cause trouble for some
1549 ;; mailers. (Byte-compiled output from the stuff above.)
1551 (while (re-search-forward (mm-string-to-multibyte
1552 "[\000-\010\013-\037\200-\237]") nil t
)
1553 (replace-match (format "\\%03o" (string-to-char (match-string 0)))
1556 ;;; Treatment of rejected articles.
1559 (defun gnus-summary-resend-bounced-mail (&optional fetch
)
1560 "Re-mail the current message.
1561 This only makes sense if the current message is a bounce message that
1562 contains some mail you have written which has been bounced back to
1564 If FETCH, try to fetch the article that this is a reply to, if indeed
1567 (gnus-summary-select-article t
)
1568 (let (summary-buffer parent
)
1571 (setq summary-buffer
(current-buffer))
1572 (set-buffer gnus-original-article-buffer
)
1574 (when (re-search-forward "^References:\n?" nil t
)
1575 (while (memq (char-after) '(?
\t ?
))
1577 (skip-chars-backward "\t\n ")
1579 (gnus-parent-id (buffer-substring (match-end 0) (point))))))
1580 (set-buffer gnus-original-article-buffer
))
1581 (gnus-setup-message 'compose-bounce
1584 (gnus-inews-insert-archive-gcc)
1585 (gnus-inews-insert-gcc)
1586 ;; If there are references, we fetch the article we answered to.
1588 (with-current-buffer summary-buffer
1589 (gnus-summary-refer-article parent
)
1590 (gnus-summary-show-all-headers))))))
1594 (defun gnus-inews-group-method (group)
1596 ;; If the group doesn't exist, we assume
1597 ;; it's an archive group...
1598 ((and (null (gnus-get-info group
))
1599 (eq (car (gnus-server-to-method gnus-message-archive-method
))
1600 (car (gnus-server-to-method (gnus-group-method group
)))))
1601 gnus-message-archive-method
)
1603 ((gnus-info-method (gnus-get-info group
))
1604 (gnus-info-method (gnus-get-info group
)))
1606 (t (gnus-server-to-method (gnus-group-method group
)))))
1608 ;; Do Gcc handling, which copied the message over to some group.
1609 (defun gnus-inews-do-gcc (&optional gcc
)
1613 (message-narrow-to-headers)
1614 (let ((gcc (or gcc
(mail-fetch-field "gcc" nil t
)))
1615 (cur (current-buffer))
1616 groups group method group-art
1617 mml-externalize-attachments
)
1619 (message-remove-header "gcc")
1621 (setq groups
(message-unquote-tokens
1622 (message-tokenize-header gcc
" ,")))
1623 ;; Copy the article over to some group(s).
1624 (while (setq group
(pop groups
))
1625 (setq method
(gnus-inews-group-method group
)
1626 group
(mm-encode-coding-string
1628 (gnus-group-name-charset method group
)))
1629 (unless (gnus-check-server method
)
1630 (error "Can't open server %s" (if (stringp method
) method
1632 (unless (gnus-request-group group nil method
)
1633 (gnus-request-create-group group method
))
1634 (setq mml-externalize-attachments
1635 (if (stringp gnus-gcc-externalize-attachments
)
1636 (string-match gnus-gcc-externalize-attachments group
)
1637 gnus-gcc-externalize-attachments
))
1639 (nnheader-set-temp-buffer " *acc*")
1640 (insert-buffer-substring cur
)
1641 (message-encode-message-body)
1643 (message-narrow-to-headers)
1644 (let* ((mail-parse-charset message-default-charset
)
1645 (newsgroups-field (save-restriction
1646 (message-narrow-to-headers-or-head)
1647 (message-fetch-field "Newsgroups")))
1648 (followup-field (save-restriction
1649 (message-narrow-to-headers-or-head)
1650 (message-fetch-field "Followup-To")))
1651 ;; BUG: We really need to get the charset for
1652 ;; each name in the Newsgroups and Followup-To
1653 ;; lines to allow crossposting between group
1654 ;; namess with incompatible character sets.
1655 ;; -- Per Abrahamsen <abraham@dina.kvl.dk> 2001-10-08.
1656 (group-field-charset
1657 (gnus-group-name-charset
1658 method
(or newsgroups-field
"")))
1659 (followup-field-charset
1660 (gnus-group-name-charset
1661 method
(or followup-field
"")))
1662 (rfc2047-header-encoding-alist
1664 (when group-field-charset
1665 (list (cons "Newsgroups" group-field-charset
)))
1666 (when followup-field-charset
1667 (list (cons "Followup-To" followup-field-charset
)))
1668 rfc2047-header-encoding-alist
)))
1669 (mail-encode-encoded-word-buffer)))
1670 (goto-char (point-min))
1671 (when (re-search-forward
1672 (concat "^" (regexp-quote mail-header-separator
) "$")
1674 (replace-match "" t t
))
1675 (when (or (not (gnus-check-backend-function
1676 'request-accept-article group
))
1677 (not (setq group-art
1678 (gnus-request-accept-article
1679 group method t t
))))
1680 (gnus-message 1 "Couldn't store article in group %s: %s"
1681 group
(gnus-status-message method
)))
1682 (when (and group-art
1683 ;; FIXME: Should gcc-mark-as-read work when
1684 ;; Gnus is not running?
1686 (or gnus-gcc-mark-as-read
1688 (boundp 'gnus-inews-mark-gcc-as-read
)
1689 (symbol-value 'gnus-inews-mark-gcc-as-read
))))
1690 (gnus-group-mark-article-read group
(cdr group-art
)))
1691 (kill-buffer (current-buffer)))))))))
1693 (defun gnus-inews-insert-gcc ()
1694 "Insert Gcc headers based on `gnus-outgoing-message-group'."
1697 (message-narrow-to-headers)
1698 (let* ((group gnus-outgoing-message-group
)
1702 ((or (stringp group
) (listp group
))
1707 (if (string-match " " gcc
)
1708 (concat "\"" gcc
"\"")
1710 (mapconcat (lambda (group)
1711 (if (string-match " " group
)
1712 (concat "\"" group
"\"")
1717 (defun gnus-inews-insert-archive-gcc (&optional group
)
1718 "Insert the Gcc to say where the article is to be archived."
1719 (setq group
(cond (group
1720 (gnus-group-decoded-name group
))
1721 (gnus-newsgroup-name
1722 (gnus-group-decoded-name gnus-newsgroup-name
))
1725 (let* ((var gnus-message-archive-group
)
1727 (and gnus-newsgroup-name
1728 (not (equal gnus-newsgroup-name
""))
1729 (gnus-group-find-parameter
1730 gnus-newsgroup-name
'gcc-self
)))
1734 ((null gnus-message-archive-method
)
1738 ;; Just a single group.
1741 ;; We don't want this.
1743 ((and (listp var
) (stringp (car var
)))
1744 ;; A list of groups.
1748 (funcall var group
))
1750 ;; An alist of regexps/functions/forms.
1755 ((stringp (caar var
))
1757 (when (string-match (caar var
) group
)
1759 ((functionp (car var
))
1761 (funcall (car var
) group
))
1763 (eval (car var
)))))))
1764 (setq var
(cdr var
)))
1767 (when (or groups gcc-self-val
)
1768 (when (stringp groups
)
1769 (setq groups
(list groups
)))
1772 (message-narrow-to-headers)
1773 (goto-char (point-max))
1776 ;; Use the `gcc-self' param value instead.
1779 (if (stringp gcc-self-val
)
1780 (if (string-match " " gcc-self-val
)
1781 (concat "\"" gcc-self-val
"\"")
1783 ;; In nndoc groups, we use the parent group name
1784 ;; instead of the current group.
1785 (let ((group (or (gnus-group-find-parameter
1786 gnus-newsgroup-name
'parent-group
)
1788 (if (string-match " " group
)
1789 (concat "\"" group
"\"")
1791 (if (not (eq gcc-self-val
'none
))
1793 (gnus-delete-line)))
1794 ;; Use the list of groups.
1795 (while (setq name
(pop groups
))
1796 (let ((str (if (string-match ":" name
)
1798 (gnus-group-prefixed-name
1799 name gnus-message-archive-method
))))
1800 (insert (if (string-match " " str
)
1801 (concat "\"" str
"\"")
1807 (defun gnus-mailing-list-followup-to ()
1808 "Look at the headers in the current buffer and return a Mail-Followup-To address."
1809 (let ((x-been-there (gnus-fetch-original-field "x-beenthere"))
1810 (list-post (gnus-fetch-original-field "list-post")))
1811 (when (and list-post
1812 (string-match "mailto:\\([^>]+\\)" list-post
))
1813 (setq list-post
(match-string 1 list-post
)))
1819 (defun gnus-configure-posting-styles (&optional group-name
)
1820 "Configure posting styles according to `gnus-posting-styles'."
1821 (unless gnus-inhibit-posting-styles
1822 (let ((group (or group-name gnus-newsgroup-name
""))
1823 (styles gnus-posting-styles
)
1824 style match attribute value v results
1825 filep name address element
)
1826 ;; If the group has a posting-style parameter, add it at the end with a
1827 ;; regexp matching everything, to be sure it takes precedence over all
1829 (when gnus-newsgroup-name
1830 (let ((tmp-style (gnus-group-find-parameter group
'posting-style t
)))
1832 (setq styles
(append styles
(list (cons ".*" tmp-style
)))))))
1833 ;; Go through all styles and look for matches.
1834 (dolist (style styles
)
1835 (setq match
(pop style
))
1836 (goto-char (point-min))
1839 ;; Regexp string match on the group name.
1840 (string-match match group
))
1842 ;; Obsolete format of header match.
1843 (and (gnus-buffer-live-p gnus-article-copy
)
1844 (with-current-buffer gnus-article-copy
1846 (nnheader-narrow-to-headers)
1847 (let ((header (message-fetch-field (pop style
))))
1849 (string-match (pop style
) header
)))))))
1850 ((or (symbolp match
)
1854 ;; Function to be called.
1857 ;; Variable to be checked.
1858 (symbol-value match
))))
1861 ((eq (car match
) 'header
)
1862 ;; New format of header match.
1863 (and (gnus-buffer-live-p gnus-article-copy
)
1864 (with-current-buffer gnus-article-copy
1866 (nnheader-narrow-to-headers)
1867 (let ((header (message-fetch-field (nth 1 match
))))
1869 (string-match (nth 2 match
) header
)))))))
1871 ;; This is a form to be evaled.
1873 ;; We have a match, so we set the variables.
1874 (dolist (attribute style
)
1875 (setq element
(pop attribute
)
1879 ((eq (car attribute
) :file
)
1882 ((eq (car attribute
) :value
)
1886 ;; We get the value.
1891 ((or (symbolp value
)
1893 (cond ((functionp value
)
1896 (symbol-value value
))))
1899 ;; Translate obsolescent value.
1901 ((eq element
'signature-file
)
1902 (setq element
'signature
1904 ((eq element
'x-face-file
)
1905 (setq element
'x-face
1907 ;; Post-processing for the signature posting-style:
1908 (and (eq element
'signature
) filep
1909 message-signature-directory
1910 ;; don't actually use the signature directory
1911 ;; if message-signature-file contains a path.
1912 (not (file-name-directory v
))
1913 (setq v
(nnheader-concat message-signature-directory v
)))
1914 ;; Get the contents of file elems.
1916 (setq v
(with-temp-buffer
1917 (insert-file-contents v
)
1921 (goto-char (point-max))
1922 (if (zerop (skip-chars-backward "\n"))
1925 (setq results
(delq (assoc element results
) results
))
1926 (push (cons element v
) results
))))
1927 ;; Now we have all the styles, so we insert them.
1928 (setq name
(assq 'name results
)
1929 address
(assq 'address results
))
1930 (setq results
(delq name
(delq address results
)))
1931 (gnus-make-local-hook 'message-setup-hook
)
1932 (setq results
(sort results
(lambda (x y
)
1933 (string-lessp (car x
) (car y
)))))
1934 (dolist (result results
)
1935 (add-hook 'message-setup-hook
1937 ((eq 'eval
(car result
))
1939 ((eq 'body
(car result
))
1943 (insert ,(cdr result
)))))
1944 ((eq 'signature
(car result
))
1945 (set (make-local-variable 'message-signature
) nil
)
1946 (set (make-local-variable 'message-signature-file
) nil
)
1947 (if (not (cdr result
))
1951 (let ((message-signature ,(cdr result
)))
1952 (when message-signature
1953 (message-insert-signature)))))))
1956 (if (symbolp (car result
))
1957 (capitalize (symbol-name (car result
)))
1961 (message-remove-header ,header
)
1962 (let ((value ,(cdr result
)))
1965 (insert ,header
": " value
)
1967 (insert "\n")))))))))
1969 (when (or name address
)
1970 (add-hook 'message-setup-hook
1972 (set (make-local-variable 'user-mail-address
)
1973 ,(or (cdr address
) user-mail-address
))
1974 (let ((user-full-name ,(or (cdr name
) (user-full-name)))
1976 ,(or (cdr address
) user-mail-address
)))
1978 (message-remove-header "From")
1980 (insert "From: " (message-make-from) "\n"))))
1983 ;;; Allow redefinition of functions.
1989 ;; arch-tag: 9f22b2f5-1c0a-49de-916e-4c88e984852b
1990 ;;; gnus-msg.el ends here