* (gnus-inews-yank-articles): Use `message-list-references' for gathering IDs
[elisp/gnus.git-] / lisp / gnus-msg.el
1 ;;; gnus-msg.el --- mail and post interface for Semi-gnus
2 ;; Copyright (C) 1995,96,97,98,99 Free Software Foundation, Inc.
3
4 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
5 ;;      Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;;      MORIOKA Tomohiko <morioka@jaist.ac.jp>
7 ;;      Shuhei KOBAYASHI <shuhei-k@jaist.ac.jp>
8 ;;      Katsumi Yamaoka  <yamaoka@jpl.org>
9 ;;      Kiyokazu SUTO    <suto@merry.xmath.ous.ac.jp>
10 ;; Keywords: mail, news, MIME
11
12 ;; This file is part of GNU Emacs.
13
14 ;; GNU Emacs is free software; you can redistribute it and/or modify
15 ;; it under the terms of the GNU General Public License as published by
16 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; any later version.
18
19 ;; GNU Emacs is distributed in the hope that it will be useful,
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22 ;; GNU General Public License for more details.
23
24 ;; You should have received a copy of the GNU General Public License
25 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
26 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
27 ;; Boston, MA 02111-1307, USA.
28
29 ;;; Commentary:
30
31 ;;; Code:
32
33 (eval-when-compile (require 'cl))
34
35 (require 'gnus)
36 (require 'gnus-ems)
37 (require 'message)
38 (require 'gnus-art)
39
40 (defcustom gnus-post-method nil
41   "*Preferred method for posting USENET news.
42
43 If this variable is `current', Gnus will use the \"current\" select
44 method when posting.  If it is nil (which is the default), Gnus will
45 use the native posting method of the server.
46
47 This method will not be used in mail groups and the like, only in
48 \"real\" newsgroups.
49
50 If not nil nor `native', the value must be a valid method as discussed
51 in the documentation of `gnus-select-method'. It can also be a list of
52 methods. If that is the case, the user will be queried for what select
53 method to use when posting."
54   :group 'gnus-group-foreign
55   :type `(choice (const nil)
56                  (const current)
57                  (const native)
58                  (sexp :tag "Methods" ,gnus-select-method)))
59
60 (defvar gnus-outgoing-message-group nil
61   "*All outgoing messages will be put in this group.
62 If you want to store all your outgoing mail and articles in the group
63 \"nnml:archive\", you set this variable to that value.  This variable
64 can also be a list of group names.
65
66 If you want to have greater control over what group to put each
67 message in, you can set this variable to a function that checks the
68 current newsgroup name and then returns a suitable group name (or list
69 of names).")
70
71 (defvar gnus-mailing-list-groups nil
72   "*Regexp matching groups that are really mailing lists.
73 This is useful when you're reading a mailing list that has been
74 gatewayed to a newsgroup, and you want to followup to an article in
75 the group.")
76
77 (defvar gnus-add-to-list nil
78   "*If non-nil, add a `to-list' parameter automatically.")
79
80 (defvar gnus-crosspost-complaint
81   "Hi,
82
83 You posted the article below with the following Newsgroups header:
84
85 Newsgroups: %s
86
87 The %s group, at least, was an inappropriate recipient
88 of this message.  Please trim your Newsgroups header to exclude this
89 group before posting in the future.
90
91 Thank you.
92
93 "
94   "Format string to be inserted when complaining about crossposts.
95 The first %s will be replaced by the Newsgroups header;
96 the second with the current group name.")
97
98 (defvar gnus-message-setup-hook '(gnus-maybe-setup-default-charset)
99   "Hook run after setting up a message buffer.")
100
101 (defvar gnus-bug-create-help-buffer t
102   "*Should we create the *Gnus Help Bug* buffer?")
103
104 (defvar gnus-posting-styles nil
105   "*Alist of styles to use when posting.")
106
107 (defvar gnus-posting-style-alist
108   '((organization . message-user-organization)
109     (signature . message-signature)
110     (signature-file . message-signature-file)
111     (address . user-mail-address)
112     (name . user-full-name))
113   "*Mapping from style parameters to variables.")
114
115 (defcustom gnus-group-posting-charset-alist
116   '(("^no\\." iso-8859-1)
117     (".*" iso-8859-1)
118     (message-this-is-news iso-8859-1)
119     (message-this-is-mail nil)
120     )
121   "Alist of regexps (to match group names) and default charsets to be unencoded when posting."
122   :type '(repeat (list (regexp :tag "Group")
123                        (symbol :tag "Charset")))
124   :group 'gnus-charset)
125
126 ;;; Internal variables.
127
128 (defvar gnus-inhibit-posting-styles nil
129   "Inhibit the use of posting styles.")
130
131 (defvar gnus-message-buffer "*Mail Gnus*")
132 (defvar gnus-article-copy nil)
133 (defvar gnus-last-posting-server nil)
134 (defvar gnus-message-group-art nil)
135
136 (defconst gnus-bug-message
137   (format "Sending a bug report to the Gnus Towers.
138 ========================================
139
140 This gnus is the %s%s.
141 If you think the bug is a Semi-gnus bug, send a bug report to Semi-gnus
142 Developers. (the addresses below are mailing list addresses)
143
144 ========================================
145
146 The buffer below is a mail buffer.  When you press `C-c C-c', it will
147 be sent to the Gnus Bug Exterminators.
148
149 At the bottom of the buffer you'll see lots of variable settings.
150 Please do not delete those.  They will tell the Bug People what your
151 environment is, so that it will be easier to locate the bugs.
152
153 If you have found a bug that makes Emacs go \"beep\", set
154 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
155 and include the backtrace in your bug report.
156
157 Please describe the bug in annoying, painstaking detail.
158
159 Thank you for your help in stamping out bugs.
160 "
161           gnus-product-name
162           (if (string= gnus-product-name "Semi-gnus")
163               ""
164             ", a modified version of Semi-gnus")))
165
166 (eval-and-compile
167   (autoload 'gnus-uu-post-news "gnus-uu" nil t)
168   (autoload 'news-setup "rnewspost")
169   (autoload 'news-reply-mode "rnewspost")
170   (autoload 'rmail-dont-reply-to "mail-utils")
171   (autoload 'rmail-output "rmailout"))
172
173 \f
174 ;;;
175 ;;; Gnus Posting Functions
176 ;;;
177
178 (gnus-define-keys (gnus-summary-send-map "S" gnus-summary-mode-map)
179   "p" gnus-summary-post-news
180   "f" gnus-summary-followup
181   "F" gnus-summary-followup-with-original
182   "c" gnus-summary-cancel-article
183   "s" gnus-summary-supersede-article
184   "r" gnus-summary-reply
185   "R" gnus-summary-reply-with-original
186   "w" gnus-summary-wide-reply
187   "W" gnus-summary-wide-reply-with-original
188   "n" gnus-summary-followup-to-mail
189   "N" gnus-summary-followup-to-mail-with-original
190   "m" gnus-summary-mail-other-window
191   "u" gnus-uu-post-news
192   "\M-c" gnus-summary-mail-crosspost-complaint
193   "om" gnus-summary-mail-forward
194   "op" gnus-summary-post-forward
195   "Om" gnus-summary-mail-digest
196   "Op" gnus-summary-post-digest)
197
198 (gnus-define-keys (gnus-send-bounce-map "D" gnus-summary-send-map)
199   "b" gnus-summary-resend-bounced-mail
200   ;; "c" gnus-summary-send-draft
201   "r" gnus-summary-resend-message)
202
203 ;;; Internal functions.
204
205 (defvar gnus-article-reply nil)
206 (defmacro gnus-setup-message (config &rest forms)
207   (let ((winconf (make-symbol "gnus-setup-message-winconf"))
208         (buffer (make-symbol "gnus-setup-message-buffer"))
209         (article (make-symbol "gnus-setup-message-article"))
210         (group (make-symbol "gnus-setup-message-group")))
211     `(let ((,winconf (current-window-configuration))
212            (,buffer (buffer-name (current-buffer)))
213            (,article (and gnus-article-reply (gnus-summary-article-number)))
214            (,group gnus-newsgroup-name)
215            (message-header-setup-hook
216             (copy-sequence message-header-setup-hook))
217            (message-mode-hook (copy-sequence message-mode-hook))
218            (message-startup-parameter-alist
219             '((reply-buffer . gnus-copy-article-buffer)
220               (original-buffer . gnus-original-article-buffer)
221               (user-agent . Gnus))))
222        (add-hook 'message-header-setup-hook 'gnus-inews-insert-gcc)
223        (add-hook 'message-header-setup-hook 'gnus-inews-insert-archive-gcc)
224        (add-hook 'message-mode-hook 'gnus-configure-posting-styles)
225        (unwind-protect
226            (progn
227              ,@forms)
228          (gnus-inews-add-send-actions ,winconf ,buffer ,article)
229          (setq gnus-message-buffer (current-buffer))
230          (set (make-local-variable 'gnus-message-group-art)
231               (cons ,group ,article))
232          (set (make-local-variable 'gnus-newsgroup-name) ,group)
233          (set (make-local-variable 'message-posting-charset)
234               (gnus-setup-posting-charset ,group))
235          (gnus-run-hooks 'gnus-message-setup-hook))
236        (gnus-add-buffer)
237        (gnus-configure-windows ,config t)
238        (set-buffer-modified-p nil))))
239
240 (defun gnus-setup-posting-charset (group)
241   (let ((alist gnus-group-posting-charset-alist)
242         elem)
243     (catch 'found
244       (while (setq elem (pop alist))
245         (when (or (and (stringp (car elem))
246                        (string-match (car elem) group))
247                   (and (gnus-functionp (car elem))
248                        (funcall (car elem) group))
249                   (and (symbolp (car elem))
250                        (symbol-value (car elem))))
251           (throw 'found (cadr elem)))))))
252
253 (defun gnus-inews-add-send-actions (winconf buffer article)
254   (make-local-hook 'message-sent-hook)
255   (add-hook 'message-sent-hook 'gnus-inews-do-gcc nil t)
256   (setq message-post-method
257         `(lambda (arg)
258            (gnus-post-method arg ,gnus-newsgroup-name)))
259   (setq message-user-agent (gnus-extended-version))
260   (when (not message-use-multi-frames)
261     (message-add-action
262      `(set-window-configuration ,winconf) 'exit 'postpone 'kill))
263   (message-add-action
264    `(when (gnus-buffer-exists-p ,buffer)
265       (save-excursion
266         (set-buffer ,buffer)
267         ,(when article
268            `(gnus-summary-mark-article-as-replied ,article))))
269    'send))
270
271 (put 'gnus-setup-message 'lisp-indent-function 1)
272 (put 'gnus-setup-message 'edebug-form-spec '(form body))
273
274 ;;; Post news commands of Gnus group mode and summary mode
275
276 (defun gnus-group-mail (&optional arg)
277   "Start composing a mail.
278 If ARG, use the group under the point to find a posting style.
279 If ARG is 1, prompt for a group name to find the posting style."
280   (interactive "P")
281   ;; We can't `let' gnus-newsgroup-name here, since that leads
282   ;; to local variables leaking.
283   (let ((group gnus-newsgroup-name)
284         (buffer (current-buffer)))
285     (unwind-protect
286         (progn
287           (setq gnus-newsgroup-name
288                 (if arg
289                     (if (= 1 (prefix-numeric-value arg))
290                         (completing-read "Use posting style of group: "
291                                          gnus-active-hashtb nil
292                                          (gnus-read-active-file-p))
293                       (gnus-group-group-name))
294                   ""))
295           (gnus-setup-message 'message (message-mail)))
296       (save-excursion
297         (set-buffer buffer)
298         (setq gnus-newsgroup-name group)))))
299
300 (defun gnus-group-post-news (&optional arg)
301   "Start composing a news message.
302 If ARG, post to the group under point.
303 If ARG is 1, prompt for a group name."
304   (interactive "P")
305   ;; Bind this variable here to make message mode hooks work ok.
306   (let ((gnus-newsgroup-name
307          (if arg
308              (if (= 1 (prefix-numeric-value arg))
309                  (completing-read "Newsgroup: " gnus-active-hashtb nil
310                                   (gnus-read-active-file-p))
311                (gnus-group-group-name))
312            "")))
313     (gnus-post-news 'post gnus-newsgroup-name)))
314
315 (defun gnus-summary-post-news ()
316   "Start composing a news message."
317   (interactive)
318   (gnus-post-news 'post gnus-newsgroup-name))
319
320 (defun gnus-summary-followup (yank &optional force-news)
321   "Compose a followup to an article.
322 If prefix argument YANK is non-nil, original article is yanked automatically."
323   (interactive
324    (list (and current-prefix-arg
325               (gnus-summary-work-articles 1))))
326   (when yank
327     (gnus-summary-goto-subject (car yank)))
328   (save-window-excursion
329     (gnus-summary-select-article))
330   (let ((headers (gnus-summary-article-header (gnus-summary-article-number)))
331         (gnus-newsgroup-name gnus-newsgroup-name))
332     ;; Send a followup.
333     (gnus-post-news nil gnus-newsgroup-name
334                     headers gnus-article-buffer
335                     yank nil force-news)))
336
337 (defun gnus-summary-followup-with-original (n &optional force-news)
338   "Compose a followup to an article and include the original article."
339   (interactive "P")
340   (gnus-summary-followup (gnus-summary-work-articles n) force-news))
341
342 (defun gnus-summary-followup-to-mail (&optional arg)
343   "Followup to the current mail message via news."
344   (interactive
345    (list (and current-prefix-arg
346               (gnus-summary-work-articles 1))))
347   (gnus-summary-followup arg t))
348
349 (defun gnus-summary-followup-to-mail-with-original (&optional arg)
350   "Followup to the current mail message via news."
351   (interactive "P")
352   (gnus-summary-followup (gnus-summary-work-articles arg) t))
353
354 (defun gnus-inews-yank-articles (articles)
355   (let* ((more-than-one (cdr articles))
356          (frame (when (and message-use-multi-frames more-than-one)
357                   (window-frame (get-buffer-window (current-buffer)))))
358          refs beg article)
359     (message-goto-body)
360     (while (setq article (pop articles))
361       (save-window-excursion
362         (set-buffer gnus-summary-buffer)
363         (gnus-summary-select-article nil nil nil article)
364         (gnus-summary-remove-process-mark article))
365       (when frame
366         (select-frame frame))
367
368       ;; Gathering references.
369       (when more-than-one
370         (setq refs (message-list-references
371                     refs
372                     (mail-header-references gnus-current-headers)
373                     (mail-header-message-id gnus-current-headers))))
374
375       (gnus-copy-article-buffer)
376       (let ((message-reply-buffer gnus-article-copy)
377             (message-reply-headers gnus-current-headers))
378         (message-yank-original)
379         (setq beg (or beg (mark t))))
380       (when articles
381         (insert "\n")))
382     (push-mark)
383
384     ;; Replace with the gathered references.
385     (when refs
386       (push-mark beg)
387       (save-restriction
388         (message-narrow-to-headers)
389         (let ((case-fold-search t))
390           (if (re-search-forward "^References:\\([\t ]+.+\n\\)+" nil t)
391               (replace-match "")
392             (goto-char (point-max))))
393         (mail-header-format
394          (list (or (assq 'References message-header-format-alist)
395                    '(References . message-shorten-references)))
396          (list (cons 'References
397                      (mapconcat 'identity (nreverse refs) " "))))
398         (backward-delete-char 1))
399       (setq beg (mark t))
400       (pop-mark))
401
402     (goto-char beg)))
403
404 (defun gnus-summary-cancel-article (&optional n symp)
405   "Cancel an article you posted.
406 Uses the process-prefix convention.  If given the symbolic
407 prefix `a', cancel using the standard posting method; if not
408 post using the current select method."
409   (interactive (gnus-interactive "P\ny"))
410   (let ((articles (gnus-summary-work-articles n))
411         (message-post-method
412          `(lambda (arg)
413             (gnus-post-method (not (eq symp 'a)) ,gnus-newsgroup-name)))
414         article)
415     (while (setq article (pop articles))
416       (when (gnus-summary-select-article t nil nil article)
417         (when (gnus-eval-in-buffer-window gnus-article-buffer
418                 (save-excursion
419                   (set-buffer gnus-original-article-buffer)
420                   (message-cancel-news)))
421           (gnus-summary-mark-as-read article gnus-canceled-mark)
422           (gnus-cache-remove-article 1))
423         (gnus-article-hide-headers-if-wanted))
424       (gnus-summary-remove-process-mark article))))
425
426 (defun gnus-summary-supersede-article ()
427   "Compose an article that will supersede a previous article.
428 This is done simply by taking the old article and adding a Supersedes
429 header line with the old Message-ID."
430   (interactive)
431   (let ((article (gnus-summary-article-number))
432         (gnus-message-setup-hook '(gnus-maybe-setup-default-charset)))
433     (gnus-setup-message 'reply-yank
434       (gnus-summary-select-article t)
435       (set-buffer gnus-original-article-buffer)
436       (message-supersede)
437       (push
438        `((lambda ()
439            (when (gnus-buffer-exists-p ,gnus-summary-buffer)
440              (save-excursion
441                (set-buffer ,gnus-summary-buffer)
442                (gnus-cache-possibly-remove-article ,article nil nil nil t)
443                (gnus-summary-mark-as-read ,article gnus-canceled-mark)))))
444        message-send-actions))))
445
446 \f
447
448 (defun gnus-copy-article-buffer (&optional article-buffer)
449   ;; make a copy of the article buffer with all text properties removed
450   ;; this copy is in the buffer gnus-article-copy.
451   ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
452   ;; this buffer should be passed to all mail/news reply/post routines.
453   (setq gnus-article-copy (gnus-get-buffer-create " *gnus article copy*"))
454   (let ((article-buffer (or article-buffer gnus-article-buffer))
455         end beg)
456     (if (not (and (get-buffer article-buffer)
457                   (gnus-buffer-exists-p article-buffer)))
458         (error "Can't find any article buffer")
459       (save-excursion
460         (set-buffer article-buffer)
461         (save-restriction
462           ;; Copy over the (displayed) article buffer, delete
463           ;; hidden text and remove text properties.
464           (widen)
465           (copy-to-buffer gnus-article-copy (point-min) (point-max))
466           (set-buffer gnus-article-copy)
467           (gnus-article-delete-text-of-type 'annotation)
468           (gnus-remove-text-with-property 'gnus-prev)
469           (gnus-remove-text-with-property 'gnus-next)
470           (insert
471            (prog1
472                (format "%s" (buffer-string))
473              (erase-buffer)))
474           ;; Find the original headers.
475           (set-buffer gnus-original-article-buffer)
476           (goto-char (point-min))
477           (while (looking-at message-unix-mail-delimiter)
478             (forward-line 1))
479           (setq beg (point))
480           (setq end (or (search-forward "\n\n" nil t) (point)))
481           ;; Delete the headers from the displayed articles.
482           (set-buffer gnus-article-copy)
483           (delete-region (goto-char (point-min))
484                          (or (search-forward "\n\n" nil t) (point-max)))
485           ;; Insert the original article headers.
486           (insert-buffer-substring gnus-original-article-buffer beg end)
487           (article-decode-encoded-words)))
488       gnus-article-copy)))
489
490 (defun gnus-post-news (post &optional group header article-buffer yank subject
491                             force-news)
492   (when article-buffer
493     (gnus-copy-article-buffer))
494   (let ((gnus-article-reply article-buffer)
495         (add-to-list gnus-add-to-list))
496     (gnus-setup-message (cond (yank 'reply-yank)
497                               (article-buffer 'reply)
498                               (t 'message))
499       (let* ((group (or group gnus-newsgroup-name))
500              (pgroup group)
501              to-address to-group mailing-list to-list
502              newsgroup-p)
503         (when group
504           (setq to-address (gnus-group-find-parameter group 'to-address)
505                 to-group (gnus-group-find-parameter group 'to-group)
506                 to-list (gnus-group-find-parameter group 'to-list)
507                 newsgroup-p (gnus-group-find-parameter group 'newsgroup)
508                 mailing-list (when gnus-mailing-list-groups
509                                (string-match gnus-mailing-list-groups group))
510                 group (gnus-group-real-name group)))
511         (if (or (and to-group
512                      (gnus-news-group-p to-group))
513                 newsgroup-p
514                 force-news
515                 (and (gnus-news-group-p
516                       (or pgroup gnus-newsgroup-name)
517                       (if header (mail-header-number header)
518                         gnus-current-article))
519                      (not mailing-list)
520                      (not to-list)
521                      (not to-address)))
522             ;; This is news.
523             (if post
524                 (message-news (or to-group group))
525               (set-buffer gnus-article-copy)
526               (gnus-msg-treat-broken-reply-to)
527               (message-followup (if (or newsgroup-p force-news) nil to-group)))
528           ;; The is mail.
529           (if post
530               (progn
531                 (message-mail (or to-address to-list))
532                 ;; Arrange for mail groups that have no `to-address' to
533                 ;; get that when the user sends off the mail.
534                 (when (and (not to-list)
535                            (not to-address)
536                            add-to-list)
537                   (push (list 'gnus-inews-add-to-address pgroup)
538                         message-send-actions)))
539             (set-buffer gnus-article-copy)
540             (gnus-msg-treat-broken-reply-to)
541             (message-wide-reply to-address)))
542         (when yank
543           (gnus-inews-yank-articles yank))))))
544
545 (defun gnus-msg-treat-broken-reply-to ()
546   "Remove the Reply-to header iff broken-reply-to."
547   (when (gnus-group-find-parameter
548          gnus-newsgroup-name 'broken-reply-to)
549     (save-restriction
550       (message-narrow-to-head)
551       (message-remove-header "reply-to"))))
552
553 (defun gnus-post-method (arg group &optional silent)
554   "Return the posting method based on GROUP and ARG.
555 If SILENT, don't prompt the user."
556   (let ((group-method (gnus-find-method-for-group group)))
557     (cond
558      ;; If the group-method is nil (which shouldn't happen) we use
559      ;; the default method.
560      ((null group-method)
561       (or (and (null (eq gnus-post-method 'active)) gnus-post-method)
562                gnus-select-method message-post-method))
563      ;; We want the inverse of the default
564      ((and arg (not (eq arg 0)))
565       (if (eq gnus-post-method 'active)
566           gnus-select-method
567         group-method))
568      ;; We query the user for a post method.
569      ((or arg
570           (and gnus-post-method
571                (not (eq gnus-post-method 'current))
572                (listp (car gnus-post-method))))
573       (let* ((methods
574               ;; Collect all methods we know about.
575               (append
576                (when (and gnus-post-method
577                           (not (eq gnus-post-method 'current)))
578                  (if (listp (car gnus-post-method))
579                      gnus-post-method
580                    (list gnus-post-method)))
581                gnus-secondary-select-methods
582                (mapcar 'cdr gnus-server-alist)
583                (mapcar 'car gnus-opened-servers)
584                (list gnus-select-method)
585                (list group-method)))
586              method-alist post-methods method)
587         ;; Weed out all mail methods.
588         (while methods
589           (setq method (gnus-server-get-method "" (pop methods)))
590           (when (and (or (gnus-method-option-p method 'post)
591                          (gnus-method-option-p method 'post-mail))
592                      (not (member method post-methods)))
593             (push method post-methods)))
594         ;; Create a name-method alist.
595         (setq method-alist
596               (mapcar
597                (lambda (m)
598                  (list (concat (cadr m) " (" (symbol-name (car m)) ")") m))
599                post-methods))
600         ;; Query the user.
601         (cadr
602          (assoc
603           (setq gnus-last-posting-server
604                 (if (and silent
605                          gnus-last-posting-server)
606                     ;; Just use the last value.
607                     gnus-last-posting-server
608                   (completing-read
609                    "Posting method: " method-alist nil t
610                    (cons (or gnus-last-posting-server "") 0))))
611           method-alist))))
612      ;; Override normal method.
613      ((and (eq gnus-post-method 'current)
614            (not (eq (car group-method) 'nndraft))
615            (not arg))
616       group-method)
617      ((and gnus-post-method
618            (not (eq gnus-post-method 'current)))
619       gnus-post-method)
620      ;; Use the normal select method.
621      (t gnus-select-method))))
622
623 \f
624
625 (defun gnus-extended-version ()
626   "Stringified gnus version."
627   (concat gnus-product-name "/" gnus-version-number " (based on "
628           gnus-original-product-name " v" gnus-original-version-number ")"))
629
630 (defun gnus-message-make-user-agent (&optional include-mime-info max-column)
631   "Return user-agent info.
632 INCLUDE-MIME-INFO the optional first argument if it is non-nil and the variable
633   `mime-edit-user-agent-value' exists, the return value will include it.
634 MAX-COLUMN the optional second argument if it is specified, the return value
635   will be folded up in the proper way."
636   (let ((user-agent (if (and include-mime-info
637                              (boundp 'mime-edit-user-agent-value))
638                         (concat (gnus-extended-version)
639                                 " "
640                                 mime-edit-user-agent-value)
641                       (gnus-extended-version))))
642     (if max-column
643         (let (boundary)
644           (unless (natnump max-column) (setq max-column 76))
645           (with-temp-buffer
646             (insert "            " user-agent)
647             (goto-char 13)
648             (while (re-search-forward "[\n\t ]+" nil t)
649               (replace-match " "))
650             (goto-char 13)
651             (while (re-search-forward "[^ ()/]+\\(/[^ ()/]+\\)? ?" nil t)
652               (while (eq ?\( (char-after (point)))
653                 (forward-list)
654                 (skip-chars-forward " "))
655               (skip-chars-backward " ")
656               (if (> (current-column) max-column)
657                   (progn
658                     (if (or (not boundary) (eq ?\n (char-after boundary)))
659                         (progn
660                           (setq boundary (point))
661                           (unless (eobp)
662                             (delete-char 1)
663                             (insert "\n ")))
664                       (goto-char boundary)
665                       (delete-char 1)
666                       (insert "\n ")))
667                 (setq boundary (point))))
668             (buffer-substring 13 (point-max))))
669       user-agent)))
670
671 \f
672 ;;;
673 ;;; Gnus Mail Functions
674 ;;;
675
676 ;;; Mail reply commands of Gnus summary mode
677
678 (defun gnus-summary-reply (&optional yank wide)
679   "Start composing a reply mail to the current message.
680 If prefix argument YANK is non-nil, the original article is yanked
681 automatically."
682   (interactive
683    (list (and current-prefix-arg
684               (gnus-summary-work-articles 1))))
685   ;; Stripping headers should be specified with mail-yank-ignored-headers.
686   (when yank
687     (gnus-summary-goto-subject (car yank)))
688   (let ((gnus-article-reply t))
689     (gnus-setup-message (if yank 'reply-yank 'reply)
690       (gnus-summary-select-article)
691       (set-buffer (gnus-copy-article-buffer))
692       (gnus-msg-treat-broken-reply-to)
693       (message-reply nil wide)
694       (when yank
695         (gnus-inews-yank-articles yank)))))
696
697 (defun gnus-summary-reply-with-original (n &optional wide)
698   "Start composing a reply mail to the current message.
699 The original article will be yanked."
700   (interactive "P")
701   (gnus-summary-reply (gnus-summary-work-articles n) wide))
702
703 (defun gnus-summary-wide-reply (&optional yank)
704   "Start composing a wide reply mail to the current message.
705 If prefix argument YANK is non-nil, the original article is yanked
706 automatically."
707   (interactive
708    (list (and current-prefix-arg
709               (gnus-summary-work-articles 1))))
710   (gnus-summary-reply yank t))
711
712 (defun gnus-summary-wide-reply-with-original (n)
713   "Start composing a wide reply mail to the current message.
714 The original article will be yanked."
715   (interactive "P")
716   (gnus-summary-reply-with-original n t))
717
718 (defun gnus-summary-mail-forward (&optional full-headers post)
719   "Forward the current message to another user.
720 If FULL-HEADERS (the prefix), include full headers when forwarding."
721   (interactive "P")
722   (gnus-setup-message 'forward
723     (gnus-summary-select-article)
724     (let ((charset default-mime-charset))
725       (set-buffer gnus-original-article-buffer)
726       (make-local-variable 'default-mime-charset)
727       (setq default-mime-charset charset)
728       )
729     (let ((message-included-forward-headers
730            (if full-headers "" message-included-forward-headers)))
731       (message-forward post))))
732
733 ;;; XXX: generate Subject and ``Topics''?
734 (defun gnus-summary-mail-digest (&optional n post)
735   "Digests and forwards all articles in this series."
736   (interactive "P")
737   (let ((subject "Digested Articles")
738         (articles (gnus-summary-work-articles n))
739         article)
740     (gnus-setup-message 'forward
741       (gnus-summary-select-article)
742       (if post (message-news nil subject) (message-mail nil subject))
743       (message-goto-body)
744       (while (setq article (pop articles))
745         (save-window-excursion
746           (set-buffer gnus-summary-buffer)
747           (gnus-summary-select-article nil nil nil article)
748           (gnus-summary-remove-process-mark article))
749         (insert (mime-make-tag "message" "rfc822") "\n")
750         (insert-buffer-substring gnus-original-article-buffer))
751       (push-mark)
752       (message-goto-body)
753       (mime-edit-enclose-digest-region (point)(mark t)))))
754
755 (defun gnus-summary-post-digest (&optional n)
756   "Digest and forwards all articles in this series to a newsgroup."
757   (interactive "P")
758   (gnus-summary-mail-digest n t))
759
760 (defun gnus-summary-resend-message (address n)
761   "Resend the current article to ADDRESS."
762   (interactive "sResend message(s) to: \nP")
763   (let ((articles (gnus-summary-work-articles n))
764         article)
765     (while (setq article (pop articles))
766       (gnus-summary-select-article nil nil nil article)
767       (save-excursion
768         (set-buffer gnus-original-article-buffer)
769         (message-resend address)))))
770
771 (defun gnus-summary-post-forward (&optional full-headers)
772   "Forward the current article to a newsgroup.
773 If FULL-HEADERS (the prefix), include full headers when forwarding."
774   (interactive "P")
775   (gnus-summary-mail-forward full-headers t))
776
777 (defvar gnus-nastygram-message
778   "The following article was inappropriately posted to %s.\n\n"
779   "Format string to insert in nastygrams.
780 The current group name will be inserted at \"%s\".")
781
782 (defun gnus-summary-mail-nastygram (n)
783   "Send a nastygram to the author of the current article."
784   (interactive "P")
785   (when (or gnus-expert-user
786             (gnus-y-or-n-p
787              "Really send a nastygram to the author of the current article? "))
788     (let ((group gnus-newsgroup-name))
789       (gnus-summary-reply-with-original n)
790       (set-buffer gnus-message-buffer)
791       (message-goto-body)
792       (insert (format gnus-nastygram-message group))
793       (message-send-and-exit))))
794
795 (defun gnus-summary-mail-crosspost-complaint (n)
796   "Send a complaint about crossposting to the current article(s)."
797   (interactive "P")
798   (let ((articles (gnus-summary-work-articles n))
799         article)
800     (while (setq article (pop articles))
801       (set-buffer gnus-summary-buffer)
802       (gnus-summary-goto-subject article)
803       (let ((group (gnus-group-real-name gnus-newsgroup-name))
804             newsgroups followup-to)
805         (gnus-summary-select-article)
806         (set-buffer gnus-original-article-buffer)
807         (if (and (<= (length (message-tokenize-header
808                               (setq newsgroups
809                                     (mail-fetch-field "newsgroups"))
810                               ", "))
811                      1)
812                  (or (not (setq followup-to (mail-fetch-field "followup-to")))
813                      (not (member group (message-tokenize-header
814                                          followup-to ", ")))))
815             (if followup-to
816                 (gnus-message 1 "Followup-to restricted")
817               (gnus-message 1 "Not a crossposted article"))
818           (set-buffer gnus-summary-buffer)
819           (gnus-summary-reply-with-original 1)
820           (set-buffer gnus-message-buffer)
821           (message-goto-body)
822           (insert (format gnus-crosspost-complaint newsgroups group))
823           (message-goto-subject)
824           (re-search-forward " *$")
825           (replace-match " (crosspost notification)" t t)
826           (gnus-deactivate-mark)
827           (when (gnus-y-or-n-p "Send this complaint? ")
828             (message-send-and-exit)))))))
829
830 (defun gnus-summary-mail-other-window ()
831   "Compose mail in other window."
832   (interactive)
833   (gnus-setup-message 'message
834     (message-mail)))
835
836 (defun gnus-mail-parse-comma-list ()
837   (let (accumulated
838         beg)
839     (skip-chars-forward " ")
840     (while (not (eobp))
841       (setq beg (point))
842       (skip-chars-forward "^,")
843       (while (zerop
844               (save-excursion
845                 (save-restriction
846                   (let ((i 0))
847                     (narrow-to-region beg (point))
848                     (goto-char beg)
849                     (logand (progn
850                               (while (search-forward "\"" nil t)
851                                 (incf i))
852                               (if (zerop i) 2 i))
853                             2)))))
854         (skip-chars-forward ",")
855         (skip-chars-forward "^,"))
856       (skip-chars-backward " ")
857       (push (buffer-substring beg (point))
858             accumulated)
859       (skip-chars-forward "^,")
860       (skip-chars-forward ", "))
861     accumulated))
862
863 (defun gnus-inews-add-to-address (group)
864   (let ((to-address (mail-fetch-field "to")))
865     (when (and to-address
866                (gnus-alive-p))
867       ;; This mail group doesn't have a `to-list', so we add one
868       ;; here.  Magic!
869       (when (gnus-y-or-n-p
870              (format "Do you want to add this as `to-list': %s " to-address))
871         (gnus-group-add-parameter group (cons 'to-list to-address))))))
872
873 (defun gnus-put-message ()
874   "Put the current message in some group and return to Gnus."
875   (interactive)
876   (let ((reply gnus-article-reply)
877         (winconf gnus-prev-winconf)
878         (group gnus-newsgroup-name))
879
880     (or (and group (not (gnus-group-read-only-p group)))
881         (setq group (read-string "Put in group: " nil
882                                  (gnus-writable-groups))))
883     (when (gnus-gethash group gnus-newsrc-hashtb)
884       (error "No such group: %s" group))
885
886     (save-excursion
887       (save-restriction
888         (widen)
889         (message-narrow-to-headers)
890         (let (gnus-deletable-headers)
891           (if (message-news-p)
892               (message-generate-headers message-required-news-headers)
893             (message-generate-headers message-required-mail-headers)))
894         (goto-char (point-max))
895         (insert "Gcc: " group "\n")
896         (widen)))
897
898     (gnus-inews-do-gcc)
899
900     (when (get-buffer gnus-group-buffer)
901       (when (gnus-buffer-exists-p (car-safe reply))
902         (set-buffer (car reply))
903         (and (cdr reply)
904              (gnus-summary-mark-article-as-replied
905               (cdr reply))))
906       (when winconf
907         (set-window-configuration winconf)))))
908
909 (defun gnus-article-mail (yank)
910   "Send a reply to the address near point.
911 If YANK is non-nil, include the original article."
912   (interactive "P")
913   (let ((address
914          (buffer-substring
915           (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
916           (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
917     (when address
918       (message-reply address)
919       (when yank
920         (gnus-inews-yank-articles (list (cdr gnus-article-current)))))))
921
922 (defvar nntp-server-type)
923 (defun gnus-bug ()
924   "Send a bug report to the Gnus maintainers."
925   (interactive)
926   (unless (gnus-alive-p)
927     (error "Gnus has been shut down"))
928   (gnus-setup-message 'bug
929     (delete-other-windows)
930     (when gnus-bug-create-help-buffer
931       (switch-to-buffer "*Gnus Help Bug*")
932       (erase-buffer)
933       (insert gnus-bug-message)
934       (goto-char (point-min)))
935     (message-pop-to-buffer "*Gnus Bug*")
936     (message-setup
937      `((To . ,gnus-maintainer) (Cc . ,semi-gnus-developers) (Subject . "")))
938     (when gnus-bug-create-help-buffer
939       (push `(gnus-bug-kill-buffer) message-send-actions))
940     (goto-char (point-min))
941     (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
942     (forward-line 1)
943     (insert (gnus-version) "\n"
944             (emacs-version) "\n")
945     (when (and (boundp 'nntp-server-type)
946                (stringp nntp-server-type))
947       (insert nntp-server-type))
948     (insert "\n\n\n\n\n")
949     (gnus-debug)
950     (goto-char (point-min))
951     (search-forward "Subject: " nil t)
952     (message "")))
953
954 (defun gnus-bug-kill-buffer ()
955   (when (get-buffer "*Gnus Help Bug*")
956     (kill-buffer "*Gnus Help Bug*")))
957
958 (defun gnus-debug ()
959   "Attempts to go through the Gnus source file and report what variables have been changed.
960 The source file has to be in the Emacs load path."
961   (interactive)
962   (let ((files '("gnus.el" "gnus-sum.el" "gnus-group.el"
963                  "gnus-art.el" "gnus-start.el" "gnus-async.el"
964                  "gnus-msg.el" "gnus-score.el" "gnus-win.el" "gnus-topic.el"
965                  "nnmail.el" "message.el"))
966         (point (point))
967         file expr olist sym)
968     (gnus-message 4 "Please wait while we snoop your variables...")
969     (sit-for 0)
970     ;; Go through all the files looking for non-default values for variables.
971     (save-excursion
972       (set-buffer (gnus-get-buffer-create " *gnus bug info*"))
973       (while files
974         (erase-buffer)
975         (when (and (setq file (locate-library (pop files)))
976                    (file-exists-p file))
977           (insert-file-contents file)
978           (goto-char (point-min))
979           (if (not (re-search-forward "^;;* *Internal variables" nil t))
980               (gnus-message 4 "Malformed sources in file %s" file)
981             (narrow-to-region (point-min) (point))
982             (goto-char (point-min))
983             (while (setq expr (ignore-errors (read (current-buffer))))
984               (ignore-errors
985                 (and (or (eq (car expr) 'defvar)
986                          (eq (car expr) 'defcustom))
987                      (stringp (nth 3 expr))
988                      (or (not (boundp (nth 1 expr)))
989                          (not (equal (eval (nth 2 expr))
990                                      (symbol-value (nth 1 expr)))))
991                      (push (nth 1 expr) olist)))))))
992       (kill-buffer (current-buffer)))
993     (when (setq olist (nreverse olist))
994       (insert "------------------ Environment follows ------------------\n\n"))
995     (while olist
996       (if (boundp (car olist))
997           (condition-case ()
998               (pp `(setq ,(car olist)
999                          ,(if (or (consp (setq sym (symbol-value (car olist))))
1000                                   (and (symbolp sym)
1001                                        (not (or (eq sym nil)
1002                                                 (eq sym t)))))
1003                               (list 'quote (symbol-value (car olist)))
1004                             (symbol-value (car olist))))
1005                   (current-buffer))
1006             (error
1007              (format "(setq %s 'whatever)\n" (car olist))))
1008         (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
1009       (setq olist (cdr olist)))
1010     (insert "\n\n")
1011     ;; Remove any control chars - they seem to cause trouble for some
1012     ;; mailers.  (Byte-compiled output from the stuff above.)
1013     (goto-char point)
1014     (while (re-search-forward "[\000-\010\013-\037\200-\237]" nil t)
1015       (replace-match (format "\\%03o" (string-to-char (match-string 0)))
1016                      t t))))
1017
1018 ;;; Treatment of rejected articles.
1019 ;;; Bounced mail.
1020
1021 (defun gnus-summary-resend-bounced-mail (&optional fetch)
1022   "Re-mail the current message.
1023 This only makes sense if the current message is a bounce message than
1024 contains some mail you have written which has been bounced back to
1025 you.
1026 If FETCH, try to fetch the article that this is a reply to, if indeed
1027 this is a reply."
1028   (interactive "P")
1029   (gnus-summary-select-article t)
1030   (set-buffer gnus-original-article-buffer)
1031   (let ((gnus-message-setup-hook '(gnus-maybe-setup-default-charset)))
1032     (gnus-setup-message 'compose-bounce
1033       (let* ((references (mail-fetch-field "references"))
1034              (parent (and references (gnus-parent-id references))))
1035         (message-bounce)
1036         ;; If there are references, we fetch the article we answered to.
1037         (and fetch parent
1038              (gnus-summary-refer-article parent)
1039              (gnus-summary-show-all-headers))))))
1040
1041 ;;; Gcc handling.
1042
1043 ;; Do Gcc handling, which copied the message over to some group.
1044 (defun gnus-inews-do-gcc (&optional gcc)
1045   (interactive)
1046   (when (gnus-alive-p)
1047     (save-excursion
1048       (save-restriction
1049         (message-narrow-to-headers)
1050         (let ((gcc (or gcc (mail-fetch-field "gcc" nil t)))
1051               (coding-system-for-write 'raw-text)
1052               groups group method)
1053           (when gcc
1054             (message-remove-header "gcc")
1055             (widen)
1056             (setq groups (message-tokenize-header gcc " ,"))
1057             ;; Copy the article over to some group(s).
1058             (while (setq group (pop groups))
1059               (gnus-check-server
1060                (setq method
1061                      (cond ((and (null (gnus-get-info group))
1062                                  (eq (car gnus-message-archive-method)
1063                                      (car
1064                                       (gnus-server-to-method
1065                                        (gnus-group-method group)))))
1066                             ;; If the group doesn't exist, we assume
1067                             ;; it's an archive group...
1068                             gnus-message-archive-method)
1069                            ;; Use the method.
1070                            ((gnus-info-method (gnus-get-info group))
1071                             (gnus-info-method (gnus-get-info group)))
1072                            ;; Find the method.
1073                            (t (gnus-group-method group)))))
1074               (gnus-check-server method)
1075               (unless (gnus-request-group group t method)
1076                 (gnus-request-create-group group method))
1077               (save-excursion
1078                 (nnheader-set-temp-buffer " *acc*")
1079                 (insert-buffer-substring message-encoding-buffer)
1080                 (gnus-run-hooks 'gnus-before-do-gcc-hook)
1081                 (goto-char (point-min))
1082                 (when (re-search-forward
1083                        (concat "^" (regexp-quote mail-header-separator) "$")
1084                        nil t)
1085                   (replace-match "" t t ))
1086                 (unless (gnus-request-accept-article group method t t)
1087                   (gnus-message 1 "Couldn't store article in group %s: %s"
1088                                 group (gnus-status-message method))
1089                   (sit-for 2))
1090                 (kill-buffer (current-buffer))))))))))
1091
1092 (defun gnus-inews-insert-gcc ()
1093   "Insert Gcc headers based on `gnus-outgoing-message-group'."
1094   (save-excursion
1095     (save-restriction
1096       (message-narrow-to-headers)
1097       (let* ((group gnus-outgoing-message-group)
1098              (gcc (cond
1099                    ((gnus-functionp group)
1100                     (funcall group))
1101                    ((or (stringp group) (list group))
1102                     group))))
1103         (when gcc
1104           (insert "Gcc: "
1105                   (if (stringp gcc) gcc
1106                     (mapconcat 'identity gcc " "))
1107                   "\n"))))))
1108
1109 (defun gnus-inews-insert-archive-gcc (&optional group)
1110   "Insert the Gcc to say where the article is to be archived."
1111   (let* ((var gnus-message-archive-group)
1112          (group (or group gnus-newsgroup-name ""))
1113          (gcc-self-val
1114           (and gnus-newsgroup-name
1115                (gnus-group-find-parameter
1116                 gnus-newsgroup-name 'gcc-self)))
1117          result
1118          (groups
1119           (cond
1120            ((null gnus-message-archive-method)
1121             ;; Ignore.
1122             nil)
1123            ((stringp var)
1124             ;; Just a single group.
1125             (list var))
1126            ((null var)
1127             ;; We don't want this.
1128             nil)
1129            ((and (listp var) (stringp (car var)))
1130             ;; A list of groups.
1131             var)
1132            ((gnus-functionp var)
1133             ;; A function.
1134             (funcall var group))
1135            (t
1136             ;; An alist of regexps/functions/forms.
1137             (while (and var
1138                         (not
1139                          (setq result
1140                                (cond
1141                                 ((stringp (caar var))
1142                                  ;; Regexp.
1143                                  (when (string-match (caar var) group)
1144                                    (cdar var)))
1145                                 ((gnus-functionp (car var))
1146                                  ;; Function.
1147                                  (funcall (car var) group))
1148                                 (t
1149                                  (eval (car var)))))))
1150               (setq var (cdr var)))
1151             result)))
1152          name)
1153     (when (or groups gcc-self-val)
1154       (when (stringp groups)
1155         (setq groups (list groups)))
1156       (save-excursion
1157         (save-restriction
1158           (message-narrow-to-headers)
1159           (goto-char (point-max))
1160           (insert "Gcc: ")
1161           (if gcc-self-val
1162               ;; Use the `gcc-self' param value instead.
1163               (progn
1164                 (insert
1165                  (if (stringp gcc-self-val)
1166                      gcc-self-val
1167                    group))
1168                 (if (not (eq gcc-self-val 'none))
1169                     (insert "\n")
1170                   (progn
1171                     (beginning-of-line)
1172                     (kill-line))))
1173             ;; Use the list of groups.
1174             (while (setq name (pop groups))
1175               (insert (if (string-match ":" name)
1176                           name
1177                         (gnus-group-prefixed-name
1178                          name gnus-message-archive-method)))
1179               (when groups
1180                 (insert " ")))
1181             (insert "\n")))))))
1182
1183 ;;; Posting styles.
1184
1185 (defvar gnus-message-style-insertions nil)
1186
1187 (defun gnus-configure-posting-styles ()
1188   "Configure posting styles according to `gnus-posting-styles'."
1189   (unless gnus-inhibit-posting-styles
1190     (let ((styles gnus-posting-styles)
1191           (gnus-newsgroup-name (or gnus-newsgroup-name ""))
1192           style match variable attribute value value-value)
1193       (make-local-variable 'gnus-message-style-insertions)
1194       ;; If the group has a posting-style parameter, add it at the end with a
1195       ;; regexp matching everything, to be sure it takes precedence over all
1196       ;; the others.
1197       (unless (zerop (length gnus-newsgroup-name))
1198         (let ((tmp-style (gnus-group-find-parameter
1199                           gnus-newsgroup-name 'posting-style t)))
1200           (when tmp-style
1201             (setq styles (append styles (list (cons ".*" tmp-style)))))))
1202       ;; Go through all styles and look for matches.
1203       (while styles
1204         (setq style (pop styles)
1205               match (pop style))
1206         (when (cond
1207                ((stringp match)
1208                 ;; Regexp string match on the group name.
1209                 (string-match match gnus-newsgroup-name))
1210                ((or (symbolp match)
1211                     (gnus-functionp match))
1212                 (cond
1213                  ((gnus-functionp match)
1214                   ;; Function to be called.
1215                   (funcall match))
1216                  ((boundp match)
1217                   ;; Variable to be checked.
1218                   (symbol-value match))))
1219                ((listp match)
1220                 ;; This is a form to be evaled.
1221                 (eval match)))
1222           ;; We have a match, so we set the variables.
1223           (while style
1224             (setq attribute (pop style)
1225                   value (cadr attribute)
1226                   variable nil)
1227             ;; We find the variable that is to be modified.
1228             (if (and (not (stringp (car attribute)))
1229                      (not (eq 'body (car attribute)))
1230                      (not (setq variable
1231                                 (cdr (assq (car attribute)
1232                                            gnus-posting-style-alist)))))
1233                 (message "Couldn't find attribute %s" (car attribute))
1234               ;; We get the value.
1235               (setq value-value
1236                     (cond
1237                      ((stringp value)
1238                       value)
1239                      ((or (symbolp value)
1240                           (gnus-functionp value))
1241                       (cond ((gnus-functionp value)
1242                              (funcall value))
1243                             ((boundp value)
1244                              (symbol-value value))))
1245                      ((listp value)
1246                       (eval value))))
1247               (if variable
1248                   ;; This is an ordinary variable.
1249                   (set (make-local-variable variable) value-value)
1250                 ;; This is either a body or a header to be inserted in the
1251                 ;; message.
1252                 (let ((attr (car attribute)))
1253                   (make-local-variable 'message-setup-hook)
1254                   (if (eq 'body attr)
1255                       (add-hook 'message-setup-hook
1256                                 `(lambda ()
1257                                    (save-excursion
1258                                      (message-goto-body)
1259                                      (insert ,value-value))))
1260                     (add-hook 'message-setup-hook
1261                               'gnus-message-insert-stylings)
1262                     (push (cons (if (stringp attr) attr
1263                                   (symbol-name attr))
1264                                 value-value)
1265                           gnus-message-style-insertions)))))))))))
1266
1267 (defun gnus-message-insert-stylings ()
1268   (let (val)
1269     (save-excursion
1270       (message-goto-eoh)
1271       (while (setq val (pop gnus-message-style-insertions))
1272         (when (cdr val)
1273           (insert (car val) ": " (cdr val) "\n"))
1274         (gnus-pull (car val) gnus-message-style-insertions t)))))
1275
1276
1277 ;;; @ for MIME Edit mode
1278 ;;;
1279
1280 (defun gnus-maybe-setup-default-charset ()
1281   (let ((charset
1282          (and (boundp 'gnus-summary-buffer)
1283               (buffer-live-p gnus-summary-buffer)
1284               (save-excursion
1285                 (set-buffer gnus-summary-buffer)
1286                 default-mime-charset))))
1287     (if charset
1288         (progn
1289           (make-local-variable 'default-mime-charset)
1290           (setq default-mime-charset charset)
1291           ))))
1292
1293
1294 ;;; Allow redefinition of functions.
1295
1296 (gnus-ems-redefine)
1297
1298 (provide 'gnus-msg)
1299
1300 ;;; gnus-msg.el ends here