1 ;;; gnus-msg.el --- mail and post interface for Gnus
2 ;; Copyright (C) 1995,96 Free Software Foundation, Inc.
4 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
5 ;; Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
32 (eval-when-compile (require 'cl))
34 ;; Added by Sudish Joseph <joseph@cis.ohio-state.edu>.
35 (defvar gnus-post-method nil
36 "*Preferred method for posting USENET news.
37 If this variable is nil, Gnus will use the current method to decide
38 which method to use when posting. If it is non-nil, it will override
39 the current method. This method will not be used in mail groups and
40 the like, only in \"real\" newsgroups.
42 The value must be a valid method as discussed in the documentation of
43 `gnus-select-method'. It can also be a list of methods. If that is
44 the case, the user will be queried for what select method to use when
47 (defvar gnus-organization-file "/usr/lib/news/organization"
48 "*Local news organization file.")
50 (defvar gnus-prepare-article-hook nil
51 "*A hook called after preparing body, but before preparing header headers.")
53 (defvar gnus-post-prepare-function nil
54 "*Function that is run after a post buffer has been prepared.
55 It is called with the name of the newsgroup that is posted to. It
56 might be used, for instance, for inserting signatures based on the
57 newsgroup name. (In that case, `gnus-signature-file' and
58 `mail-signature' should both be set to nil).")
60 (defvar gnus-post-prepare-hook nil
61 "*Hook that is run after a post buffer has been prepared.
62 If you want to insert the signature, you might put
63 `gnus-inews-insert-signature' in this hook.")
65 (defvar gnus-use-followup-to 'ask
66 "*Specifies what to do with Followup-To header.
67 If nil, ignore the header. If it is t, use its value, but ignore
68 \"poster\". If it is the symbol `ask', query the user whether to
69 ignore the \"poster\" value. If it is the symbol `use', always use
72 (defvar gnus-followup-to-function nil
73 "*A variable that contains a function that returns a followup address.
74 The function will be called in the buffer of the article that is being
75 followed up. The buffer will be narrowed to the headers of the
76 article. To pick header headers, one might use `mail-fetch-field'. The
77 function will be called with the name of the current newsgroup as the
80 Here's an example `gnus-followup-to-function':
82 (setq gnus-followup-to-function
84 (cond ((string= group \"mail.list\")
85 (or (mail-fetch-field \"sender\")
86 (mail-fetch-field \"from\")))
88 (or (mail-fetch-field \"reply-to\")
89 (mail-fetch-field \"from\"))))))")
91 (defvar gnus-reply-to-function nil
92 "*A variable that contains a function that returns a reply address.
93 See the `gnus-followup-to-function' variable for an explanation of how
94 this variable is used.
96 This function should return a string that will be used to fill in the
97 header. This function may also return a list. In that case, every
98 list element should be a cons where the first car should be a string
99 with the header name, and the cdr should be a string with the header
102 (defvar gnus-author-copy (getenv "AUTHORCOPY")
103 "*Save outgoing articles in this file.
104 Initialized from the AUTHORCOPY environment variable.
106 If this variable begins with the character \"|\", outgoing articles
107 will be piped to the named program. It is possible to save an article
108 in an MH folder as follows:
110 \(setq gnus-author-copy \"|/usr/local/lib/mh/rcvstore +Article\")
112 If the first character is not a pipe, articles are saved using the
113 function specified by the `gnus-author-copy-saver' variable.")
115 (defvar gnus-mail-self-blind nil
116 "*Non-nil means insert a BCC header in all outgoing articles.
117 This will result in having a copy of the article mailed to yourself.
118 The BCC header is inserted when the post buffer is initialized, so you
119 can remove or alter the BCC header to override the default.")
121 (defvar gnus-author-copy-saver (function rmail-output)
122 "*A function called to save outgoing articles.
123 This function will be called with the same of the file to store the
124 article in. The default function is `rmail-output' which saves in Unix
127 (defvar gnus-outgoing-message-group nil
128 "*All outgoing messages will be put in this group.
129 If you want to store all your outgoing mail and articles in the group
130 \"nnml:archive\", you set this variable to that value. This variable
131 can also be a list of group names.
133 If you want to have greater control over what group to put each
134 message in, you can set this variable to a function that checks the
135 current newsgroup name and then returns a suitable group name (or list
138 (defvar gnus-message-archive-group
139 '((if (eq major-mode 'news-reply-mode) "misc-news" "misc-mail"))
140 "*Name of the group in which to save the messages you've written.
141 This can either be a string, a list of strings; or an alist
142 of regexps/functions/forms to be evaluated to return a string (or a list
143 of strings). The functions are called with the name of the current
144 group (or nil) as a parameter.")
146 (defvar gnus-mailing-list-groups nil
147 "*Regexp matching groups that are really mailing lists.
148 This is useful when you're reading a mailing list that has been
149 gatewayed to a newsgroup, and you want to followup to an article in
152 (defvar gnus-draft-group-directory
154 (concat (file-name-as-directory gnus-article-save-directory)
156 "*The directory where draft messages will be stored.")
158 (defvar gnus-use-draft t
159 "*Whether Gnus should use the draft group.")
161 (defvar gnus-posting-styles nil
162 "*Alist of styles to use when posting.")
164 (defvar gnus-posting-style-alist
165 '((organization . gnus-organization-file)
166 (signature . gnus-signature-file)
167 (from . gnus-user-from-line)))
169 (defvar gnus-user-login-name nil
170 "*The login name of the user.
171 Got from the function `user-login-name' if undefined.")
173 (defvar gnus-user-full-name nil
174 "*The full name of the user.
175 Got from the NAME environment variable if undefined.")
177 (defvar gnus-user-from-line nil
178 "*Your full, complete e-mail address.
179 Overrides the other Gnus variables if it is non-nil.
181 Here are two example values of this variable:
183 \"Lars Magne Ingebrigtsen <larsi@ifi.uio.no>\"
187 \"larsi@ifi.uio.no (Lars Magne Ingebrigtsen)\"
189 The first version is recommended, but the name has to be quoted if it
190 contains non-alphanumerical characters.")
192 (defvar gnus-signature-file "~/.signature"
193 "*Your signature file.
194 If the variable is a string that doesn't correspond to a file, the
195 string itself is inserted.")
197 (defvar gnus-signature-function nil
198 "*A function that should return a signature file name.
199 The function will be called with the name of the newsgroup being
201 If the function returns a string that doesn't correspond to a file, the
202 string itself is inserted.
203 If the function returns nil, the `gnus-signature-file' variable will
206 (defvar gnus-forward-start-separator
207 "------- Start of forwarded message -------\n"
208 "*Delimiter inserted before forwarded messages.")
210 (defvar gnus-forward-end-separator
211 "------- End of forwarded message -------\n"
212 "*Delimiter inserted after forwarded messages.")
214 (defvar gnus-signature-before-forwarded-message t
215 "*If non-nil, put the signature before any included forwarded message.")
217 (defvar gnus-forward-included-headers
218 "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-\\:^Message-ID:\\|^References:"
219 "*Regexp matching headers to be included in forwarded messages.")
221 (defvar gnus-required-headers
222 '(From Date Newsgroups Subject Message-ID Organization Lines X-Newsreader)
223 "*Headers to be generated or prompted for when posting an article.
224 RFC977 and RFC1036 require From, Date, Newsgroups, Subject,
225 Message-ID. Organization, Lines, In-Reply-To, Expires, and
226 X-Newsreader are optional. If you want Gnus not to insert some
227 header, remove it from this list.")
229 (defvar gnus-required-mail-headers
230 '(From Date To Subject (optional . In-Reply-To) Message-ID Organization Lines)
231 "*Headers to be generated or prompted for when mailing a message.
232 RFC822 required that From, Date, To, Subject and Message-ID be
233 included. Organization, Lines and X-Mailer are optional.")
235 (defvar gnus-deletable-headers '(Message-ID Date)
236 "*Headers to be deleted if they already exists and were generated by Gnus previously.")
238 (defvar gnus-removable-headers '(NNTP-Posting-Host Xref)
239 "*Headers to be removed unconditionally before posting.")
241 (defvar gnus-article-expires 14
242 "*Number of days before your article expires.
243 This variable isn't used unless you have the `Expires' element in
244 `gnus-required-headers'.")
246 (defvar gnus-distribution-function nil
247 "*Function that should return the Distribution header for outgoing articles.
248 It will be called from the buffer where the outgoing article
249 is being prepared with the group name as the only parameter.
250 It should return a valid distribution.
252 The function will only be called if you have the `Distribution' header in
253 `gnus-required-headers'.")
255 (defvar gnus-check-before-posting
256 '(subject-cmsg multiple-headers sendsys message-id from
257 long-lines control-chars size new-text
258 redirected-followup signature approved sender empty)
259 "In non-nil, Gnus will attempt to run some checks on outgoing posts.
260 If this variable is t, Gnus will check everything it can. If it is a
261 list, then those elements in that list will be checked.")
263 (defvar gnus-delete-supersedes-headers
264 "^Path:\\|^Date\\|^NNTP-Posting-Host:\\|^Supersedes:\\|^Xref:\\|^Lines:"
265 "*Header lines matching this regexp will be deleted before posting.
266 It's best to delete old Path and Date headers before posting to avoid
269 (defvar gnus-auto-mail-to-author nil
270 "*If non-nil, mail the authors of articles a copy of your follow-ups.
271 If this variable is `ask', the user will be prompted for whether to
272 mail a copy. The string given by `gnus-mail-courtesy-message' will be
273 inserted at the beginning of the mail copy.")
275 ;; Added by Ethan Bradford <ethanb@ptolemy.astro.washington.edu>.
276 (defvar gnus-mail-courtesy-message
277 "The following message is a courtesy copy of an article\nthat has been posted as well.\n\n"
278 "*This is inserted at the start of a mailed copy of a posted message.
279 If this variable is nil, no such courtesy message will be added.")
281 (defvar gnus-mail-method 'sendmail
282 "*Method to use for composing mail.
283 There are three legal values: `sendmail' (which is the default), `mh',
286 (defvar gnus-mail-reply-method (function gnus-mail-reply-using-mail)
287 "*Function to compose a reply.
288 Three pre-made functions are `gnus-mail-reply-using-mail' (sendmail);
289 `gnus-mail-reply-using-mhe' (MH-E); and `gnus-mail-reply-using-vm'.")
291 (defvar gnus-mail-forward-method (function gnus-mail-forward-using-mail)
292 "*Function to forward the current message to another user.
293 Three pre-made functions are `gnus-mail-forward-using-mail' (sendmail);
294 `gnus-mail-forward-using-mhe' (MH-E); and `gnus-mail-forward-using-vm'.")
296 (defvar gnus-mail-other-window-method 'gnus-mail-other-window-using-mail
297 "*Function to compose mail in the other window.
298 Three pre-made functions are `gnus-mail-other-window-using-mail'
299 (sendmail); `gnus-mail-other-window-using-mhe' (MH-E); and
300 `gnus-mail-other-window-using-vm'.")
302 (defvar gnus-inews-article-function 'gnus-inews-article
303 "*Function to post an article.")
305 (defvar gnus-bounced-headers-junk "^\\(Received\\):"
306 "*Regexp that matches headers to be removed in resent bounced mail.")
308 (defvar gnus-inews-article-hook (list 'gnus-inews-do-fcc)
309 "*A hook called before finally posting an article.
310 The default hook (`gnus-inews-do-fcc') does FCC processing (ie. saves
311 the article to a file).")
313 (defvar gnus-inews-article-header-hook nil
314 "*A hook called after inserting the headers in an article to be posted.
315 The hook is called from the *post-news* buffer, narrowed to the
318 (defvar gnus-mail-hook nil
319 "*A hook called as the last thing after setting up a mail buffer.")
321 (defvar gnus-message-sent-hook nil
322 "*A hook run after an article has been sent (or attempted sent).")
324 ;;; Internal variables.
326 (defvar gnus-post-news-buffer "*post-news*")
327 (defvar gnus-mail-buffer "*Mail Gnus*")
328 (defvar gnus-article-copy nil)
329 (defvar gnus-reply-subject nil)
330 (defvar gnus-newsgroup-followup nil)
331 (defvar gnus-add-to-address nil)
332 (defvar gnus-in-reply-to nil)
333 (defvar gnus-last-posting-server nil)
336 (autoload 'gnus-uu-post-news "gnus-uu" nil t)
337 (autoload 'news-setup "rnewspost")
338 (autoload 'news-reply-mode "rnewspost")
339 (autoload 'rmail-dont-reply-to "mail-utils")
340 (autoload 'rmail-output "rmailout"))
344 ;;; Gnus Posting Functions
348 (gnus-summary-send-map "S" gnus-summary-mode-map)
349 "p" gnus-summary-post-news
350 "f" gnus-summary-followup
351 "F" gnus-summary-followup-with-original
352 "b" gnus-summary-followup-and-reply
353 "B" gnus-summary-followup-and-reply-with-original
354 "c" gnus-summary-cancel-article
355 "s" gnus-summary-supersede-article
356 "r" gnus-summary-reply
357 "R" gnus-summary-reply-with-original
358 "m" gnus-summary-mail-other-window
359 "u" gnus-uu-post-news
360 "om" gnus-summary-mail-forward
361 "op" gnus-summary-post-forward
362 "Om" gnus-uu-digest-mail-forward
363 "Op" gnus-uu-digest-post-forward)
366 (gnus-send-bounce-map "D" gnus-summary-send-map)
367 "b" gnus-summary-resend-bounced-mail
368 "c" gnus-summary-send-draft
369 "r" gnus-summary-resend-message)
371 ;;; Internal functions.
373 (defun gnus-number-base36 (num len)
374 (if (if (< len 0) (<= num 0) (= len 0))
376 (concat (gnus-number-base36 (/ num 36) (1- len))
377 (char-to-string (aref "zyxwvutsrqponmlkjihgfedcba9876543210"
380 ;;; Post news commands of Gnus group mode and summary mode
382 (defun gnus-group-mail ()
383 "Start composing a mail."
386 ;; We might want to prompt here.
387 (when (and gnus-interactive-post
388 (not gnus-expert-user))
389 (read-string "To: "))))
391 (defun gnus-group-post-news (&optional arg)
393 The newsgroup under the cursor is used as the group to post to.
395 If you wish to get an empty post buffer, use a prefix ARG. You can
396 also do this by calling this function from the bottom of the Group
399 (let ((gnus-newsgroup-name nil)
400 (group (unless arg (gnus-group-group-name)))
402 ;; We might want to prompt here.
403 (when (and gnus-interactive-post
404 (not gnus-expert-user))
405 (setq gnus-newsgroup-name
407 (completing-read "Group: " gnus-active-hashtb nil nil
408 (cons (or group "") 0)))))
409 (gnus-post-news 'post group nil gnus-article-buffer)))
411 (defun gnus-summary-post-news ()
414 (gnus-set-global-variables)
415 (gnus-post-news 'post gnus-newsgroup-name))
417 (defun gnus-summary-followup (yank &optional yank-articles)
418 "Compose a followup to an article.
419 If prefix argument YANK is non-nil, original article is yanked automatically."
421 (gnus-set-global-variables)
422 (if yank-articles (gnus-summary-goto-subject (car yank-articles)))
423 (save-window-excursion
424 (gnus-summary-select-article))
425 (let ((headers (gnus-summary-article-header (gnus-summary-article-number)))
426 (gnus-newsgroup-name gnus-newsgroup-name))
427 ;; Check Followup-To: poster.
428 (set-buffer gnus-article-buffer)
429 (if (and gnus-use-followup-to
430 (string-equal "poster" (gnus-fetch-field "followup-to"))
431 (or (not (memq gnus-use-followup-to '(t ask)))
433 "Do you want to ignore `Followup-To: poster'? "))))
434 ;; Mail to the poster.
435 (gnus-summary-reply yank)
437 (gnus-post-news nil gnus-newsgroup-name
438 headers gnus-article-buffer
439 (or yank-articles (not (not yank)))))))
441 (defun gnus-summary-followup-with-original (n)
442 "Compose a followup to an article and include the original article."
444 (gnus-summary-followup t (gnus-summary-work-articles n)))
446 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
447 (defun gnus-summary-followup-and-reply (yank &optional yank-articles)
448 "Compose a followup and do an auto mail to author."
450 (gnus-set-global-variables)
451 (let ((gnus-auto-mail-to-author 'force))
452 (gnus-summary-followup yank yank-articles)))
454 (defun gnus-summary-followup-and-reply-with-original (n)
455 "Compose a followup, include the original, and do an auto mail to author."
457 (gnus-summary-followup-and-reply t (gnus-summary-work-articles n)))
459 (defun gnus-summary-cancel-article (n)
460 "Cancel an article you posted."
462 (gnus-set-global-variables)
463 (let ((articles (gnus-summary-work-articles n))
465 (while (setq article (pop articles))
466 (when (gnus-summary-select-article t nil nil article)
467 (when (gnus-eval-in-buffer-window
468 gnus-original-article-buffer (gnus-cancel-news))
469 (gnus-summary-mark-as-read article gnus-canceled-mark))
470 (gnus-article-hide-headers-if-wanted))
471 (gnus-summary-remove-process-mark article))))
473 (defun gnus-summary-supersede-article ()
474 "Compose an article that will supersede a previous article.
475 This is done simply by taking the old article and adding a Supersedes
476 header line with the old Message-ID."
478 (gnus-set-global-variables)
479 (gnus-summary-select-article t)
480 ;; Check whether the user owns the article that is to be superseded.
481 (unless (string-equal
482 (downcase (mail-strip-quoted-names
483 (mail-header-from gnus-current-headers)))
484 (downcase (mail-strip-quoted-names (gnus-inews-user-name))))
485 (error "This article is not yours."))
486 ;; Get a normal *post-news* buffer.
487 (gnus-new-news gnus-newsgroup-name t)
489 (insert-buffer-substring gnus-original-article-buffer)
490 (nnheader-narrow-to-headers)
491 ;; Remove unwanted headers.
492 (when gnus-delete-supersedes-headers
493 (nnheader-remove-header gnus-delete-supersedes-headers t))
494 (goto-char (point-min))
495 (if (not (re-search-forward "^Message-ID: " nil t))
496 (error "No Message-ID in this article")
497 (replace-match "Supersedes: " t t))
498 (goto-char (point-max))
499 (insert mail-header-separator)
505 (defalias 'sendnews 'gnus-post-news)
508 (defalias 'postnews 'gnus-post-news)
510 (defun gnus-copy-article-buffer (&optional article-buffer)
511 ;; make a copy of the article buffer with all text properties removed
512 ;; this copy is in the buffer gnus-article-copy.
513 ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
514 ;; this buffer should be passed to all mail/news reply/post routines.
515 (setq gnus-article-copy (get-buffer-create " *gnus article copy*"))
516 (buffer-disable-undo gnus-article-copy)
517 (or (memq gnus-article-copy gnus-buffer-list)
518 (setq gnus-buffer-list (cons gnus-article-copy gnus-buffer-list)))
519 (let ((article-buffer (or article-buffer gnus-article-buffer)))
520 (if (and (get-buffer article-buffer)
521 (buffer-name (get-buffer article-buffer)))
523 (set-buffer article-buffer)
525 (copy-to-buffer gnus-article-copy (point-min) (point-max))
526 (set-text-properties (point-min) (point-max)
527 nil gnus-article-copy)))))
529 (defun gnus-post-news (post &optional group header article-buffer yank subject)
530 "Begin editing a new USENET news article to be posted.
531 Type \\[describe-mode] in the buffer to get a list of commands."
532 (interactive (list t))
533 (let* ((group (or group gnus-newsgroup-name))
535 to-address to-group mailing-list to-list)
537 (setq to-address (gnus-group-get-parameter group 'to-address)
538 to-group (gnus-group-get-parameter group 'to-group)
539 to-list (gnus-group-get-parameter group 'to-list)
540 mailing-list (when gnus-mailing-list-groups
541 (string-match gnus-mailing-list-groups group))
542 group (gnus-group-real-name group)))
543 (if (or (and to-group
544 (gnus-news-group-p to-group))
545 (and (gnus-news-group-p
546 (or pgroup gnus-newsgroup-name)
547 (if header (mail-header-number header) gnus-current-article))
553 (gnus-new-news (or to-group group))
554 (gnus-news-followup yank (or to-group group)))
558 (gnus-new-mail (or to-address to-list))
559 ;; Arrange for mail groups that have no `to-address' to
560 ;; get that when the user sends off the mail.
562 (make-local-variable 'gnus-add-to-address)
563 (setq gnus-add-to-address group)))
564 (gnus-mail-reply yank to-address 'followup)))))
566 (defun gnus-post-method (group query-method &optional silent)
567 "Return the posting method based on GROUP and query-method.
568 If SILENT, don't prompt the user."
569 (let ((group-method (if (stringp group)
570 (gnus-find-method-for-group group)
573 ;; If the group-method is nil (which shouldn't happen) we use
574 ;; the default method.
576 (or gnus-post-method gnus-select-method))
577 ;; We want this group's method.
578 ((and query-method (not (eq query-method 0)))
580 ;; We query the user for a post method.
582 (and gnus-post-method
583 (listp (car gnus-post-method))))
585 ;; Collect all methods we know about.
587 (when gnus-post-method
588 (if (listp (car gnus-post-method))
590 (listp gnus-post-method)))
591 gnus-secondary-select-methods
592 (list gnus-select-method)
593 (list group-method)))
594 method-alist post-methods method)
595 ;; Weed out all mail methods.
597 (setq method (gnus-server-get-method "" (pop methods)))
598 (when (or (gnus-method-option-p method 'post)
599 (gnus-method-option-p method 'post-mail))
600 (push method post-methods)))
601 ;; Create a name-method alist.
605 (list (concat (cadr m) " (" (symbol-name (car m)) ")") m))
610 (setq gnus-last-posting-server
612 gnus-last-posting-server)
613 ;; Just use the last value.
614 gnus-last-posting-server
616 "Posting method: " method-alist nil t
617 (cons (or gnus-last-posting-server "") 0))))
619 ;; Override normal method.
620 ((and gnus-post-method
621 (or (gnus-method-option-p group-method 'post)
622 (gnus-method-option-p group-method 'post-mail)))
624 ;; Perhaps this is a mail group?
625 ((and (not (gnus-member-of-valid 'post group))
626 (not (gnus-method-option-p group-method 'post-mail)))
628 ;; Use the normal select method.
629 (t gnus-select-method))))
631 (defun gnus-news-group-p (group &optional article)
632 "Return non-nil if GROUP (and ARTICLE) come from a news server."
633 (or (gnus-member-of-valid 'post group) ; Ordinary news group.
634 (and (gnus-member-of-valid 'post-mail group) ; Combined group.
635 (eq (gnus-request-type group article) 'news))))
637 (defun gnus-inews-news (&optional use-group-method)
638 "Send a news message.
640 If given a non-zero prefix and the group is a foreign group, this
641 function will attempt to use the foreign server to post the article.
643 If given an zero prefix, the user will be prompted for a posting
646 (or gnus-current-select-method
647 (setq gnus-current-select-method gnus-select-method))
648 (let* ((case-fold-search nil)
649 (reply gnus-article-reply)
652 (gnus-start-news-server) ;Use default server.
654 (goto-char (point-min))
655 (run-hooks 'news-inews-hook)
658 (gnus-message 5 "Posting to USENET...")
659 (setq post-result (funcall gnus-inews-article-function use-group-method))
661 ((eq post-result 'illegal)
665 (gnus-message 5 "Posting to USENET...done")
666 (set-buffer-modified-p nil)
667 ;; We mark the article as replied.
668 (when (gnus-buffer-exists-p (car-safe reply))
670 (set-buffer gnus-summary-buffer)
671 (gnus-summary-mark-article-as-replied (cdr reply)))))
673 ;; We cannot signal an error.
677 1 "Article rejected: %s"
679 (gnus-post-method gnus-newsgroup-name use-group-method t))))))
681 (let ((conf gnus-prev-winconf))
684 ;; Restore last window configuration.
685 (and conf (set-window-configuration conf))))))
687 (defun gnus-inews-narrow-to-headers ()
690 (goto-char (point-min))
691 (or (and (re-search-forward
692 (concat "^" (regexp-quote mail-header-separator) "$") nil t)
695 (goto-char (point-min)))
697 (defun gnus-inews-send-mail-copy ()
698 ;; Mail the message if To, Bcc or Cc exists.
699 (let* ((types '("to" "bcc" "cc"))
701 (buffer (current-buffer))
705 (gnus-inews-narrow-to-headers)
708 (or (mail-fetch-field (car ty) nil t)
709 (setq types (delete (car ty) types)))
713 ;; We do not want to send mail.
715 (gnus-message 5 "Sending via mail...")
718 ;; We copy the article over to a temp buffer since we are
719 ;; going to modify it a little.
720 (nnheader-set-temp-buffer " *Gnus-mailing*")
721 (insert-buffer-substring buffer)
722 ;; We remove Fcc, because we don't want the mailer to see
724 (gnus-inews-narrow-to-headers)
725 (nnheader-remove-header "fcc")
727 ;; Insert the X-Courtesy-Message header.
728 (and (or (member "to" types)
731 (goto-char (point-max))
732 (insert "Posted-To: "
733 (mail-fetch-field "newsgroups") "\n")))
737 (if (and gnus-mail-courtesy-message
738 (or (member "to" types)
739 (member "cc" types)))
740 ;; We only want to insert the courtesy mail message if
741 ;; we use To or Cc; Bcc should not have one. Well, if
742 ;; both Bcc and To are present, it will get one
745 ;; Insert "courtesy" mail message.
746 (goto-char (point-min))
748 (concat "^" (regexp-quote mail-header-separator) "$"))
750 (insert gnus-mail-courtesy-message)))
753 (kill-buffer (current-buffer))
754 (gnus-message 5 "Sending via mail...done"))))))
756 (defun gnus-inews-remove-headers-after-mail ()
759 (let ((case-fold-search t))
760 (gnus-inews-narrow-to-headers)
761 ;; Remove Bcc completely.
762 (nnheader-remove-header "bcc")
763 ;; We transform To and Cc headers to avoid re-mailing if the user
764 ;; accidentally (or purposefully) leans on the `C-c C-c' keys
765 ;; and the news server rejects the posting.
766 (while (re-search-forward "^\\(to\\|[bcf]cc\\|cc\\):" nil t)
771 (defun gnus-inews-dex-headers ()
772 "Remove \"X-\" prefixes from To and Cc headers."
775 (let ((case-fold-search t))
776 (nnheader-narrow-to-headers)
777 (while (re-search-forward "^X-\\(to\\|[bcf]cc\\|cc\\):" nil t)
782 (defun gnus-inews-remove-empty-headers ()
783 "Remove empty headers from news and mail.
784 The buffer should be narrowed to the headers before this function is
787 (goto-char (point-min))
788 (while (re-search-forward "^[^ \t:]+:\\([ \t]*\n\\)+[^ \t]" nil t)
789 (delete-region (match-beginning 0) (1- (match-end 0)))
790 (beginning-of-line))))
792 (defun gnus-inews-check-post ()
793 "Check whether the post looks ok."
795 (not gnus-check-before-posting)
797 ;; We narrow to the headers and check them first.
800 (goto-char (point-min))
805 (concat "^" (regexp-quote mail-header-separator) "$"))
806 (match-beginning 0)))
807 (goto-char (point-min))
809 ;; Check for commands in Subject.
811 (gnus-check-before-posting 'subject-cmsg)
813 (if (string-match "^cmsg " (mail-fetch-field "subject"))
815 "The control code \"cmsg \" is in the subject. Really post? ")
817 ;; Check for multiple identical headers.
818 (or (gnus-check-before-posting 'multiple-headers)
821 (while (and (not found) (re-search-forward "^[^ \t:]+: "
824 (or (re-search-forward
825 (concat "^" (setq found
828 (- (match-end 0) 2))))
833 (format "Multiple %s headers. Really post? " found))
835 ;; Check for Version and Sendsys.
836 (or (gnus-check-before-posting 'sendsys)
838 (if (re-search-forward "^Sendsys:\\|^Version:" nil t)
840 (format "The article contains a %s command. Really post? "
841 (buffer-substring (match-beginning 0)
842 (1- (match-end 0)))))
844 ;; Check for Approved.
845 (or (gnus-check-before-posting 'approved)
847 (if (re-search-forward "^Approved:" nil t)
849 "The article contains an Approved header. Really post? ")
851 ;; Check whether a Followup-To has redirected the newsgroup.
853 (gnus-check-before-posting 'redirected-followup)
854 (not gnus-newsgroup-followup)
856 (let ((followups (gnus-tokenize-header
857 (mail-fetch-field "Newsgroups")))
858 (newsgroups (gnus-tokenize-header
859 (car gnus-newsgroup-followup)))
861 (while (and followups
862 (not (member followups newsgroups)))
863 (setq followups (cdr followups)))
867 "Followup redirected from original newsgroups. Really post? "
869 ;; Check the Message-ID header.
870 (or (gnus-check-before-posting 'message-id)
872 (let* ((case-fold-search t)
873 (message-id (mail-fetch-field "message-id")))
875 (and (string-match "@" message-id)
876 (string-match "@[^\\.]*\\." message-id))
879 "The Message-ID looks strange: \"%s\". Really post? "
881 ;; Check the From header.
883 (gnus-check-before-posting 'from)
885 (let* ((case-fold-search t)
886 (from (mail-fetch-field "from")))
889 (gnus-y-or-n-p "There is no From line. Really post? "))
890 ((not (string-match "@[^\\.]*\\." from))
893 "The address looks strange: \"%s\". Really post? " from)))
894 ((string-match "(.*).*(.*)" from)
897 "The From header looks strange: \"%s\". Really post? "
899 ((string-match "<[^>]+> *$" from)
900 (let ((name (substring from 0 (match-beginning 0))))
902 (string-match "^ *\"[^\"]*\" *$" name)
903 (not (string-match "[][.!()<>@,;:\\]" name))
906 "The From header name has bogus characters. Really post? "
910 ;; Check for long lines.
911 (or (gnus-check-before-posting 'long-lines)
913 (goto-char (point-min))
915 (concat "^" (regexp-quote mail-header-separator) "$"))
919 (< (current-column) 80))
920 (zerop (forward-line 1))))
924 "You have lines longer than 79 characters. Really post? "))))
925 ;; Check whether the article is empty.
926 (or (gnus-check-before-posting 'empty)
928 (goto-char (point-min))
930 (concat "^" (regexp-quote mail-header-separator) "$"))
932 (or (re-search-forward "[^ \n\t]" nil t)
933 (gnus-y-or-n-p "Empty article. Really post?"))))
934 ;; Check for control characters.
935 (or (gnus-check-before-posting 'control-chars)
937 (if (re-search-forward "[\000-\007\013\015-\037\200-\237]" nil t)
939 "The article contains control characters. Really post? ")
941 ;; Check excessive size.
942 (or (gnus-check-before-posting 'size)
943 (if (> (buffer-size) 60000)
945 (format "The article is %d octets long. Really post? "
948 ;; Use the (size . checksum) variable to see whether the
949 ;; article is empty or has only quoted text.
951 (gnus-check-before-posting 'new-text)
952 (if (and (= (buffer-size) (car gnus-article-check-size))
953 (= (gnus-article-checksum) (cdr gnus-article-check-size)))
955 "It looks like there's no new text in your article. Really post? ")
957 ;; Check the length of the signature.
958 (or (gnus-check-before-posting 'signature)
960 (goto-char (point-max))
961 (if (not (re-search-backward gnus-signature-separator nil t))
963 (if (> (count-lines (point) (point-max)) 5)
966 "Your .sig is %d lines; it should be max 4. Really post? "
967 (count-lines (point) (point-max))))
970 (defun gnus-tokenize-header (header &optional separator)
971 "Split HEADER into a list of header elements.
972 \",\" is used as the separator."
974 (separator (or separator ","))
976 (format "[ \t]*\\([^%s]+\\)?\\(%s\\|\\'\\)" separator separator))
978 (while (and (string-match regexp header beg)
979 (< beg (length header)))
980 (when (match-beginning 1)
981 (push (match-string 1 header) elems))
982 (setq beg (match-end 0)))
985 (defun gnus-article-checksum ()
989 (setq sum (logxor sum (following-char)))
993 ;; Returns non-nil if this type is not to be checked.
994 (defun gnus-check-before-posting (type)
996 (or (not gnus-check-before-posting)
997 (if (listp gnus-check-before-posting)
998 (memq type gnus-check-before-posting)
1001 (defun gnus-cancel-news ()
1002 "Cancel an article you posted."
1004 (if (or gnus-expert-user
1005 (gnus-yes-or-no-p "Do you really want to cancel this article? "))
1010 (or (gnus-news-group-p gnus-newsgroup-name)
1011 (error "This backend does not support canceling"))
1013 ;; Get header info. from original article.
1015 (gnus-article-show-all-headers)
1016 (goto-char (point-min))
1017 (search-forward "\n\n" nil 'move)
1018 (narrow-to-region (point-min) (point))
1019 (setq from (mail-fetch-field "from"))
1020 (setq newsgroups (mail-fetch-field "newsgroups"))
1021 (setq message-id (mail-fetch-field "message-id"))
1022 (setq distribution (mail-fetch-field "distribution")))
1023 ;; Verify if the article is absolutely user's by comparing
1024 ;; user id with value of its From: field.
1027 (downcase (mail-strip-quoted-names from))
1028 (downcase (mail-strip-quoted-names (gnus-inews-user-name)))))
1030 (ding) (gnus-message 3 "This article is not yours.")
1032 ;; Make control article.
1033 (set-buffer (get-buffer-create " *Gnus-canceling*"))
1034 (buffer-disable-undo (current-buffer))
1036 (insert "Newsgroups: " newsgroups "\n"
1037 "From: " (gnus-inews-user-name) "\n"
1038 "Subject: cancel " message-id "\n"
1039 "Control: cancel " message-id "\n"
1041 (concat "Distribution: " distribution "\n")
1043 mail-header-separator "\n"
1044 "This is a cancel message from " from ".\n")
1045 ;; Send the control article to NNTP server.
1046 (gnus-message 5 "Canceling your article...")
1048 (if (funcall gnus-inews-article-function)
1049 (gnus-message 5 "Canceling your article...done")
1052 (gnus-message 1 "Cancel failed; %s"
1053 (gnus-status-message gnus-newsgroup-name))
1056 ;; Kill the article buffer.
1057 (kill-buffer (current-buffer))))))))
1060 ;;; Lowlevel inews interface.
1062 ;; Dummy to avoid byte-compile warning.
1063 (defvar nnspool-rejected-article-hook)
1065 (defun gnus-inews-article (&optional use-group-method)
1066 "Post an article in current buffer using NNTP protocol."
1067 (let ((artbuf (current-buffer))
1070 (goto-char (point-max))
1071 ;; Require a newline at the end of the buffer since inews may
1072 ;; append a .signature.
1073 (or (= (preceding-char) ?\n)
1075 ;; Prepare article headers. All message body such as signature
1076 ;; must be inserted before Lines: field is prepared.
1078 (gnus-inews-narrow-to-headers)
1079 ;; Fix some headers.
1080 (gnus-inews-cleanup-headers)
1081 ;; Remove some headers.
1082 (gnus-inews-remove-headers)
1083 ;; Insert some headers.
1084 (gnus-inews-insert-headers)
1085 ;; Let the user do all of the above.
1086 (run-hooks 'gnus-inews-article-header-hook)
1087 ;; Copy the Gcc header, if any.
1088 (setq gcc (mail-fetch-field "gcc"))
1090 ;; Check whether the article is a good Net Citizen.
1091 (if (and gnus-article-check-size
1092 (not (gnus-inews-check-post)))
1095 ;; We fudge a hook for nnspool.
1096 (setq nnspool-rejected-article-hook
1102 (set-buffer (, (buffer-name)))
1103 (gnus-associate-buffer-with-draft nil 'silent))
1107 1 "Couldn't enter rejected article into draft group")))))))
1109 ;; Looks ok, so we do the nasty.
1111 ;; This hook may insert a signature.
1113 (goto-char (point-min))
1114 (let ((gnus-newsgroup-name (or (mail-fetch-field "newsgroups")
1115 gnus-newsgroup-name)))
1116 (run-hooks 'gnus-prepare-article-hook)))
1117 ;; Send off copies using mail, if that is wanted.
1118 (gnus-inews-send-mail-copy)
1119 ;; Remove more headers.
1120 (gnus-inews-remove-headers-after-mail)
1121 ;; Copy the article over to a temp buffer.
1122 (nnheader-set-temp-buffer " *Gnus-posting*")
1123 (insert-buffer-substring artbuf)
1124 ;; Remove the header separator.
1125 (goto-char (point-min))
1127 (concat "^" (regexp-quote mail-header-separator) "$"))
1128 (replace-match "" t t)
1129 ;; Remove X- prefixes to headers.
1130 (gnus-inews-dex-headers)
1131 ;; Run final inews hooks. This hook may do FCC.
1132 ;; The article must be saved before being posted because
1133 ;; `gnus-request-post' modifies the buffer.
1134 (run-hooks 'gnus-inews-article-hook)
1135 ;; Copy the article over to some group, possibly.
1136 (and gcc (gnus-inews-do-gcc gcc))
1137 ;; Post the article.
1138 (setq result (gnus-request-post
1139 (gnus-post-method gnus-newsgroup-name use-group-method)))
1140 (kill-buffer (current-buffer)))
1141 (run-hooks 'gnus-message-sent-hook)
1142 ;; If the posting was unsuccessful (that it, it was rejected) we
1143 ;; put it into the draft group.
1144 (or result (gnus-associate-buffer-with-draft))
1147 (defun gnus-inews-cleanup-headers ()
1148 ;; Correct newsgroups field: change sequence of spaces to comma and
1149 ;; eliminate spaces around commas. Eliminate imbedded line breaks.
1150 (goto-char (point-min))
1151 (if (re-search-forward "^Newsgroups: +" nil t)
1155 (if (re-search-forward "^[^ \t]" nil t)
1159 (goto-char (point-min))
1160 (while (re-search-forward "\n[ \t]+" nil t)
1161 (replace-match " " t t)) ;No line breaks (too confusing)
1162 (goto-char (point-min))
1163 (while (re-search-forward "[ \t\n]*,[ \t\n]*\\|[ \t]+" nil t)
1164 (replace-match "," t t))
1165 (goto-char (point-min))
1166 ;; Remove a trailing comma.
1167 (if (re-search-forward ",$" nil t)
1168 (replace-match "" t t))))
1170 ;; Added by Per Abrahamsen <abraham@iesd.auc.dk>.
1171 ;; Help save the the world!
1174 (let ((newsgroups (mail-fetch-field "newsgroups"))
1175 (followup-to (mail-fetch-field "followup-to"))
1178 (string-match "," newsgroups) (not followup-to))
1180 (while (string-match "," newsgroups)
1182 (cons (list (substring newsgroups 0 (match-beginning 0)))
1184 (setq newsgroups (substring newsgroups (match-end 0))))
1185 (setq groups (nreverse (cons (list newsgroups) groups)))
1187 (setq to (completing-read
1188 "Followups to: (default all groups) " groups))
1189 (if (> (length to) 0)
1191 (goto-char (point-min))
1192 (insert "Followup-To: " to "\n")))))))
1194 ;; Cleanup Followup-To.
1195 (goto-char (point-min))
1196 (if (search-forward-regexp "^Followup-To: +" nil t)
1200 (if (re-search-forward "^[^ \t]" nil 'end)
1203 (goto-char (point-min))
1204 (replace-regexp "\n[ \t]+" " ") ;No line breaks (too confusing)
1205 (goto-char (point-min))
1206 (replace-regexp "[ \t\n]*,[ \t\n]*\\|[ \t]+" ","))))
1209 (defun gnus-inews-remove-headers ()
1210 (let ((case-fold-search t)
1211 (headers gnus-removable-headers))
1212 ;; Remove toxic headers.
1214 (goto-char (point-min))
1215 (and (re-search-forward
1216 (concat "^" (downcase (format "%s" (car headers))))
1218 (delete-region (progn (beginning-of-line) (point))
1219 (progn (forward-line 1) (point))))
1220 (setq headers (cdr headers)))))
1222 ;;; Since the X-Newsreader/X-Mailer are ``vanity'' headers, they might
1223 ;;; as well include the Emacs version as well.
1224 ;;; The following function works with later GNU Emacs, and XEmacs.
1225 (defun gnus-extended-version ()
1226 "Stringified Gnus version and Emacs version"
1232 ((string-match "^\\([0-9]+\\.[0-9]+\\)\\.[.0-9]+$" emacs-version)
1233 (concat "Emacs " (substring emacs-version
1236 ((string-match "\\([A-Z]*[Mm][Aa][Cc][Ss]\\)" emacs-version)
1237 (concat (substring emacs-version
1240 (format " %d.%d" emacs-major-version emacs-minor-version)))
1241 (t emacs-version))))
1243 (defun gnus-inews-insert-headers (&optional headers)
1244 "Prepare article headers.
1245 Headers already prepared in the buffer are not modified.
1246 Headers in `gnus-required-headers' will be generated."
1247 (let* ((Date (gnus-inews-date))
1248 (Message-ID (gnus-inews-message-id))
1249 (Organization (gnus-inews-organization))
1250 (From (gnus-inews-user-name))
1251 (Path (gnus-inews-path))
1254 (In-Reply-To (gnus-inews-in-reply-to))
1256 (Distribution (gnus-inews-distribution))
1257 (Lines (gnus-inews-lines))
1258 (X-Newsreader (gnus-extended-version))
1259 (X-Mailer X-Newsreader)
1260 (Expires (gnus-inews-expires))
1261 (headers (or headers gnus-required-headers))
1262 (case-fold-search t)
1264 ;; First we remove any old generated headers.
1265 (let ((headers gnus-deletable-headers))
1267 (goto-char (point-min))
1268 (and (re-search-forward
1269 (concat "^" (symbol-name (car headers)) ": *") nil t)
1270 (get-text-property (1+ (match-beginning 0)) 'gnus-deletable)
1272 (setq headers (cdr headers))))
1273 ;; If there are References, and no "Re: ", then the thread has
1274 ;; changed name. See Son-of-1036.
1275 (if (and (mail-fetch-field "references")
1276 (get-buffer gnus-article-buffer))
1277 (let ((psubject (gnus-simplify-subject-re
1278 (mail-fetch-field "subject"))))
1279 (or (and psubject gnus-reply-subject
1280 (string= (gnus-simplify-subject-re gnus-reply-subject)
1283 (string-match "@" Message-ID)
1285 (concat (substring Message-ID 0 (match-beginning 0))
1287 (substring Message-ID (match-beginning 0))))))))
1288 ;; Go through all the required headers and see if they are in the
1289 ;; articles already. If they are not, or are empty, they are
1290 ;; inserted automatically - except for Subject, Newsgroups and
1293 (goto-char (point-min))
1294 (setq elem (pop headers))
1296 (setq header (car elem))
1298 (when (or (not (re-search-forward
1299 (concat "^" (downcase (symbol-name header)) ":") nil t))
1301 ;; The header was found. We insert a space after the
1302 ;; colon, if there is none.
1303 (if (/= (following-char) ? ) (insert " "))
1304 ;; Find out whether the header is empty...
1305 (looking-at "[ \t]*$")))
1306 ;; So we find out what value we should insert.
1309 ((and (consp elem) (eq (car elem) 'optional))
1310 ;; This is an optional header. If the cdr of this
1311 ;; is something that is nil, then we do not insert
1313 (setq header (cdr elem))
1314 (or (and (fboundp (cdr elem)) (funcall (cdr elem)))
1315 (and (boundp (cdr elem)) (symbol-value (cdr elem)))))
1317 ;; The element is a cons. Either the cdr is a
1318 ;; string to be inserted verbatim, or it is a
1319 ;; function, and we insert the value returned from
1321 (or (and (stringp (cdr elem)) (cdr elem))
1322 (and (fboundp (cdr elem)) (funcall (cdr elem)))))
1323 ((and (boundp header) (symbol-value header))
1324 ;; The element is a symbol. We insert the value
1325 ;; of this symbol, if any.
1326 (symbol-value header))
1328 ;; We couldn't generate a value for this header,
1329 ;; so we just ask the user.
1330 (read-from-minibuffer
1331 (format "Empty header for %s; enter value: " header)))))
1332 ;; Finally insert the header.
1334 (not (equal value "")))
1338 ;; This header didn't exist, so we insert it.
1339 (goto-char (point-max))
1340 (insert (symbol-name header) ": " value "\n")
1342 ;; The value of this header was empty, so we clear
1343 ;; totally and insert the new value.
1344 (delete-region (point) (gnus-point-at-eol))
1346 ;; Add the deletable property to the headers that require it.
1347 (and (memq header gnus-deletable-headers)
1348 (progn (beginning-of-line) (looking-at "[^:]+: "))
1349 (add-text-properties
1350 (point) (match-end 0)
1351 '(gnus-deletable t face italic) (current-buffer)))))))
1352 ;; Insert new Sender if the From is strange.
1353 (let ((from (mail-fetch-field "from"))
1354 (sender (mail-fetch-field "sender"))
1355 (secure-sender (gnus-inews-real-user-address)))
1357 (not (gnus-check-before-posting 'sender))
1359 (downcase (car (cdr (gnus-extract-address-components
1361 (downcase (gnus-inews-real-user-address))))
1365 (downcase (car (cdr (gnus-extract-address-components
1367 (downcase secure-sender)))))
1368 (goto-char (point-min))
1369 ;; Rename any old Sender headers to Original-Sender.
1370 (when (re-search-forward "^Sender:" nil t)
1372 (insert "Original-")
1373 (beginning-of-line))
1374 (insert "Sender: " secure-sender "\n")))))
1376 (defun gnus-inews-insert-signature ()
1377 "Insert a signature file.
1378 If `gnus-signature-function' is bound and returns a string, this
1379 string is used instead of the variable `gnus-signature-file'.
1380 In either case, if the string is a file name, this file is
1381 inserted. If the string is not a file name, the string itself is
1384 If you never want any signature inserted, set both of these variables to
1388 (or (and gnus-signature-function
1389 (funcall gnus-signature-function gnus-newsgroup-name))
1390 gnus-signature-file)))
1392 (or (file-exists-p signature)
1393 (string-match " " signature)
1395 "^/[^/]+/" (expand-file-name signature)))))
1397 (goto-char (point-max))
1398 (if (and mail-signature (search-backward "\n-- \n" nil t))
1400 ;; Delete any previous signatures.
1401 (if (search-backward "\n-- \n" nil t)
1402 (delete-region (point) (point-max)))
1403 (or (eolp) (insert "\n"))
1405 (if (file-exists-p signature)
1406 (insert-file-contents signature)
1408 (goto-char (point-max))
1409 (or (bolp) (insert "\n"))))))))
1411 ;; Written by "Mr. Per Persson" <pp@solace.mh.se>.
1412 (defun gnus-inews-insert-mime-headers ()
1413 (goto-char (point-min))
1414 (let ((mail-header-separator
1416 (goto-char (point-min))
1417 (if (and (search-forward (concat "\n" mail-header-separator "\n")
1419 (not (search-backward "\n\n" nil t)))
1420 mail-header-separator
1422 (or (mail-position-on-field "Mime-Version")
1424 (cond ((save-restriction
1426 (goto-char (point-min))
1427 (re-search-forward "[\200-\377]" nil t))
1428 (or (mail-position-on-field "Content-Type")
1429 (insert "text/plain; charset=ISO-8859-1"))
1430 (or (mail-position-on-field "Content-Transfer-Encoding")
1432 (t (or (mail-position-on-field "Content-Type")
1433 (insert "text/plain; charset=US-ASCII"))
1434 (or (mail-position-on-field "Content-Transfer-Encoding")
1435 (insert "7bit")))))))
1437 (defun gnus-inews-do-fcc ()
1438 "Process Fcc headers in the current buffer.
1439 Unless the first character of the field is `|', the article is saved
1440 to the specified file using the function specified by the variable
1441 gnus-author-copy-saver. The default function rmail-output saves in
1442 Unix mailbox format.
1444 If the first character is `|', the contents of the article is sent to
1445 a program specified by the rest of the value."
1446 (let ((case-fold-search t) ;Should ignore case.
1450 (nnheader-narrow-to-headers)
1451 (while (setq file (mail-fetch-field "fcc"))
1453 (nnheader-remove-header "fcc" nil t))
1454 ;; Process FCC operations.
1457 (setq file (pop list))
1458 (if (string-match "^[ \t]*|[ \t]*\\(.*\\)[ \t]*$" file)
1459 ;; Pipe the article to the program in question.
1460 (call-process-region (point-min) (point-max) shell-file-name
1461 nil nil nil "-c" (match-string 1 file))
1462 ;; Save the article.
1463 (setq file (expand-file-name file))
1464 (gnus-make-directory (file-name-directory file))
1465 (if (and gnus-author-copy-saver
1466 (not (eq gnus-author-copy-saver 'rmail-output)))
1467 (funcall gnus-author-copy-saver file)
1468 (if (and (file-readable-p file) (mail-file-babyl-p file))
1469 (gnus-output-to-rmail file)
1470 (let ((mail-use-rfc822 t))
1471 (rmail-output file 1 t t))))))))))
1473 (defun gnus-inews-path ()
1475 (let ((login-name (gnus-inews-login-name)))
1476 (cond ((null gnus-use-generic-path)
1477 (concat (nth 1 gnus-select-method) "!" login-name))
1478 ((stringp gnus-use-generic-path)
1479 ;; Support GENERICPATH. Suggested by vixie@decwrl.dec.com.
1480 (concat gnus-use-generic-path "!" login-name))
1483 (defun gnus-inews-user-name ()
1484 "Return user's network address as \"NAME@DOMAIN (FULL-NAME)\"."
1485 (let ((full-name (gnus-inews-full-name))
1486 (address (if (or gnus-user-login-name gnus-use-generic-from
1487 gnus-local-domain (getenv "DOMAINNAME"))
1488 (concat (gnus-inews-login-name) "@"
1489 (gnus-inews-domain-name gnus-use-generic-from))
1490 user-mail-address)))
1491 (or gnus-user-from-line
1493 ;; User's full name.
1494 (cond ((string-equal full-name "&") ;Unix hack.
1495 (concat " (" (user-login-name) ")"))
1496 ((string-match "[^ ]+@[^ ]+ +(.*)" address)
1499 (concat " (" full-name ")")))))))
1501 (defun gnus-inews-real-user-address ()
1502 "Return the \"real\" user address.
1503 This function tries to ignore all user modifications, and
1504 give as trustworthy answer as possible."
1505 (concat (user-login-name) "@" (system-name)))
1507 (defun gnus-inews-login-name ()
1508 "Return login name."
1509 (or gnus-user-login-name (getenv "LOGNAME") (user-login-name)))
1511 (defun gnus-inews-full-name ()
1512 "Return full user name."
1513 (or gnus-user-full-name (getenv "NAME") (user-full-name)))
1515 (defun gnus-inews-domain-name (&optional genericfrom)
1516 "Return user's domain name.
1517 If optional argument GENERICFROM is a string, use it as the domain
1518 name; if it is non-nil, strip off local host name from the domain name.
1519 If the function `system-name' returns full internet name and the
1520 domain is undefined, the domain name is got from it."
1521 (if (or genericfrom gnus-local-domain (getenv "DOMAINNAME"))
1522 (let* ((system-name (system-name))
1524 (or (if (stringp genericfrom) genericfrom)
1525 (getenv "DOMAINNAME")
1526 (and (boundp 'mail-host-address)
1529 ;; Function `system-name' may return full internet name.
1530 ;; Suggested by Mike DeCorte <mrd@sun.soe.clarkson.edu>.
1531 (if (string-match "\\.." system-name)
1532 ;; Some machines return "name.", and that's not
1534 (substring system-name (1- (match-end 0))))
1535 (read-string "Domain name (no host): ")))
1536 (host (or (if (string-match "\\." system-name)
1537 (substring system-name 0 (match-beginning 0)))
1539 (if (string-equal "." (substring domain 0 1))
1540 (setq domain (substring domain 1)))
1541 ;; Support GENERICFROM as same as standard Bnews system.
1542 ;; Suggested by ohm@kaba.junet and vixie@decwrl.dec.com.
1543 (cond ((null genericfrom)
1544 (concat host "." domain))
1545 ;;((stringp genericfrom) genericfrom)
1547 (if (string-match "\\." (system-name))
1549 (if (string-match "@\\([^ ]+\\)\\($\\| \\)" user-mail-address)
1550 (substring user-mail-address
1551 (match-beginning 1) (match-end 1))
1554 (defun gnus-inews-full-address ()
1555 (let ((domain (gnus-inews-domain-name))
1556 (system (system-name))
1557 (case-fold-search t))
1558 (if (string-match "\\." system) system
1559 (if (string-match (concat "^" (regexp-quote system)) domain) domain
1560 (concat system "." domain)))))
1562 (defun gnus-inews-expires ()
1563 "Return an Expires header based on `gnus-article-expires'."
1564 (let ((current (current-time))
1565 (future (* 1.0 gnus-article-expires 60 60 24)))
1566 ;; Add the future to current.
1567 (setcar current (+ (car current) (round (/ future (expt 2 16)))))
1568 (setcar (cdr current) (+ (nth 1 current) (% (round future) (expt 2 16))))
1569 ;; Return the date in the future in UT.
1570 (timezone-make-date-arpa-standard
1571 (current-time-string current) (current-time-zone) '(0 "UT"))))
1573 (defun gnus-inews-distribution ()
1574 "Return the current Distribution header, if any."
1575 (when (and gnus-distribution-function
1576 (fboundp gnus-distribution-function))
1577 (funcall gnus-distribution-function (or gnus-newsgroup-name ""))))
1579 (defun gnus-inews-message-id ()
1580 "Generate unique Message-ID for user."
1581 ;; Message-ID should not contain a slash and should be terminated by
1582 ;; a number. I don't know the reason why it is so.
1583 (concat "<" (gnus-inews-unique-id) "@" (gnus-inews-full-address) ">"))
1585 (defvar gnus-unique-id-char nil)
1587 ;; If you ever change this function, make sure the new version
1588 ;; cannot generate IDs that the old version could.
1589 ;; You might for example insert a "." somewhere (not next to another dot
1590 ;; or string boundary), or modify the newsreader name to "Ding".
1591 (defun gnus-inews-unique-id ()
1592 ;; Don't use microseconds from (current-time), they may be unsupported.
1593 ;; Instead we use this randomly inited counter.
1594 (setq gnus-unique-id-char
1595 (% (1+ (or gnus-unique-id-char (logand (random t) (1- (lsh 1 20)))))
1596 ;; (current-time) returns 16-bit ints,
1597 ;; and 2^16*25 just fits into 4 digits i base 36.
1599 (let ((tm (if (fboundp 'current-time)
1600 (current-time) '(12191 46742 287898))))
1602 (if (memq system-type '(ms-dos emx vax-vms))
1603 (let ((user (downcase (gnus-inews-login-name))))
1604 (while (string-match "[^a-z0-9_]" user)
1605 (aset user (match-beginning 0) ?_))
1607 (gnus-number-base36 (user-uid) -1))
1608 (gnus-number-base36 (+ (car tm) (lsh (% gnus-unique-id-char 25) 16)) 4)
1609 (gnus-number-base36 (+ (nth 1 tm) (lsh (/ gnus-unique-id-char 25) 16)) 4)
1610 ;; Append the newsreader name, because while the generated
1611 ;; ID is unique to this newsreader, other newsreaders might
1612 ;; otherwise generate the same ID via another algorithm.
1616 (defun gnus-inews-date ()
1617 "Current time string."
1618 (let ((now (current-time)))
1619 (timezone-make-date-arpa-standard
1620 (current-time-string now) (current-time-zone now))))
1622 (defun gnus-inews-organization ()
1623 "Return user's organization.
1624 The ORGANIZATION environment variable is used if defined.
1625 If not, the variable `gnus-local-organization' is used instead.
1626 If it is a function, the function will be called with the current
1627 newsgroup name as the argument.
1628 If this is a file name, the contents of this file will be used as the
1630 (let* ((organization
1631 (or (getenv "ORGANIZATION")
1632 (if gnus-local-organization
1633 (if (gnus-functionp gnus-local-organization)
1634 (funcall gnus-local-organization gnus-newsgroup-name)
1635 gnus-local-organization))
1636 gnus-organization-file
1637 "~/.organization")))
1638 (and (stringp organization)
1639 (> (length organization) 0)
1640 (or (file-exists-p organization)
1641 (string-match " " organization)
1642 (not (string-match "^/usr/lib/\\|^~/" organization)))
1644 (gnus-set-work-buffer)
1645 (if (file-exists-p organization)
1646 (insert-file-contents organization)
1647 (insert organization))
1648 (goto-char (point-min))
1649 (while (re-search-forward " *\n *" nil t)
1650 (replace-match " " t t))
1651 (buffer-substring (point-min) (point-max))))))
1653 (defun gnus-inews-lines ()
1654 "Count the number of lines and return numeric string."
1658 (goto-char (point-min))
1660 (concat "^" (regexp-quote mail-header-separator) "$"))
1662 (int-to-string (count-lines (point) (point-max))))))
1664 (defun gnus-inews-in-reply-to ()
1665 "Return the In-Reply-To header for this message."
1670 ;;; Gnus Mail Functions
1673 ;;; Mail reply commands of Gnus summary mode
1675 (defun gnus-summary-reply (yank &optional yank-articles)
1676 "Reply mail to news author.
1677 If prefix argument YANK is non-nil, original article is yanked automatically.
1678 Customize the variable gnus-mail-reply-method to use another mailer."
1680 ;; Bug fix by jbw@bigbird.bu.edu (Joe Wells)
1681 ;; Stripping headers should be specified with mail-yank-ignored-headers.
1682 (gnus-set-global-variables)
1683 (if yank-articles (gnus-summary-goto-subject (car yank-articles)))
1684 (gnus-summary-select-article)
1685 (bury-buffer gnus-article-buffer)
1686 (gnus-mail-reply (or yank-articles (not (not yank)))))
1688 (defun gnus-summary-reply-with-original (n)
1689 "Reply mail to news author with original article.
1690 Customize the variable gnus-mail-reply-method to use another mailer."
1692 (gnus-summary-reply t (gnus-summary-work-articles n)))
1694 (defun gnus-summary-mail-forward (post)
1695 "Forward the current message to another user.
1696 Customize the variable gnus-mail-forward-method to use another mailer."
1698 (gnus-set-global-variables)
1699 (gnus-summary-select-article)
1700 (gnus-copy-article-buffer)
1702 (gnus-forward-using-post gnus-original-article-buffer)
1703 (gnus-mail-forward gnus-original-article-buffer)))
1705 (defun gnus-summary-resend-message (address)
1706 "Resend the current article to ADDRESS."
1707 (interactive "sResend message to: ")
1708 (gnus-summary-select-article)
1711 ;; We first set up a normal mail buffer.
1712 (nnheader-set-temp-buffer " *Gnus resend*")
1713 ;; This code from sendmail.el
1715 (let ((fill-prefix "\t")
1716 (address-start (point)))
1717 (insert address "\n")
1718 (fill-region-as-paragraph address-start (point-max)))
1719 (insert mail-header-separator "\n")
1720 ;; Insert our usual headers.
1721 (gnus-inews-narrow-to-headers)
1722 (gnus-inews-insert-headers '(From Date To))
1723 (goto-char (point-min))
1724 ;; Rename them all to "Resent-*".
1725 (while (re-search-forward "^[A-Za-z]" nil t)
1730 (delete-region (point) (point-max))
1732 ;; Insert the message to be resent.
1733 (insert-buffer-substring gnus-original-article-buffer)
1734 (goto-char (point-min))
1735 (search-forward "\n\n")
1737 (insert mail-header-separator)
1738 ;; Rename all old ("Also-")Resent headers.
1739 (while (re-search-backward "^\\(Also-\\)?Resent-" beg t)
1744 (kill-buffer (current-buffer)))))
1746 (defun gnus-summary-post-forward ()
1747 "Forward the current article to a newsgroup."
1749 (gnus-summary-mail-forward t))
1751 (defvar gnus-nastygram-message
1752 "The following article was inappropriately posted to %s.\n"
1753 "Format string to insert in nastygrams.
1754 The current group name will be inserted at \"%s\".")
1756 (defun gnus-summary-mail-nastygram (n)
1757 "Send a nastygram to the author of the current article."
1759 (if (or gnus-expert-user
1761 "Really send a nastygram to the author of the current article? "))
1762 (let ((group gnus-newsgroup-name))
1763 (gnus-summary-reply-with-original n)
1764 (set-buffer gnus-mail-buffer)
1765 (insert (format gnus-nastygram-message group))
1766 (gnus-mail-send-and-exit))))
1768 (defun gnus-summary-mail-other-window ()
1769 "Compose mail in other window.
1770 Customize the variable `gnus-mail-other-window-method' to use another
1773 (gnus-set-global-variables)
1775 ;; We might want to prompt here.
1776 (when (and gnus-interactive-post
1777 (not gnus-expert-user))
1778 (read-string "To: ")))
1779 (gnus-configure-windows 'summary-mail 'force))
1781 (defun gnus-new-mail (&optional to)
1783 (when (and gnus-interactive-post
1784 (not gnus-expert-user))
1785 (setq subject (read-string "Subject: ")))
1786 (pop-to-buffer gnus-mail-buffer)
1788 (gnus-mail-setup 'new to subject)
1789 (gnus-inews-insert-gcc)
1790 (gnus-inews-insert-archive-gcc)
1791 (run-hooks 'gnus-mail-hook)))
1793 (defun gnus-mail-reply (&optional yank to-address followup)
1795 (set-buffer gnus-summary-buffer)
1796 (let ((group (gnus-group-real-name gnus-newsgroup-name))
1797 (cur (cons (current-buffer) (cdr gnus-article-current)))
1798 (winconf (current-window-configuration))
1799 from subject date reply-to message-of to cc
1800 references message-id sender follow-to sendto elt new-cc new-to
1802 (set-buffer (get-buffer-create gnus-mail-buffer))
1804 (if (and (buffer-modified-p)
1807 "Unsent message being composed; erase it? ")))
1811 (gnus-copy-article-buffer)
1813 (set-buffer gnus-article-copy)
1814 (nnheader-narrow-to-headers)
1816 ;; This is a regular reply.
1817 (if (gnus-functionp gnus-reply-to-function)
1818 (setq follow-to (funcall gnus-reply-to-function group)))
1819 ;; This is a followup.
1820 (if (gnus-functionp gnus-followup-to-function)
1823 (funcall gnus-followup-to-function group)))))
1824 (setq from (mail-fetch-field "from"))
1825 (setq date (or (mail-fetch-field "date")
1826 (mail-header-date gnus-current-headers)))
1827 (setq message-of (gnus-message-of from date))
1828 (setq sender (mail-fetch-field "sender"))
1829 (setq subject (or (mail-fetch-field "subject") "none"))
1830 ;; Remove any (buggy) Re:'s that are present and make a
1832 (and (string-match "^[ \t]*[Re][Ee]:[ \t]*" subject)
1833 (setq subject (substring subject (match-end 0))))
1834 (setq subject (concat "Re: " subject))
1835 (setq to (mail-fetch-field "to"))
1836 (setq cc (mail-fetch-field "cc"))
1837 (setq mct (mail-fetch-field "mail-copies-to"))
1839 (unless (gnus-group-get-parameter group 'broken-reply-to)
1840 (mail-fetch-field "reply-to")))
1841 (setq references (mail-fetch-field "references"))
1842 (setq message-id (mail-fetch-field "message-id"))
1844 (setq mctdo (not (equal mct "never")))
1846 (if (not (and followup (not to-address)))
1847 (setq new-to (or reply-to from))
1850 (gnus-set-work-buffer)
1851 (unless (equal mct "never")
1852 (insert (or reply-to from "")))
1854 (if (bolp) "" ", ") (or to "")
1855 (if (or (not mct) (not mctdo)) ""
1856 (concat (if (bolp) "" ", ") mct))
1857 (if cc (concat (if (bolp) "" ", ") cc) ""))
1858 ;; Remove addresses that match `rmail-dont-reply-to-names'.
1859 (insert (prog1 (rmail-dont-reply-to (buffer-string))
1861 (goto-char (point-min))
1865 (cons (mail-strip-quoted-names addr) addr))
1866 (nreverse (gnus-mail-parse-comma-list))))
1869 (setq ccalist (delq (assoc (car (pop s)) s) ccalist)))))
1870 (setq new-to (cdr (pop ccalist)))
1873 (lambda (addr) (cdr addr))
1877 (setq news-reply-yank-from (or from "(nobody)"))
1878 (setq news-reply-yank-message-id
1879 (or message-id "(unknown Message-ID)"))
1881 ;; Gather the "to" addresses out of the follow-to list and remove
1883 (if (and follow-to (listp follow-to))
1884 (while (setq elt (assoc "To" follow-to))
1885 (setq sendto (concat sendto (and sendto ", ") (cdr elt)))
1886 (setq follow-to (delq elt follow-to))))
1889 (if followup 'followup 'reply)
1891 (if (and follow-to (not (stringp follow-to))) sendto
1892 (or follow-to new-to sender "")))
1894 (if (zerop (length new-cc)) nil new-cc)
1897 (make-local-variable 'gnus-article-reply)
1898 (setq gnus-article-reply cur)
1899 (make-local-variable 'gnus-prev-winconf)
1900 (setq gnus-prev-winconf winconf)
1901 (make-local-variable 'gnus-reply-subject)
1902 (setq gnus-reply-subject subject)
1903 (make-local-variable 'gnus-in-reply-to)
1904 (setq gnus-in-reply-to message-of)
1906 (auto-save-mode auto-save-default)
1907 (gnus-inews-insert-gcc)
1908 (gnus-inews-insert-archive-gcc)
1910 (when (and follow-to (listp follow-to))
1912 (gnus-inews-narrow-to-headers)
1913 (re-search-forward "^To:" nil t)
1917 ;; Insert the rest of the Follow-To headers.
1919 (goto-char (point-min))
1920 (if (not (re-search-forward
1921 (concat "^" (caar follow-to) ": *") nil t))
1924 (insert (caar follow-to) ": " (cdar follow-to) "\n"))
1927 (insert (cdar follow-to)))
1928 (setq follow-to (cdr follow-to)))
1930 (nnheader-insert-references references message-id)
1932 ;; Now the headers should be ok, so we do the yanking.
1933 (goto-char (point-min))
1935 (concat "^" (regexp-quote mail-header-separator) "$"))
1938 (gnus-configure-windows 'reply 'force)
1939 (let ((last (point))
1941 (if (not (listp yank))
1943 ;; Just a single article being yanked.
1945 (mail-yank-original nil))
1946 (or mail-yank-hooks mail-citation-hook
1947 (run-hooks 'news-reply-header-hook)))
1949 (save-window-excursion
1950 (set-buffer gnus-summary-buffer)
1951 (gnus-summary-select-article nil nil nil (car yank))
1952 (gnus-summary-remove-process-mark (car yank)))
1955 (gnus-copy-article-buffer)
1956 (mail-yank-original nil)
1958 (narrow-to-region (point-min) (point))
1959 (goto-char (mark t))
1960 (let ((news-reply-yank-from
1962 (set-buffer gnus-article-buffer)
1963 (or (mail-fetch-field "from") "(nobody)")))
1964 (news-reply-yank-message-id
1966 (set-buffer gnus-article-buffer)
1967 (or (mail-fetch-field "message-id")
1968 "(unknown Message-ID)"))))
1969 (or mail-yank-hooks mail-citation-hook
1970 (run-hooks 'news-reply-header-hook))
1971 (setq end (point-max)))))
1973 (setq yank (cdr yank))))
1976 (gnus-configure-windows 'reply-yank 'force))
1977 (run-hooks 'gnus-mail-hook)
1978 ;; Mark this buffer as unchanged.
1979 (set-buffer-modified-p nil)))))
1981 (defun gnus-mail-parse-comma-list ()
1984 (skip-chars-forward " ")
1987 (skip-chars-forward "^,")
1992 (narrow-to-region beg (point))
1995 (while (search-forward "\"" nil t)
1997 (if (zerop i) 2 i)) 2)))))
1998 (skip-chars-forward ",")
1999 (skip-chars-forward "^,"))
2000 (skip-chars-backward " ")
2002 (cons (buffer-substring beg (point))
2004 (skip-chars-forward "^,")
2005 (skip-chars-forward ", "))
2008 (defun gnus-new-news (&optional group inhibit-prompt)
2009 "Set up a *post-news* buffer that points to GROUP.
2010 If INHIBIT-PROMPT, never prompt for a Subject."
2011 (let ((winconf (current-window-configuration))
2013 (when (and gnus-interactive-post
2014 (not inhibit-prompt)
2015 (not gnus-expert-user))
2016 (setq subject (read-string "Subject: ")))
2017 (pop-to-buffer gnus-post-news-buffer)
2020 ;; Let posting styles be configured.
2021 (gnus-configure-posting-styles)
2022 (news-setup nil subject nil (and group (gnus-group-real-name group)) nil)
2023 ;; Associate this buffer with the draft group.
2024 (gnus-enter-buffer-into-draft)
2025 (goto-char (point-min))
2027 (unless (re-search-forward
2028 (concat "^" (regexp-quote mail-header-separator) "$") nil t)
2029 (goto-char (point-max)))
2032 (gnus-inews-insert-bfcc)
2033 (gnus-inews-insert-gcc)
2034 (gnus-inews-insert-archive-gcc)
2035 (gnus-inews-insert-signature)
2036 (and gnus-post-prepare-function
2037 (gnus-functionp gnus-post-prepare-function)
2038 (funcall gnus-post-prepare-function group))
2039 (run-hooks 'gnus-post-prepare-hook)
2040 (gnus-inews-set-point)
2041 (make-local-variable 'gnus-prev-winconf)
2042 (setq gnus-prev-winconf winconf)
2043 (gnus-inews-modify-mail-mode-map)
2044 (local-set-key "\C-c\C-c" 'gnus-inews-news)))
2046 (defun gnus-news-followup (&optional yank group)
2048 (set-buffer gnus-summary-buffer)
2049 (if (not (or (not gnus-novice-user)
2052 "Are you sure you want to post to all of USENET? ")))
2054 (let ((group (gnus-group-real-name (or group gnus-newsgroup-name)))
2055 (cur (cons (current-buffer) (cdr gnus-article-current)))
2056 (winconf (current-window-configuration))
2057 from subject date reply-to message-of
2058 references message-id sender follow-to sendto elt
2059 followup-to distribution newsgroups)
2060 (set-buffer (get-buffer-create gnus-post-news-buffer))
2062 ;; Associate this buffer with the draft group.
2063 (gnus-enter-buffer-into-draft)
2064 (if (and (buffer-modified-p)
2067 "Unsent message being composed; erase it? ")))
2071 (gnus-copy-article-buffer)
2073 (set-buffer gnus-article-copy)
2074 (nnheader-narrow-to-headers)
2075 (if (gnus-functionp gnus-followup-to-function)
2078 (funcall gnus-followup-to-function group))))
2079 (setq from (mail-fetch-field "from"))
2080 (setq date (or (mail-fetch-field "date")
2081 (mail-header-date gnus-current-headers)))
2082 (setq message-of (gnus-message-of from date))
2083 (setq subject (or (mail-fetch-field "subject") "none"))
2084 ;; Remove any (buggy) Re:'s that are present and make a
2086 (and (string-match "^[ \t]*[Re][Ee]:[ \t]*" subject)
2087 (setq subject (substring subject (match-end 0))))
2088 (setq subject (concat "Re: " subject))
2089 (setq references (mail-fetch-field "references"))
2090 (setq message-id (mail-fetch-field "message-id"))
2091 (setq followup-to (mail-fetch-field "followup-to"))
2092 (setq newsgroups (mail-fetch-field "newsgroups"))
2093 (setq distribution (mail-fetch-field "distribution"))
2094 ;; Remove bogus distribution.
2095 (and (stringp distribution)
2096 (string-match "world" distribution)
2097 (setq distribution nil))
2100 (setq news-reply-yank-from (or from "(nobody)"))
2101 (setq news-reply-yank-message-id
2102 (or message-id "(unknown Message-ID)"))
2104 ;; Gather the "to" addresses out of the follow-to list and remove
2106 (if (and follow-to (listp follow-to))
2107 (while (setq elt (assoc "Newsgroups" follow-to))
2108 (setq sendto (concat sendto (and sendto ", ") (cdr elt)))
2109 (setq follow-to (delq elt follow-to))))
2111 ;; Let posting styles be configured.
2112 (gnus-configure-posting-styles)
2114 (news-setup nil subject nil
2117 gnus-use-followup-to
2118 (or (not (eq gnus-use-followup-to 'ask))
2121 "Use Followup-To %s? " followup-to)))
2123 newsgroups group "")
2126 (make-local-variable 'gnus-article-reply)
2127 (setq gnus-article-reply cur)
2128 (make-local-variable 'gnus-prev-winconf)
2129 (setq gnus-prev-winconf winconf)
2130 (make-local-variable 'gnus-reply-subject)
2131 (setq gnus-reply-subject (mail-header-subject gnus-current-headers))
2132 (make-local-variable 'gnus-in-reply-to)
2133 (setq gnus-in-reply-to message-of)
2134 (when (and followup-to newsgroups)
2135 (make-local-variable 'gnus-newsgroup-followup)
2136 (setq gnus-newsgroup-followup
2137 (cons newsgroups followup-to)))
2139 (gnus-inews-insert-signature)
2141 (and gnus-post-prepare-function
2142 (gnus-functionp gnus-post-prepare-function)
2143 (funcall gnus-post-prepare-function group))
2144 (run-hooks 'gnus-post-prepare-hook)
2146 (auto-save-mode auto-save-default)
2147 (gnus-inews-modify-mail-mode-map)
2148 (local-set-key "\C-c\C-c" 'gnus-inews-news)
2150 (if (and follow-to (listp follow-to))
2152 (goto-char (point-min))
2153 (and (re-search-forward "^Newsgroups:" nil t)
2156 (insert (car (car follow-to)) ": "
2157 (cdr (car follow-to)) "\n")
2158 (setq follow-to (cdr follow-to)))))
2160 ;; If a distribution existed, we use it.
2163 (mail-position-on-field "Distribution")
2164 (insert distribution)))
2166 (nnheader-insert-references references message-id)
2168 ;; Handle `gnus-auto-mail-to-author'.
2169 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
2170 ;; Revised to respect Reply-To by Ulrik Dickow <dickow@nbi.dk>.
2171 (let ((to (if (if (eq gnus-auto-mail-to-author 'ask)
2172 (y-or-n-p "Also send mail to author? ")
2173 gnus-auto-mail-to-author)
2175 (set-buffer gnus-article-copy)
2176 (unless (gnus-group-get-parameter
2177 group 'broken-reply-to)
2178 (gnus-fetch-field "reply-to")))
2180 (x-mail (save-excursion
2181 (set-buffer gnus-article-copy)
2182 (gnus-fetch-field "x-mail-copy-to"))))
2183 ;; Deny sending copy if there's a negative X-Mail-Copy-To
2186 (if (and (string= x-mail "never")
2187 (not (eq gnus-auto-mail-to-author 'force)))
2190 ;; Insert a To or Cc header.
2192 (if (mail-fetch-field "To")
2195 (insert "Cc: " to "\n"))
2196 (mail-position-on-field "To")
2199 (gnus-inews-insert-bfcc)
2200 (gnus-inews-insert-gcc)
2201 (gnus-inews-insert-archive-gcc)
2203 ;; Now the headers should be ok, so we do the yanking.
2204 (goto-char (point-min))
2206 (concat "^" (regexp-quote mail-header-separator) "$"))
2210 (gnus-configure-windows 'followup 'force)
2213 (let ((last (point))
2215 (if (not (listp yank))
2218 (mail-yank-original nil))
2219 (or mail-yank-hooks mail-citation-hook
2220 (run-hooks 'news-reply-header-hook)))
2222 (save-window-excursion
2223 (set-buffer gnus-summary-buffer)
2224 (gnus-summary-select-article nil nil nil (car yank))
2225 (gnus-summary-remove-process-mark (car yank)))
2227 (gnus-copy-article-buffer)
2228 (mail-yank-original nil)
2230 (or mail-yank-hooks mail-citation-hook
2231 (run-hooks 'news-reply-header-hook))
2233 (setq yank (cdr yank))))
2235 (gnus-configure-windows 'followup-yank 'force))
2237 (make-local-variable 'gnus-article-check-size)
2238 (setq gnus-article-check-size
2239 (cons (buffer-size) (gnus-article-checksum)))
2240 (gnus-inews-set-point))))))
2242 (defun gnus-message-of (from date)
2243 "Take a FROM and a DATE and return an IN-REPLY-TO."
2246 (string-match " *at \\| *@ \\| *(\\| *<" from)))
2247 (concat (if stop-pos (substring from 0 stop-pos) from)
2249 (if (or (not date) (string= date ""))
2250 "(unknown date)" date)))))
2252 (defun gnus-mail-yank-original ()
2255 (mail-yank-original nil))
2256 (or mail-yank-hooks mail-citation-hook
2257 (run-hooks 'news-reply-header-hook)))
2259 (defun gnus-mail-send-and-exit (&optional dont-send)
2260 "Send the current mail and return to Gnus."
2262 (let* ((reply gnus-article-reply)
2263 (winconf gnus-prev-winconf)
2264 (address-group gnus-add-to-address)
2265 (to-address (and address-group
2266 (mail-fetch-field "to"))))
2267 (setq gnus-add-to-address nil)
2268 (let ((buffer-file-name nil))
2269 (or dont-send (gnus-mail-send)))
2271 ;; This mail group doesn't have a `to-list', so we add one
2274 (gnus-group-add-parameter
2275 address-group (cons 'to-list to-address)))
2276 (if (get-buffer gnus-group-buffer)
2278 (if (gnus-buffer-exists-p (car-safe reply))
2280 (set-buffer (car reply))
2282 (gnus-summary-mark-article-as-replied
2284 (and winconf (set-window-configuration winconf))))))
2286 (defun gnus-kill-message-buffer ()
2287 "Kill the current buffer after dissociating it from the draft group."
2289 (when (gnus-y-or-n-p "Dissociate and kill the current buffer? ")
2290 (gnus-dissociate-buffer-from-draft)
2291 (kill-buffer (current-buffer))))
2293 (defun gnus-put-message ()
2294 "Put the current message in some group and return to Gnus."
2296 (let ((reply gnus-article-reply)
2297 (winconf gnus-prev-winconf)
2298 (group gnus-newsgroup-name)
2301 (or (and group (not (gnus-group-read-only-p group)))
2302 (setq group (read-string "Put in group: " nil
2303 (gnus-writable-groups))))
2304 (and (gnus-gethash group gnus-newsrc-hashtb)
2305 (error "No such group: %s" group))
2310 (gnus-inews-narrow-to-headers)
2311 (let (gnus-deletable-headers)
2312 (if (eq major-mode 'mail-mode)
2313 (gnus-inews-insert-headers gnus-required-mail-headers)
2314 (gnus-inews-insert-headers)))
2315 (goto-char (point-max))
2316 (insert "Gcc: " group "\n")
2321 (if (get-buffer gnus-group-buffer)
2323 (if (gnus-buffer-exists-p (car-safe reply))
2325 (set-buffer (car reply))
2327 (gnus-summary-mark-article-as-replied
2329 (and winconf (set-window-configuration winconf))))))
2331 (defun gnus-forward-make-subject (buffer)
2334 (concat "[" (if (memq 'mail (assoc (symbol-name
2335 (car (gnus-find-method-for-group
2336 gnus-newsgroup-name)))
2337 gnus-valid-select-methods))
2338 (gnus-fetch-field "From")
2339 gnus-newsgroup-name)
2340 "] " (or (gnus-fetch-field "Subject") ""))))
2342 (defun gnus-forward-insert-buffer (buffer)
2345 ;; Put point where we want it before inserting the forwarded
2347 (if gnus-signature-before-forwarded-message
2348 (goto-char (point-max))
2349 (goto-char (point-min))
2351 (concat "^" (regexp-quote mail-header-separator) "$"))
2353 ;; Narrow to the area we are to insert.
2354 (narrow-to-region (point) (point))
2355 ;; Insert the separators and the forwarded buffer.
2356 (insert gnus-forward-start-separator)
2357 (insert-buffer-substring buffer)
2358 (goto-char (point-max))
2359 (insert gnus-forward-end-separator)
2360 ;; Remove all unwanted headers.
2361 (goto-char (point-min))
2364 (narrow-to-region (point) (if (search-forward "\n\n" nil t)
2367 (goto-char (point-min))
2368 (delete-non-matching-lines gnus-forward-included-headers))
2369 ;; Delete any invisible text.
2370 (goto-char (point-min))
2372 (while (setq beg (next-single-property-change (point) 'invisible))
2374 (delete-region beg (or (next-single-property-change
2378 (defun gnus-mail-forward (&optional buffer)
2379 "Forward the current message to another user using mail."
2380 (let* ((forward-buffer (or buffer (current-buffer)))
2381 (winconf (current-window-configuration))
2382 (subject (gnus-forward-make-subject forward-buffer)))
2383 (set-buffer (get-buffer-create gnus-mail-buffer))
2384 (if (and (buffer-modified-p)
2387 "Unsent message being composed; erase it? ")))
2390 (gnus-mail-setup 'forward nil subject)
2391 (make-local-variable 'gnus-prev-winconf)
2392 (setq gnus-prev-winconf winconf)
2393 (gnus-forward-insert-buffer forward-buffer)
2394 (goto-char (point-min))
2395 (re-search-forward "^To: ?" nil t)
2396 (gnus-configure-windows 'mail-forward 'force)
2397 ;; You have a chance to arrange the message.
2398 (run-hooks 'gnus-mail-forward-hook)
2399 (run-hooks 'gnus-mail-hook))))
2401 (defun gnus-forward-using-post (&optional buffer)
2403 (let* ((forward-buffer (or buffer (current-buffer)))
2404 (subject (gnus-forward-make-subject forward-buffer))
2405 (gnus-newsgroup-name nil))
2406 (gnus-post-news 'post nil nil nil nil subject)
2408 (gnus-forward-insert-buffer forward-buffer)
2409 ;; You have a chance to arrange the message.
2410 (run-hooks 'gnus-mail-forward-hook)))))
2412 (defun gnus-mail-other-window-using-mail ()
2413 "Compose mail other window using mail."
2414 (let ((winconf (current-window-configuration)))
2415 (mail-other-window nil nil nil nil nil (get-buffer gnus-article-buffer))
2416 (gnus-inews-modify-mail-mode-map)
2417 (make-local-variable 'gnus-prev-winconf)
2418 (setq gnus-prev-winconf winconf)
2419 (run-hooks 'gnus-mail-hook)
2420 (gnus-configure-windows 'summary-mail 'force)))
2422 (defun gnus-article-mail (yank)
2423 "Send a reply to the address near point.
2424 If YANK is non-nil, include the original article."
2428 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
2429 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
2432 (switch-to-buffer gnus-summary-buffer)
2433 (gnus-mail-reply yank address)))))
2436 "Send a bug report to the Gnus maintainers."
2438 (let ((winconf (current-window-configuration)))
2439 (delete-other-windows)
2440 (switch-to-buffer "*Gnus Help Bug*")
2442 (insert gnus-bug-message)
2443 (goto-char (point-min))
2444 (pop-to-buffer "*Gnus Bug*")
2447 (mail-setup gnus-maintainer nil nil nil nil nil)
2448 (auto-save-mode auto-save-default)
2449 (make-local-variable 'gnus-prev-winconf)
2450 (setq gnus-prev-winconf winconf)
2451 (gnus-inews-modify-mail-mode-map)
2452 (local-set-key "\C-c\C-c" 'gnus-bug-mail-send-and-exit)
2453 (goto-char (point-min))
2454 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
2456 (insert (gnus-version) "\n")
2457 (insert (emacs-version))
2458 (insert "\n\n\n\n\n")
2460 (goto-char (point-min))
2461 (search-forward "Subject: " nil t)
2464 (defun gnus-bug-mail-send-and-exit ()
2465 "Send the bug message and exit."
2467 (let ((cur (current-buffer)))
2468 (and (get-buffer "*Gnus Help Bug*")
2469 (kill-buffer "*Gnus Help Bug*"))
2470 (gnus-mail-send-and-exit)
2471 (when (buffer-name cur)
2472 (kill-buffer cur))))
2474 (defun gnus-debug ()
2475 "Attemps to go through the Gnus source file and report what variables have been changed.
2476 The source file has to be in the Emacs load path."
2478 (let ((files '("gnus.el" "gnus-msg.el" "gnus-score.el" "nnmail.el"))
2479 file dirs expr olist sym)
2480 (message "Please wait while we snoop your variables...")
2483 (set-buffer (get-buffer-create " *gnus bug info*"))
2484 (buffer-disable-undo (current-buffer))
2487 (setq dirs load-path)
2489 (if (or (not (car dirs))
2490 (not (stringp (car dirs)))
2492 (setq file (concat (file-name-as-directory
2493 (car dirs)) (car files))))))
2494 (setq dirs (cdr dirs))
2496 (insert-file-contents file)
2497 (goto-char (point-min))
2498 (if (not (re-search-forward "^;;* *Internal variables" nil t))
2499 (message "Malformed sources in file %s" file)
2500 (narrow-to-region (point-min) (point))
2501 (goto-char (point-min))
2502 (while (setq expr (condition-case ()
2503 (read (current-buffer)) (error nil)))
2505 (and (eq (car expr) 'defvar)
2506 (stringp (nth 3 expr))
2507 (or (not (boundp (nth 1 expr)))
2508 (not (equal (eval (nth 2 expr))
2509 (symbol-value (nth 1 expr)))))
2510 (setq olist (cons (nth 1 expr) olist)))
2512 (setq files (cdr files)))
2513 (kill-buffer (current-buffer)))
2514 (when (setq olist (nreverse olist))
2515 (insert "------------------ Environment follows ------------------\n\n"))
2517 (if (boundp (car olist))
2518 (insert "(setq " (symbol-name (car olist))
2519 (if (or (consp (setq sym (symbol-value (car olist))))
2521 (not (or (eq sym nil)
2524 (prin1-to-string (symbol-value (car olist))) ")\n")
2525 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
2526 (setq olist (cdr olist)))
2528 ;; Remove any null chars - they seem to cause trouble for some
2529 ;; mailers. (Byte-compiled output from the stuff above.)
2530 (goto-char (point-min))
2531 (while (re-search-forward "[\000\200]" nil t)
2532 (replace-match "" t t))))
2535 ;;; Treatment of rejected articles.
2540 (defun gnus-summary-resend-bounced-mail (fetch)
2541 "Re-mail the current message.
2542 This only makes sense if the current message is a bounce message than
2543 contains some mail you have written which has been bounced back to
2545 If FETCH, try to fetch the article that this is a reply to, if indeed
2548 (gnus-summary-select-article t)
2549 ;; Create a mail buffer.
2552 (insert-buffer-substring gnus-article-buffer)
2553 (goto-char (point-min))
2554 (or (re-search-forward "--- *Original message.*\n" nil t)
2555 (and (search-forward "\n\n" nil t)
2556 (re-search-forward "^Return-Path:.*\n" nil t)))
2557 ;; We remove everything before the bounced mail.
2560 (if (re-search-forward "[^ \t]*:" nil t)
2566 (nnheader-narrow-to-headers)
2567 (nnheader-remove-header gnus-bounced-headers-junk t)
2568 (setq references (mail-fetch-field "references"))
2569 (goto-char (point-max))
2570 (insert mail-header-separator)))
2571 ;; If there are references, we fetch the article we answered to.
2574 (string-match "\\(<[^]+>\\)[ \t]*$" references)
2575 (gnus-summary-refer-article
2576 (substring references (match-beginning 1) (match-end 1)))
2578 (gnus-summary-show-all-headers)
2579 (gnus-configure-windows 'compose-bounce))))
2580 (goto-char (point-min)))
2584 (defun gnus-mail-send (&optional no-generated-headers)
2585 "Send the current buffer as mail.
2586 Headers will be generated before sending."
2588 (unless no-generated-headers
2592 (gnus-inews-narrow-to-headers)
2593 (gnus-inews-insert-headers gnus-required-mail-headers)
2594 (gnus-inews-remove-empty-headers))))
2596 ;; Remove the header separator.
2597 (goto-char (point-min))
2598 (and (re-search-forward
2599 (concat "^" (regexp-quote mail-header-separator) "$") nil t)
2600 (replace-match "" t t))
2601 ;; Run final inews hooks. This hook may do FCC.
2602 (run-hooks 'gnus-inews-article-hook)
2604 (nnheader-narrow-to-headers)
2605 (nnheader-remove-header "^[gf]cc:" t)
2607 (goto-char (point-min))
2608 (search-forward "\n\n")
2610 (insert mail-header-separator)
2612 (run-hooks 'gnus-message-sent-hook))
2614 (defun gnus-inews-modify-mail-mode-map ()
2615 (use-local-map (copy-keymap (current-local-map)))
2616 (local-set-key "\C-c\C-c" 'gnus-mail-send-and-exit)
2617 (local-set-key "\C-c\C-p" 'gnus-put-message)
2618 (local-set-key "\C-c\C-k" 'gnus-kill-message-buffer)
2619 (local-set-key "\C-c\M-d" 'gnus-dissociate-buffer-from-draft)
2620 (local-set-key "\C-c\C-d" 'gnus-associate-buffer-with-draft))
2622 (defun gnus-mail-setup (type &optional to subject in-reply-to cc
2623 replybuffer actions)
2624 ;; Let posting styles be configured.
2625 (gnus-configure-posting-styles)
2629 (eq gnus-mail-method 'mh)
2630 (and (or (eq type 'reply) (eq type 'followup))
2631 (eq gnus-mail-reply-method 'gnus-mail-reply-using-mhe))
2632 (and (eq type 'forward)
2633 (eq gnus-mail-forward-method 'gnus-mail-forward-using-mhe))
2635 (eq gnus-mail-other-window-method
2636 'gnus-mail-other-window-using-mhe)))
2637 'gnus-mh-mail-setup)
2639 (eq gnus-mail-method 'vm)
2640 (and (or (eq type 'reply) (eq type 'followup))
2641 (eq gnus-mail-reply-method 'gnus-mail-reply-using-vm))
2642 (and (eq type 'forward)
2643 (eq gnus-mail-forward-method 'gnus-mail-forward-using-vm))
2645 (eq gnus-mail-other-window-method
2646 'gnus-mail-other-window-using-vm)))
2647 'gnus-vm-mail-setup)
2649 (eq gnus-mail-method 'sendmail)
2650 (and (or (eq type 'reply) (eq type 'followup))
2651 (eq gnus-mail-reply-method 'gnus-mail-reply-using-mail))
2652 (and (eq type 'forward)
2653 (eq gnus-mail-forward-method 'gnus-mail-forward-using-mail))
2655 (eq gnus-mail-other-window-method
2656 'gnus-mail-other-window-using-mail)))
2657 'gnus-sendmail-mail-setup)
2659 (cond ((or (eq type 'reply) (eq type 'followup))
2660 gnus-mail-reply-method)
2662 gnus-mail-forward-method)
2664 gnus-mail-other-window-method))))
2665 to subject in-reply-to cc replybuffer actions)
2666 ;; Associate this mail buffer with the draft group.
2667 (gnus-enter-buffer-into-draft))
2669 (defun gnus-sendmail-mail-setup (to subject in-reply-to cc replybuffer actions)
2671 (mail-setup to subject nil cc replybuffer actions)
2672 (gnus-inews-set-point)
2673 (gnus-inews-modify-mail-mode-map))
2677 ;; Do Gcc handling, which copied the message over to some group.
2678 (defun gnus-inews-do-gcc (&optional gcc)
2681 (nnheader-narrow-to-headers)
2682 (let ((gcc (or gcc (mail-fetch-field "gcc" nil t)))
2683 (cur (current-buffer))
2684 end groups group method)
2686 (nnheader-remove-header "gcc")
2688 (setq groups (gnus-tokenize-header gcc " ,"))
2689 ;; Copy the article over to some group(s).
2690 (while (setq group (pop groups))
2693 (cond ((and (null (gnus-get-info group))
2694 (eq (car gnus-message-archive-method)
2695 (car (gnus-group-method-name group))))
2696 ;; If the group doesn't exist, we assume
2697 ;; it's an archive group...
2698 gnus-message-archive-method)
2699 (t (gnus-find-method-for-group group)))))
2700 (unless (gnus-request-group group t method)
2701 (gnus-request-create-group group method))
2702 (gnus-check-server method)
2704 (nnheader-set-temp-buffer " *acc*")
2705 (insert-buffer-substring cur)
2706 (unless (condition-case ()
2707 (gnus-request-accept-article group t method)
2709 (gnus-message 1 "Couldn't store article in group %s: %s"
2710 group (gnus-status-message method))
2712 (kill-buffer (current-buffer)))))))))
2714 (defun gnus-inews-insert-bfcc ()
2715 "Insert Bcc and Fcc headers."
2717 ;; Handle author copy using BCC field.
2718 (when (and gnus-mail-self-blind
2719 (not (mail-fetch-field "bcc")))
2720 (mail-position-on-field "Bcc")
2721 (insert (if (stringp gnus-mail-self-blind)
2722 gnus-mail-self-blind
2723 (user-login-name))))
2724 ;; Handle author copy using FCC field.
2725 (when gnus-author-copy
2726 (mail-position-on-field "Fcc")
2727 (insert gnus-author-copy))))
2729 (defun gnus-inews-insert-gcc ()
2730 "Insert Gcc headers based on `gnus-outgoing-message-group'."
2733 (gnus-inews-narrow-to-headers)
2734 (let* ((group gnus-outgoing-message-group)
2736 ((gnus-functionp group)
2738 ((or (stringp group) (list group))
2742 (if (stringp gcc) gcc
2743 (mapconcat 'identity gcc " "))
2746 (defun gnus-inews-insert-archive-gcc ()
2747 "Insert the Gcc to say where the article is to be archived."
2748 (let* ((var gnus-message-archive-group)
2753 ;; Just a single group.
2756 ;; We don't want this.
2758 ((and (listp var) (stringp (car var)))
2759 ;; A list of groups.
2761 ((gnus-functionp var)
2763 (funcall var gnus-newsgroup-name))
2765 ;; An alist of regexps/functions/forms.
2770 ((stringp (caar var))
2772 (when (string-match (caar var)
2773 gnus-newsgroup-name)
2775 ((gnus-functionp (car var))
2777 (funcall (car var) gnus-newsgroup-name))
2779 (eval (car var)))))))
2780 (setq var (cdr var)))
2783 (when (stringp groups)
2784 (setq groups (list groups)))
2787 (gnus-inews-narrow-to-headers)
2788 (goto-char (point-max))
2791 (insert (gnus-group-prefixed-name
2792 (pop groups) gnus-message-archive-method))
2796 ;;; Handling rejected (and postponed) news.
2798 (defun gnus-draft-group ()
2799 "Return the name of the draft group."
2800 (gnus-group-prefixed-name
2801 (file-name-nondirectory gnus-draft-group-directory)
2802 (list 'nndraft gnus-draft-group-directory)))
2804 (defun gnus-make-draft-group ()
2805 "Make the draft group or die trying."
2806 (let* ((method (` (nndraft "private"
2808 (, gnus-draft-group-directory)))))
2809 (group (gnus-draft-group)))
2810 (or (gnus-gethash group gnus-newsrc-hashtb)
2811 (gnus-group-make-group (gnus-group-real-name group) method)
2812 (error "Can't create the draft group"))
2813 (gnus-check-server method)
2816 (defun gnus-associate-buffer-with-draft (&optional generate silent)
2817 "Enter the current buffer into the draft group."
2819 (when (gnus-request-accept-article (gnus-make-draft-group) t)
2821 ;; This function does the proper marking of articles.
2822 (gnus-mail-send-and-exit 'dont-send))
2823 (set-buffer-modified-p nil)))
2825 (defun gnus-enter-buffer-into-draft ()
2826 (when gnus-use-draft
2828 ;; Make sure the draft group exists.
2829 (gnus-make-draft-group)
2830 ;; Associate the buffer with the draft group.
2831 (let ((article (gnus-request-associate-buffer (gnus-draft-group))))
2832 ;; Arrange for deletion of the draft after successful sending.
2833 (make-local-variable 'gnus-message-sent-hook)
2834 (setq gnus-message-sent-hook
2837 (let ((gnus-verbose-backends nil))
2838 (gnus-request-expire-articles
2839 (quote ,(list article))
2840 ,(gnus-draft-group) t)))))))))
2842 (defun gnus-dissociate-buffer-from-draft ()
2843 "Disable auto-saving and association to the draft group of the current buffer."
2845 (run-hooks 'gnus-message-sent-hook)
2846 (setq buffer-file-name nil)
2847 (setq buffer-auto-save-file-name nil))
2849 (defun gnus-summary-send-draft ()
2850 "Enter a mail/post buffer to edit and send the draft."
2852 (gnus-set-global-variables)
2853 (unless (equal gnus-newsgroup-name (gnus-draft-group))
2854 (error "This function can only be used in the draft buffer"))
2856 (if (not (setq buf (gnus-request-restore-buffer
2857 (gnus-summary-article-number) gnus-newsgroup-name)))
2858 (error "Couldn't restore the article")
2859 (setq point (point))
2860 (switch-to-buffer buf)
2861 (gnus-inews-modify-mail-mode-map)
2862 (when (eq major-mode 'news-reply-mode)
2863 (local-set-key "\C-c\C-c" 'gnus-inews-news))
2864 (gnus-enter-buffer-into-draft)
2865 ;; Insert the separator.
2866 (goto-char (point-min))
2867 (search-forward "\n\n")
2869 (insert mail-header-separator)
2870 ;; Configure windows.
2871 (let ((gnus-draft-buffer (current-buffer)))
2872 (gnus-configure-windows 'draft)
2873 (goto-char (point))))))
2875 (defun gnus-configure-posting-styles ()
2876 "Configure posting styles according to `gnus-posting-styles'."
2877 (let ((styles gnus-posting-styles)
2878 (gnus-newsgroup-name (or gnus-newsgroup-name ""))
2879 style match variable attribute value value-value)
2880 ;; Go through all styles and look for matches.
2882 (setq style (pop styles)
2884 (when (cond ((stringp match)
2885 ;; Regexp string match on the group name.
2886 (string-match match gnus-newsgroup-name))
2887 ((or (symbolp match)
2888 (gnus-functionp match))
2889 (cond ((gnus-functionp match)
2890 ;; Function to be called.
2893 ;; Variable to be checked.
2894 (symbol-value match))))
2896 ;; This is a form to be evaled.
2898 ;; We have a match, so we set the variables.
2900 (setq attribute (pop style)
2901 value (cdr attribute))
2902 ;; We find the variable that is to be modified.
2903 (if (and (not (stringp (car attribute)))
2904 (not (setq variable (cdr (assq (car attribute)
2905 gnus-posting-style-alist)))))
2906 (message "Couldn't find attribute %s" (car attribute))
2907 ;; We set the variable.
2909 (cond ((stringp value)
2911 ((or (symbolp value)
2912 (gnus-functionp value))
2913 (cond ((gnus-functionp value)
2916 (symbol-value value))))
2921 ;; This is an ordinary variable.
2922 (make-local-variable variable)
2923 (set variable value-value))
2924 ;; This is a header to be added to the headers when
2927 (make-local-variable gnus-required-headers)
2928 (make-local-variable gnus-required-mail-headers)
2929 (push (cons (car attribute) value-value)
2930 gnus-required-headers)
2931 (push (cons (car attribute) value-value)
2932 gnus-required-mail-headers)))))))))
2934 (defun gnus-inews-set-point ()
2935 "Move point to where the user probably wants to find it."
2936 (gnus-inews-narrow-to-headers)
2938 ((re-search-forward "^[^:]+:[ \t]*$" nil t)
2939 (search-backward ":" )
2943 (goto-char (point-max))
2946 (unless (looking-at "$")
2947 (forward-line 2)))))
2949 ;;; Allow redefinition of functions.
2955 ;;; gnus-msg.el ends here