Mercurial > emacs
annotate lisp/gnus/nngateway.el @ 27024:3b652889d81a
*** empty log message ***
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Tue, 28 Dec 1999 18:14:44 +0000 |
parents | 15fc6acbae7a |
children | 9968f55ad26e |
rev | line source |
---|---|
17493 | 1 ;;; nngateway.el --- posting news via mail gateways |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23712
diff
changeset
|
2 ;; Copyright (C) 1996,97,98 Free Software Foundation, Inc. |
17493 | 3 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23712
diff
changeset
|
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> |
17493 | 5 ;; Keywords: news, mail |
6 | |
7 ;; This file is part of GNU Emacs. | |
8 | |
9 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
10 ;; it under the terms of the GNU General Public License as published by | |
11 ;; the Free Software Foundation; either version 2, or (at your option) | |
12 ;; any later version. | |
13 | |
14 ;; GNU Emacs is distributed in the hope that it will be useful, | |
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 ;; GNU General Public License for more details. | |
18 | |
19 ;; You should have received a copy of the GNU General Public License | |
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
22 ;; Boston, MA 02111-1307, USA. | |
23 | |
24 ;;; Commentary: | |
25 | |
26 ;;; Code: | |
27 | |
23712 | 28 (eval-when-compile (require 'cl)) |
17493 | 29 (require 'nnoo) |
30 (require 'message) | |
31 | |
32 (nnoo-declare nngateway) | |
33 | |
34 (defvoo nngateway-address nil | |
35 "Address of the mail-to-news gateway.") | |
36 | |
37 (defvoo nngateway-header-transformation 'nngateway-simple-header-transformation | |
38 "Function to be called to rewrite the news headers into mail headers. | |
39 It is called narrowed to the headers to be transformed with one | |
40 parameter -- the gateway address.") | |
41 | |
42 ;;; Interface functions | |
43 | |
44 (nnoo-define-basics nngateway) | |
45 | |
46 (deffoo nngateway-open-server (server &optional defs) | |
47 (if (nngateway-server-opened server) | |
48 t | |
49 (unless (assq 'nngateway-address defs) | |
50 (setq defs (append defs (list (list 'nngateway-address server))))) | |
51 (nnoo-change-server 'nngateway server defs))) | |
52 | |
53 (deffoo nngateway-request-post (&optional server) | |
54 (when (or (nngateway-server-opened server) | |
55 (nngateway-open-server server)) | |
56 ;; Rewrite the header. | |
57 (let ((buf (current-buffer))) | |
58 (nnheader-temp-write nil | |
59 (insert-buffer-substring buf) | |
60 (message-narrow-to-head) | |
61 (funcall nngateway-header-transformation nngateway-address) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
17493
diff
changeset
|
62 (goto-char (point-max)) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
17493
diff
changeset
|
63 (insert mail-header-separator "\n") |
17493 | 64 (widen) |
65 (let (message-required-mail-headers) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23712
diff
changeset
|
66 (funcall message-send-mail-function)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23712
diff
changeset
|
67 t)))) |
17493 | 68 |
69 ;;; Internal functions | |
70 | |
71 (defun nngateway-simple-header-transformation (gateway) | |
72 "Transform the headers to use GATEWAY." | |
73 (let ((newsgroups (mail-fetch-field "newsgroups"))) | |
74 (message-remove-header "to") | |
75 (message-remove-header "cc") | |
76 (goto-char (point-min)) | |
77 (insert "To: " (nnheader-replace-chars-in-string newsgroups ?. ?-) | |
78 "@" gateway "\n"))) | |
79 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23712
diff
changeset
|
80 (defun nngateway-mail2news-header-transformation (gateway) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23712
diff
changeset
|
81 "Transform the headers for sending to a mail2news gateway." |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23712
diff
changeset
|
82 (message-remove-header "to") |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23712
diff
changeset
|
83 (message-remove-header "cc") |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23712
diff
changeset
|
84 (goto-char (point-min)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23712
diff
changeset
|
85 (insert "To: " gateway "\n")) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23712
diff
changeset
|
86 |
17493 | 87 (nnoo-define-skeleton nngateway) |
88 | |
89 (provide 'nngateway) | |
90 | |
91 ;;; nngateway.el ends here |