Mercurial > emacs
annotate lisp/mail/rnewspost.el @ 12855:2481803f0338
(vip-set-hooks): Use view-mode-hook, not view-hook.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Mon, 14 Aug 1995 21:56:42 +0000 |
parents | 4b5452f8ad12 |
children | 187735b53d52 |
rev | line source |
---|---|
658
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
35
diff
changeset
|
1 ;;; rnewspost.el --- USENET news poster/mailer for GNU Emacs |
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
35
diff
changeset
|
2 |
11235 | 3 ;; Copyright (C) 1985, 1986, 1987, 1995 Free Software Foundation, Inc. |
846
20674ae6bf52
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
814
diff
changeset
|
4 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
658
diff
changeset
|
5 ;; Maintainer: FSF |
814
38b2499cb3e9
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
807
diff
changeset
|
6 ;; Keywords: mail, news |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
658
diff
changeset
|
7 |
35 | 8 ;; This file is part of GNU Emacs. |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
658
diff
changeset
|
12 ;; the Free Software Foundation; either version 2, or (at your option) |
35 | 13 ;; any later version. |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
23 | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
658
diff
changeset
|
24 ;; Change Log: |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
658
diff
changeset
|
25 |
35 | 26 ;; moved posting and mail code from rnews.el |
27 ;; tower@prep.ai.mit.edu Wed Oct 29 1986 | |
28 ;; brought posting code almost up to the revision of RFC 850 for News 2.11 | |
29 ;; - couldn't see handling the special meaning of the Keyword: poster | |
30 ;; - not worth the code space to support the old A news Title: (which | |
31 ;; Subject: replaced) and Article-I.D.: (which Message-ID: replaced) | |
32 ;; tower@prep Nov 86 | |
33 ;; changed C-c C-r key-binding due to rename of news-caesar-buffer-body | |
34 ;; tower@prep 21 Nov 86 | |
35 ;; added (require 'rnews) tower@prep 22 Apr 87 | |
36 ;; restricted call of news-show-all-headers in news-post-news & news-reply | |
37 ;; tower@prep 28 Apr 87 | |
38 ;; commented out Posting-Front-End to save USENET bytes tower@prep Jul 31 87 | |
39 ;; commented out -n and -t args in news-inews tower@prep 15 Oct 87 | |
40 | |
41 ;Now in paths.el. | |
42 ;(defvar news-inews-program "inews" | |
43 ; "Function to post news.") | |
44 | |
45 ;; Replying and posting news items are done by these functions. | |
46 ;; imported from rmail and modified to work with rnews ... | |
47 ;; Mon Mar 25,1985 at 03:07:04 ads@mit-hermes. | |
48 ;; this is done so that rnews can operate independently from rmail.el and | |
49 ;; sendmail and dosen't have to autoload these functions. | |
50 ;; | |
51 ;;; >> Nuked by Mly to autoload those functions again, as the duplication of | |
52 ;;; >> code was making maintenance too difficult. | |
53 | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
658
diff
changeset
|
54 ;;; Code: |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
658
diff
changeset
|
55 |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
658
diff
changeset
|
56 (require 'sendmail) |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
658
diff
changeset
|
57 (require 'rnews) |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
658
diff
changeset
|
58 |
35 | 59 (defvar news-reply-mode-map () "Mode map used by news-reply.") |
60 | |
61 (or news-reply-mode-map | |
62 (progn | |
63 (setq news-reply-mode-map (make-keymap)) | |
64 (define-key news-reply-mode-map "\C-c\C-f\C-d" 'news-reply-distribution) | |
65 (define-key news-reply-mode-map "\C-c\C-f\C-k" 'news-reply-keywords) | |
66 (define-key news-reply-mode-map "\C-c\C-f\C-n" 'news-reply-newsgroups) | |
67 (define-key news-reply-mode-map "\C-c\C-f\C-f" 'news-reply-followup-to) | |
68 (define-key news-reply-mode-map "\C-c\C-f\C-s" 'mail-subject) | |
69 (define-key news-reply-mode-map "\C-c\C-f\C-a" 'news-reply-summary) | |
9534
323dc8f5028a
(news-reply-mode-map): Add C-c C-t binding.
Richard M. Stallman <rms@gnu.org>
parents:
1033
diff
changeset
|
70 (define-key news-reply-mode-map "\C-c\C-t" 'mail-text) |
35 | 71 (define-key news-reply-mode-map "\C-c\C-r" 'news-caesar-buffer-body) |
72 (define-key news-reply-mode-map "\C-c\C-w" 'news-reply-signature) | |
73 (define-key news-reply-mode-map "\C-c\C-y" 'news-reply-yank-original) | |
74 (define-key news-reply-mode-map "\C-c\C-q" 'mail-fill-yanked-message) | |
75 (define-key news-reply-mode-map "\C-c\C-c" 'news-inews) | |
10972
ffdc2e03b480
(news-reply-mode-map): Add menu bar menus.
Richard M. Stallman <rms@gnu.org>
parents:
10891
diff
changeset
|
76 (define-key news-reply-mode-map "\C-c\C-s" 'news-inews) |
ffdc2e03b480
(news-reply-mode-map): Add menu bar menus.
Richard M. Stallman <rms@gnu.org>
parents:
10891
diff
changeset
|
77 (define-key news-reply-mode-map [menu-bar] (make-sparse-keymap)) |
ffdc2e03b480
(news-reply-mode-map): Add menu bar menus.
Richard M. Stallman <rms@gnu.org>
parents:
10891
diff
changeset
|
78 (define-key news-reply-mode-map [menu-bar fields] |
ffdc2e03b480
(news-reply-mode-map): Add menu bar menus.
Richard M. Stallman <rms@gnu.org>
parents:
10891
diff
changeset
|
79 (cons "Fields" (make-sparse-keymap "Fields"))) |
ffdc2e03b480
(news-reply-mode-map): Add menu bar menus.
Richard M. Stallman <rms@gnu.org>
parents:
10891
diff
changeset
|
80 (define-key news-reply-mode-map [menu-bar fields news-reply-distribution] |
ffdc2e03b480
(news-reply-mode-map): Add menu bar menus.
Richard M. Stallman <rms@gnu.org>
parents:
10891
diff
changeset
|
81 '("Distribution" . news-reply-distribution)) |
ffdc2e03b480
(news-reply-mode-map): Add menu bar menus.
Richard M. Stallman <rms@gnu.org>
parents:
10891
diff
changeset
|
82 (define-key news-reply-mode-map [menu-bar fields news-reply-keywords] |
ffdc2e03b480
(news-reply-mode-map): Add menu bar menus.
Richard M. Stallman <rms@gnu.org>
parents:
10891
diff
changeset
|
83 '("Keywords" . news-reply-keywords)) |
ffdc2e03b480
(news-reply-mode-map): Add menu bar menus.
Richard M. Stallman <rms@gnu.org>
parents:
10891
diff
changeset
|
84 (define-key news-reply-mode-map [menu-bar fields news-reply-newsgroups] |
ffdc2e03b480
(news-reply-mode-map): Add menu bar menus.
Richard M. Stallman <rms@gnu.org>
parents:
10891
diff
changeset
|
85 '("Newsgroups" . news-reply-newsgroups)) |
ffdc2e03b480
(news-reply-mode-map): Add menu bar menus.
Richard M. Stallman <rms@gnu.org>
parents:
10891
diff
changeset
|
86 (define-key news-reply-mode-map [menu-bar fields news-reply-followup-to] |
ffdc2e03b480
(news-reply-mode-map): Add menu bar menus.
Richard M. Stallman <rms@gnu.org>
parents:
10891
diff
changeset
|
87 '("Followup-to" . news-reply-followup-to)) |
ffdc2e03b480
(news-reply-mode-map): Add menu bar menus.
Richard M. Stallman <rms@gnu.org>
parents:
10891
diff
changeset
|
88 (define-key news-reply-mode-map [menu-bar fields mail-subject] |
ffdc2e03b480
(news-reply-mode-map): Add menu bar menus.
Richard M. Stallman <rms@gnu.org>
parents:
10891
diff
changeset
|
89 '("Subject" . mail-subject)) |
ffdc2e03b480
(news-reply-mode-map): Add menu bar menus.
Richard M. Stallman <rms@gnu.org>
parents:
10891
diff
changeset
|
90 (define-key news-reply-mode-map [menu-bar fields news-reply-summary] |
ffdc2e03b480
(news-reply-mode-map): Add menu bar menus.
Richard M. Stallman <rms@gnu.org>
parents:
10891
diff
changeset
|
91 '("Summary" . news-reply-summary)) |
ffdc2e03b480
(news-reply-mode-map): Add menu bar menus.
Richard M. Stallman <rms@gnu.org>
parents:
10891
diff
changeset
|
92 (define-key news-reply-mode-map [menu-bar fields mail-text] |
ffdc2e03b480
(news-reply-mode-map): Add menu bar menus.
Richard M. Stallman <rms@gnu.org>
parents:
10891
diff
changeset
|
93 '("Text" . mail-text)) |
ffdc2e03b480
(news-reply-mode-map): Add menu bar menus.
Richard M. Stallman <rms@gnu.org>
parents:
10891
diff
changeset
|
94 (define-key news-reply-mode-map [menu-bar news] |
ffdc2e03b480
(news-reply-mode-map): Add menu bar menus.
Richard M. Stallman <rms@gnu.org>
parents:
10891
diff
changeset
|
95 (cons "News" (make-sparse-keymap "News"))) |
ffdc2e03b480
(news-reply-mode-map): Add menu bar menus.
Richard M. Stallman <rms@gnu.org>
parents:
10891
diff
changeset
|
96 (define-key news-reply-mode-map [menu-bar news news-caesar-buffer-body] |
ffdc2e03b480
(news-reply-mode-map): Add menu bar menus.
Richard M. Stallman <rms@gnu.org>
parents:
10891
diff
changeset
|
97 '("Rot13" . news-caesar-buffer-body)) |
ffdc2e03b480
(news-reply-mode-map): Add menu bar menus.
Richard M. Stallman <rms@gnu.org>
parents:
10891
diff
changeset
|
98 (define-key news-reply-mode-map [menu-bar news news-reply-signature] |
ffdc2e03b480
(news-reply-mode-map): Add menu bar menus.
Richard M. Stallman <rms@gnu.org>
parents:
10891
diff
changeset
|
99 '("Signature" . news-reply-signature)) |
ffdc2e03b480
(news-reply-mode-map): Add menu bar menus.
Richard M. Stallman <rms@gnu.org>
parents:
10891
diff
changeset
|
100 (define-key news-reply-mode-map [menu-bar news news-reply-yank-original] |
ffdc2e03b480
(news-reply-mode-map): Add menu bar menus.
Richard M. Stallman <rms@gnu.org>
parents:
10891
diff
changeset
|
101 '("Yank Original" . news-reply-yank-original)) |
ffdc2e03b480
(news-reply-mode-map): Add menu bar menus.
Richard M. Stallman <rms@gnu.org>
parents:
10891
diff
changeset
|
102 (define-key news-reply-mode-map [menu-bar news mail-fill-yanked-message] |
ffdc2e03b480
(news-reply-mode-map): Add menu bar menus.
Richard M. Stallman <rms@gnu.org>
parents:
10891
diff
changeset
|
103 '("Fill Yanked Messages" . mail-fill-yanked-message)) |
ffdc2e03b480
(news-reply-mode-map): Add menu bar menus.
Richard M. Stallman <rms@gnu.org>
parents:
10891
diff
changeset
|
104 (define-key news-reply-mode-map [menu-bar news news-inews] |
ffdc2e03b480
(news-reply-mode-map): Add menu bar menus.
Richard M. Stallman <rms@gnu.org>
parents:
10891
diff
changeset
|
105 '("Send" . news-inews)))) |
35 | 106 |
107 (defun news-reply-mode () | |
108 "Major mode for editing news to be posted on USENET. | |
109 First-time posters are asked to please read the articles in newsgroup: | |
110 news.announce.newusers . | |
111 Like Text Mode but with these additional commands: | |
112 | |
113 C-c C-s news-inews (post the message) C-c C-c news-inews | |
114 C-c C-f move to a header field (and create it if there isn't): | |
115 C-c C-f C-n move to Newsgroups: C-c C-f C-s move to Subj: | |
116 C-c C-f C-f move to Followup-To: C-c C-f C-k move to Keywords: | |
117 C-c C-f C-d move to Distribution: C-c C-f C-a move to Summary: | |
118 C-c C-y news-reply-yank-original (insert current message, in NEWS). | |
119 C-c C-q mail-fill-yanked-message (fill what was yanked). | |
120 C-c C-r caesar rotate all letters by 13 places in the article's body (rot13)." | |
121 (interactive) | |
122 ;; require... | |
123 (or (fboundp 'mail-setup) (load "sendmail")) | |
124 (kill-all-local-variables) | |
125 (make-local-variable 'mail-reply-buffer) | |
126 (setq mail-reply-buffer nil) | |
127 (set-syntax-table text-mode-syntax-table) | |
128 (use-local-map news-reply-mode-map) | |
129 (setq local-abbrev-table text-mode-abbrev-table) | |
130 (setq major-mode 'news-reply-mode) | |
10587
99b9f20b6921
(news-reply-mode): Change mode-name to News Reply.
Richard M. Stallman <rms@gnu.org>
parents:
10184
diff
changeset
|
131 (setq mode-name "News Reply") |
35 | 132 (make-local-variable 'paragraph-separate) |
133 (make-local-variable 'paragraph-start) | |
11769
4b5452f8ad12
(news-reply-mode): Add ^ to paragraph delimiters.
Richard M. Stallman <rms@gnu.org>
parents:
11762
diff
changeset
|
134 (setq paragraph-start |
4b5452f8ad12
(news-reply-mode): Add ^ to paragraph delimiters.
Richard M. Stallman <rms@gnu.org>
parents:
11762
diff
changeset
|
135 (concat "^" (regexp-quote mail-header-separator) "$\\|" |
4b5452f8ad12
(news-reply-mode): Add ^ to paragraph delimiters.
Richard M. Stallman <rms@gnu.org>
parents:
11762
diff
changeset
|
136 paragraph-start)) |
4b5452f8ad12
(news-reply-mode): Add ^ to paragraph delimiters.
Richard M. Stallman <rms@gnu.org>
parents:
11762
diff
changeset
|
137 (setq paragraph-separate |
4b5452f8ad12
(news-reply-mode): Add ^ to paragraph delimiters.
Richard M. Stallman <rms@gnu.org>
parents:
11762
diff
changeset
|
138 (concat "^" (regexp-quote mail-header-separator) "$\\|" |
4b5452f8ad12
(news-reply-mode): Add ^ to paragraph delimiters.
Richard M. Stallman <rms@gnu.org>
parents:
11762
diff
changeset
|
139 paragraph-separate)) |
35 | 140 (run-hooks 'text-mode-hook 'news-reply-mode-hook)) |
141 | |
142 (defvar news-reply-yank-from | |
10804 | 143 "Save `From:' field for `news-reply-yank-original'." |
35 | 144 "") |
145 | |
146 (defvar news-reply-yank-message-id | |
10804 | 147 "Save `Message-Id:' field for `news-reply-yank-original'." |
35 | 148 "") |
149 | |
150 (defun news-reply-yank-original (arg) | |
10804 | 151 "Insert the message being replied to, if any (in Mail mode). |
35 | 152 Puts point before the text and mark after. |
153 Indents each nonblank line ARG spaces (default 3). | |
154 Just \\[universal-argument] as argument means don't indent | |
155 and don't delete any header fields." | |
156 (interactive "P") | |
157 (mail-yank-original arg) | |
158 (exchange-point-and-mark) | |
159 (run-hooks 'news-reply-header-hook)) | |
160 | |
161 (defvar news-reply-header-hook | |
162 '(lambda () | |
163 (insert "In article " news-reply-yank-message-id | |
164 " " news-reply-yank-from " writes:\n\n")) | |
165 "Hook for inserting a header at the top of a yanked message.") | |
166 | |
167 (defun news-reply-newsgroups () | |
10804 | 168 "Move point to end of `Newsgroups:' field. |
169 RFC 850 constrains the `Newsgroups:' field to be a comma-separated list | |
170 of valid newsgroup names at your site. For example, | |
171 Newsgroups: news.misc,comp.misc,rec.misc" | |
35 | 172 (interactive) |
173 (expand-abbrev) | |
174 (goto-char (point-min)) | |
175 (mail-position-on-field "Newsgroups")) | |
176 | |
177 (defun news-reply-followup-to () | |
10804 | 178 "Move point to end of `Followup-To:' field. Create the field if none. |
35 | 179 One usually requests followups to only one newsgroup. |
10804 | 180 RFC 850 constrains the `Followup-To:' field to be a comma-separated list |
181 of valid newsgroups names at your site, and it must be a subset of the | |
182 `Newsgroups:' field. For example: | |
183 Newsgroups: news.misc,comp.misc,rec.misc,misc.misc,soc.misc | |
184 Followup-To: news.misc,comp.misc,rec.misc" | |
35 | 185 (interactive) |
186 (expand-abbrev) | |
187 (or (mail-position-on-field "Followup-To" t) | |
188 (progn (mail-position-on-field "newsgroups") | |
189 (insert "\nFollowup-To: "))) | |
190 ;; @@ could do a completing read based on the Newsgroups: field to | |
191 ;; @@ fill in the Followup-To: field | |
192 ) | |
193 | |
194 (defun news-reply-distribution () | |
10804 | 195 "Move point to end of `Distribution:' optional field. |
35 | 196 Create the field if none. Without this field the posting goes to all of |
197 USENET. The field is used to restrict the posting to parts of USENET." | |
198 (interactive) | |
199 (expand-abbrev) | |
200 (mail-position-on-field "Distribution") | |
201 ;; @@could do a completing read based on the news library file: | |
202 ;; @@ ../distributions to fill in the field. | |
203 ) | |
204 | |
205 (defun news-reply-keywords () | |
10804 | 206 "Move point to end of `Keywords:' optional field. Create the field if none. |
35 | 207 Used as an aid to the news reader, it can contain a few, well selected keywords |
208 identifying the message." | |
209 (interactive) | |
210 (expand-abbrev) | |
211 (mail-position-on-field "Keywords")) | |
212 | |
213 (defun news-reply-summary () | |
10804 | 214 "Move point to end of `Summary:' optional field. Create the field if none. |
35 | 215 Used as an aid to the news reader, it can contain a succinct |
216 summary (abstract) of the message." | |
217 (interactive) | |
218 (expand-abbrev) | |
219 (mail-position-on-field "Summary")) | |
220 | |
221 (defun news-reply-signature () | |
11762
329197fc1477
(news-setup): Bind mail-signature to nil.
Richard M. Stallman <rms@gnu.org>
parents:
11644
diff
changeset
|
222 "The inews program appends `~/.signature' automatically." |
35 | 223 (interactive) |
11762
329197fc1477
(news-setup): Bind mail-signature to nil.
Richard M. Stallman <rms@gnu.org>
parents:
11644
diff
changeset
|
224 (message "`~/.signature' will be appended automatically.")) |
35 | 225 |
226 (defun news-setup (to subject in-reply-to newsgroups replybuffer) | |
10804 | 227 "Set up the news reply or posting buffer with the proper headers and mode." |
35 | 228 (setq mail-reply-buffer replybuffer) |
11762
329197fc1477
(news-setup): Bind mail-signature to nil.
Richard M. Stallman <rms@gnu.org>
parents:
11644
diff
changeset
|
229 (let ((mail-setup-hook nil) |
329197fc1477
(news-setup): Bind mail-signature to nil.
Richard M. Stallman <rms@gnu.org>
parents:
11644
diff
changeset
|
230 ;; Avoid inserting a signature. |
329197fc1477
(news-setup): Bind mail-signature to nil.
Richard M. Stallman <rms@gnu.org>
parents:
11644
diff
changeset
|
231 (mail-signature)) |
35 | 232 (if (null to) |
233 ;; this hack is needed so that inews wont be confused by | |
234 ;; the fcc: and bcc: fields | |
235 (let ((mail-self-blind nil) | |
236 (mail-archive-file-name nil)) | |
237 (mail-setup to subject in-reply-to nil replybuffer nil) | |
238 (beginning-of-line) | |
1033 | 239 (delete-region (point) (progn (forward-line 1) (point))) |
35 | 240 (goto-char (point-max))) |
241 (mail-setup to subject in-reply-to nil replybuffer nil)) | |
242 ;;;(mail-position-on-field "Posting-Front-End") | |
243 ;;;(insert (emacs-version)) | |
244 (goto-char (point-max)) | |
245 (if (let ((case-fold-search t)) | |
246 (re-search-backward "^Subject:" (point-min) t)) | |
247 (progn (beginning-of-line) | |
248 (insert "Newsgroups: " (or newsgroups "") "\n") | |
249 (if (not newsgroups) | |
250 (backward-char 1) | |
251 (goto-char (point-max))))) | |
252 (run-hooks 'news-setup-hook))) | |
253 | |
254 (defun news-inews () | |
255 "Send a news message using inews." | |
256 (interactive) | |
257 (let* (newsgroups subject | |
258 (case-fold-search nil)) | |
259 (save-excursion | |
260 (save-restriction | |
261 (goto-char (point-min)) | |
262 (search-forward (concat "\n" mail-header-separator "\n")) | |
263 (narrow-to-region (point-min) (point)) | |
264 (setq newsgroups (mail-fetch-field "newsgroups") | |
265 subject (mail-fetch-field "subject"))) | |
266 (widen) | |
267 (goto-char (point-min)) | |
268 (run-hooks 'news-inews-hook) | |
269 (goto-char (point-min)) | |
270 (search-forward (concat "\n" mail-header-separator "\n")) | |
271 (replace-match "\n\n") | |
272 (goto-char (point-max)) | |
273 ;; require a newline at the end for inews to append .signature to | |
274 (or (= (preceding-char) ?\n) | |
275 (insert ?\n)) | |
276 (message "Posting to USENET...") | |
277 (call-process-region (point-min) (point-max) | |
278 news-inews-program nil 0 nil | |
279 "-h") ; take all header lines! | |
280 ;@@ setting of subject and newsgroups still needed? | |
281 ;"-t" subject | |
282 ;"-n" newsgroups | |
283 (message "Posting to USENET... done") | |
284 (goto-char (point-min)) ;restore internal header separator | |
285 (search-forward "\n\n") | |
286 (replace-match (concat "\n" mail-header-separator "\n")) | |
287 (set-buffer-modified-p nil)) | |
288 (and (fboundp 'bury-buffer) (bury-buffer)))) | |
289 | |
290 ;@@ shares some code with news-reply and news-post-news | |
291 (defun news-mail-reply () | |
292 "Mail a reply to the author of the current article. | |
293 While composing the reply, use \\[news-reply-yank-original] to yank the | |
294 original message into it." | |
295 (interactive) | |
296 (let (from cc subject date to reply-to | |
297 (buffer (current-buffer))) | |
298 (save-restriction | |
299 (narrow-to-region (point-min) (progn (goto-line (point-min)) | |
300 (search-forward "\n\n") | |
301 (- (point) 1))) | |
302 (setq from (mail-fetch-field "from") | |
303 subject (mail-fetch-field "subject") | |
304 reply-to (mail-fetch-field "reply-to") | |
10184
4fe4f49bcdb1
(news-mail-reply): Restore the saved narrowing before calling `mail'.
Richard M. Stallman <rms@gnu.org>
parents:
9534
diff
changeset
|
305 date (mail-fetch-field "date"))) |
4fe4f49bcdb1
(news-mail-reply): Restore the saved narrowing before calling `mail'.
Richard M. Stallman <rms@gnu.org>
parents:
9534
diff
changeset
|
306 (setq to from) |
4fe4f49bcdb1
(news-mail-reply): Restore the saved narrowing before calling `mail'.
Richard M. Stallman <rms@gnu.org>
parents:
9534
diff
changeset
|
307 (pop-to-buffer "*mail*") |
4fe4f49bcdb1
(news-mail-reply): Restore the saved narrowing before calling `mail'.
Richard M. Stallman <rms@gnu.org>
parents:
9534
diff
changeset
|
308 (mail nil |
4fe4f49bcdb1
(news-mail-reply): Restore the saved narrowing before calling `mail'.
Richard M. Stallman <rms@gnu.org>
parents:
9534
diff
changeset
|
309 (if reply-to reply-to to) |
4fe4f49bcdb1
(news-mail-reply): Restore the saved narrowing before calling `mail'.
Richard M. Stallman <rms@gnu.org>
parents:
9534
diff
changeset
|
310 subject |
4fe4f49bcdb1
(news-mail-reply): Restore the saved narrowing before calling `mail'.
Richard M. Stallman <rms@gnu.org>
parents:
9534
diff
changeset
|
311 (let ((stop-pos (string-match " *at \\| *@ \\| *(\\| *<" from))) |
4fe4f49bcdb1
(news-mail-reply): Restore the saved narrowing before calling `mail'.
Richard M. Stallman <rms@gnu.org>
parents:
9534
diff
changeset
|
312 (concat (if stop-pos (substring from 0 stop-pos) from) |
4fe4f49bcdb1
(news-mail-reply): Restore the saved narrowing before calling `mail'.
Richard M. Stallman <rms@gnu.org>
parents:
9534
diff
changeset
|
313 "'s message of " |
4fe4f49bcdb1
(news-mail-reply): Restore the saved narrowing before calling `mail'.
Richard M. Stallman <rms@gnu.org>
parents:
9534
diff
changeset
|
314 date)) |
4fe4f49bcdb1
(news-mail-reply): Restore the saved narrowing before calling `mail'.
Richard M. Stallman <rms@gnu.org>
parents:
9534
diff
changeset
|
315 nil |
4fe4f49bcdb1
(news-mail-reply): Restore the saved narrowing before calling `mail'.
Richard M. Stallman <rms@gnu.org>
parents:
9534
diff
changeset
|
316 buffer))) |
35 | 317 |
318 ;@@ the guts of news-reply and news-post-news should be combined. -tower | |
319 (defun news-reply () | |
320 "Compose and post a reply (aka a followup) to the current article on USENET. | |
321 While composing the followup, use \\[news-reply-yank-original] to yank the | |
322 original message into it." | |
323 (interactive) | |
324 (if (y-or-n-p "Are you sure you want to followup to all of USENET? ") | |
325 (let (from cc subject date to followup-to newsgroups message-of | |
326 references distribution message-id | |
327 (buffer (current-buffer))) | |
328 (save-restriction | |
329 (and (not (= 0 (buffer-size))) ;@@real problem is non-existence of | |
330 ;@@ of article file | |
331 (equal major-mode 'news-mode) ;@@ if rmail-mode, | |
332 ;@@ should show full headers | |
333 (progn | |
334 (news-show-all-headers) ;@@ should save/restore header state, | |
335 ;@@ but rnews.el lacks support | |
336 (narrow-to-region (point-min) (progn (goto-char (point-min)) | |
337 (search-forward "\n\n") | |
338 (- (point) 1))))) | |
339 (setq from (mail-fetch-field "from") | |
340 news-reply-yank-from from | |
341 ;; @@ not handling old Title: field | |
342 subject (mail-fetch-field "subject") | |
343 date (mail-fetch-field "date") | |
344 followup-to (mail-fetch-field "followup-to") | |
345 newsgroups (or followup-to | |
346 (mail-fetch-field "newsgroups")) | |
347 references (mail-fetch-field "references") | |
348 ;; @@ not handling old Article-I.D.: field | |
349 distribution (mail-fetch-field "distribution") | |
350 message-id (mail-fetch-field "message-id") | |
351 news-reply-yank-message-id message-id) | |
352 (pop-to-buffer "*post-news*") | |
353 (news-reply-mode) | |
354 (if (and (buffer-modified-p) | |
355 (not | |
356 (y-or-n-p "Unsent article being composed; erase it? "))) | |
357 () | |
358 (progn | |
359 (erase-buffer) | |
360 (and subject | |
361 (progn (if (string-match "\\`Re: " subject) | |
362 (while (string-match "\\`Re: " subject) | |
363 (setq subject (substring subject 4)))) | |
364 (setq subject (concat "Re: " subject)))) | |
365 (and from | |
366 (progn | |
367 (let ((stop-pos | |
368 (string-match " *at \\| *@ \\| *(\\| *<" from))) | |
369 (setq message-of | |
370 (concat | |
371 (if stop-pos (substring from 0 stop-pos) from) | |
372 "'s message of " | |
373 date))))) | |
374 (news-setup | |
375 nil | |
376 subject | |
377 message-of | |
378 newsgroups | |
379 buffer) | |
380 (if followup-to | |
381 (progn (news-reply-followup-to) | |
382 (insert followup-to))) | |
383 (if distribution | |
384 (progn | |
385 (mail-position-on-field "Distribution") | |
386 (insert distribution))) | |
387 (mail-position-on-field "References") | |
388 (if references | |
389 (insert references)) | |
390 (if (and references message-id) | |
391 (insert " ")) | |
392 (if message-id | |
393 (insert message-id)) | |
394 (goto-char (point-max)))))) | |
395 (message ""))) | |
396 | |
397 ;@@ the guts of news-reply and news-post-news should be combined. -tower | |
10804 | 398 ;;;###autoload |
35 | 399 (defun news-post-news () |
400 "Begin editing a new USENET news article to be posted. | |
401 Type \\[describe-mode] once editing the article to get a list of commands." | |
402 (interactive) | |
403 (if (y-or-n-p "Are you sure you want to post to all of USENET? ") | |
404 (let ((buffer (current-buffer))) | |
405 (save-restriction | |
406 (and (not (= 0 (buffer-size))) ;@@real problem is non-existence of | |
407 ;@@ of article file | |
408 (equal major-mode 'news-mode) ;@@ if rmail-mode, | |
409 ;@@ should show full headers | |
410 (progn | |
411 (news-show-all-headers) ;@@ should save/restore header state, | |
412 ;@@ but rnews.el lacks support | |
413 (narrow-to-region (point-min) (progn (goto-char (point-min)) | |
414 (search-forward "\n\n") | |
415 (- (point) 1))))) | |
416 (setq news-reply-yank-from (mail-fetch-field "from") | |
417 ;; @@ not handling old Article-I.D.: field | |
418 news-reply-yank-message-id (mail-fetch-field "message-id"))) | |
419 (pop-to-buffer "*post-news*") | |
420 (news-reply-mode) | |
421 (if (and (buffer-modified-p) | |
422 (not (y-or-n-p "Unsent article being composed; erase it? "))) | |
423 () ;@@ not saving point from last time | |
424 (progn (erase-buffer) | |
425 (news-setup () () () () buffer)))) | |
426 (message ""))) | |
427 | |
428 (defun news-mail-other-window () | |
429 "Send mail in another window. | |
430 While composing the message, use \\[news-reply-yank-original] to yank the | |
431 original message into it." | |
432 (interactive) | |
433 (mail-other-window nil nil nil nil nil (current-buffer))) | |
658
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
35
diff
changeset
|
434 |
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
35
diff
changeset
|
435 ;;; rnewspost.el ends here |