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 gnus-visible-headers
218 "*Regexp matching headers to be included in forwarded messages.")
220 (defvar gnus-required-headers
221 '(From Date Newsgroups Subject Message-ID Organization Lines X-Newsreader)
222 "*Headers to be generated or prompted for when posting an article.
223 RFC977 and RFC1036 require From, Date, Newsgroups, Subject,
224 Message-ID. Organization, Lines, In-Reply-To, Expires, and
225 X-Newsreader are optional. If you want Gnus not to insert some
226 header, remove it from this list.")
228 (defvar gnus-required-mail-headers
229 '(From Date To Subject (optional . In-Reply-To) Message-ID Organization Lines)
230 "*Headers to be generated or prompted for when mailing a message.
231 RFC822 required that From, Date, To, Subject and Message-ID be
232 included. Organization, Lines and X-Mailer are optional.")
234 (defvar gnus-deletable-headers '(Message-ID Date)
235 "*Headers to be deleted if they already exists and were generated by Gnus previously.")
237 (defvar gnus-removable-headers '(NNTP-Posting-Host Xref)
238 "*Headers to be removed unconditionally before posting.")
240 (defvar gnus-article-expires 14
241 "*Number of days before your article expires.
242 This variable isn't used unless you have the `Expires' element in
243 `gnus-required-headers'.")
245 (defvar gnus-distribution-function nil
246 "*Function that should return the Distribution header for outgoing articles.
247 It will be called from the buffer where the outgoing article
248 is being prepared with the group name as the only parameter.
249 It should return a valid distribution.
251 The function will only be called if you have the `Distribution' header in
252 `gnus-required-headers'.")
254 (defvar gnus-check-before-posting
255 '(subject-cmsg multiple-headers sendsys message-id from
256 long-lines control-chars size new-text
257 redirected-followup signature approved sender empty)
258 "In non-nil, Gnus will attempt to run some checks on outgoing posts.
259 If this variable is t, Gnus will check everything it can. If it is a
260 list, then those elements in that list will be checked.")
262 (defvar gnus-delete-supersedes-headers
263 "^Path:\\|^Date\\|^NNTP-Posting-Host:\\|^Supersedes:\\|^Xref:\\|^Lines:"
264 "*Header lines matching this regexp will be deleted before posting.
265 It's best to delete old Path and Date headers before posting to avoid
268 (defvar gnus-auto-mail-to-author nil
269 "*If non-nil, mail the authors of articles a copy of your follow-ups.
270 If this variable is `ask', the user will be prompted for whether to
271 mail a copy. The string given by `gnus-mail-courtesy-message' will be
272 inserted at the beginning of the mail copy.")
274 ;; Added by Ethan Bradford <ethanb@ptolemy.astro.washington.edu>.
275 (defvar gnus-mail-courtesy-message
276 "The following message is a courtesy copy of an article\nthat has been posted as well.\n\n"
277 "*This is inserted at the start of a mailed copy of a posted message.
278 If this variable is nil, no such courtesy message will be added.")
280 (defvar gnus-mail-method 'sendmail
281 "*Method to use for composing mail.
282 There are three legal values: `sendmail' (which is the default), `mh',
285 (defvar gnus-mail-reply-method (function gnus-mail-reply-using-mail)
286 "*Function to compose a reply.
287 Three pre-made functions are `gnus-mail-reply-using-mail' (sendmail);
288 `gnus-mail-reply-using-mhe' (MH-E); and `gnus-mail-reply-using-vm'.")
290 (defvar gnus-mail-forward-method (function gnus-mail-forward-using-mail)
291 "*Function to forward the current message to another user.
292 Three pre-made functions are `gnus-mail-forward-using-mail' (sendmail);
293 `gnus-mail-forward-using-mhe' (MH-E); and `gnus-mail-forward-using-vm'.")
295 (defvar gnus-mail-other-window-method 'gnus-mail-other-window-using-mail
296 "*Function to compose mail in the other window.
297 Three pre-made functions are `gnus-mail-other-window-using-mail'
298 (sendmail); `gnus-mail-other-window-using-mhe' (MH-E); and
299 `gnus-mail-other-window-using-vm'.")
301 (defvar gnus-inews-article-function 'gnus-inews-article
302 "*Function to post an article.")
304 (defvar gnus-bounced-headers-junk "^\\(Received\\):"
305 "*Regexp that matches headers to be removed in resent bounced mail.")
307 (defvar gnus-inews-article-hook (list 'gnus-inews-do-fcc)
308 "*A hook called before finally posting an article.
309 The default hook (`gnus-inews-do-fcc') does FCC processing (ie. saves
310 the article to a file).")
312 (defvar gnus-inews-article-header-hook nil
313 "*A hook called after inserting the headers in an article to be posted.
314 The hook is called from the *post-news* buffer, narrowed to the
317 (defvar gnus-mail-hook nil
318 "*A hook called as the last thing after setting up a mail buffer.")
320 (defvar gnus-message-sent-hook nil
321 "*A hook run after an article has been sent (or attempted sent).")
323 ;;; Internal variables.
325 (defvar gnus-post-news-buffer "*post-news*")
326 (defvar gnus-mail-buffer "*Mail Gnus*")
327 (defvar gnus-article-copy nil)
328 (defvar gnus-reply-subject nil)
329 (defvar gnus-newsgroup-followup nil)
330 (defvar gnus-add-to-address nil)
331 (defvar gnus-in-reply-to nil)
332 (defvar gnus-last-posting-server nil)
335 (autoload 'gnus-uu-post-news "gnus-uu" nil t)
336 (autoload 'news-setup "rnewspost")
337 (autoload 'news-reply-mode "rnewspost")
338 (autoload 'rmail-dont-reply-to "mail-utils")
339 (autoload 'rmail-output "rmailout"))
343 ;;; Gnus Posting Functions
347 (gnus-summary-send-map "S" gnus-summary-mode-map)
348 "p" gnus-summary-post-news
349 "f" gnus-summary-followup
350 "F" gnus-summary-followup-with-original
351 "b" gnus-summary-followup-and-reply
352 "B" gnus-summary-followup-and-reply-with-original
353 "c" gnus-summary-cancel-article
354 "s" gnus-summary-supersede-article
355 "r" gnus-summary-reply
356 "R" gnus-summary-reply-with-original
357 "m" gnus-summary-mail-other-window
358 "u" gnus-uu-post-news
359 "om" gnus-summary-mail-forward
360 "op" gnus-summary-post-forward
361 "Om" gnus-uu-digest-mail-forward
362 "Op" gnus-uu-digest-post-forward)
365 (gnus-send-bounce-map "D" gnus-summary-send-map)
366 "b" gnus-summary-resend-bounced-mail
367 "c" gnus-summary-send-draft
368 "r" gnus-summary-resend-message)
370 ;;; Internal functions.
372 (defun gnus-number-base36 (num len)
373 (if (if (< len 0) (<= num 0) (= len 0))
375 (concat (gnus-number-base36 (/ num 36) (1- len))
376 (char-to-string (aref "zyxwvutsrqponmlkjihgfedcba9876543210"
379 ;;; Post news commands of Gnus group mode and summary mode
381 (defun gnus-group-mail ()
382 "Start composing a mail."
385 ;; We might want to prompt here.
386 (when (and gnus-interactive-post
387 (not gnus-expert-user))
388 (read-string "To: "))))
390 (defun gnus-group-post-news (&optional arg)
392 The newsgroup under the cursor is used as the group to post to.
394 If you wish to get an empty post buffer, use a prefix ARG. You can
395 also do this by calling this function from the bottom of the Group
398 (let ((gnus-newsgroup-name nil)
399 (group (unless arg (gnus-group-group-name)))
401 ;; We might want to prompt here.
402 (when (and gnus-interactive-post
403 (not gnus-expert-user))
404 (setq gnus-newsgroup-name
406 (completing-read "Group: " gnus-active-hashtb nil nil
407 (cons (or group "") 0)))))
408 (gnus-post-news 'post group nil gnus-article-buffer)))
410 (defun gnus-summary-post-news ()
413 (gnus-set-global-variables)
414 (gnus-post-news 'post gnus-newsgroup-name))
416 (defun gnus-summary-followup (yank &optional yank-articles)
417 "Compose a followup to an article.
418 If prefix argument YANK is non-nil, original article is yanked automatically."
420 (gnus-set-global-variables)
421 (if yank-articles (gnus-summary-goto-subject (car yank-articles)))
422 (save-window-excursion
423 (gnus-summary-select-article))
424 (let ((headers (gnus-summary-article-header (gnus-summary-article-number)))
425 (gnus-newsgroup-name gnus-newsgroup-name))
426 ;; Check Followup-To: poster.
427 (set-buffer gnus-article-buffer)
428 (if (and gnus-use-followup-to
429 (string-equal "poster" (gnus-fetch-field "followup-to"))
430 (or (not (memq gnus-use-followup-to '(t ask)))
432 "Do you want to ignore `Followup-To: poster'? "))))
433 ;; Mail to the poster.
434 (gnus-summary-reply yank)
436 (gnus-post-news nil gnus-newsgroup-name
437 headers gnus-article-buffer
438 (or yank-articles (not (not yank)))))))
440 (defun gnus-summary-followup-with-original (n)
441 "Compose a followup to an article and include the original article."
443 (gnus-summary-followup t (gnus-summary-work-articles n)))
445 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
446 (defun gnus-summary-followup-and-reply (yank &optional yank-articles)
447 "Compose a followup and do an auto mail to author."
449 (gnus-set-global-variables)
450 (let ((gnus-auto-mail-to-author 'force))
451 (gnus-summary-followup yank yank-articles)))
453 (defun gnus-summary-followup-and-reply-with-original (n)
454 "Compose a followup, include the original, and do an auto mail to author."
456 (gnus-summary-followup-and-reply t (gnus-summary-work-articles n)))
458 (defun gnus-summary-cancel-article (n)
459 "Cancel an article you posted."
461 (gnus-set-global-variables)
462 (let ((articles (gnus-summary-work-articles n))
464 (while (setq article (pop articles))
465 (when (gnus-summary-select-article t nil nil article)
466 (when (gnus-eval-in-buffer-window
467 gnus-original-article-buffer (gnus-cancel-news))
468 (gnus-summary-mark-as-read article gnus-canceled-mark))
469 (gnus-article-hide-headers-if-wanted))
470 (gnus-summary-remove-process-mark article))))
472 (defun gnus-summary-supersede-article ()
473 "Compose an article that will supersede a previous article.
474 This is done simply by taking the old article and adding a Supersedes
475 header line with the old Message-ID."
477 (gnus-set-global-variables)
478 (gnus-summary-select-article t)
479 ;; Check whether the user owns the article that is to be superseded.
480 (unless (string-equal
481 (downcase (mail-strip-quoted-names
482 (mail-header-from gnus-current-headers)))
483 (downcase (mail-strip-quoted-names (gnus-inews-user-name))))
484 (error "This article is not yours."))
485 ;; Get a normal *post-news* buffer.
486 (gnus-new-news gnus-newsgroup-name t)
488 (insert-buffer-substring gnus-original-article-buffer)
489 (nnheader-narrow-to-headers)
490 ;; Remove unwanted headers.
491 (when gnus-delete-supersedes-headers
492 (nnheader-remove-header gnus-delete-supersedes-headers t))
493 (goto-char (point-min))
494 (if (not (re-search-forward "^Message-ID: " nil t))
495 (error "No Message-ID in this article")
496 (replace-match "Supersedes: " t t))
497 (goto-char (point-max))
498 (insert mail-header-separator)
504 (defalias 'sendnews 'gnus-post-news)
507 (defalias 'postnews 'gnus-post-news)
509 (defun gnus-copy-article-buffer (&optional article-buffer)
510 ;; make a copy of the article buffer with all text properties removed
511 ;; this copy is in the buffer gnus-article-copy.
512 ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
513 ;; this buffer should be passed to all mail/news reply/post routines.
514 (setq gnus-article-copy (get-buffer-create " *gnus article copy*"))
515 (buffer-disable-undo gnus-article-copy)
516 (or (memq gnus-article-copy gnus-buffer-list)
517 (setq gnus-buffer-list (cons gnus-article-copy gnus-buffer-list)))
518 (let ((article-buffer (or article-buffer gnus-article-buffer)))
519 (if (and (get-buffer article-buffer)
520 (buffer-name (get-buffer article-buffer)))
522 (set-buffer article-buffer)
524 (copy-to-buffer gnus-article-copy (point-min) (point-max))
525 (set-text-properties (point-min) (point-max)
526 nil gnus-article-copy)))))
528 (defun gnus-post-news (post &optional group header article-buffer yank subject)
529 "Begin editing a new USENET news article to be posted.
530 Type \\[describe-mode] in the buffer to get a list of commands."
531 (interactive (list t))
532 (let* ((group (or group gnus-newsgroup-name))
534 to-address to-group mailing-list to-list)
536 (setq to-address (gnus-group-get-parameter group 'to-address)
537 to-group (gnus-group-get-parameter group 'to-group)
538 to-list (gnus-group-get-parameter group 'to-list)
539 mailing-list (when gnus-mailing-list-groups
540 (string-match gnus-mailing-list-groups group))
541 group (gnus-group-real-name group)))
543 (and (gnus-news-group-p
544 (or pgroup gnus-newsgroup-name)
545 (if header (mail-header-number header) gnus-current-article))
551 (gnus-new-news (or to-group group))
552 (gnus-news-followup yank (or to-group group)))
556 (gnus-new-mail (or to-address to-list))
557 ;; Arrange for mail groups that have no `to-address' to
558 ;; get that when the user sends off the mail.
560 (make-local-variable 'gnus-add-to-address)
561 (setq gnus-add-to-address group)))
562 (gnus-mail-reply yank to-address 'followup)))))
564 (defun gnus-post-method (group query-method &optional silent)
565 "Return the posting method based on GROUP and query-method.
566 If SILENT, don't prompt the user."
567 (let ((group-method (if (stringp group)
568 (gnus-find-method-for-group group)
571 ;; If the group-method is nil (which shouldn't happen) we use
572 ;; the default method.
574 (or gnus-post-method gnus-select-method))
575 ;; We want this group's method.
576 ((and query-method (not (eq query-method 0)))
578 ;; We query the user for a post method.
580 (and gnus-post-method
581 (listp (car gnus-post-method))))
583 ;; Collect all methods we know about.
585 (when gnus-post-method
586 (if (listp (car gnus-post-method))
588 (listp gnus-post-method)))
589 gnus-secondary-select-methods
590 (list gnus-select-method)
591 (list group-method)))
592 method-alist post-methods method)
593 ;; Weed out all mail methods.
595 (setq method (gnus-server-get-method "" (pop methods)))
596 (when (or (gnus-method-option-p method 'post)
597 (gnus-method-option-p method 'post-mail))
598 (push method post-methods)))
599 ;; Create a name-method alist.
603 (list (concat (cadr m) " (" (symbol-name (car m)) ")") m))
608 (setq gnus-last-posting-server
610 gnus-last-posting-server)
611 ;; Just use the last value.
612 gnus-last-posting-server
614 "Posting method: " method-alist nil t
615 (cons (or gnus-last-posting-server "") 0))))
617 ;; Override normal method.
618 ((and gnus-post-method
619 (or (gnus-method-option-p group-method 'post)
620 (gnus-method-option-p group-method 'post-mail)))
622 ;; Perhaps this is a mail group?
623 ((and (not (gnus-member-of-valid 'post group))
624 (not (gnus-method-option-p group-method 'post-mail)))
626 ;; Use the normal select method.
627 (t gnus-select-method))))
629 (defun gnus-news-group-p (group &optional article)
630 "Return non-nil if GROUP (and ARTICLE) come from a news server."
631 (or (gnus-member-of-valid 'post group) ; Ordinary news group.
632 (and (gnus-member-of-valid 'post-mail group) ; Combined group.
633 (eq (gnus-request-type group article) 'news))))
635 (defun gnus-inews-news (&optional use-group-method)
636 "Send a news message.
638 If given a non-zero prefix and the group is a foreign group, this
639 function will attempt to use the foreign server to post the article.
641 If given an zero prefix, the user will be prompted for a posting
644 (or gnus-current-select-method
645 (setq gnus-current-select-method gnus-select-method))
646 (let* ((case-fold-search nil)
647 (reply gnus-article-reply)
650 (gnus-start-news-server) ;Use default server.
652 (goto-char (point-min))
653 (run-hooks 'news-inews-hook)
656 (gnus-message 5 "Posting to USENET...")
657 (setq post-result (funcall gnus-inews-article-function use-group-method))
659 ((eq post-result 'illegal)
663 (gnus-message 5 "Posting to USENET...done")
664 (set-buffer-modified-p nil)
665 ;; We mark the article as replied.
666 (when (gnus-buffer-exists-p (car-safe reply))
668 (set-buffer gnus-summary-buffer)
669 (gnus-summary-mark-article-as-replied (cdr reply)))))
671 ;; We cannot signal an error.
675 1 "Article rejected: %s"
677 (gnus-post-method gnus-newsgroup-name use-group-method t))))))
679 (let ((conf gnus-prev-winconf))
682 ;; Restore last window configuration.
683 (and conf (set-window-configuration conf))))))
685 (defun gnus-inews-narrow-to-headers ()
688 (goto-char (point-min))
689 (or (and (re-search-forward
690 (concat "^" (regexp-quote mail-header-separator) "$") nil t)
693 (goto-char (point-min)))
695 (defun gnus-inews-send-mail-copy ()
696 ;; Mail the message if To, Bcc or Cc exists.
697 (let* ((types '("to" "bcc" "cc"))
699 (buffer (current-buffer))
703 (gnus-inews-narrow-to-headers)
706 (or (mail-fetch-field (car ty) nil t)
707 (setq types (delete (car ty) types)))
711 ;; We do not want to send mail.
713 (gnus-message 5 "Sending via mail...")
716 ;; We copy the article over to a temp buffer since we are
717 ;; going to modify it a little.
718 (nnheader-set-temp-buffer " *Gnus-mailing*")
719 (insert-buffer-substring buffer)
720 ;; We remove Fcc, because we don't want the mailer to see
722 (gnus-inews-narrow-to-headers)
723 (nnheader-remove-header "fcc")
725 ;; Insert the X-Courtesy-Message header.
726 (and (or (member "to" types)
729 (goto-char (point-max))
730 (insert "Posted-To: "
731 (mail-fetch-field "newsgroups") "\n")))
735 (if (and gnus-mail-courtesy-message
736 (or (member "to" types)
737 (member "cc" types)))
738 ;; We only want to insert the courtesy mail message if
739 ;; we use To or Cc; Bcc should not have one. Well, if
740 ;; both Bcc and To are present, it will get one
743 ;; Insert "courtesy" mail message.
744 (goto-char (point-min))
746 (concat "^" (regexp-quote mail-header-separator) "$"))
748 (insert gnus-mail-courtesy-message)))
751 (kill-buffer (current-buffer))
752 (gnus-message 5 "Sending via mail...done"))))))
754 (defun gnus-inews-remove-headers-after-mail ()
757 (let ((case-fold-search t))
758 (gnus-inews-narrow-to-headers)
759 ;; Remove Bcc completely.
760 (nnheader-remove-header "bcc")
761 ;; We transform To and Cc headers to avoid re-mailing if the user
762 ;; accidentally (or purposefully) leans on the `C-c C-c' keys
763 ;; and the news server rejects the posting.
764 (while (re-search-forward "^\\(to\\|[bcf]cc\\|cc\\):" nil t)
769 (defun gnus-inews-dex-headers ()
770 "Remove \"X-\" prefixes from To and Cc headers."
773 (let ((case-fold-search t))
774 (nnheader-narrow-to-headers)
775 (while (re-search-forward "^X-\\(to\\|[bcf]cc\\|cc\\):" nil t)
780 (defun gnus-inews-remove-empty-headers ()
781 "Remove empty headers from news and mail.
782 The buffer should be narrowed to the headers before this function is
785 (goto-char (point-min))
786 (while (re-search-forward "^[^ \t:]+:\\([ \t]*\n\\)+[^ \t]" nil t)
787 (delete-region (match-beginning 0) (1- (match-end 0)))
788 (beginning-of-line))))
790 (defun gnus-inews-check-post ()
791 "Check whether the post looks ok."
793 (not gnus-check-before-posting)
795 ;; We narrow to the headers and check them first.
798 (goto-char (point-min))
803 (concat "^" (regexp-quote mail-header-separator) "$"))
804 (match-beginning 0)))
805 (goto-char (point-min))
807 ;; Check for commands in Subject.
809 (gnus-check-before-posting 'subject-cmsg)
811 (if (string-match "^cmsg " (mail-fetch-field "subject"))
813 "The control code \"cmsg \" is in the subject. Really post? ")
815 ;; Check for multiple identical headers.
816 (or (gnus-check-before-posting 'multiple-headers)
819 (while (and (not found) (re-search-forward "^[^ \t:]+: "
822 (or (re-search-forward
823 (concat "^" (setq found
826 (- (match-end 0) 2))))
831 (format "Multiple %s headers. Really post? " found))
833 ;; Check for Version and Sendsys.
834 (or (gnus-check-before-posting 'sendsys)
836 (if (re-search-forward "^Sendsys:\\|^Version:" nil t)
838 (format "The article contains a %s command. Really post? "
839 (buffer-substring (match-beginning 0)
840 (1- (match-end 0)))))
842 ;; Check for Approved.
843 (or (gnus-check-before-posting 'approved)
845 (if (re-search-forward "^Approved:" nil t)
847 "The article contains an Approved header. Really post? ")
849 ;; Check whether a Followup-To has redirected the newsgroup.
851 (gnus-check-before-posting 'redirected-followup)
852 (not gnus-newsgroup-followup)
854 (let ((followups (gnus-tokenize-header
855 (mail-fetch-field "Newsgroups")))
856 (newsgroups (gnus-tokenize-header
857 (car gnus-newsgroup-followup)))
859 (while (and followups
860 (not (member followups newsgroups)))
861 (setq followups (cdr followups)))
865 "Followup redirected from original newsgroups. Really post? "
867 ;; Check the Message-ID header.
868 (or (gnus-check-before-posting 'message-id)
870 (let* ((case-fold-search t)
871 (message-id (mail-fetch-field "message-id")))
873 (and (string-match "@" message-id)
874 (string-match "@[^\\.]*\\." message-id))
877 "The Message-ID looks strange: \"%s\". Really post? "
879 ;; Check the From header.
881 (gnus-check-before-posting 'from)
883 (let* ((case-fold-search t)
884 (from (mail-fetch-field "from")))
887 (gnus-y-or-n-p "There is no From line. Really post? "))
888 ((not (string-match "@[^\\.]*\\." from))
891 "The address looks strange: \"%s\". Really post? " from)))
892 ((string-match "(.*).*(.*)" from)
895 "The From header looks strange: \"%s\". Really post? "
897 ((string-match "<[^>]+> *$" from)
898 (let ((name (substring from 0 (match-beginning 0))))
900 (string-match "^ *\"[^\"]*\" *$" name)
901 (not (string-match "[][.!()<>@,;:\\]" name))
904 "The From header name has bogus characters. Really post? "
908 ;; Check for long lines.
909 (or (gnus-check-before-posting 'long-lines)
911 (goto-char (point-min))
913 (concat "^" (regexp-quote mail-header-separator) "$"))
917 (< (current-column) 80))
918 (zerop (forward-line 1))))
922 "You have lines longer than 79 characters. Really post? "))))
923 ;; Check whether the article is empty.
924 (or (gnus-check-before-posting 'empty)
926 (goto-char (point-min))
928 (concat "^" (regexp-quote mail-header-separator) "$"))
930 (or (re-search-forward "[^ \n\t]" nil t)
931 (gnus-y-or-n-p "Empty article. Really post?"))))
932 ;; Check for control characters.
933 (or (gnus-check-before-posting 'control-chars)
935 (if (re-search-forward "[\000-\007\013\015-\037\200-\237]" nil t)
937 "The article contains control characters. Really post? ")
939 ;; Check excessive size.
940 (or (gnus-check-before-posting 'size)
941 (if (> (buffer-size) 60000)
943 (format "The article is %d octets long. Really post? "
946 ;; Use the (size . checksum) variable to see whether the
947 ;; article is empty or has only quoted text.
949 (gnus-check-before-posting 'new-text)
950 (if (and (= (buffer-size) (car gnus-article-check-size))
951 (= (gnus-article-checksum) (cdr gnus-article-check-size)))
953 "It looks like there's no new text in your article. Really post? ")
955 ;; Check the length of the signature.
956 (or (gnus-check-before-posting 'signature)
958 (goto-char (point-max))
959 (if (not (re-search-backward gnus-signature-separator nil t))
961 (if (> (count-lines (point) (point-max)) 5)
964 "Your .sig is %d lines; it should be max 4. Really post? "
965 (count-lines (point) (point-max))))
968 (defun gnus-tokenize-header (header &optional separator)
969 "Split HEADER into a list of header elements.
970 \",\" is used as the separator."
972 (separator (or separator ","))
974 (format "[ \t]*\\([^%s]+\\)?\\(%s\\|\\'\\)" separator separator))
976 (while (and (string-match regexp header beg)
977 (< beg (length header)))
978 (when (match-beginning 1)
979 (push (match-string 1 header) elems))
980 (setq beg (match-end 0)))
983 (defun gnus-article-checksum ()
987 (setq sum (logxor sum (following-char)))
991 ;; Returns non-nil if this type is not to be checked.
992 (defun gnus-check-before-posting (type)
994 (or (not gnus-check-before-posting)
995 (if (listp gnus-check-before-posting)
996 (memq type gnus-check-before-posting)
999 (defun gnus-cancel-news ()
1000 "Cancel an article you posted."
1002 (if (or gnus-expert-user
1003 (gnus-yes-or-no-p "Do you really want to cancel this article? "))
1008 (or (gnus-news-group-p gnus-newsgroup-name)
1009 (error "This backend does not support canceling"))
1011 ;; Get header info. from original article.
1013 (gnus-article-show-all-headers)
1014 (goto-char (point-min))
1015 (search-forward "\n\n" nil 'move)
1016 (narrow-to-region (point-min) (point))
1017 (setq from (mail-fetch-field "from"))
1018 (setq newsgroups (mail-fetch-field "newsgroups"))
1019 (setq message-id (mail-fetch-field "message-id"))
1020 (setq distribution (mail-fetch-field "distribution")))
1021 ;; Verify if the article is absolutely user's by comparing
1022 ;; user id with value of its From: field.
1025 (downcase (mail-strip-quoted-names from))
1026 (downcase (mail-strip-quoted-names (gnus-inews-user-name)))))
1028 (ding) (gnus-message 3 "This article is not yours.")
1030 ;; Make control article.
1031 (set-buffer (get-buffer-create " *Gnus-canceling*"))
1032 (buffer-disable-undo (current-buffer))
1034 (insert "Newsgroups: " newsgroups "\n"
1035 "From: " (gnus-inews-user-name) "\n"
1036 "Subject: cancel " message-id "\n"
1037 "Control: cancel " message-id "\n"
1039 (concat "Distribution: " distribution "\n")
1041 mail-header-separator "\n"
1042 "This is a cancel message from " from ".\n")
1043 ;; Send the control article to NNTP server.
1044 (gnus-message 5 "Canceling your article...")
1046 (if (funcall gnus-inews-article-function)
1047 (gnus-message 5 "Canceling your article...done")
1050 (gnus-message 1 "Cancel failed; %s"
1051 (gnus-status-message gnus-newsgroup-name))
1054 ;; Kill the article buffer.
1055 (kill-buffer (current-buffer))))))))
1058 ;;; Lowlevel inews interface.
1060 ;; Dummy to avoid byte-compile warning.
1061 (defvar nnspool-rejected-article-hook)
1063 (defun gnus-inews-article (&optional use-group-method)
1064 "Post an article in current buffer using NNTP protocol."
1065 (let ((artbuf (current-buffer))
1068 (goto-char (point-max))
1069 ;; Require a newline at the end of the buffer since inews may
1070 ;; append a .signature.
1071 (or (= (preceding-char) ?\n)
1073 ;; Prepare article headers. All message body such as signature
1074 ;; must be inserted before Lines: field is prepared.
1076 (gnus-inews-narrow-to-headers)
1077 ;; Fix some headers.
1078 (gnus-inews-cleanup-headers)
1079 ;; Remove some headers.
1080 (gnus-inews-remove-headers)
1081 ;; Insert some headers.
1082 (gnus-inews-insert-headers)
1083 ;; Let the user do all of the above.
1084 (run-hooks 'gnus-inews-article-header-hook)
1085 ;; Copy the Gcc header, if any.
1086 (setq gcc (mail-fetch-field "gcc"))
1088 ;; Check whether the article is a good Net Citizen.
1089 (if (and gnus-article-check-size
1090 (not (gnus-inews-check-post)))
1093 ;; We fudge a hook for nnspool.
1094 (setq nnspool-rejected-article-hook
1100 (set-buffer (, (buffer-name)))
1101 (gnus-associate-buffer-with-draft nil 'silent))
1105 1 "Couldn't enter rejected article into draft group")))))))
1107 ;; Looks ok, so we do the nasty.
1109 ;; This hook may insert a signature.
1111 (goto-char (point-min))
1112 (let ((gnus-newsgroup-name (or (mail-fetch-field "newsgroups")
1113 gnus-newsgroup-name)))
1114 (run-hooks 'gnus-prepare-article-hook)))
1115 ;; Send off copies using mail, if that is wanted.
1116 (gnus-inews-send-mail-copy)
1117 ;; Remove more headers.
1118 (gnus-inews-remove-headers-after-mail)
1119 ;; Copy the article over to a temp buffer.
1120 (nnheader-set-temp-buffer " *Gnus-posting*")
1121 (insert-buffer-substring artbuf)
1122 ;; Remove the header separator.
1123 (goto-char (point-min))
1125 (concat "^" (regexp-quote mail-header-separator) "$"))
1126 (replace-match "" t t)
1127 ;; Remove X- prefixes to headers.
1128 (gnus-inews-dex-headers)
1129 ;; Run final inews hooks. This hook may do FCC.
1130 ;; The article must be saved before being posted because
1131 ;; `gnus-request-post' modifies the buffer.
1132 (run-hooks 'gnus-inews-article-hook)
1133 ;; Copy the article over to some group, possibly.
1134 (and gcc (gnus-inews-do-gcc gcc))
1135 ;; Post the article.
1136 (setq result (gnus-request-post
1137 (gnus-post-method gnus-newsgroup-name use-group-method)))
1138 (kill-buffer (current-buffer)))
1139 (run-hooks 'gnus-message-sent-hook)
1140 ;; If the posting was unsuccessful (that it, it was rejected) we
1141 ;; put it into the draft group.
1142 (or result (gnus-associate-buffer-with-draft))
1145 (defun gnus-inews-cleanup-headers ()
1146 ;; Correct newsgroups field: change sequence of spaces to comma and
1147 ;; eliminate spaces around commas. Eliminate imbedded line breaks.
1148 (goto-char (point-min))
1149 (if (re-search-forward "^Newsgroups: +" nil t)
1153 (if (re-search-forward "^[^ \t]" nil t)
1157 (goto-char (point-min))
1158 (while (re-search-forward "\n[ \t]+" nil t)
1159 (replace-match " " t t)) ;No line breaks (too confusing)
1160 (goto-char (point-min))
1161 (while (re-search-forward "[ \t\n]*,[ \t\n]*\\|[ \t]+" nil t)
1162 (replace-match "," t t))
1163 (goto-char (point-min))
1164 ;; Remove a trailing comma.
1165 (if (re-search-forward ",$" nil t)
1166 (replace-match "" t t))))
1168 ;; Added by Per Abrahamsen <abraham@iesd.auc.dk>.
1169 ;; Help save the the world!
1172 (let ((newsgroups (mail-fetch-field "newsgroups"))
1173 (followup-to (mail-fetch-field "followup-to"))
1176 (string-match "," newsgroups) (not followup-to))
1178 (while (string-match "," newsgroups)
1180 (cons (list (substring newsgroups 0 (match-beginning 0)))
1182 (setq newsgroups (substring newsgroups (match-end 0))))
1183 (setq groups (nreverse (cons (list newsgroups) groups)))
1185 (setq to (completing-read
1186 "Followups to: (default all groups) " groups))
1187 (if (> (length to) 0)
1189 (goto-char (point-min))
1190 (insert "Followup-To: " to "\n")))))))
1192 ;; Cleanup Followup-To.
1193 (goto-char (point-min))
1194 (if (search-forward-regexp "^Followup-To: +" nil t)
1198 (if (re-search-forward "^[^ \t]" nil 'end)
1201 (goto-char (point-min))
1202 (replace-regexp "\n[ \t]+" " ") ;No line breaks (too confusing)
1203 (goto-char (point-min))
1204 (replace-regexp "[ \t\n]*,[ \t\n]*\\|[ \t]+" ","))))
1207 (defun gnus-inews-remove-headers ()
1208 (let ((case-fold-search t)
1209 (headers gnus-removable-headers))
1210 ;; Remove toxic headers.
1212 (goto-char (point-min))
1213 (and (re-search-forward
1214 (concat "^" (downcase (format "%s" (car headers))))
1216 (delete-region (progn (beginning-of-line) (point))
1217 (progn (forward-line 1) (point))))
1218 (setq headers (cdr headers)))))
1220 ;;; Since the X-Newsreader/X-Mailer are ``vanity'' headers, they might
1221 ;;; as well include the Emacs version as well.
1222 ;;; The following function works with later GNU Emacs, and XEmacs.
1223 (defun gnus-extended-version ()
1224 "Stringified Gnus version and Emacs version"
1230 ((string-match "^\\([0-9]+\\.[0-9]+\\)\\.[.0-9]+$" emacs-version)
1231 (concat "Emacs " (substring emacs-version
1234 ((string-match "\\([A-Z]*[Mm][Aa][Cc][Ss]\\)" emacs-version)
1235 (concat (substring emacs-version
1238 (format " %d.%d" emacs-major-version emacs-minor-version)))
1239 (t emacs-version))))
1241 (defun gnus-inews-insert-headers (&optional headers)
1242 "Prepare article headers.
1243 Headers already prepared in the buffer are not modified.
1244 Headers in `gnus-required-headers' will be generated."
1245 (let* ((Date (gnus-inews-date))
1246 (Message-ID (gnus-inews-message-id))
1247 (Organization (gnus-inews-organization))
1248 (From (gnus-inews-user-name))
1249 (Path (gnus-inews-path))
1252 (In-Reply-To (gnus-inews-in-reply-to))
1254 (Distribution (gnus-inews-distribution))
1255 (Lines (gnus-inews-lines))
1256 (X-Newsreader (gnus-extended-version))
1257 (X-Mailer X-Newsreader)
1258 (Expires (gnus-inews-expires))
1259 (headers (or headers gnus-required-headers))
1260 (case-fold-search t)
1262 ;; First we remove any old generated headers.
1263 (let ((headers gnus-deletable-headers))
1265 (goto-char (point-min))
1266 (and (re-search-forward
1267 (concat "^" (symbol-name (car headers)) ": *") nil t)
1268 (get-text-property (1+ (match-beginning 0)) 'gnus-deletable)
1270 (setq headers (cdr headers))))
1271 ;; If there are References, and no "Re: ", then the thread has
1272 ;; changed name. See Son-of-1036.
1273 (if (and (mail-fetch-field "references")
1274 (get-buffer gnus-article-buffer))
1275 (let ((psubject (gnus-simplify-subject-re
1276 (mail-fetch-field "subject"))))
1277 (or (and psubject gnus-reply-subject
1278 (string= (gnus-simplify-subject-re gnus-reply-subject)
1281 (string-match "@" Message-ID)
1283 (concat (substring Message-ID 0 (match-beginning 0))
1285 (substring Message-ID (match-beginning 0))))))))
1286 ;; Go through all the required headers and see if they are in the
1287 ;; articles already. If they are not, or are empty, they are
1288 ;; inserted automatically - except for Subject, Newsgroups and
1291 (goto-char (point-min))
1292 (setq elem (pop headers))
1294 (setq header (car elem))
1296 (when (or (not (re-search-forward
1297 (concat "^" (downcase (symbol-name header)) ":") nil t))
1299 ;; The header was found. We insert a space after the
1300 ;; colon, if there is none.
1301 (if (/= (following-char) ? ) (insert " "))
1302 ;; Find out whether the header is empty...
1303 (looking-at "[ \t]*$")))
1304 ;; So we find out what value we should insert.
1307 ((and (consp elem) (eq (car elem) 'optional))
1308 ;; This is an optional header. If the cdr of this
1309 ;; is something that is nil, then we do not insert
1311 (setq header (cdr elem))
1312 (or (and (fboundp (cdr elem)) (funcall (cdr elem)))
1313 (and (boundp (cdr elem)) (symbol-value (cdr elem)))))
1315 ;; The element is a cons. Either the cdr is a
1316 ;; string to be inserted verbatim, or it is a
1317 ;; function, and we insert the value returned from
1319 (or (and (stringp (cdr elem)) (cdr elem))
1320 (and (fboundp (cdr elem)) (funcall (cdr elem)))))
1321 ((and (boundp header) (symbol-value header))
1322 ;; The element is a symbol. We insert the value
1323 ;; of this symbol, if any.
1324 (symbol-value header))
1326 ;; We couldn't generate a value for this header,
1327 ;; so we just ask the user.
1328 (read-from-minibuffer
1329 (format "Empty header for %s; enter value: " header)))))
1330 ;; Finally insert the header.
1332 (not (equal value "")))
1336 ;; This header didn't exist, so we insert it.
1337 (goto-char (point-max))
1338 (insert (symbol-name header) ": " value "\n")
1340 ;; The value of this header was empty, so we clear
1341 ;; totally and insert the new value.
1342 (delete-region (point) (gnus-point-at-eol))
1344 ;; Add the deletable property to the headers that require it.
1345 (and (memq header gnus-deletable-headers)
1346 (progn (beginning-of-line) (looking-at "[^:]+: "))
1347 (add-text-properties
1348 (point) (match-end 0)
1349 '(gnus-deletable t face italic) (current-buffer)))))))
1350 ;; Insert new Sender if the From is strange.
1351 (let ((from (mail-fetch-field "from"))
1352 (sender (mail-fetch-field "sender"))
1353 (secure-sender (gnus-inews-real-user-address)))
1355 (not (gnus-check-before-posting 'sender))
1357 (downcase (car (cdr (gnus-extract-address-components
1359 (downcase (gnus-inews-real-user-address))))
1363 (downcase (car (cdr (gnus-extract-address-components
1365 (downcase secure-sender)))))
1366 (goto-char (point-min))
1367 ;; Rename any old Sender headers to Original-Sender.
1368 (when (re-search-forward "^Sender:" nil t)
1370 (insert "Original-")
1371 (beginning-of-line))
1372 (insert "Sender: " secure-sender "\n")))))
1374 (defun gnus-inews-insert-signature ()
1375 "Insert a signature file.
1376 If `gnus-signature-function' is bound and returns a string, this
1377 string is used instead of the variable `gnus-signature-file'.
1378 In either case, if the string is a file name, this file is
1379 inserted. If the string is not a file name, the string itself is
1382 If you never want any signature inserted, set both of these variables to
1386 (or (and gnus-signature-function
1387 (funcall gnus-signature-function gnus-newsgroup-name))
1388 gnus-signature-file)))
1390 (or (file-exists-p signature)
1391 (string-match " " signature)
1393 "^/[^/]+/" (expand-file-name signature)))))
1395 (goto-char (point-max))
1396 (if (and mail-signature (search-backward "\n-- \n" nil t))
1398 ;; Delete any previous signatures.
1399 (if (search-backward "\n-- \n" nil t)
1400 (delete-region (point) (point-max)))
1401 (or (eolp) (insert "\n"))
1403 (if (file-exists-p signature)
1404 (insert-file-contents signature)
1406 (goto-char (point-max))
1407 (or (bolp) (insert "\n"))))))))
1409 ;; Written by "Mr. Per Persson" <pp@solace.mh.se>.
1410 (defun gnus-inews-insert-mime-headers ()
1411 (goto-char (point-min))
1412 (let ((mail-header-separator
1414 (goto-char (point-min))
1415 (if (and (search-forward (concat "\n" mail-header-separator "\n")
1417 (not (search-backward "\n\n" nil t)))
1418 mail-header-separator
1420 (or (mail-position-on-field "Mime-Version")
1422 (cond ((save-restriction
1424 (goto-char (point-min))
1425 (re-search-forward "[\200-\377]" nil t))
1426 (or (mail-position-on-field "Content-Type")
1427 (insert "text/plain; charset=ISO-8859-1"))
1428 (or (mail-position-on-field "Content-Transfer-Encoding")
1430 (t (or (mail-position-on-field "Content-Type")
1431 (insert "text/plain; charset=US-ASCII"))
1432 (or (mail-position-on-field "Content-Transfer-Encoding")
1433 (insert "7bit")))))))
1435 (defun gnus-inews-do-fcc ()
1436 "Process Fcc headers in the current buffer.
1437 Unless the first character of the field is `|', the article is saved
1438 to the specified file using the function specified by the variable
1439 gnus-author-copy-saver. The default function rmail-output saves in
1440 Unix mailbox format.
1442 If the first character is `|', the contents of the article is sent to
1443 a program specified by the rest of the value."
1444 (let ((case-fold-search t) ;Should ignore case.
1448 (nnheader-narrow-to-headers)
1449 (while (setq file (mail-fetch-field "fcc"))
1451 (nnheader-remove-header "fcc" nil t))
1452 ;; Process FCC operations.
1455 (setq file (pop list))
1456 (if (string-match "^[ \t]*|[ \t]*\\(.*\\)[ \t]*$" file)
1457 ;; Pipe the article to the program in question.
1458 (call-process-region (point-min) (point-max) shell-file-name
1459 nil nil nil "-c" (match-string 1 file))
1460 ;; Save the article.
1461 (setq file (expand-file-name file))
1462 (gnus-make-directory (file-name-directory file))
1463 (if (and gnus-author-copy-saver
1464 (not (eq gnus-author-copy-saver 'rmail-output)))
1465 (funcall gnus-author-copy-saver file)
1466 (if (and (file-readable-p file) (mail-file-babyl-p file))
1467 (gnus-output-to-rmail file)
1468 (let ((mail-use-rfc822 t))
1469 (rmail-output file 1 t t))))))))))
1471 (defun gnus-inews-path ()
1473 (let ((login-name (gnus-inews-login-name)))
1474 (cond ((null gnus-use-generic-path)
1475 (concat (nth 1 gnus-select-method) "!" login-name))
1476 ((stringp gnus-use-generic-path)
1477 ;; Support GENERICPATH. Suggested by vixie@decwrl.dec.com.
1478 (concat gnus-use-generic-path "!" login-name))
1481 (defun gnus-inews-user-name ()
1482 "Return user's network address as \"NAME@DOMAIN (FULL-NAME)\"."
1483 (let ((full-name (gnus-inews-full-name))
1484 (address (if (or gnus-user-login-name gnus-use-generic-from
1485 gnus-local-domain (getenv "DOMAINNAME"))
1486 (concat (gnus-inews-login-name) "@"
1487 (gnus-inews-domain-name gnus-use-generic-from))
1488 user-mail-address)))
1489 (or gnus-user-from-line
1491 ;; User's full name.
1492 (cond ((string-equal full-name "&") ;Unix hack.
1493 (concat " (" (user-login-name) ")"))
1494 ((string-match "[^ ]+@[^ ]+ +(.*)" address)
1497 (concat " (" full-name ")")))))))
1499 (defun gnus-inews-real-user-address ()
1500 "Return the \"real\" user address.
1501 This function tries to ignore all user modifications, and
1502 give as trustworthy answer as possible."
1503 (concat (user-login-name) "@" (system-name)))
1505 (defun gnus-inews-login-name ()
1506 "Return login name."
1507 (or gnus-user-login-name (getenv "LOGNAME") (user-login-name)))
1509 (defun gnus-inews-full-name ()
1510 "Return full user name."
1511 (or gnus-user-full-name (getenv "NAME") (user-full-name)))
1513 (defun gnus-inews-domain-name (&optional genericfrom)
1514 "Return user's domain name.
1515 If optional argument GENERICFROM is a string, use it as the domain
1516 name; if it is non-nil, strip off local host name from the domain name.
1517 If the function `system-name' returns full internet name and the
1518 domain is undefined, the domain name is got from it."
1519 (if (or genericfrom gnus-local-domain (getenv "DOMAINNAME"))
1520 (let* ((system-name (system-name))
1522 (or (if (stringp genericfrom) genericfrom)
1523 (getenv "DOMAINNAME")
1524 (and (boundp 'mail-host-address)
1527 ;; Function `system-name' may return full internet name.
1528 ;; Suggested by Mike DeCorte <mrd@sun.soe.clarkson.edu>.
1529 (if (string-match "\\.." system-name)
1530 ;; Some machines return "name.", and that's not
1532 (substring system-name (1- (match-end 0))))
1533 (read-string "Domain name (no host): ")))
1534 (host (or (if (string-match "\\." system-name)
1535 (substring system-name 0 (match-beginning 0)))
1537 (if (string-equal "." (substring domain 0 1))
1538 (setq domain (substring domain 1)))
1539 ;; Support GENERICFROM as same as standard Bnews system.
1540 ;; Suggested by ohm@kaba.junet and vixie@decwrl.dec.com.
1541 (cond ((null genericfrom)
1542 (concat host "." domain))
1543 ;;((stringp genericfrom) genericfrom)
1545 (if (string-match "\\." (system-name))
1547 (if (string-match "@\\([^ ]+\\)\\($\\| \\)" user-mail-address)
1548 (substring user-mail-address
1549 (match-beginning 1) (match-end 1))
1552 (defun gnus-inews-full-address ()
1553 (let ((domain (gnus-inews-domain-name))
1554 (system (system-name))
1555 (case-fold-search t))
1556 (if (string-match "\\." system) system
1557 (if (string-match (concat "^" (regexp-quote system)) domain) domain
1558 (concat system "." domain)))))
1560 (defun gnus-inews-expires ()
1561 "Return an Expires header based on `gnus-article-expires'."
1562 (let ((current (current-time))
1563 (future (* 1.0 gnus-article-expires 60 60 24)))
1564 ;; Add the future to current.
1565 (setcar current (+ (car current) (round (/ future (expt 2 16)))))
1566 (setcar (cdr current) (+ (nth 1 current) (% (round future) (expt 2 16))))
1567 ;; Return the date in the future in UT.
1568 (timezone-make-date-arpa-standard
1569 (current-time-string current) (current-time-zone) '(0 "UT"))))
1571 (defun gnus-inews-distribution ()
1572 "Return the current Distribution header, if any."
1573 (when (and gnus-distribution-function
1574 (fboundp gnus-distribution-function))
1575 (funcall gnus-distribution-function (or gnus-newsgroup-name ""))))
1577 (defun gnus-inews-message-id ()
1578 "Generate unique Message-ID for user."
1579 ;; Message-ID should not contain a slash and should be terminated by
1580 ;; a number. I don't know the reason why it is so.
1581 (concat "<" (gnus-inews-unique-id) "@" (gnus-inews-full-address) ">"))
1583 (defvar gnus-unique-id-char nil)
1585 ;; If you ever change this function, make sure the new version
1586 ;; cannot generate IDs that the old version could.
1587 ;; You might for example insert a "." somewhere (not next to another dot
1588 ;; or string boundary), or modify the newsreader name to "Ding".
1589 (defun gnus-inews-unique-id ()
1590 ;; Don't use microseconds from (current-time), they may be unsupported.
1591 ;; Instead we use this randomly inited counter.
1592 (setq gnus-unique-id-char
1593 (% (1+ (or gnus-unique-id-char (logand (random t) (1- (lsh 1 20)))))
1594 ;; (current-time) returns 16-bit ints,
1595 ;; and 2^16*25 just fits into 4 digits i base 36.
1597 (let ((tm (if (fboundp 'current-time)
1598 (current-time) '(12191 46742 287898))))
1600 (if (memq system-type '(ms-dos emx vax-vms))
1601 (let ((user (downcase (gnus-inews-login-name))))
1602 (while (string-match "[^a-z0-9_]" user)
1603 (aset user (match-beginning 0) ?_))
1605 (gnus-number-base36 (user-uid) -1))
1606 (gnus-number-base36 (+ (car tm) (lsh (% gnus-unique-id-char 25) 16)) 4)
1607 (gnus-number-base36 (+ (nth 1 tm) (lsh (/ gnus-unique-id-char 25) 16)) 4)
1608 ;; Append the newsreader name, because while the generated
1609 ;; ID is unique to this newsreader, other newsreaders might
1610 ;; otherwise generate the same ID via another algorithm.
1614 (defun gnus-inews-date ()
1615 "Current time string."
1616 (let ((now (current-time)))
1617 (timezone-make-date-arpa-standard
1618 (current-time-string now) (current-time-zone now))))
1620 (defun gnus-inews-organization ()
1621 "Return user's organization.
1622 The ORGANIZATION environment variable is used if defined.
1623 If not, the variable `gnus-local-organization' is used instead.
1624 If it is a function, the function will be called with the current
1625 newsgroup name as the argument.
1626 If this is a file name, the contents of this file will be used as the
1628 (let* ((organization
1629 (or (getenv "ORGANIZATION")
1630 (if gnus-local-organization
1631 (if (gnus-functionp gnus-local-organization)
1632 (funcall gnus-local-organization gnus-newsgroup-name)
1633 gnus-local-organization))
1634 gnus-organization-file
1635 "~/.organization")))
1636 (and (stringp organization)
1637 (> (length organization) 0)
1638 (or (file-exists-p organization)
1639 (string-match " " organization)
1640 (not (string-match "^/usr/lib/\\|^~/" organization)))
1642 (gnus-set-work-buffer)
1643 (if (file-exists-p organization)
1644 (insert-file-contents organization)
1645 (insert organization))
1646 (goto-char (point-min))
1647 (while (re-search-forward " *\n *" nil t)
1648 (replace-match " " t t))
1649 (buffer-substring (point-min) (point-max))))))
1651 (defun gnus-inews-lines ()
1652 "Count the number of lines and return numeric string."
1656 (goto-char (point-min))
1658 (concat "^" (regexp-quote mail-header-separator) "$"))
1660 (int-to-string (count-lines (point) (point-max))))))
1662 (defun gnus-inews-in-reply-to ()
1663 "Return the In-Reply-To header for this message."
1668 ;;; Gnus Mail Functions
1671 ;;; Mail reply commands of Gnus summary mode
1673 (defun gnus-summary-reply (yank &optional yank-articles)
1674 "Reply mail to news author.
1675 If prefix argument YANK is non-nil, original article is yanked automatically.
1676 Customize the variable gnus-mail-reply-method to use another mailer."
1678 ;; Bug fix by jbw@bigbird.bu.edu (Joe Wells)
1679 ;; Stripping headers should be specified with mail-yank-ignored-headers.
1680 (gnus-set-global-variables)
1681 (if yank-articles (gnus-summary-goto-subject (car yank-articles)))
1682 (gnus-summary-select-article)
1683 (bury-buffer gnus-article-buffer)
1684 (gnus-mail-reply (or yank-articles (not (not yank)))))
1686 (defun gnus-summary-reply-with-original (n)
1687 "Reply mail to news author with original article.
1688 Customize the variable gnus-mail-reply-method to use another mailer."
1690 (gnus-summary-reply t (gnus-summary-work-articles n)))
1692 (defun gnus-summary-mail-forward (post)
1693 "Forward the current message to another user.
1694 Customize the variable gnus-mail-forward-method to use another mailer."
1696 (gnus-set-global-variables)
1697 (gnus-summary-select-article)
1698 (gnus-copy-article-buffer)
1700 (gnus-forward-using-post gnus-original-article-buffer)
1701 (gnus-mail-forward gnus-original-article-buffer)))
1703 (defun gnus-summary-resend-message (address)
1704 "Resend the current article to ADDRESS."
1705 (interactive "sResend message to: ")
1706 (gnus-summary-select-article)
1709 ;; We first set up a normal mail buffer.
1710 (nnheader-set-temp-buffer " *Gnus resend*")
1711 ;; This code from sendmail.el
1713 (let ((fill-prefix "\t")
1714 (address-start (point)))
1715 (insert address "\n")
1716 (fill-region-as-paragraph address-start (point-max)))
1717 (insert mail-header-separator "\n")
1718 ;; Insert our usual headers.
1719 (gnus-inews-narrow-to-headers)
1720 (gnus-inews-insert-headers '(From Date To))
1721 (goto-char (point-min))
1722 ;; Rename them all to "Resent-*".
1723 (while (re-search-forward "^[A-Za-z]" nil t)
1728 (delete-region (point) (point-max))
1730 ;; Insert the message to be resent.
1731 (insert-buffer-substring gnus-original-article-buffer)
1732 (goto-char (point-min))
1733 (search-forward "\n\n")
1735 (insert mail-header-separator)
1736 ;; Rename all old ("Also-")Resent headers.
1737 (while (re-search-backward "^\\(Also-\\)?Resent-" beg t)
1742 (kill-buffer (current-buffer)))))
1744 (defun gnus-summary-post-forward ()
1745 "Forward the current article to a newsgroup."
1747 (gnus-summary-mail-forward t))
1749 (defvar gnus-nastygram-message
1750 "The following article was inappropriately posted to %s.\n"
1751 "Format string to insert in nastygrams.
1752 The current group name will be inserted at \"%s\".")
1754 (defun gnus-summary-mail-nastygram (n)
1755 "Send a nastygram to the author of the current article."
1757 (if (or gnus-expert-user
1759 "Really send a nastygram to the author of the current article? "))
1760 (let ((group gnus-newsgroup-name))
1761 (gnus-summary-reply-with-original n)
1762 (set-buffer gnus-mail-buffer)
1763 (insert (format gnus-nastygram-message group))
1764 (gnus-mail-send-and-exit))))
1766 (defun gnus-summary-mail-other-window ()
1767 "Compose mail in other window.
1768 Customize the variable `gnus-mail-other-window-method' to use another
1771 (gnus-set-global-variables)
1773 ;; We might want to prompt here.
1774 (when (and gnus-interactive-post
1775 (not gnus-expert-user))
1776 (read-string "To: ")))
1777 (gnus-configure-windows 'summary-mail 'force))
1779 (defun gnus-new-mail (&optional to)
1781 (when (and gnus-interactive-post
1782 (not gnus-expert-user))
1783 (setq subject (read-string "Subject: ")))
1784 (pop-to-buffer gnus-mail-buffer)
1786 (gnus-mail-setup 'new to subject)
1787 (gnus-inews-insert-gcc)
1788 (gnus-inews-insert-archive-gcc)
1789 (run-hooks 'gnus-mail-hook)))
1791 (defun gnus-mail-reply (&optional yank to-address followup)
1793 (set-buffer gnus-summary-buffer)
1794 (let ((group (gnus-group-real-name gnus-newsgroup-name))
1795 (cur (cons (current-buffer) (cdr gnus-article-current)))
1796 (winconf (current-window-configuration))
1797 from subject date reply-to message-of to cc
1798 references message-id sender follow-to sendto elt new-cc new-to
1800 (set-buffer (get-buffer-create gnus-mail-buffer))
1802 (if (and (buffer-modified-p)
1805 "Unsent message being composed; erase it? ")))
1809 (gnus-copy-article-buffer)
1811 (set-buffer gnus-article-copy)
1812 (nnheader-narrow-to-headers)
1814 ;; This is a regular reply.
1815 (if (gnus-functionp gnus-reply-to-function)
1816 (setq follow-to (funcall gnus-reply-to-function group)))
1817 ;; This is a followup.
1818 (if (gnus-functionp gnus-followup-to-function)
1821 (funcall gnus-followup-to-function group)))))
1822 (setq from (mail-fetch-field "from"))
1823 (setq date (or (mail-fetch-field "date")
1824 (mail-header-date gnus-current-headers)))
1825 (setq message-of (gnus-message-of from date))
1826 (setq sender (mail-fetch-field "sender"))
1827 (setq subject (or (mail-fetch-field "subject") "none"))
1828 ;; Remove any (buggy) Re:'s that are present and make a
1830 (and (string-match "^[ \t]*[Re][Ee]:[ \t]*" subject)
1831 (setq subject (substring subject (match-end 0))))
1832 (setq subject (concat "Re: " subject))
1833 (setq to (mail-fetch-field "to"))
1834 (setq cc (mail-fetch-field "cc"))
1835 (setq mct (mail-fetch-field "mail-copies-to"))
1837 (unless (gnus-group-get-parameter group 'broken-reply-to)
1838 (mail-fetch-field "reply-to")))
1839 (setq references (mail-fetch-field "references"))
1840 (setq message-id (mail-fetch-field "message-id"))
1842 (setq mctdo (not (equal mct "never")))
1844 (if (not (and followup (not to-address)))
1845 (setq new-to (or reply-to from))
1848 (gnus-set-work-buffer)
1849 (unless (equal mct "never")
1850 (insert (or reply-to from "")))
1852 (if (bolp) "" ", ") (or to "")
1853 (if (or (not mct) (not mctdo)) ""
1854 (concat (if (bolp) "" ", ") mct))
1855 (if cc (concat (if (bolp) "" ", ") cc) ""))
1856 ;; Remove addresses that match `rmail-dont-reply-to-names'.
1857 (insert (prog1 (rmail-dont-reply-to (buffer-string))
1859 (goto-char (point-min))
1863 (cons (mail-strip-quoted-names addr) addr))
1864 (nreverse (gnus-mail-parse-comma-list))))
1867 (setq ccalist (delq (assoc (car (pop s)) s) ccalist)))))
1868 (setq new-to (cdr (pop ccalist)))
1871 (lambda (addr) (cdr addr))
1875 (setq news-reply-yank-from (or from "(nobody)"))
1876 (setq news-reply-yank-message-id
1877 (or message-id "(unknown Message-ID)"))
1879 ;; Gather the "to" addresses out of the follow-to list and remove
1881 (if (and follow-to (listp follow-to))
1882 (while (setq elt (assoc "To" follow-to))
1883 (setq sendto (concat sendto (and sendto ", ") (cdr elt)))
1884 (setq follow-to (delq elt follow-to))))
1887 (if followup 'followup 'reply)
1889 (if (and follow-to (not (stringp follow-to))) sendto
1890 (or follow-to new-to sender "")))
1892 (if (zerop (length new-cc)) nil new-cc)
1895 (make-local-variable 'gnus-article-reply)
1896 (setq gnus-article-reply cur)
1897 (make-local-variable 'gnus-prev-winconf)
1898 (setq gnus-prev-winconf winconf)
1899 (make-local-variable 'gnus-reply-subject)
1900 (setq gnus-reply-subject subject)
1901 (make-local-variable 'gnus-in-reply-to)
1902 (setq gnus-in-reply-to message-of)
1904 (auto-save-mode auto-save-default)
1905 (gnus-inews-insert-gcc)
1906 (gnus-inews-insert-archive-gcc)
1908 (when (and follow-to (listp follow-to))
1910 (gnus-inews-narrow-to-headers)
1911 (re-search-forward "^To:" nil t)
1915 ;; Insert the rest of the Follow-To headers.
1917 (goto-char (point-min))
1918 (if (not (re-search-forward
1919 (concat "^" (caar follow-to) ": *") nil t))
1922 (insert (caar follow-to) ": " (cdar follow-to) "\n"))
1925 (insert (cdar follow-to)))
1926 (setq follow-to (cdr follow-to)))
1928 (nnheader-insert-references references message-id)
1930 ;; Now the headers should be ok, so we do the yanking.
1931 (goto-char (point-min))
1933 (concat "^" (regexp-quote mail-header-separator) "$"))
1936 (gnus-configure-windows 'reply 'force)
1937 (let ((last (point))
1939 (if (not (listp yank))
1941 ;; Just a single article being yanked.
1943 (mail-yank-original nil))
1944 (or mail-yank-hooks mail-citation-hook
1945 (run-hooks 'news-reply-header-hook)))
1947 (save-window-excursion
1948 (set-buffer gnus-summary-buffer)
1949 (gnus-summary-select-article nil nil nil (car yank))
1950 (gnus-summary-remove-process-mark (car yank)))
1953 (gnus-copy-article-buffer)
1954 (mail-yank-original nil)
1956 (narrow-to-region (point-min) (point))
1957 (goto-char (mark t))
1958 (let ((news-reply-yank-from
1960 (set-buffer gnus-article-buffer)
1961 (or (mail-fetch-field "from") "(nobody)")))
1962 (news-reply-yank-message-id
1964 (set-buffer gnus-article-buffer)
1965 (or (mail-fetch-field "message-id")
1966 "(unknown Message-ID)"))))
1967 (or mail-yank-hooks mail-citation-hook
1968 (run-hooks 'news-reply-header-hook))
1969 (setq end (point-max)))))
1971 (setq yank (cdr yank))))
1974 (gnus-configure-windows 'reply-yank 'force))
1975 (run-hooks 'gnus-mail-hook)
1976 ;; Mark this buffer as unchanged.
1977 (set-buffer-modified-p nil)))))
1979 (defun gnus-mail-parse-comma-list ()
1982 (skip-chars-forward " ")
1985 (skip-chars-forward "^,")
1990 (narrow-to-region beg (point))
1993 (while (search-forward "\"" nil t)
1995 (if (zerop i) 2 i)) 2)))))
1996 (skip-chars-forward ",")
1997 (skip-chars-forward "^,"))
1998 (skip-chars-backward " ")
2000 (cons (buffer-substring beg (point))
2002 (skip-chars-forward "^,")
2003 (skip-chars-forward ", "))
2006 (defun gnus-new-news (&optional group inhibit-prompt)
2007 "Set up a *post-news* buffer that points to GROUP.
2008 If INHIBIT-PROMPT, never prompt for a Subject."
2009 (let ((winconf (current-window-configuration))
2011 (when (and gnus-interactive-post
2012 (not inhibit-prompt)
2013 (not gnus-expert-user))
2014 (setq subject (read-string "Subject: ")))
2015 (pop-to-buffer gnus-post-news-buffer)
2018 ;; Let posting styles be configured.
2019 (gnus-configure-posting-styles)
2020 (news-setup nil subject nil (and group (gnus-group-real-name group)) nil)
2021 ;; Associate this buffer with the draft group.
2022 (gnus-enter-buffer-into-draft)
2023 (goto-char (point-min))
2025 (unless (re-search-forward
2026 (concat "^" (regexp-quote mail-header-separator) "$") nil t)
2027 (goto-char (point-max)))
2030 (gnus-inews-insert-bfcc)
2031 (gnus-inews-insert-gcc)
2032 (gnus-inews-insert-archive-gcc)
2033 (gnus-inews-insert-signature)
2034 (and gnus-post-prepare-function
2035 (gnus-functionp gnus-post-prepare-function)
2036 (funcall gnus-post-prepare-function group))
2037 (run-hooks 'gnus-post-prepare-hook)
2038 (gnus-inews-set-point)
2039 (make-local-variable 'gnus-prev-winconf)
2040 (setq gnus-prev-winconf winconf)
2041 (gnus-inews-modify-mail-mode-map)
2042 (local-set-key "\C-c\C-c" 'gnus-inews-news)))
2044 (defun gnus-news-followup (&optional yank group)
2046 (set-buffer gnus-summary-buffer)
2047 (if (not (or (not gnus-novice-user)
2050 "Are you sure you want to post to all of USENET? ")))
2052 (let ((group (gnus-group-real-name (or group gnus-newsgroup-name)))
2053 (cur (cons (current-buffer) (cdr gnus-article-current)))
2054 (winconf (current-window-configuration))
2055 from subject date reply-to message-of
2056 references message-id sender follow-to sendto elt
2057 followup-to distribution newsgroups)
2058 (set-buffer (get-buffer-create gnus-post-news-buffer))
2060 ;; Associate this buffer with the draft group.
2061 (gnus-enter-buffer-into-draft)
2062 (if (and (buffer-modified-p)
2065 "Unsent message being composed; erase it? ")))
2069 (gnus-copy-article-buffer)
2071 (set-buffer gnus-article-copy)
2072 (nnheader-narrow-to-headers)
2073 (if (gnus-functionp gnus-followup-to-function)
2076 (funcall gnus-followup-to-function group))))
2077 (setq from (mail-fetch-field "from"))
2078 (setq date (or (mail-fetch-field "date")
2079 (mail-header-date gnus-current-headers)))
2080 (setq message-of (gnus-message-of from date))
2081 (setq subject (or (mail-fetch-field "subject") "none"))
2082 ;; Remove any (buggy) Re:'s that are present and make a
2084 (and (string-match "^[ \t]*[Re][Ee]:[ \t]*" subject)
2085 (setq subject (substring subject (match-end 0))))
2086 (setq subject (concat "Re: " subject))
2087 (setq references (mail-fetch-field "references"))
2088 (setq message-id (mail-fetch-field "message-id"))
2089 (setq followup-to (mail-fetch-field "followup-to"))
2090 (setq newsgroups (mail-fetch-field "newsgroups"))
2091 (setq distribution (mail-fetch-field "distribution"))
2092 ;; Remove bogus distribution.
2093 (and (stringp distribution)
2094 (string-match "world" distribution)
2095 (setq distribution nil))
2098 (setq news-reply-yank-from (or from "(nobody)"))
2099 (setq news-reply-yank-message-id
2100 (or message-id "(unknown Message-ID)"))
2102 ;; Gather the "to" addresses out of the follow-to list and remove
2104 (if (and follow-to (listp follow-to))
2105 (while (setq elt (assoc "Newsgroups" follow-to))
2106 (setq sendto (concat sendto (and sendto ", ") (cdr elt)))
2107 (setq follow-to (delq elt follow-to))))
2109 ;; Let posting styles be configured.
2110 (gnus-configure-posting-styles)
2112 (news-setup nil subject nil
2115 gnus-use-followup-to
2116 (or (not (eq gnus-use-followup-to 'ask))
2119 "Use Followup-To %s? " followup-to)))
2121 newsgroups group "")
2124 (make-local-variable 'gnus-article-reply)
2125 (setq gnus-article-reply cur)
2126 (make-local-variable 'gnus-prev-winconf)
2127 (setq gnus-prev-winconf winconf)
2128 (make-local-variable 'gnus-reply-subject)
2129 (setq gnus-reply-subject (mail-header-subject gnus-current-headers))
2130 (make-local-variable 'gnus-in-reply-to)
2131 (setq gnus-in-reply-to message-of)
2132 (when (and followup-to newsgroups)
2133 (make-local-variable 'gnus-newsgroup-followup)
2134 (setq gnus-newsgroup-followup
2135 (cons newsgroups followup-to)))
2137 (gnus-inews-insert-signature)
2139 (and gnus-post-prepare-function
2140 (gnus-functionp gnus-post-prepare-function)
2141 (funcall gnus-post-prepare-function group))
2142 (run-hooks 'gnus-post-prepare-hook)
2144 (auto-save-mode auto-save-default)
2145 (gnus-inews-modify-mail-mode-map)
2146 (local-set-key "\C-c\C-c" 'gnus-inews-news)
2148 (if (and follow-to (listp follow-to))
2150 (goto-char (point-min))
2151 (and (re-search-forward "^Newsgroups:" nil t)
2154 (insert (car (car follow-to)) ": "
2155 (cdr (car follow-to)) "\n")
2156 (setq follow-to (cdr follow-to)))))
2158 ;; If a distribution existed, we use it.
2161 (mail-position-on-field "Distribution")
2162 (insert distribution)))
2164 (nnheader-insert-references references message-id)
2166 ;; Handle `gnus-auto-mail-to-author'.
2167 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
2168 ;; Revised to respect Reply-To by Ulrik Dickow <dickow@nbi.dk>.
2169 (let ((to (if (if (eq gnus-auto-mail-to-author 'ask)
2170 (y-or-n-p "Also send mail to author? ")
2171 gnus-auto-mail-to-author)
2173 (set-buffer gnus-article-copy)
2174 (unless (gnus-group-get-parameter
2175 group 'broken-reply-to)
2176 (gnus-fetch-field "reply-to")))
2178 (x-mail (save-excursion
2179 (set-buffer gnus-article-copy)
2180 (gnus-fetch-field "x-mail-copy-to"))))
2181 ;; Deny sending copy if there's a negative X-Mail-Copy-To
2184 (if (and (string= x-mail "never")
2185 (not (eq gnus-auto-mail-to-author 'force)))
2188 ;; Insert a To or Cc header.
2190 (if (mail-fetch-field "To")
2193 (insert "Cc: " to "\n"))
2194 (mail-position-on-field "To")
2197 (gnus-inews-insert-bfcc)
2198 (gnus-inews-insert-gcc)
2199 (gnus-inews-insert-archive-gcc)
2201 ;; Now the headers should be ok, so we do the yanking.
2202 (goto-char (point-min))
2204 (concat "^" (regexp-quote mail-header-separator) "$"))
2208 (gnus-configure-windows 'followup 'force)
2211 (let ((last (point))
2213 (if (not (listp yank))
2216 (mail-yank-original nil))
2217 (or mail-yank-hooks mail-citation-hook
2218 (run-hooks 'news-reply-header-hook)))
2220 (save-window-excursion
2221 (set-buffer gnus-summary-buffer)
2222 (gnus-summary-select-article nil nil nil (car yank))
2223 (gnus-summary-remove-process-mark (car yank)))
2225 (gnus-copy-article-buffer)
2226 (mail-yank-original nil)
2228 (or mail-yank-hooks mail-citation-hook
2229 (run-hooks 'news-reply-header-hook))
2231 (setq yank (cdr yank))))
2233 (gnus-configure-windows 'followup-yank 'force))
2235 (make-local-variable 'gnus-article-check-size)
2236 (setq gnus-article-check-size
2237 (cons (buffer-size) (gnus-article-checksum)))
2238 (gnus-inews-set-point))))))
2240 (defun gnus-message-of (from date)
2241 "Take a FROM and a DATE and return an IN-REPLY-TO."
2244 (string-match " *at \\| *@ \\| *(\\| *<" from)))
2245 (concat (if stop-pos (substring from 0 stop-pos) from)
2247 (if (or (not date) (string= date ""))
2248 "(unknown date)" date)))))
2250 (defun gnus-mail-yank-original ()
2253 (mail-yank-original nil))
2254 (or mail-yank-hooks mail-citation-hook
2255 (run-hooks 'news-reply-header-hook)))
2257 (defun gnus-mail-send-and-exit (&optional dont-send)
2258 "Send the current mail and return to Gnus."
2260 (let* ((reply gnus-article-reply)
2261 (winconf gnus-prev-winconf)
2262 (address-group gnus-add-to-address)
2263 (to-address (and address-group
2264 (mail-fetch-field "to"))))
2265 (setq gnus-add-to-address nil)
2266 (let ((buffer-file-name nil))
2267 (or dont-send (gnus-mail-send)))
2269 ;; This mail group doesn't have a `to-list', so we add one
2272 (gnus-group-add-parameter
2273 address-group (cons 'to-list to-address)))
2274 (if (get-buffer gnus-group-buffer)
2276 (if (gnus-buffer-exists-p (car-safe reply))
2278 (set-buffer (car reply))
2280 (gnus-summary-mark-article-as-replied
2282 (and winconf (set-window-configuration winconf))))))
2284 (defun gnus-kill-message-buffer ()
2285 "Kill the current buffer after dissociating it from the draft group."
2287 (when (gnus-y-or-n-p "Dissociate and kill the current buffer? ")
2288 (gnus-dissociate-buffer-from-draft)
2289 (kill-buffer (current-buffer))))
2291 (defun gnus-put-message ()
2292 "Put the current message in some group and return to Gnus."
2294 (let ((reply gnus-article-reply)
2295 (winconf gnus-prev-winconf)
2296 (group gnus-newsgroup-name)
2299 (or (and group (not (gnus-group-read-only-p group)))
2300 (setq group (read-string "Put in group: " nil
2301 (gnus-writable-groups))))
2302 (and (gnus-gethash group gnus-newsrc-hashtb)
2303 (error "No such group: %s" group))
2308 (gnus-inews-narrow-to-headers)
2309 (let (gnus-deletable-headers)
2310 (if (eq major-mode 'mail-mode)
2311 (gnus-inews-insert-headers gnus-required-mail-headers)
2312 (gnus-inews-insert-headers)))
2313 (goto-char (point-max))
2314 (insert "Gcc: " group "\n")
2319 (if (get-buffer gnus-group-buffer)
2321 (if (gnus-buffer-exists-p (car-safe reply))
2323 (set-buffer (car reply))
2325 (gnus-summary-mark-article-as-replied
2327 (and winconf (set-window-configuration winconf))))))
2329 (defun gnus-forward-make-subject (buffer)
2332 (concat "[" (if (memq 'mail (assoc (symbol-name
2333 (car (gnus-find-method-for-group
2334 gnus-newsgroup-name)))
2335 gnus-valid-select-methods))
2336 (gnus-fetch-field "From")
2337 gnus-newsgroup-name)
2338 "] " (or (gnus-fetch-field "Subject") ""))))
2340 (defun gnus-forward-insert-buffer (buffer)
2343 ;; Put point where we want it before inserting the forwarded
2345 (if gnus-signature-before-forwarded-message
2346 (goto-char (point-max))
2347 (goto-char (point-min))
2349 (concat "^" (regexp-quote mail-header-separator) "$"))
2351 ;; Narrow to the area we are to insert.
2352 (narrow-to-region (point) (point))
2353 ;; Insert the separators and the forwarded buffer.
2354 (insert gnus-forward-start-separator)
2355 (insert-buffer-substring buffer)
2356 (goto-char (point-max))
2357 (insert gnus-forward-end-separator)
2358 ;; Remove all unwanted headers.
2359 (goto-char (point-min))
2362 (narrow-to-region (point) (if (search-forward "\n\n" nil t)
2365 (goto-char (point-min))
2366 (delete-non-matching-lines gnus-forward-included-headers))
2367 ;; Delete any invisible text.
2368 (goto-char (point-min))
2370 (while (setq beg (next-single-property-change (point) 'invisible))
2372 (delete-region beg (or (next-single-property-change
2376 (defun gnus-mail-forward (&optional buffer)
2377 "Forward the current message to another user using mail."
2378 (let* ((forward-buffer (or buffer (current-buffer)))
2379 (winconf (current-window-configuration))
2380 (subject (gnus-forward-make-subject forward-buffer)))
2381 (set-buffer (get-buffer-create gnus-mail-buffer))
2382 (if (and (buffer-modified-p)
2385 "Unsent message being composed; erase it? ")))
2388 (gnus-mail-setup 'forward nil subject)
2389 (make-local-variable 'gnus-prev-winconf)
2390 (setq gnus-prev-winconf winconf)
2391 (gnus-forward-insert-buffer forward-buffer)
2392 (goto-char (point-min))
2393 (re-search-forward "^To: ?" nil t)
2394 (gnus-configure-windows 'mail-forward 'force)
2395 ;; You have a chance to arrange the message.
2396 (run-hooks 'gnus-mail-forward-hook)
2397 (run-hooks 'gnus-mail-hook))))
2399 (defun gnus-forward-using-post (&optional buffer)
2401 (let* ((forward-buffer (or buffer (current-buffer)))
2402 (subject (gnus-forward-make-subject forward-buffer))
2403 (gnus-newsgroup-name nil))
2404 (gnus-post-news 'post nil nil nil nil subject)
2406 (gnus-forward-insert-buffer forward-buffer)
2407 ;; You have a chance to arrange the message.
2408 (run-hooks 'gnus-mail-forward-hook)))))
2410 (defun gnus-mail-other-window-using-mail ()
2411 "Compose mail other window using mail."
2412 (let ((winconf (current-window-configuration)))
2413 (mail-other-window nil nil nil nil nil (get-buffer gnus-article-buffer))
2414 (gnus-inews-modify-mail-mode-map)
2415 (make-local-variable 'gnus-prev-winconf)
2416 (setq gnus-prev-winconf winconf)
2417 (run-hooks 'gnus-mail-hook)
2418 (gnus-configure-windows 'summary-mail 'force)))
2420 (defun gnus-article-mail (yank)
2421 "Send a reply to the address near point.
2422 If YANK is non-nil, include the original article."
2426 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
2427 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
2430 (switch-to-buffer gnus-summary-buffer)
2431 (gnus-mail-reply yank address)))))
2434 "Send a bug report to the Gnus maintainers."
2436 (let ((winconf (current-window-configuration)))
2437 (delete-other-windows)
2438 (switch-to-buffer "*Gnus Help Bug*")
2440 (insert gnus-bug-message)
2441 (goto-char (point-min))
2442 (pop-to-buffer "*Gnus Bug*")
2445 (mail-setup gnus-maintainer nil nil nil nil nil)
2446 (auto-save-mode auto-save-default)
2447 (make-local-variable 'gnus-prev-winconf)
2448 (setq gnus-prev-winconf winconf)
2449 (gnus-inews-modify-mail-mode-map)
2450 (local-set-key "\C-c\C-c" 'gnus-bug-mail-send-and-exit)
2451 (goto-char (point-min))
2452 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
2454 (insert (gnus-version) "\n")
2455 (insert (emacs-version))
2456 (insert "\n\n\n\n\n")
2458 (goto-char (point-min))
2459 (search-forward "Subject: " nil t)
2462 (defun gnus-bug-mail-send-and-exit ()
2463 "Send the bug message and exit."
2465 (and (get-buffer "*Gnus Help Bug*")
2466 (kill-buffer "*Gnus Help Bug*"))
2467 (gnus-mail-send-and-exit))
2469 (defun gnus-debug ()
2470 "Attemps to go through the Gnus source file and report what variables have been changed.
2471 The source file has to be in the Emacs load path."
2473 (let ((files '("gnus.el" "gnus-msg.el" "gnus-score.el" "nnmail.el"))
2474 file dirs expr olist sym)
2475 (message "Please wait while we snoop your variables...")
2478 (set-buffer (get-buffer-create " *gnus bug info*"))
2479 (buffer-disable-undo (current-buffer))
2482 (setq dirs load-path)
2484 (if (or (not (car dirs))
2485 (not (stringp (car dirs)))
2487 (setq file (concat (file-name-as-directory
2488 (car dirs)) (car files))))))
2489 (setq dirs (cdr dirs))
2491 (insert-file-contents file)
2492 (goto-char (point-min))
2493 (if (not (re-search-forward "^;;* *Internal variables" nil t))
2494 (message "Malformed sources in file %s" file)
2495 (narrow-to-region (point-min) (point))
2496 (goto-char (point-min))
2497 (while (setq expr (condition-case ()
2498 (read (current-buffer)) (error nil)))
2500 (and (eq (car expr) 'defvar)
2501 (stringp (nth 3 expr))
2502 (or (not (boundp (nth 1 expr)))
2503 (not (equal (eval (nth 2 expr))
2504 (symbol-value (nth 1 expr)))))
2505 (setq olist (cons (nth 1 expr) olist)))
2507 (setq files (cdr files)))
2508 (kill-buffer (current-buffer)))
2509 (when (setq olist (nreverse olist))
2510 (insert "------------------ Environment follows ------------------\n\n"))
2512 (if (boundp (car olist))
2513 (insert "(setq " (symbol-name (car olist))
2514 (if (or (consp (setq sym (symbol-value (car olist))))
2516 (not (or (eq sym nil)
2519 (prin1-to-string (symbol-value (car olist))) ")\n")
2520 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
2521 (setq olist (cdr olist)))
2523 ;; Remove any null chars - they seem to cause trouble for some
2524 ;; mailers. (Byte-compiled output from the stuff above.)
2525 (goto-char (point-min))
2526 (while (re-search-forward "[\000\200]" nil t)
2527 (replace-match "" t t))))
2530 ;;; Treatment of rejected articles.
2535 (defun gnus-summary-resend-bounced-mail (fetch)
2536 "Re-mail the current message.
2537 This only makes sense if the current message is a bounce message than
2538 contains some mail you have written which has been bounced back to
2540 If FETCH, try to fetch the article that this is a reply to, if indeed
2543 (gnus-summary-select-article t)
2544 ;; Create a mail buffer.
2547 (insert-buffer-substring gnus-article-buffer)
2548 (goto-char (point-min))
2549 (or (re-search-forward "--- *Original message.*\n" nil t)
2550 (and (search-forward "\n\n" nil t)
2551 (re-search-forward "^Return-Path:.*\n" nil t)))
2552 ;; We remove everything before the bounced mail.
2555 (if (re-search-forward "[^ \t]*:" nil t)
2561 (nnheader-narrow-to-headers)
2562 (nnheader-remove-header gnus-bounced-headers-junk t)
2563 (setq references (mail-fetch-field "references"))
2564 (goto-char (point-max))
2565 (insert mail-header-separator)))
2566 ;; If there are references, we fetch the article we answered to.
2569 (string-match "\\(<[^]+>\\)[ \t]*$" references)
2570 (gnus-summary-refer-article
2571 (substring references (match-beginning 1) (match-end 1)))
2573 (gnus-summary-show-all-headers)
2574 (gnus-configure-windows 'compose-bounce))))
2575 (goto-char (point-min)))
2579 (defun gnus-mail-send (&optional no-generated-headers)
2580 "Send the current buffer as mail.
2581 Headers will be generated before sending."
2583 (unless no-generated-headers
2587 (gnus-inews-narrow-to-headers)
2588 (gnus-inews-insert-headers gnus-required-mail-headers)
2589 (gnus-inews-remove-empty-headers))))
2591 ;; Remove the header separator.
2592 (goto-char (point-min))
2593 (and (re-search-forward
2594 (concat "^" (regexp-quote mail-header-separator) "$") nil t)
2595 (replace-match "" t t))
2596 ;; Run final inews hooks. This hook may do FCC.
2597 (run-hooks 'gnus-inews-article-hook)
2599 (nnheader-narrow-to-headers)
2600 (nnheader-remove-header "^[gf]cc:" t)
2602 (goto-char (point-min))
2603 (search-forward "\n\n")
2605 (insert mail-header-separator)
2607 (run-hooks 'gnus-message-sent-hook))
2609 (defun gnus-inews-modify-mail-mode-map ()
2610 (use-local-map (copy-keymap (current-local-map)))
2611 (local-set-key "\C-c\C-c" 'gnus-mail-send-and-exit)
2612 (local-set-key "\C-c\C-p" 'gnus-put-message)
2613 (local-set-key "\C-c\C-k" 'gnus-kill-message-buffer)
2614 (local-set-key "\C-c\M-d" 'gnus-dissociate-buffer-from-draft)
2615 (local-set-key "\C-c\C-d" 'gnus-associate-buffer-with-draft))
2617 (defun gnus-mail-setup (type &optional to subject in-reply-to cc
2618 replybuffer actions)
2619 ;; Let posting styles be configured.
2620 (gnus-configure-posting-styles)
2624 (eq gnus-mail-method 'mh)
2625 (and (or (eq type 'reply) (eq type 'followup))
2626 (eq gnus-mail-reply-method 'gnus-mail-reply-using-mhe))
2627 (and (eq type 'forward)
2628 (eq gnus-mail-forward-method 'gnus-mail-forward-using-mhe))
2630 (eq gnus-mail-other-window-method
2631 'gnus-mail-other-window-using-mhe)))
2632 'gnus-mh-mail-setup)
2634 (eq gnus-mail-method 'vm)
2635 (and (or (eq type 'reply) (eq type 'followup))
2636 (eq gnus-mail-reply-method 'gnus-mail-reply-using-vm))
2637 (and (eq type 'forward)
2638 (eq gnus-mail-forward-method 'gnus-mail-forward-using-vm))
2640 (eq gnus-mail-other-window-method
2641 'gnus-mail-other-window-using-vm)))
2642 'gnus-vm-mail-setup)
2644 (eq gnus-mail-method 'sendmail)
2645 (and (or (eq type 'reply) (eq type 'followup))
2646 (eq gnus-mail-reply-method 'gnus-mail-reply-using-mail))
2647 (and (eq type 'forward)
2648 (eq gnus-mail-forward-method 'gnus-mail-forward-using-mail))
2650 (eq gnus-mail-other-window-method
2651 'gnus-mail-other-window-using-mail)))
2652 'gnus-sendmail-mail-setup)
2654 (cond ((or (eq type 'reply) (eq type 'followup))
2655 gnus-mail-reply-method)
2657 gnus-mail-forward-method)
2659 gnus-mail-other-window-method))))
2660 to subject in-reply-to cc replybuffer actions)
2661 ;; Associate this mail buffer with the draft group.
2662 (gnus-enter-buffer-into-draft))
2664 (defun gnus-sendmail-mail-setup (to subject in-reply-to cc replybuffer actions)
2666 (mail-setup to subject nil cc replybuffer actions)
2667 (gnus-inews-set-point)
2668 (gnus-inews-modify-mail-mode-map))
2672 ;; Do Gcc handling, which copied the message over to some group.
2673 (defun gnus-inews-do-gcc (&optional gcc)
2676 (nnheader-narrow-to-headers)
2677 (let ((gcc (or gcc (mail-fetch-field "gcc" nil t)))
2678 (cur (current-buffer))
2679 end groups group method)
2681 (nnheader-remove-header "gcc")
2683 (setq groups (gnus-tokenize-header gcc " "))
2684 ;; Copy the article over to some group(s).
2685 (while (setq group (pop groups))
2688 (cond ((and (null (gnus-get-info group))
2689 (eq (car gnus-message-archive-method)
2690 (car (gnus-group-method-name group))))
2691 ;; If the group doesn't exist, we assume
2692 ;; it's an archive group...
2693 gnus-message-archive-method)
2694 (t (gnus-find-method-for-group group)))))
2695 (unless (gnus-request-group group t method)
2696 (gnus-request-create-group group method))
2697 (gnus-check-server method)
2699 (nnheader-set-temp-buffer " *acc*")
2700 (insert-buffer-substring cur)
2701 (unless (condition-case ()
2702 (gnus-request-accept-article group t method)
2704 (gnus-message 1 "Couldn't store article in group %s: %s"
2705 group (gnus-status-message method))
2707 (kill-buffer (current-buffer)))))))))
2709 (defun gnus-inews-insert-bfcc ()
2710 "Insert Bcc and Fcc headers."
2712 ;; Handle author copy using BCC field.
2713 (when (and gnus-mail-self-blind
2714 (not (mail-fetch-field "bcc")))
2715 (mail-position-on-field "Bcc")
2716 (insert (if (stringp gnus-mail-self-blind)
2717 gnus-mail-self-blind
2718 (user-login-name))))
2719 ;; Handle author copy using FCC field.
2720 (when gnus-author-copy
2721 (mail-position-on-field "Fcc")
2722 (insert gnus-author-copy))))
2724 (defun gnus-inews-insert-gcc ()
2725 "Insert Gcc headers based on `gnus-outgoing-message-group'."
2728 (gnus-inews-narrow-to-headers)
2729 (let* ((group gnus-outgoing-message-group)
2731 ((gnus-functionp group)
2733 ((or (stringp group) (list group))
2737 (if (stringp gcc) gcc
2738 (mapconcat 'identity gcc " "))
2741 (defun gnus-inews-insert-archive-gcc ()
2742 "Insert the Gcc to say where the article is to be archived."
2743 (let* ((var gnus-message-archive-group)
2748 ;; Just a single group.
2751 ;; We don't want this.
2753 ((and (listp var) (stringp (car var)))
2754 ;; A list of groups.
2756 ((gnus-functionp var)
2758 (funcall var gnus-newsgroup-name))
2760 ;; An alist of regexps/functions/forms.
2765 ((stringp (caar var))
2767 (when (string-match (caar var)
2768 gnus-newsgroup-name)
2770 ((gnus-functionp (car var))
2772 (funcall (car var) gnus-newsgroup-name))
2774 (eval (car var)))))))
2775 (setq var (cdr var)))
2778 (when (stringp groups)
2779 (setq groups (list groups)))
2782 (gnus-inews-narrow-to-headers)
2783 (goto-char (point-max))
2786 (insert (gnus-group-prefixed-name
2787 (pop groups) gnus-message-archive-method))
2791 ;;; Handling rejected (and postponed) news.
2793 (defun gnus-draft-group ()
2794 "Return the name of the draft group."
2795 (gnus-group-prefixed-name
2796 (file-name-nondirectory gnus-draft-group-directory)
2797 (list 'nndraft gnus-draft-group-directory)))
2799 (defun gnus-make-draft-group ()
2800 "Make the draft group or die trying."
2801 (let* ((method (` (nndraft "private"
2803 (, gnus-draft-group-directory)))))
2804 (group (gnus-draft-group)))
2805 (or (gnus-gethash group gnus-newsrc-hashtb)
2806 (gnus-group-make-group (gnus-group-real-name group) method)
2807 (error "Can't create the draft group"))
2808 (gnus-check-server method)
2811 (defun gnus-associate-buffer-with-draft (&optional generate silent)
2812 "Enter the current buffer into the draft group."
2814 (when (gnus-request-accept-article (gnus-make-draft-group) t)
2816 ;; This function does the proper marking of articles.
2817 (gnus-mail-send-and-exit 'dont-send))
2818 (set-buffer-modified-p nil)))
2820 (defun gnus-enter-buffer-into-draft ()
2821 (when gnus-use-draft
2823 ;; Make sure the draft group exists.
2824 (gnus-make-draft-group)
2825 ;; Associate the buffer with the draft group.
2826 (let ((article (gnus-request-associate-buffer (gnus-draft-group))))
2827 ;; Arrange for deletion of the draft after successful sending.
2828 (make-local-variable 'gnus-message-sent-hook)
2829 (setq gnus-message-sent-hook
2832 (let ((gnus-verbose-backends nil))
2833 (gnus-request-expire-articles
2834 (quote ,(list article))
2835 ,(gnus-draft-group) t)))))))))
2837 (defun gnus-dissociate-buffer-from-draft ()
2838 "Disable auto-saving and association to the draft group of the current buffer."
2840 (run-hooks 'gnus-message-sent-hook)
2841 (setq buffer-file-name nil)
2842 (setq buffer-auto-save-file-name nil))
2844 (defun gnus-summary-send-draft ()
2845 "Enter a mail/post buffer to edit and send the draft."
2847 (gnus-set-global-variables)
2848 (unless (equal gnus-newsgroup-name (gnus-draft-group))
2849 (error "This function can only be used in the draft buffer"))
2851 (if (not (setq buf (gnus-request-restore-buffer
2852 (gnus-summary-article-number) gnus-newsgroup-name)))
2853 (error "Couldn't restore the article")
2854 (setq point (point))
2855 (switch-to-buffer buf)
2856 (gnus-inews-modify-mail-mode-map)
2857 (when (eq major-mode 'news-reply-mode)
2858 (local-set-key "\C-c\C-c" 'gnus-inews-news))
2859 (gnus-enter-buffer-into-draft)
2860 ;; Insert the separator.
2861 (goto-char (point-min))
2862 (search-forward "\n\n")
2864 (insert mail-header-separator)
2865 ;; Configure windows.
2866 (let ((gnus-draft-buffer (current-buffer)))
2867 (gnus-configure-windows 'draft)
2868 (goto-char (point))))))
2870 (defun gnus-configure-posting-styles ()
2871 "Configure posting styles according to `gnus-posting-styles'."
2872 (let ((styles gnus-posting-styles)
2873 (gnus-newsgroup-name (or gnus-newsgroup-name ""))
2874 style match variable attribute value value-value)
2875 ;; Go through all styles and look for matches.
2877 (setq style (pop styles)
2879 (when (cond ((stringp match)
2880 ;; Regexp string match on the group name.
2881 (string-match match gnus-newsgroup-name))
2882 ((or (symbolp match)
2883 (gnus-functionp match))
2884 (cond ((gnus-functionp match)
2885 ;; Function to be called.
2888 ;; Variable to be checked.
2889 (symbol-value match))))
2891 ;; This is a form to be evaled.
2893 ;; We have a match, so we set the variables.
2895 (setq attribute (pop style)
2896 value (cdr attribute))
2897 ;; We find the variable that is to be modified.
2898 (if (and (not (stringp (car attribute)))
2899 (not (setq variable (cdr (assq (car attribute)
2900 gnus-posting-style-alist)))))
2901 (message "Couldn't find attribute %s" (car attribute))
2902 ;; We set the variable.
2904 (cond ((stringp value)
2906 ((or (symbolp value)
2907 (gnus-functionp value))
2908 (cond ((gnus-functionp value)
2911 (symbol-value value))))
2916 ;; This is an ordinary variable.
2917 (make-local-variable variable)
2918 (set variable value-value))
2919 ;; This is a header to be added to the headers when
2922 (make-local-variable gnus-required-headers)
2923 (make-local-variable gnus-required-mail-headers)
2924 (push (cons (car attribute) value-value)
2925 gnus-required-headers)
2926 (push (cons (car attribute) value-value)
2927 gnus-required-mail-headers)))))))))
2929 (defun gnus-inews-set-point ()
2930 "Move point to where the user probably wants to find it."
2931 (gnus-inews-narrow-to-headers)
2933 ((re-search-forward "^[^:]+:[ \t]*$" nil t)
2934 (search-backward ":" )
2938 (goto-char (point-max))
2941 (unless (looking-at "$")
2942 (forward-line 2)))))
2944 ;;; Allow redefinition of functions.
2950 ;;; gnus-msg.el ends here