*** empty log message ***
[gnus] / lisp / gnus-msg.el
1 ;;; gnus-msg.el --- mail and post interface for Gnus
2 ;; Copyright (C) 1995 Free Software Foundation, Inc.
3
4 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
5 ;;      Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
6 ;; Keywords: news
7
8 ;; This file is part of GNU Emacs.
9
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; any later version.
14
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 ;; GNU General Public License for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING.  If not, write to
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
23
24 ;;; Commentary:
25
26 ;;; Code:
27
28 (require 'gnus)
29 (require 'sendmail)
30 (require 'gnus-ems)
31 (require 'rmail)
32
33 (defvar gnus-organization-file "/usr/lib/news/organization"
34   "*Local news organization file.")
35
36 (defvar gnus-post-prepare-function nil
37   "*Function that is run after a post buffer has been prepared.
38 It is called with the name of the newsgroup that is posted to. It
39 might be used, for instance, for inserting signatures based on the
40 newsgroup name. (In that case, `gnus-signature-file' and
41 `mail-signature' should both be set to nil).")
42
43 (defvar gnus-post-prepare-hook nil
44   "*Hook that is run after a post buffer has been prepared.
45 If you want to insert the signature, you might put
46 `gnus-inews-insert-signature' in this hook.")
47
48 (defvar gnus-use-followup-to 'use
49   "*Specifies what to do with Followup-To header.
50 If nil, ignore the header. If it is t, use its value, but ignore 
51 `poster'. If it is neither nil nor t, which is the default, always use
52 the value.") 
53
54 (defvar gnus-followup-to-function nil
55   "*A variable that contains a function that returns a followup address.
56 The function will be called in the buffer of the article that is being
57 followed up. The buffer will be narrowed to the headers of the
58 article. To pick header headers, one might use `mail-fetch-field'.  The
59 function will be called with the name of the current newsgroup as the
60 argument.
61
62 Here's an example `gnus-followup-to-function':
63
64 (setq gnus-followup-to-function
65       (lambda (group)
66         (cond ((string= group \"mail.list\")
67                (or (mail-fetch-field \"sender\") 
68                    (mail-fetch-field \"from\")))
69               (t
70                (or (mail-fetch-field \"reply-to\") 
71                    (mail-fetch-field \"from\"))))))")
72
73 (defvar gnus-reply-to-function nil
74   "*A variable that contains a function that returns a reply address.
75 See the `gnus-followup-to-function' variable for an explanation of how
76 this variable is used.
77
78 This function should return a string that will be used to fill in the
79 header.  This function may also return a list.  In that case, every
80 list element should be a cons where the first car should be a string
81 with the header name, and the cdr should be a string with the header
82 value.")
83
84 (defvar gnus-author-copy (getenv "AUTHORCOPY")
85   "*Save outgoing articles in this file.
86 Initialized from the AUTHORCOPY environment variable.
87
88 If this variable begins with the character \"|\", outgoing articles
89 will be piped to the named program. It is possible to save an article
90 in an MH folder as follows:
91
92 \(setq gnus-author-copy \"|/usr/local/lib/mh/rcvstore +Article\")
93
94 If the first character is not a pipe, articles are saved using the
95 function specified by the `gnus-author-copy-saver' variable.")
96
97 (defvar gnus-mail-self-blind nil
98   "*Non-nil means insert a BCC header in all outgoing articles.
99 This will result in having a copy of the article mailed to yourself.
100 The BCC header is inserted when the post buffer is initialized, so you
101 can remove or alter the BCC header to override the default.")
102
103 (defvar gnus-author-copy-saver (function rmail-output)
104   "*A function called to save outgoing articles.
105 This function will be called with the same of the file to store the
106 article in. The default function is `rmail-output' which saves in Unix
107 mailbox format.")
108
109 (defvar gnus-user-login-name nil
110   "*The login name of the user.
111 Got from the function `user-login-name' if undefined.")
112
113 (defvar gnus-user-full-name nil
114   "*The full name of the user.
115 Got from the NAME environment variable if undefined.")
116
117 (defvar gnus-user-from-line nil
118   "*Your full, complete e-mail address.  
119 Overrides the other Gnus variables if it is non-nil.
120
121 Here are two example values of this variable:
122
123  \"Lars Magne Ingebrigtsen <larsi@ifi.uio.no>\"
124
125 and
126
127  \"larsi@ifi.uio.no (Lars Magne Ingebrigtsen)\"
128
129 The first version is recommended, but the name has to be quoted if it
130 contains non-alphanumerical characters.")
131
132 (defvar gnus-signature-file "~/.signature"
133   "*Your signature file.
134 If the variable is a string that doesn't correspond to a file, the
135 string itself is inserted.")
136
137 (defvar gnus-signature-function nil
138   "*A function that should return a signature file name.
139 The function will be called with the name of the newsgroup being
140 posted to.
141 If the function returns a string that doesn't correspond to a file, the
142 string itself is inserted.
143 If the function returns nil, the `gnus-signature-file' variable will
144 be used instead.")
145
146 (defvar gnus-required-headers
147   '(From Date Newsgroups Subject Message-ID Organization Lines X-Newsreader)
148   "*Headers to be generated or prompted for when posting an article.
149 RFC977 and RFC1036 require From, Date, Newsgroups, Subject,
150 Message-ID.  Organization, Lines and X-Newsreader are optional.  If
151 you want Gnus not to insert some header, remove it from this list.")
152
153 (defvar gnus-deletable-headers '(Message-ID Date)
154   "*Headers to be deleted if they already exists.")
155
156 (defvar gnus-check-before-posting 
157   '(subject-cmsg multiple-headers sendsys message-id from
158                  long-lines control-chars size new-text
159                  signature)
160   "In non-nil, Gnus will attempt to run some checks on outgoing posts.
161 If this variable is t, Gnus will check everything it can.  If it is a
162 list, then those elements in that list will be checked.")
163
164 (defvar gnus-delete-supersedes-headers "^Path:\\|^Date\\|^NNTP-Posting-Host:"
165   "*Header lines matching this regexp will be deleted before posting.
166 It's best to delete old Path and Date headers before psoting to avoid
167 any confusion.")
168
169 (defvar gnus-auto-mail-to-author nil
170   "*If non-nil, mail the authors of articles a copy of your follow-ups.
171 If this variable is `ask', the user will be prompted for whether to
172 mail a copy.  The string given by `gnus-mail-courtesy-message' will be
173 inserted at the beginning of the mail copy.
174
175 Mail is sent using the function specified by the
176 `gnus-mail-send-method' variable.")
177
178 ;; Added by Ethan Bradford <ethanb@ptolemy.astro.washington.edu>.
179 (defvar gnus-mail-courtesy-message
180   "The following message is a courtesy copy of an article\nthat has been posted as well.\n\n"
181   "*This is inserted at the start of a mailed copy of a posted message.
182 If this variable is nil, no such courtesy message will be added.")
183
184 (defvar gnus-mail-reply-method (function gnus-mail-reply-using-mail)
185   "*Function to compose a reply.
186 Three pre-made functions are `gnus-mail-reply-using-mail' (sendmail);
187 `gnus-mail-reply-using-mhe' (MH-E); and `gnus-mail-reply-using-vm'.")
188
189 (defvar gnus-mail-forward-method (function gnus-mail-forward-using-mail)
190   "*Function to forward the current message to another user.
191 Three pre-made functions are `gnus-mail-forward-using-mail' (sendmail);
192 `gnus-mail-forward-using-mhe' (MH-E); and `gnus-mail-forward-using-vm'.") 
193
194 (defvar gnus-mail-other-window-method 'gnus-mail-other-window-using-mail
195   "*Function to compose mail in the other window.
196 Three pre-made functions are `gnus-mail-other-window-using-mail'
197 (sendmail); `gnus-mail-other-window-using-mhe' (MH-E); and
198 `gnus-mail-other-window-using-vm'.")
199
200 (defvar gnus-mail-send-method send-mail-function
201   "*Function to mail a message which is also being posted as an article.
202 The message must have To or Cc header.  The default is copied from
203 the variable `send-mail-function'.")
204
205 (defvar gnus-inews-article-function 'gnus-inews-article
206   "*Function to post an article.")
207
208 (defvar gnus-inews-article-hook (list 'gnus-inews-do-fcc)
209   "*A hook called before finally posting an article.
210 The default hook (`gnus-inews-do-fcc') does FCC processing (ie. saves
211 the article to a file).")
212
213 (defvar gnus-inews-article-header-hook nil
214   "*A hook called after inserting the headers in an article to be posted.
215 The hook is called from the *post-news* buffer, narrowed to the
216 headers.")
217
218 (defvar gnus-mail-hook nil
219   "*A hook called as the last thing after setting up a mail buffer.")
220
221 ;;; Internal variables.
222
223 (defvar gnus-post-news-buffer "*post-news*")
224 (defvar gnus-mail-buffer "*mail*")
225 (defvar gnus-summary-send-map nil)
226 (defvar gnus-article-copy nil)
227 (defvar gnus-reply-subject nil)
228
229 \f
230 ;;;
231 ;;; Gnus Posting Functions
232 ;;;
233
234 (define-prefix-command 'gnus-summary-send-map)
235 (define-key gnus-summary-mode-map "S" 'gnus-summary-send-map)
236 (define-key gnus-summary-send-map "p" 'gnus-summary-post-news)
237 (define-key gnus-summary-send-map "f" 'gnus-summary-followup)
238 (define-key gnus-summary-send-map "F" 'gnus-summary-followup-with-original)
239 (define-key gnus-summary-send-map "b" 'gnus-summary-followup-and-reply)
240 (define-key gnus-summary-send-map "B" 'gnus-summary-followup-and-reply-with-original)
241 (define-key gnus-summary-send-map "c" 'gnus-summary-cancel-article)
242 (define-key gnus-summary-send-map "s" 'gnus-summary-supersede-article)
243 (define-key gnus-summary-send-map "r" 'gnus-summary-reply)
244 (define-key gnus-summary-send-map "R" 'gnus-summary-reply-with-original)
245 (define-key gnus-summary-send-map "m" 'gnus-summary-mail-other-window)
246 (define-key gnus-summary-send-map "u" 'gnus-uu-post-news)
247 (define-key gnus-summary-send-map "om" 'gnus-summary-mail-forward)
248 (define-key gnus-summary-send-map "op" 'gnus-summary-post-forward)
249 (define-key gnus-summary-send-map "Om" 'gnus-uu-digest-mail-forward)
250 (define-key gnus-summary-send-map "Op" 'gnus-uu-digest-post-forward)
251
252 ;;; Internal functions.
253
254 (defun gnus-number-base36 (num len)
255   (if (if (< len 0) (<= num 0) (= len 0))
256       ""
257     (concat (gnus-number-base36 (/ num 36) (1- len))
258             (char-to-string (aref "zyxwvutsrqponmlkjihgfedcba9876543210"
259                                   (% num 36))))))
260
261 ;;; Post news commands of Gnus group mode and summary mode
262
263 (defun gnus-group-mail ()
264   "Start composing a mail."
265   (interactive)
266   (funcall gnus-mail-other-window-method))
267
268 (defun gnus-group-post-news ()
269   "Post an article."
270   (interactive)
271   (let ((gnus-newsgroup-name nil))
272     (gnus-post-news 'post nil nil gnus-article-buffer)))
273
274 (defun gnus-summary-post-news ()
275   "Post an article."
276   (interactive)
277   (gnus-set-global-variables)
278   (gnus-post-news 'post gnus-newsgroup-name))
279
280 (defun gnus-summary-followup (yank &optional yank-articles)
281   "Compose a followup to an article.
282 If prefix argument YANK is non-nil, original article is yanked automatically."
283   (interactive "P")
284   (gnus-set-global-variables)
285   (if yank-articles (gnus-summary-goto-subject (car yank-articles)))
286   (save-window-excursion
287     (gnus-summary-select-article))
288   (let ((headers (gnus-get-header-by-number (gnus-summary-article-number)))
289         (gnus-newsgroup-name gnus-newsgroup-name))
290     ;; Check Followup-To: poster.
291     (set-buffer gnus-article-buffer)
292     (if (and gnus-use-followup-to
293              (string-equal "poster" (gnus-fetch-field "followup-to"))
294              (or (not (eq gnus-use-followup-to t))
295                  (not (gnus-y-or-n-p 
296                        "Do you want to ignore `Followup-To: poster'? "))))
297         ;; Mail to the poster. 
298         (gnus-summary-reply yank)
299       (gnus-post-news nil gnus-newsgroup-name
300                       headers gnus-article-buffer 
301                       (or yank-articles (not (not yank)))))))
302
303 (defun gnus-summary-followup-with-original (n)
304   "Compose a followup to an article and include the original article."
305   (interactive "P")
306   (gnus-summary-followup t (gnus-summary-work-articles n)))
307
308 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
309 (defun gnus-summary-followup-and-reply (yank &optional yank-articles)
310   "Compose a followup and do an auto mail to author."
311   (interactive "P")
312   (gnus-set-global-variables)
313   (let ((gnus-auto-mail-to-author t))
314     (gnus-summary-followup yank yank-articles)))
315
316 (defun gnus-summary-followup-and-reply-with-original (n)
317   "Compose a followup, include the original, and do an auto mail to author."
318   (interactive "P")
319   (gnus-summary-followup-and-reply t (gnus-summary-work-articles n)))
320
321 (defun gnus-summary-cancel-article (n)
322   "Cancel an article you posted."
323   (interactive "P")
324   (gnus-set-global-variables)
325   (let ((articles (gnus-summary-work-articles n)))
326     (while articles
327       (gnus-summary-select-article t nil nil (car articles))
328       (and (gnus-eval-in-buffer-window gnus-article-buffer (gnus-cancel-news))
329            (gnus-summary-mark-as-read (car articles) gnus-canceled-mark))
330       (gnus-summary-remove-process-mark (car articles))
331       (gnus-article-hide-headers-if-wanted)
332       (setq articles (cdr articles)))))
333
334 (defun gnus-summary-supersede-article ()
335   "Compose an article that will supersede a previous article.
336 This is done simply by taking the old article and adding a Supersedes
337 header line with the old Message-ID."
338   (interactive)
339   (gnus-set-global-variables)
340   (gnus-summary-select-article t)
341   (if (not
342        (string-equal
343         (downcase (mail-strip-quoted-names 
344                    (header-from gnus-current-headers)))
345         (downcase (mail-strip-quoted-names (gnus-inews-user-name)))))
346       (error "This article is not yours."))
347   (save-excursion
348     (set-buffer gnus-article-buffer)
349     (let ((buffer-read-only nil))
350       (goto-char (point-min))
351       (search-forward "\n\n" nil t)
352       (if (not (re-search-backward "^Message-ID: " nil t))
353           (error "No Message-ID in this article"))))
354   (if (gnus-post-news 'post gnus-newsgroup-name)
355       (progn
356         (erase-buffer)
357         (insert-buffer gnus-article-buffer)
358         (goto-char (point-min))
359         (search-forward "\n\n" nil t)
360         (if (not (re-search-backward "^Message-ID: " nil t))
361             (error "No Message-ID in this article")
362           (replace-match "Supersedes: " t t))
363         (search-forward "\n\n")
364         (forward-line -1)
365         (insert mail-header-separator)
366
367         (forward-line -1)
368         (narrow-to-region (point-min) (point))
369         (goto-char (point-min))
370         (and gnus-delete-supersedes-headers
371              (delete-matching-lines gnus-delete-supersedes-headers))
372         (widen))))
373
374 \f
375 ;;;###autoload
376 (defalias 'sendnews 'gnus-post-news)
377
378 ;;;###autoload
379 (defalias 'postnews 'gnus-post-news)
380
381 (defun gnus-copy-article-buffer (&optional article-buffer)
382   ;; make a copy of the article buffer with all text properties removed
383   ;; this copy is in the buffer gnus-article-copy.
384   ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
385   ;; this buffer should be passed to all mail/news reply/post routines.
386   (setq gnus-article-copy (get-buffer-create " *gnus article copy*"))
387   (buffer-disable-undo gnus-article-copy)
388   (or (memq gnus-article-copy gnus-buffer-list)
389       (setq gnus-buffer-list (cons gnus-article-copy gnus-buffer-list)))
390   (let ((article-buffer (or article-buffer gnus-article-buffer)))
391     (if (and (get-buffer article-buffer)
392              (buffer-name (get-buffer article-buffer)))
393         (save-excursion
394           (set-buffer article-buffer)
395           (widen)
396           (copy-to-buffer gnus-article-copy (point-min) (point-max))
397           (set-text-properties (point-min) (point-max) 
398                                nil gnus-article-copy)))))
399
400 (defun gnus-post-news (post &optional group header article-buffer yank subject)
401   "Begin editing a new USENET news article to be posted.
402 Type \\[describe-mode] in the buffer to get a list of commands."
403   (interactive (list t))
404   (gnus-copy-article-buffer article-buffer)
405   (if (or (not gnus-novice-user)
406           gnus-expert-user
407           (not (eq 'post 
408                    (nth 1 (assoc 
409                            (format "%s" (car (gnus-find-method-for-group 
410                                               gnus-newsgroup-name)))
411                            gnus-valid-select-methods))))
412           (and group
413                (assq 'to-address 
414                      (nth 5 (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))))
415           (gnus-y-or-n-p "Are you sure you want to post to all of USENET? "))
416       (let ((sumart (if (not post)
417                         (save-excursion
418                           (set-buffer gnus-summary-buffer)
419                           (cons (current-buffer) gnus-current-article))))
420             (from (and header (header-from header)))
421             (winconf (current-window-configuration))
422             real-group)
423         (and gnus-interactive-post
424              (not gnus-expert-user)
425              post (not group)
426              (progn
427                (setq group 
428                      (completing-read "Group: " gnus-active-hashtb))
429                (or subject
430                    (setq subject (read-string "Subject: ")))))
431         (setq mail-reply-buffer gnus-article-copy)
432
433         (let ((newsgroup-name (or group gnus-newsgroup-name "")))
434           (setq real-group (and group (gnus-group-real-name group)))
435           (setq gnus-post-news-buffer 
436                 (gnus-request-post-buffer 
437                  post real-group subject header gnus-article-copy
438                  (nth 2 (and group (gnus-gethash group gnus-newsrc-hashtb)))
439                  (or (cdr (assq 'to-group
440                                 (nth 5 (nth 2 (gnus-gethash 
441                                                newsgroup-name
442                                                gnus-newsrc-hashtb)))))
443                      (if (and (boundp 'gnus-followup-to-function)
444                               gnus-followup-to-function
445                               gnus-article-copy)
446                          (save-excursion
447                            (set-buffer gnus-article-copy)
448                            (funcall gnus-followup-to-function group))))
449                  gnus-use-followup-to))
450           (if post
451               (gnus-configure-windows 'post 'force)
452             (if yank
453                 (gnus-configure-windows 'followup-yank 'force)
454               (gnus-configure-windows 'followup 'force)))
455           (gnus-overload-functions)
456           (make-local-variable 'gnus-article-reply)
457           (make-local-variable 'gnus-article-check-size)
458           (make-local-variable 'gnus-reply-subject)
459           (setq gnus-reply-subject (and header (header-subject header)))
460           (setq gnus-article-reply sumart)
461           ;; Handle `gnus-auto-mail-to-author'.
462           ;; Suggested by Daniel Quinlan <quinlan@best.com>.
463           ;; Revised to respect Reply-To by Ulrik Dickow <dickow@nbi.dk>.
464           (let ((to (and (not post)
465                          (if (if (eq gnus-auto-mail-to-author 'ask)
466                                  (y-or-n-p "Also send mail to author? ")
467                                gnus-auto-mail-to-author)
468                              (or (save-excursion
469                                    (set-buffer gnus-article-copy)
470                                    (gnus-fetch-field "reply-to"))
471                                  from)))))
472             (if to
473                 (progn
474                   (if (mail-fetch-field "To")
475                       (progn
476                         (beginning-of-line)
477                         (insert "Cc: " to "\n"))
478                     (mail-position-on-field "To")
479                     (insert to)))))
480           ;; Handle author copy using BCC field.
481           (if (and gnus-mail-self-blind
482                    (not (mail-fetch-field "bcc")))
483               (progn
484                 (mail-position-on-field "Bcc")
485                 (insert (if (stringp gnus-mail-self-blind)
486                             gnus-mail-self-blind
487                           (user-login-name)))))
488           ;; Handle author copy using FCC field.
489           (if gnus-author-copy
490               (progn
491                 (mail-position-on-field "Fcc")
492                 (insert gnus-author-copy)))
493           (goto-char (point-min))
494           (if post 
495               (cond ((not group)
496                      (re-search-forward "^Newsgroup:" nil t)
497                      (end-of-line))
498                     ((not subject)
499                      (re-search-forward "^Subject:" nil t)
500                      (end-of-line))
501                     (t
502                      (re-search-forward 
503                       (concat "^" (regexp-quote mail-header-separator) "$"))
504                      (forward-line 1)))
505             (re-search-forward 
506              (concat "^" (regexp-quote mail-header-separator) "$"))
507             (forward-line 1)
508             (if (not yank)
509                 ()
510               (save-excursion 
511                 (if (not (listp yank))
512                     (news-reply-yank-original nil)
513                   (setq yank (reverse yank))
514                   (while yank
515                     (save-excursion
516                       (save-window-excursion
517                         (set-buffer gnus-summary-buffer)
518                         (gnus-summary-select-article nil nil nil (car yank))
519                         (gnus-summary-remove-process-mark (car yank)))
520                       (let ((mail-reply-buffer gnus-article-copy))
521                         (gnus-copy-article-buffer)
522                         (let ((news-reply-yank-message-id
523                                (save-excursion
524                                  (set-buffer gnus-article-copy)
525                                  (mail-fetch-field "message-id")))
526                               (news-reply-yank-from
527                                (save-excursion
528                                  (set-buffer gnus-article-copy)
529                                  (mail-fetch-field "from"))))
530                           (news-reply-yank-original nil))
531                         (setq yank (cdr yank)))))))))
532           (if gnus-post-prepare-function
533               (funcall gnus-post-prepare-function group))
534           (run-hooks 'gnus-post-prepare-hook)
535           (make-local-variable 'gnus-prev-winconf)
536           (setq gnus-prev-winconf winconf))))
537   (setq gnus-article-check-size (cons (buffer-size) (gnus-article-checksum)))
538   (message "")
539   t)
540
541 (defun gnus-inews-news (&optional use-group-method)
542   "Send a news message.
543 If given a prefix, and the group is a foreign group, this function
544 will attempt to use the foreign server to post the article."
545   (interactive "P")
546   (let* ((case-fold-search nil)
547          (server-running (gnus-server-opened gnus-current-select-method))
548          (reply gnus-article-reply)
549          error post-result)
550     (save-excursion
551       ;; Connect to default NNTP server if necessary.
552       ;; Suggested by yuki@flab.fujitsu.junet.
553       (gnus-start-news-server)          ;Use default server.
554       ;; NNTP server must be opened before current buffer is modified.
555       (widen)
556       (goto-char (point-min))
557       (run-hooks 'news-inews-hook)
558       (save-restriction
559         (narrow-to-region
560          (point-min)
561          (progn
562            (goto-char (point-min))
563            (re-search-forward 
564             (concat "^" (regexp-quote mail-header-separator) "$"))
565            (match-beginning 0)))
566
567         ;; Correct newsgroups field: change sequence of spaces to comma and 
568         ;; eliminate spaces around commas.  Eliminate imbedded line breaks.
569         (goto-char (point-min))
570         (if (search-forward-regexp "^Newsgroups: +" nil t)
571             (save-restriction
572               (narrow-to-region
573                (point)
574                (if (re-search-forward "^[^ \t]" nil 'end)
575                    (match-beginning 0)
576                  (point-max)))
577               (goto-char (point-min))
578               (replace-regexp "\n[ \t]+" " ") ;No line breaks (too confusing)
579               (goto-char (point-min))
580               (replace-regexp "[ \t\n]*,[ \t\n]*\\|[ \t]+" ",")))
581
582         ;; Added by Per Abrahamsen <abraham@iesd.auc.dk>.
583         ;; Help save the the world!
584         (or 
585          gnus-expert-user
586          (let ((newsgroups (mail-fetch-field "newsgroups"))
587                (followup-to (mail-fetch-field "followup-to"))
588                groups to)
589            (if (and (string-match "," newsgroups) (not followup-to))
590                (progn
591                  (while (string-match "," newsgroups)
592                    (setq groups
593                          (cons (list (substring newsgroups
594                                                 0 (match-beginning 0)))
595                                groups))
596                    (setq newsgroups (substring newsgroups (match-end 0))))
597                  (setq groups (nreverse (cons (list newsgroups) groups)))
598
599                  (setq to
600                        (completing-read "Followups to: (default all groups) "
601                                         groups))
602                  (if (> (length to) 0)
603                      (progn
604                        (goto-char (point-min))
605                        (insert "Followup-To: " to "\n")))))))
606
607         ;; Cleanup Followup-To.
608         (goto-char (point-min))
609         (if (search-forward-regexp "^Followup-To: +" nil t)
610             (save-restriction
611               (narrow-to-region
612                (point)
613                (if (re-search-forward "^[^ \t]" nil 'end)
614                    (match-beginning 0)
615                  (point-max)))
616               (goto-char (point-min))
617               (replace-regexp "\n[ \t]+" " ") ;No line breaks (too confusing)
618               (goto-char (point-min))
619               (replace-regexp "[ \t\n]*,[ \t\n]*\\|[ \t]+" ",")))
620
621         ;; Mail the message too if To:, Bcc:. or Cc: exists.
622         (let* ((types '("to" "bcc" "cc"))
623                (ty types)
624                fcc-line)
625           (while ty
626             (or (mail-fetch-field (car ty) nil t)
627                 (setq types (delete (car ty) types)))
628             (setq ty (cdr ty)))
629
630           (if (not types)
631               ;; We do not want to send mail.
632               ()
633             (if (not gnus-mail-send-method)
634                 (progn
635                   (ding)
636                   (gnus-message 
637                    1 "No mailer defined.  To: and/or Cc: fields ignored.")
638                   (sit-for 1))
639               (save-excursion
640                 ;; We want to remove Fcc, because we want to handle
641                 ;; that one ourselves...  
642                   
643                 (goto-char (point-min))
644                 (if (re-search-forward "^Fcc: " nil t)
645                     (progn
646                       (setq fcc-line
647                             (buffer-substring
648                              (progn (beginning-of-line) (point))
649                              (progn (forward-line 1) (point))))
650                       (forward-line -1)
651                       (gnus-delete-line)))
652
653                 ;; We generate a Message-ID so that the mail and the
654                 ;; news copy of the message both get the same ID.
655                 (or (mail-fetch-field "message-id")
656                     (progn
657                       (goto-char (point-max))
658                       (insert "Message-ID: " (gnus-inews-message-id) "\n")))
659
660                 (save-restriction
661                   (widen)
662                   (gnus-message 5 "Sending via mail...")
663
664                   (if (and gnus-mail-courtesy-message
665                            (or (member "to" types)
666                                (member "cc" types)))
667                       ;; We only want to insert the courtesy mail
668                       ;; message if we use to or cc; bcc should not
669                       ;; have one. Well, if both bcc and to are
670                       ;; present, it will get one anyway.
671                       (progn
672                         ;; Insert "courtesy" mail message.
673                         (goto-char (point-min))
674                         (re-search-forward
675                          (concat "^" (regexp-quote
676                                       mail-header-separator) "$"))
677                         (forward-line 1)
678                         (insert gnus-mail-courtesy-message)
679                         (funcall gnus-mail-send-method)
680                         (goto-char (point-min))
681                         (search-forward gnus-mail-courtesy-message)
682                         (replace-match "" t t))
683                     (funcall gnus-mail-send-method))
684
685                   (gnus-message 5 "Sending via mail...done")
686                       
687                   (goto-char (point-min))
688                   (narrow-to-region
689                    (point) 
690                    (re-search-forward 
691                     (concat "^" (regexp-quote mail-header-separator) "$")))
692                   (goto-char (point-min))
693                   (delete-matching-lines "^BCC:"))
694                 (if fcc-line
695                     (progn
696                       (goto-char (point-max))
697                       (insert fcc-line))))))))
698
699       ;; Send to server. 
700       (gnus-message 5 "Posting to USENET...")
701       (setq post-result (funcall gnus-inews-article-function use-group-method))
702       (cond ((eq post-result 'illegal)
703              (setq error t)
704              (ding))
705             (post-result
706              (gnus-message 5 "Posting to USENET...done")
707              (if (gnus-buffer-exists-p (car-safe reply))
708                  (progn
709                    (save-excursion
710                      (set-buffer gnus-summary-buffer)
711                      (gnus-summary-mark-article-as-replied 
712                       (cdr reply)))))
713              (set-buffer-modified-p nil))
714             (t
715              ;; We cannot signal an error.
716              (setq error t)
717              (ding)
718              (gnus-message 1 "Article rejected: %s" 
719                            (gnus-status-message gnus-select-method)))))
720     ;; If NNTP server is opened by gnus-inews-news, close it by myself.
721     (or server-running
722         (gnus-close-server (gnus-find-method-for-group gnus-newsgroup-name)))
723     (let ((conf gnus-prev-winconf))
724       (if (not error)
725           (progn
726             (bury-buffer)
727             ;; Restore last window configuration.
728             (and conf (set-window-configuration conf)))))))
729
730 (defun gnus-inews-check-post ()
731   "Check whether the post looks ok."
732   (or
733    (not gnus-check-before-posting)
734    (and 
735     ;; We narrow to the headers and check them first.
736     (save-excursion
737       (save-restriction
738         (goto-char (point-min))
739         (narrow-to-region 
740          (point) 
741          (progn
742            (re-search-forward 
743             (concat "^" (regexp-quote mail-header-separator) "$"))
744            (match-beginning 0)))
745         (goto-char (point-min))
746         (and 
747          ;; Check for commands in Subject.
748          (or 
749           (gnus-check-before-posting 'subject-cmsg)
750           (save-excursion
751             (if (string-match "^cmsg " (mail-fetch-field "subject"))
752                 (gnus-y-or-n-p
753                  "The control code \"cmsg \" is in the subject. Really post? ")
754               t)))
755          ;; Check for multiple identical headers.
756          (or (gnus-check-before-posting 'multiple-headers)
757              (save-excursion
758                (let (found)
759                  (while (and (not found) (re-search-forward "^[^ \t:]+: "
760                                                             nil t))
761                    (save-excursion
762                      (or (re-search-forward 
763                           (concat "^" (setq found
764                                             (buffer-substring 
765                                              (match-beginning 0) 
766                                              (- (match-end 0) 2))))
767                           nil t)
768                          (setq found nil))))
769                  (if found
770                      (gnus-y-or-n-p 
771                       (format "Multiple %s headers. Really post? " found))
772                    t))))
773          ;; Check for version and sendsys.
774          (or (gnus-check-before-posting 'sendsys)
775              (save-excursion
776                (if (re-search-forward "^Sendsys:\\|^Version:" nil t)
777                    (gnus-y-or-n-p
778                     (format "The article contains a %s command. Really post? "
779                             (buffer-substring (match-beginning 0) 
780                                               (1- (match-end 0)))))
781                  t)))
782          ;; Check the Message-Id header.
783          (or (gnus-check-before-posting 'message-id)
784              (save-excursion
785                (let* ((case-fold-search t)
786                       (message-id (mail-fetch-field "message-id")))
787                  (or (not message-id)
788                      (and (string-match "@" message-id)
789                           (string-match "@[^\\.]*\\." message-id))
790                      (gnus-y-or-n-p
791                       (format 
792                        "The Message-ID looks strange: \"%s\". Really post? "
793                        message-id))))))
794          ;; Check the From header.
795          (or (gnus-check-before-posting 'from)
796              (save-excursion
797                (let* ((case-fold-search t)
798                       (from (mail-fetch-field "from")))
799                  (cond
800                   ((not from)
801                    (gnus-y-or-n-p "There is no From line. Really post? "))
802                   ((not (string-match "@[^\\.]*\\." from))
803                    (gnus-y-or-n-p
804                     (format 
805                      "The address looks strange: \"%s\". Really post? " from)))
806                   ((string-match "(.*).*(.*)" from)
807                    (gnus-y-or-n-p
808                     (format
809                      "The From header looks strange: \"%s\". Really post? " 
810                      from)))
811                   (t t)))))
812          )))
813     ;; Check for long lines.
814     (or (gnus-check-before-posting 'long-lines)
815         (save-excursion
816           (goto-char (point-min))
817           (re-search-forward
818            (concat "^" (regexp-quote mail-header-separator) "$"))
819           (while (and
820                   (progn
821                     (end-of-line)
822                     (< (current-column) 80))
823                   (zerop (forward-line 1))))
824           (or (bolp)
825               (eobp)
826               (gnus-y-or-n-p
827                (format
828                 "You have lines longer than 79 characters.  Really post? ")))))
829     ;; Check for control characters.
830     (or (gnus-check-before-posting 'control-chars)
831         (save-excursion
832           (if (re-search-forward "[\000-\007\013\015-\037\200-\237]" nil t)
833               (gnus-y-or-n-p 
834                "The article contains control characters. Really post? ")
835             t)))
836     ;; Check excessive size.
837     (or (gnus-check-before-posting 'size)
838         (if (> (buffer-size) 60000)
839             (gnus-y-or-n-p
840              (format "The article is %d octets long. Really post? "
841                      (buffer-size)))
842           t))
843     ;; Use the (size . checksum) variable to see whether the
844     ;; article is empty or has only quoted text.
845     (or
846      (gnus-check-before-posting 'new-text)
847      (if (and (= (buffer-size) (car gnus-article-check-size))
848               (= (gnus-article-checksum) (cdr gnus-article-check-size)))
849          (gnus-y-or-n-p
850           "It looks like there's no new text in your article. Really post? ")
851        t))
852     ;; Check the length of the signature.
853     (or (gnus-check-before-posting 'signature)
854         (progn
855           (goto-char (point-max))
856           (if (not (re-search-backward gnus-signature-separator nil t))
857               t
858             (if (> (count-lines (point) (point-max)) 4)
859                 (gnus-y-or-n-p
860                  (format
861                   "Your .sig is %d lines; it should be max 4.  Really post? "
862                   (count-lines (point) (point-max))))
863               t)))))))
864
865 (defun gnus-article-checksum ()
866   (let ((sum 0))
867     (save-excursion
868       (while (not (eobp))
869         (setq sum (logxor sum (following-char)))
870         (forward-char 1)))
871     sum))
872
873 ;; Returns non-nil if this type is not to be checked.
874 (defun gnus-check-before-posting (type)
875   (not 
876    (or (not gnus-check-before-posting)
877        (if (listp gnus-check-before-posting)
878            (memq type gnus-check-before-posting)
879          t))))
880
881 (defun gnus-cancel-news ()
882   "Cancel an article you posted."
883   (interactive)
884   (if (or gnus-expert-user
885           (gnus-yes-or-no-p "Do you really want to cancel this article? "))
886       (let ((from nil)
887             (newsgroups nil)
888             (message-id nil)
889             (distribution nil))
890         (or (gnus-member-of-valid 'post gnus-newsgroup-name)
891             (error "This backend does not support canceling"))
892         (save-excursion
893           ;; Get header info. from original article.
894           (save-restriction
895             (gnus-article-show-all-headers)
896             (goto-char (point-min))
897             (search-forward "\n\n" nil 'move)
898             (narrow-to-region (point-min) (point))
899             (setq from (mail-fetch-field "from"))
900             (setq newsgroups (mail-fetch-field "newsgroups"))
901             (setq message-id (mail-fetch-field "message-id"))
902             (setq distribution (mail-fetch-field "distribution")))
903           ;; Verify if the article is absolutely user's by comparing
904           ;; user id with value of its From: field.
905           (if (not
906                (string-equal
907                 (downcase (mail-strip-quoted-names from))
908                 (downcase (mail-strip-quoted-names (gnus-inews-user-name)))))
909               (progn
910                 (ding) (gnus-message 3 "This article is not yours.")
911                 nil)
912             ;; Make control article.
913             (set-buffer (get-buffer-create " *Gnus-canceling*"))
914             (buffer-disable-undo (current-buffer))
915             (erase-buffer)
916             (insert "Newsgroups: " newsgroups "\n"
917                     "Subject: cancel " message-id "\n"
918                     "Control: cancel " message-id "\n"
919                     (if distribution
920                         (concat "Distribution: " distribution "\n")
921                       "")
922                     mail-header-separator "\n"
923                     "This is a cancel message from " from ".\n")
924             ;; Send the control article to NNTP server.
925             (gnus-message 5 "Canceling your article...")
926             (prog1
927                 (if (funcall gnus-inews-article-function)
928                     (gnus-message 5 "Canceling your article...done")
929                   (progn
930                     (ding) 
931                     (gnus-message 1 "Cancel failed; %s" 
932                                   (gnus-status-message gnus-newsgroup-name))
933                     nil)
934                   t)
935               ;; Kill the article buffer.
936               (kill-buffer (current-buffer))))))))
937
938 \f
939 ;;; Lowlevel inews interface
940
941 (defun gnus-inews-article (&optional use-group-method)
942   "Post an article in current buffer using NNTP protocol."
943   (let ((artbuf (current-buffer))
944         (tmpbuf (get-buffer-create " *Gnus-posting*")))
945     (widen)
946     (goto-char (point-max))
947     ;; require a newline at the end for inews to append .signature to
948     (or (= (preceding-char) ?\n)
949         (insert ?\n))
950     ;; Prepare article headers.  All message body such as signature
951     ;; must be inserted before Lines: field is prepared.
952     (save-restriction
953       (goto-char (point-min))
954       (narrow-to-region 
955        (point-min) 
956        (save-excursion
957          (re-search-forward 
958           (concat "^" (regexp-quote mail-header-separator) "$"))
959          (match-beginning 0)))
960       (gnus-inews-remove-headers)
961       (gnus-inews-insert-headers)
962       (run-hooks 'gnus-inews-article-header-hook)
963       (widen))
964     ;; Check whether the article is a good Net Citizen.
965     (if (and gnus-article-check-size
966              (not (gnus-inews-check-post)))
967         ;; Aber nein!
968         'illegal
969       ;; Looks ok, so we do the nasty.
970       (save-excursion
971         (set-buffer tmpbuf)
972         (buffer-disable-undo (current-buffer))
973         (erase-buffer)
974         (insert-buffer-substring artbuf)
975         ;; Remove the header separator.
976         (goto-char (point-min))
977         (re-search-forward
978          (concat "^" (regexp-quote mail-header-separator) "$"))
979         (replace-match "" t t)
980         ;; This hook may insert a signature.
981         (run-hooks 'gnus-prepare-article-hook)
982         ;; Run final inews hooks.  This hook may do FCC.
983         ;; The article must be saved before being posted because
984         ;; `gnus-request-post' modifies the buffer.
985         (run-hooks 'gnus-inews-article-hook)
986         ;; Post an article to NNTP server.
987         ;; Return NIL if post failed.
988         (prog1
989             (gnus-request-post 
990              (if use-group-method
991                  (gnus-find-method-for-group gnus-newsgroup-name)
992                gnus-select-method) use-group-method)
993           (kill-buffer (current-buffer)))))))
994
995 (defun gnus-inews-remove-headers ()
996   (let ((case-fold-search t))
997     ;; Remove NNTP-posting-host.
998     (goto-char (point-min))
999     (and (re-search-forward "^nntp-posting-host:" nil t)
1000          (delete-region (progn (beginning-of-line) (point))
1001                         (progn (forward-line 1) (point))))
1002     ;; Remove Bcc.
1003     (goto-char (point-min))
1004     (and (re-search-forward "^bcc:" nil t)
1005          (delete-region (progn (beginning-of-line) (point))
1006                         (progn (forward-line 1) (point))))))
1007   
1008 (defun gnus-inews-insert-headers ()
1009   "Prepare article headers.
1010 Headers already prepared in the buffer are not modified.
1011 Headers in `gnus-required-headers' will be generated."
1012   (let ((Date (gnus-inews-date))
1013         (Message-ID (gnus-inews-message-id))
1014         (Organization (gnus-inews-organization))
1015         (From (gnus-inews-user-name))
1016         (Path (gnus-inews-path))
1017         (Subject nil)
1018         (Newsgroups nil)
1019         (Distribution nil)
1020         (Lines (gnus-inews-lines))
1021         (X-Newsreader gnus-version)
1022         (headers gnus-required-headers)
1023         (case-fold-search t)
1024         header value elem)
1025     ;; First we remove any old generated headers.
1026     (let ((headers gnus-deletable-headers))
1027       (while headers
1028         (goto-char (point-min))
1029         (and (re-search-forward 
1030               (concat "^" (symbol-name (car headers)) ": *") nil t)
1031              (get-text-property (1+ (match-beginning 0)) 'gnus-deletable)
1032              (gnus-delete-line))
1033         (setq headers (cdr headers))))
1034     ;; If there are References, and no "Re: ", then the thread has
1035     ;; changed name. See Son-of-1036.
1036     (if (and (mail-fetch-field "references")
1037              (get-buffer gnus-article-buffer))
1038         (let ((psubject (gnus-simplify-subject-re
1039                          (mail-fetch-field "subject"))))
1040           (or (and psubject gnus-reply-subject 
1041                    (string= (gnus-simplify-subject-re gnus-reply-subject)
1042                             psubject))
1043               (progn
1044                 (string-match "@" Message-ID)
1045                 (setq Message-ID
1046                       (concat (substring Message-ID 0 (match-beginning 0))
1047                               "_-_" 
1048                               (substring Message-ID (match-beginning 0))))))))
1049     ;; Go through all the required headers and see if they are in the
1050     ;; articles already. If they are not, or are empty, they are
1051     ;; inserted automatically - except for Subject, Newsgroups and
1052     ;; Distribution. 
1053     (while headers
1054       (goto-char (point-min))
1055       (setq elem (car headers))
1056       (if (consp elem)
1057           (setq header (car elem))
1058         (setq header elem))
1059       (if (or (not (re-search-forward 
1060                     (concat "^" (downcase (symbol-name header)) ":") nil t))
1061               (progn
1062                 (if (= (following-char) ? ) (forward-char 1) (insert " "))
1063                 (looking-at "[ \t]*$")))
1064           (progn
1065             (setq value 
1066                   (or (if (consp elem)
1067                           ;; The element is a cons.  Either the cdr is
1068                           ;; a string to be inserted verbatim, or it
1069                           ;; is a function, and we insert the value
1070                           ;; returned from this function.
1071                           (or (and (stringp (cdr elem)) (cdr elem))
1072                               (and (fboundp (cdr elem)) (funcall (cdr elem))))
1073                         ;; The element is a symbol.  We insert the
1074                         ;; value of this symbol, if any.
1075                         (and (boundp header) (symbol-value header)))
1076                       ;; We couldn't generate a value for this header,
1077                       ;; so we just ask the user.
1078                       (read-from-minibuffer
1079                        (format "Empty header for %s; enter value: " header))))
1080             ;; Finally insert the header.
1081             (save-excursion
1082               (if (bolp)
1083                   (progn
1084                     (goto-char (point-max))
1085                     (insert (symbol-name header) ": " value "\n")
1086                     (forward-line -1))
1087                 (replace-match value t t))
1088               ;; Add the deletable property to the headers that require it.
1089               (and (memq header gnus-deletable-headers)
1090                    (progn (beginning-of-line) (looking-at "[^:]+: "))
1091                    (add-text-properties 
1092                     (point) (match-end 0)
1093                     '(gnus-deletable t face italic) (current-buffer))))))
1094       (setq headers (cdr headers)))
1095     ;; Insert new Sender if the From is strange. 
1096     (let ((from (mail-fetch-field "from")))
1097       (if (and from (not (string=
1098                           (downcase (car (gnus-extract-address-components 
1099                                           from)))
1100                           (downcase (gnus-inews-real-user-address)))))
1101           (progn
1102             (goto-char (point-min))    
1103             (and (re-search-forward "^Sender:" nil t)
1104                  (progn
1105                    (beginning-of-line)
1106                    (insert "Original-")
1107                    (beginning-of-line)))
1108             (insert "Sender: " (gnus-inews-real-user-address) "\n"))))))
1109
1110
1111 (defun gnus-inews-insert-signature ()
1112   "Insert a signature file.
1113 If `gnus-signature-function' is bound and returns a string, this
1114 string is used instead of the variable `gnus-signature-file'.
1115 In either case, if the string is a file name, this file is
1116 inserted. If the string is not a file name, the string itself is
1117 inserted. 
1118 If you never want any signature inserted, set both those variables to
1119 nil."
1120   (save-excursion
1121     (let ((signature 
1122            (or (and gnus-signature-function
1123                     (funcall gnus-signature-function gnus-newsgroup-name))
1124                gnus-signature-file)))
1125       (if (and signature
1126                (or (file-exists-p signature)
1127                    (string-match " " signature)
1128                    (not (string-match 
1129                          "^/[^/]+/" (expand-file-name signature)))))
1130           (progn
1131             (goto-char (point-max))
1132             (if (and mail-signature (search-backward "\n-- \n" nil t))
1133                 ()
1134               ;; Delete any previous signatures.
1135               (if (search-backward "\n-- \n" nil t)
1136                   (delete-region (point) (point-max)))
1137               (or (eolp) (insert "\n"))
1138               (insert "-- \n")
1139               (if (file-exists-p signature)
1140                   (insert-file-contents signature)
1141                 (insert signature))
1142               (goto-char (point-max))
1143               (or (bolp) (insert "\n"))))))))
1144
1145 ;; Written by "Mr. Per Persson" <pp@solace.mh.se>.
1146 (defun gnus-inews-insert-mime-headers ()
1147   (let ((mail-header-separator ""))
1148     (or (mail-position-on-field "Mime-Version")
1149         (insert "1.0")
1150         (cond ((save-excursion
1151                  (beginning-of-buffer)
1152                  (re-search-forward "[\200-\377]" nil t))
1153                (or (mail-position-on-field "Content-Type")
1154                    (insert "text/plain; charset=ISO-8859-1"))
1155                (or (mail-position-on-field "Content-Transfer-Encoding")
1156                    (insert "8bit")))
1157               (t (or (mail-position-on-field "Content-Type")
1158                      (insert "text/plain; charset=US-ASCII"))
1159                  (or (mail-position-on-field "Content-Transfer-Encoding")
1160                      (insert "7bit")))))))
1161
1162 (defun gnus-inews-do-fcc ()
1163   "Process FCC: fields in current article buffer.
1164 Unless the first character of the field is `|', the article is saved
1165 to the specified file using the function specified by the variable
1166 gnus-author-copy-saver.  The default function rmail-output saves in
1167 Unix mailbox format.
1168 If the first character is `|', the contents of the article is send to
1169 a program specified by the rest of the value."
1170   (let ((fcc-list nil)
1171         (fcc-file nil)
1172         (case-fold-search t))           ;Should ignore case.
1173     (save-excursion
1174       (save-restriction
1175         (goto-char (point-min))
1176         (search-forward "\n\n")
1177         (narrow-to-region (point-min) (point))
1178         (goto-char (point-min))
1179         (while (re-search-forward "^FCC:[ \t]*" nil t)
1180           (setq fcc-list
1181                 (cons (buffer-substring
1182                        (point)
1183                        (progn
1184                          (end-of-line)
1185                          (skip-chars-backward " \t")
1186                          (point)))
1187                       fcc-list))
1188           (delete-region (match-beginning 0)
1189                          (progn (forward-line 1) (point))))
1190         ;; Process FCC operations.
1191         (widen)
1192         (while fcc-list
1193           (setq fcc-file (car fcc-list))
1194           (setq fcc-list (cdr fcc-list))
1195           (cond ((string-match "^[ \t]*|[ \t]*\\(.*\\)[ \t]*$" fcc-file)
1196                  (let ((program (substring fcc-file
1197                                            (match-beginning 1) (match-end 1))))
1198                    ;; Suggested by yuki@flab.fujitsu.junet.
1199                    ;; Send article to named program.
1200                    (call-process-region (point-min) (point-max) shell-file-name
1201                                         nil nil nil "-c" program)))
1202                 (t
1203                  ;; Suggested by hyoko@flab.fujitsu.junet.
1204                  ;; Save article in Unix mail format by default.
1205                  (gnus-make-directory (file-name-directory fcc-file))
1206                  (if (and gnus-author-copy-saver
1207                           (not (eq gnus-author-copy-saver 'rmail-output)))
1208                      (funcall gnus-author-copy-saver fcc-file)
1209                    (if (and (file-readable-p fcc-file) (rmail-file-p fcc-file))
1210                        (gnus-output-to-rmail fcc-file)
1211                      (rmail-output fcc-file 1 t t))))))))))
1212
1213 (defun gnus-inews-path ()
1214   "Return uucp path."
1215   (let ((login-name (gnus-inews-login-name)))
1216     (cond ((null gnus-use-generic-path)
1217            (concat (nth 1 gnus-select-method) "!" login-name))
1218           ((stringp gnus-use-generic-path)
1219            ;; Support GENERICPATH.  Suggested by vixie@decwrl.dec.com.
1220            (concat gnus-use-generic-path "!" login-name))
1221           (t login-name))))
1222
1223 (defun gnus-inews-user-name ()
1224   "Return user's network address as \"NAME@DOMAIN (FULL-NAME)\"."
1225   (let ((full-name (gnus-inews-full-name)))
1226     (or gnus-user-from-line
1227         (concat (if (or gnus-user-login-name gnus-use-generic-from
1228                         gnus-local-domain (getenv "DOMAINNAME"))
1229                     (concat (gnus-inews-login-name) "@"
1230                             (gnus-inews-domain-name gnus-use-generic-from))
1231                   user-mail-address)
1232                 ;; User's full name.
1233                 (cond ((string-equal full-name "") "")
1234                       ((string-equal full-name "&") ;Unix hack.
1235                        (concat " (" (user-login-name) ")"))
1236                       (t
1237                        (concat " (" full-name ")")))))))
1238
1239 (defun gnus-inews-real-user-address ()
1240   "Return the \"real\" user address.
1241 This function tries to ignore all user modifications, and 
1242 give as trustworthy answer as possible."
1243   (concat (user-login-name) "@" (gnus-inews-full-address)))
1244
1245 (defun gnus-inews-login-name ()
1246   "Return login name."
1247   (or gnus-user-login-name (getenv "LOGNAME") (user-login-name)))
1248
1249 (defun gnus-inews-full-name ()
1250   "Return full user name."
1251   (or gnus-user-full-name (getenv "NAME") (user-full-name)))
1252
1253 (defun gnus-inews-domain-name (&optional genericfrom)
1254   "Return user's domain name.
1255 If optional argument GENERICFROM is a string, use it as the domain
1256 name; if it is non-nil, strip off local host name from the domain name.
1257 If the function `system-name' returns full internet name and the
1258 domain is undefined, the domain name is got from it."
1259   (if (or genericfrom gnus-local-domain (getenv "DOMAINNAME"))
1260       (let* ((system-name (system-name))
1261              (domain 
1262               (or (if (stringp genericfrom) genericfrom)
1263                   (getenv "DOMAINNAME")
1264                   gnus-local-domain
1265                   ;; Function `system-name' may return full internet name.
1266                   ;; Suggested by Mike DeCorte <mrd@sun.soe.clarkson.edu>.
1267                   (if (string-match "\\." system-name)
1268                       (substring system-name (match-end 0)))
1269                   (read-string "Domain name (no host): ")))
1270              (host (or (if (string-match "\\." system-name)
1271                            (substring system-name 0 (match-beginning 0)))
1272                        system-name)))
1273         (if (string-equal "." (substring domain 0 1))
1274             (setq domain (substring domain 1)))
1275         ;; Support GENERICFROM as same as standard Bnews system.
1276         ;; Suggested by ohm@kaba.junet and vixie@decwrl.dec.com.
1277         (cond ((null genericfrom)
1278                (concat host "." domain))
1279               ;;((stringp genericfrom) genericfrom)
1280               (t domain)))
1281     (if (string-match "\\." (system-name))
1282         (system-name)
1283       (substring user-mail-address 
1284                  (1+ (string-match "@" user-mail-address))))))
1285
1286 (defun gnus-inews-full-address ()
1287   (let ((domain (gnus-inews-domain-name))
1288         (system (system-name))
1289         (case-fold-search t))
1290     (if (string-match "\\." system) system
1291       (if (string-match (concat "^" (regexp-quote system)) domain) domain
1292         (concat system "." domain)))))
1293
1294 (defun gnus-inews-message-id ()
1295   "Generate unique Message-ID for user."
1296   ;; Message-ID should not contain a slash and should be terminated by
1297   ;; a number.  I don't know the reason why it is so.
1298   (concat "<" (gnus-inews-unique-id) "@" (gnus-inews-full-address) ">"))
1299
1300 (defvar gnus-unique-id-char nil)
1301
1302 ;; If you ever change this function, make sure the new version
1303 ;; cannot generate IDs that the old version could.
1304 ;; You might for example insert a "." somewhere (not next to another dot
1305 ;; or string boundary), or modify the newsreader name to "Ding".
1306 (defun gnus-inews-unique-id ()
1307   ;; Dont use microseconds from (current-time), they may be unsupported.
1308   ;; Instead we use this randomly inited counter.
1309   (setq gnus-unique-id-char
1310         (% (1+ (or gnus-unique-id-char (logand (random t) (1- (lsh 1 20)))))
1311            ;; (current-time) returns 16-bit ints,
1312            ;; and 2^16*25 just fits into 4 digits i base 36.
1313            (* 25 25)))
1314   (let ((tm (if (fboundp 'current-time)
1315                 (current-time) '(12191 46742 287898))))
1316     (concat
1317      (if (memq system-type '(ms-dos emx vax-vms))
1318          (let ((user (downcase (gnus-inews-login-name))))
1319            (while (string-match "[^a-z0-9_]" user)
1320              (aset user (match-beginning 0) ?_))
1321            user)
1322        (gnus-number-base36 (user-uid) -1))
1323      (gnus-number-base36 (+ (car   tm) (lsh (% gnus-unique-id-char 25) 16)) 4)
1324      (gnus-number-base36 (+ (nth 1 tm) (lsh (/ gnus-unique-id-char 25) 16)) 4)
1325      ;; Append the newsreader name, because while the generated
1326      ;; ID is unique to this newsreader, other newsreaders might
1327      ;; otherwise generate the same ID via another algorithm.
1328      ".fsf")))
1329
1330
1331 (defun gnus-inews-date ()
1332   "Current time string."
1333   (timezone-make-date-arpa-standard 
1334    (current-time-string) (current-time-zone)))
1335
1336 (defun gnus-inews-organization ()
1337   "Return user's organization.
1338 The ORGANIZATION environment variable is used if defined.
1339 If not, the variable `gnus-local-organization' is used instead.
1340 If it is a function, the function will be called with the current
1341 newsgroup name as the argument.
1342 If this is a file name, the contents of this file will be used as the
1343 organization."
1344   (let* ((organization 
1345           (or (getenv "ORGANIZATION")
1346               (if gnus-local-organization
1347                   (if (and (symbolp gnus-local-organization)
1348                            (fboundp gnus-local-organization))
1349                       (funcall gnus-local-organization gnus-newsgroup-name)
1350                     gnus-local-organization))
1351               gnus-organization-file
1352               "~/.organization")))
1353     (and (stringp organization)
1354          (> (length organization) 0)
1355          (or (file-exists-p organization)
1356              (string-match " " organization)
1357              (not (string-match "^/usr/lib/" organization)))
1358          (save-excursion
1359            (gnus-set-work-buffer)
1360            (if (file-exists-p organization)
1361                (insert-file-contents organization)
1362              (insert organization))
1363            (goto-char (point-min))
1364            (while (re-search-forward " *\n *" nil t)
1365              (replace-match " " t t))
1366            (buffer-substring (point-min) (point-max))))))
1367
1368 (defun gnus-inews-lines ()
1369   "Count the number of lines and return numeric string."
1370   (save-excursion
1371     (save-restriction
1372       (widen)
1373       (goto-char (point-min))
1374       (re-search-forward 
1375        (concat "^" (regexp-quote mail-header-separator) "$"))
1376       (forward-line 1)
1377       (int-to-string (count-lines (point) (point-max))))))
1378
1379 \f
1380 ;;;
1381 ;;; Gnus Mail Functions 
1382 ;;;
1383
1384 ;;; Mail reply commands of Gnus summary mode
1385
1386 (defun gnus-summary-reply (yank &optional yank-articles)
1387   "Reply mail to news author.
1388 If prefix argument YANK is non-nil, original article is yanked automatically.
1389 Customize the variable gnus-mail-reply-method to use another mailer."
1390   (interactive "P")
1391   ;; Bug fix by jbw@bigbird.bu.edu (Joe Wells)
1392   ;; Stripping headers should be specified with mail-yank-ignored-headers.
1393   (gnus-set-global-variables)
1394   (if yank-articles (gnus-summary-goto-subject (car yank-articles)))
1395   (gnus-summary-select-article)
1396   (let ((gnus-newsgroup-name gnus-newsgroup-name))
1397     (bury-buffer gnus-article-buffer)
1398     (funcall gnus-mail-reply-method (or yank-articles (not (not yank))))))
1399
1400 (defun gnus-summary-reply-with-original (n)
1401   "Reply mail to news author with original article.
1402 Customize the variable gnus-mail-reply-method to use another mailer."
1403   (interactive "P")
1404   (gnus-summary-reply t (gnus-summary-work-articles n)))
1405
1406 (defun gnus-summary-mail-forward (post)
1407   "Forward the current message to another user.
1408 Customize the variable gnus-mail-forward-method to use another mailer."
1409   (interactive "P")
1410   (gnus-set-global-variables)
1411   (gnus-summary-select-article)
1412   (gnus-copy-article-buffer)
1413   (let ((gnus-newsgroup-name gnus-newsgroup-name))
1414     (if post
1415         (gnus-forward-using-post gnus-article-copy)
1416       (funcall gnus-mail-forward-method gnus-article-copy))))
1417
1418 (defun gnus-summary-post-forward ()
1419   "Forward the current article to a newsgroup."
1420   (interactive)
1421   (gnus-summary-mail-forward t))
1422
1423 (defvar gnus-nastygram-message 
1424   "The following article was inappropriately posted to %s.\n"
1425   "Format string to insert in nastygrams.
1426 The current group name will be inserted at \"%s\".")
1427
1428 (defun gnus-summary-mail-nastygram (n)
1429   "Send a nastygram to the author of the current article."
1430   (interactive "P")
1431   (if (or gnus-expert-user
1432           (gnus-y-or-n-p 
1433            "Really send a nastygram to the author of the current article? "))
1434       (let ((group gnus-newsgroup-name))
1435         (gnus-summary-reply-with-original n)
1436         (set-buffer gnus-mail-buffer)
1437         (insert (format gnus-nastygram-message group))
1438         (gnus-mail-send-and-exit))))
1439
1440 (defun gnus-summary-mail-other-window ()
1441   "Compose mail in other window.
1442 Customize the variable `gnus-mail-other-window-method' to use another
1443 mailer."
1444   (interactive)
1445   (gnus-set-global-variables)
1446   (let ((gnus-newsgroup-name gnus-newsgroup-name))
1447     (funcall gnus-mail-other-window-method)))
1448
1449 (defun gnus-mail-reply-using-mail (&optional yank to-address)
1450   (save-excursion
1451     (set-buffer gnus-summary-buffer)
1452     (let ((group (gnus-group-real-name gnus-newsgroup-name))
1453           (cur (cons (current-buffer) (cdr gnus-article-current)))
1454           (winconf (current-window-configuration))
1455           from subject date reply-to message-of
1456           references message-id sender follow-to sendto elt)
1457       (set-buffer (get-buffer-create gnus-mail-buffer))
1458       (mail-mode)
1459       (make-local-variable 'gnus-article-reply)
1460       (setq gnus-article-reply cur)
1461       (make-local-variable 'gnus-prev-winconf)
1462       (setq gnus-prev-winconf winconf)
1463       (if (and (buffer-modified-p)
1464                (> (buffer-size) 0)
1465                (not (gnus-y-or-n-p 
1466                      "Unsent article being composed; erase it? ")))
1467           ()
1468         (erase-buffer)
1469         (save-excursion
1470           (gnus-copy-article-buffer)
1471           (save-restriction
1472             (set-buffer gnus-article-copy)
1473             (gnus-narrow-to-headers)
1474             (if (and (boundp 'gnus-reply-to-function)
1475                      gnus-reply-to-function)
1476                 (setq follow-to (funcall gnus-reply-to-function group)))
1477             (setq from (mail-fetch-field "from"))
1478             (setq date (or (mail-fetch-field "date") 
1479                            (header-date gnus-current-headers)))
1480             (and from
1481                  (let ((stop-pos 
1482                         (string-match "  *at \\|  *@ \\| *(\\| *<" from)))
1483                    (setq message-of
1484                          (concat (if stop-pos (substring from 0 stop-pos) from)
1485                                  "'s message of " date))))
1486             (setq sender (mail-fetch-field "sender"))
1487             (setq subject (or (mail-fetch-field "subject")
1488                               "Re: none"))
1489             (or (string-match "^[Rr][Ee]:" subject)
1490                 (setq subject (concat "Re: " subject)))
1491             (setq reply-to (mail-fetch-field "reply-to"))
1492             (setq references (mail-fetch-field "references"))
1493             (setq message-id (mail-fetch-field "message-id"))
1494             (widen))
1495           (setq news-reply-yank-from (or from "(nobody)")))
1496         (setq news-reply-yank-message-id
1497               (or message-id "(unknown Message-ID)"))
1498
1499         ;; Gather the "to" addresses out of the follow-to list and remove
1500         ;; them as we go.
1501         (if (and follow-to (listp follow-to))
1502             (while (setq elt (assoc "To" follow-to))
1503               (setq sendto (concat sendto (and sendto ", ") (cdr elt)))
1504               (setq follow-to (delq elt follow-to))))
1505
1506         (mail-setup (or to-address 
1507                         (if (and follow-to (not (stringp follow-to))) sendto
1508                           (or follow-to reply-to from sender "")))
1509                     subject message-of nil gnus-article-copy nil)
1510
1511         (use-local-map (copy-keymap mail-mode-map))
1512         (local-set-key "\C-c\C-c" 'gnus-mail-send-and-exit)
1513
1514         (if (and follow-to (listp follow-to))
1515             (progn
1516               (goto-char (point-min))
1517               (re-search-forward "^To:" nil t)
1518               (beginning-of-line)
1519               (forward-line 1)
1520               (while follow-to
1521                 (insert (car (car follow-to)) ": " (cdr (car follow-to)) "\n")
1522                 (setq follow-to (cdr follow-to)))))
1523         ;; Fold long references line to follow RFC1036.
1524         (mail-position-on-field "References")
1525         (let ((begin (- (point) (length "References: ")))
1526               (fill-column 78)
1527               (fill-prefix "\t"))
1528           (if references (insert references))
1529           (if (and references message-id) (insert " "))
1530           (if message-id (insert message-id))
1531           ;; The region must end with a newline to fill the region
1532           ;; without inserting extra newline.
1533           (fill-region-as-paragraph begin (1+ (point))))
1534         (goto-char (point-min))
1535         (re-search-forward
1536          (concat "^" (regexp-quote mail-header-separator) "$"))
1537         (forward-line 1)
1538         (if (not yank)
1539             (gnus-configure-windows 'reply 'force)
1540           (let ((last (point))
1541                 end)
1542             (if (not (listp yank))
1543                 (progn
1544                   (save-excursion
1545                     (mail-yank-original nil))
1546                   (or mail-yank-hooks mail-citation-hook
1547                       (run-hooks 'news-reply-header-hook)))
1548               (while yank
1549                 (save-window-excursion
1550                   (set-buffer gnus-summary-buffer)
1551                   (gnus-summary-select-article nil nil nil (car yank))
1552                   (gnus-summary-remove-process-mark (car yank)))
1553                 (save-excursion
1554                   (gnus-copy-article-buffer)
1555                   (mail-yank-original nil)
1556                   (setq end (point)))
1557                 (or mail-yank-hooks mail-citation-hook
1558                     (run-hooks 'news-reply-header-hook))
1559                 (goto-char end)
1560                 (setq yank (cdr yank))))
1561             (goto-char last))
1562           (gnus-configure-windows 'reply-yank 'force))
1563         (run-hooks 'gnus-mail-hook)))))
1564
1565 (defun gnus-mail-yank-original ()
1566   (interactive)
1567   (save-excursion
1568    (mail-yank-original nil))
1569   (or mail-yank-hooks mail-citation-hook
1570       (run-hooks 'news-reply-header-hook)))
1571
1572 (defun gnus-mail-send-and-exit ()
1573   (interactive)
1574   (let ((reply gnus-article-reply)
1575         (winconf gnus-prev-winconf))
1576     (mail-send-and-exit nil)
1577     (if (get-buffer gnus-group-buffer)
1578         (progn
1579           (if (gnus-buffer-exists-p (car-safe reply))
1580               (progn
1581                 (set-buffer (car reply))
1582                 (and (cdr reply)
1583                      (gnus-summary-mark-article-as-replied 
1584                       (cdr reply)))))
1585           (and winconf (set-window-configuration winconf))))))
1586
1587 (defun gnus-forward-make-subject (buffer)
1588   (save-excursion
1589     (set-buffer buffer)
1590     (concat "[" (if (memq 'mail (assoc (symbol-name 
1591                                         (car (gnus-find-method-for-group 
1592                                               gnus-newsgroup-name)))
1593                                        gnus-valid-select-methods))
1594                     (gnus-fetch-field "From")
1595                 gnus-newsgroup-name)
1596             "] " (or (gnus-fetch-field "Subject") ""))))
1597
1598 (defun gnus-forward-insert-buffer (buffer)
1599   (let ((beg (goto-char (point-max))))
1600     (insert "------- Start of forwarded message -------\n")
1601     (insert-buffer buffer)
1602     (goto-char (point-max))
1603     (insert "------- End of forwarded message -------\n")
1604     ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>. 
1605     (goto-char beg)
1606     (while (setq beg (next-single-property-change (point) 'invisible))
1607       (goto-char beg)
1608       (delete-region beg (or (next-single-property-change 
1609                               (point) 'invisible)
1610                              (point-max))))))
1611
1612 (defun gnus-mail-forward-using-mail (&optional buffer)
1613   "Forward the current message to another user using mail."
1614   ;; This is almost a carbon copy of rmail-forward in rmail.el.
1615   (let* ((forward-buffer (or buffer (current-buffer)))
1616          (winconf (current-window-configuration))
1617          (subject (gnus-forward-make-subject forward-buffer)))
1618     (set-buffer forward-buffer)
1619     (mail nil nil subject)
1620     (use-local-map (copy-keymap (current-local-map)))
1621     (local-set-key "\C-c\C-c" 'gnus-mail-send-and-exit)
1622     (make-local-variable 'gnus-prev-winconf)
1623     (setq gnus-prev-winconf winconf)
1624     (gnus-forward-insert-buffer forward-buffer)
1625     (goto-char (point-min))
1626     (re-search-forward "^To: " nil t)
1627     (gnus-configure-windows 'mail-forward 'force)
1628     ;; You have a chance to arrange the message.
1629     (run-hooks 'gnus-mail-forward-hook)
1630     (run-hooks 'gnus-mail-hook)))
1631
1632 (defun gnus-forward-using-post (&optional buffer)
1633   (save-excursion
1634     (let* ((forward-buffer (or buffer (current-buffer))) 
1635            (subject (gnus-forward-make-subject forward-buffer))
1636            (gnus-newsgroup-name nil))
1637       (gnus-post-news 'post nil nil nil nil subject)
1638       (save-excursion
1639         (gnus-forward-insert-buffer forward-buffer)
1640         ;; You have a chance to arrange the message.
1641         (run-hooks 'gnus-mail-forward-hook)))))
1642
1643 (defun gnus-mail-other-window-using-mail ()
1644   "Compose mail other window using mail."
1645   (let ((winconf (current-window-configuration)))
1646     (mail-other-window nil nil nil nil nil (get-buffer gnus-article-buffer))
1647     (use-local-map (copy-keymap (current-local-map)))
1648     (local-set-key "\C-c\C-c" 'gnus-mail-send-and-exit)
1649     (make-local-variable 'gnus-prev-winconf)
1650     (setq gnus-prev-winconf winconf)
1651     (run-hooks 'gnus-mail-hook)
1652     (gnus-configure-windows 'summary-mail 'force)))
1653
1654 (defun gnus-article-mail (yank)
1655   "Send a reply to the address near point.
1656 If YANK is non-nil, include the original article."
1657   (interactive "P")
1658   (let ((address 
1659          (buffer-substring
1660           (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
1661           (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
1662     (and address
1663          (progn
1664            (switch-to-buffer gnus-summary-buffer)
1665            (funcall gnus-mail-reply-method yank address)))))
1666
1667 (defun gnus-article-mail-with-original ()
1668   "Send a reply to the address near point and include the original article."
1669   (interactive)
1670   (gnus-article-mail 'yank))
1671
1672 (defun gnus-bug ()
1673   "Send a bug report to the Gnus maintainers."
1674   (interactive)
1675   (let ((winconf (current-window-configuration)))
1676     (delete-other-windows)
1677     (switch-to-buffer "*Gnus Help Bug*")
1678     (erase-buffer)
1679     (insert gnus-bug-message)
1680     (goto-char (point-min))
1681     (pop-to-buffer "*Gnus Bug*")
1682     (erase-buffer)
1683     (mail-mode)
1684     (mail-setup gnus-maintainer nil nil nil nil nil)
1685     (make-local-variable 'gnus-prev-winconf)
1686     (setq gnus-prev-winconf winconf)
1687     (use-local-map (copy-keymap mail-mode-map))
1688     (local-set-key "\C-c\C-c" 'gnus-bug-mail-send-and-exit)
1689     (goto-char (point-min))
1690     (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
1691     (forward-line 1)
1692     (insert (format "%s\n%s\n\n\n\n\n" (gnus-version) (emacs-version)))
1693     (gnus-debug)
1694     (goto-char (point-min))
1695     (search-forward "Subject: " nil t)
1696     (message "")))
1697
1698 (defun gnus-bug-mail-send-and-exit ()
1699   "Send the bug message and exit."
1700   (interactive)
1701   (and (get-buffer "*Gnus Help Bug*")
1702        (kill-buffer "*Gnus Help Bug*"))
1703   (gnus-mail-send-and-exit))
1704
1705 (defun gnus-debug ()
1706   "Attemps to go through the Gnus source file and report what variables have been changed.
1707 The source file has to be in the Emacs load path."
1708   (interactive)
1709   (let ((files '("gnus.el" "gnus-msg.el" "gnus-score.el"))
1710         file dirs expr olist sym)
1711     (message "Please wait while we snoop your variables...")
1712     (sit-for 0)
1713     (save-excursion
1714       (set-buffer (get-buffer-create " *gnus bug info*"))
1715       (buffer-disable-undo (current-buffer))
1716       (while files
1717         (erase-buffer)
1718         (setq dirs load-path)
1719         (while dirs
1720           (if (or (not (car dirs))
1721                   (not (stringp (car dirs)))
1722                   (not (file-exists-p 
1723                         (setq file (concat (file-name-as-directory 
1724                                             (car dirs)) (car files))))))
1725               (setq dirs (cdr dirs))
1726             (setq dirs nil)
1727             (insert-file-contents file)
1728             (goto-char (point-min))
1729             (or (re-search-forward "^;;* *Internal variables" nil t)
1730                 (error "Malformed sources in file %s" file))
1731             (narrow-to-region (point-min) (point))
1732             (goto-char (point-min))
1733             (while (setq expr (condition-case () 
1734                                   (read (current-buffer)) (error nil)))
1735               (condition-case ()
1736                   (and (eq (car expr) 'defvar)
1737                        (stringp (nth 3 expr))
1738                        (or (not (boundp (nth 1 expr)))
1739                            (not (equal (eval (nth 2 expr))
1740                                        (symbol-value (nth 1 expr)))))
1741                        (setq olist (cons (nth 1 expr) olist)))
1742                 (error nil)))))
1743         (setq files (cdr files)))
1744       (kill-buffer (current-buffer)))
1745     (insert "------------------- Environment follows -------------------\n\n")
1746     (while olist
1747       (if (boundp (car olist))
1748           (insert "(setq " (symbol-name (car olist)) 
1749                   (if (or (consp (setq sym (symbol-value (car olist))))
1750                           (and (symbolp sym)
1751                                (not (or (eq sym nil)
1752                                         (eq sym t)))))
1753                       " '" " ")
1754                   (prin1-to-string (symbol-value (car olist))) ")\n")
1755         (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
1756       (setq olist (cdr olist)))
1757     (insert "\n\n")
1758     ;; Remove any null chars - they seem to cause trouble for some
1759     ;; mailers. (Byte-compiled output from the stuff above.) 
1760     (goto-char (point-min))
1761     (while (re-search-forward "[\000\200]" nil t)
1762       (replace-match "" t t))))
1763
1764 (gnus-ems-redefine)
1765
1766 (provide 'gnus-msg)
1767
1768 ;;; gnus-msg.el ends here