Mercurial > emacs
annotate lisp/=gnuspost.el @ 5345:80332dac0573
Check for setsid.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 25 Dec 1993 01:43:19 +0000 |
parents | 666b3dcc9905 |
children | 1209d8bbffd3 |
rev | line source |
---|---|
660
08eb386dd0f3
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
1 ;;; gnuspost.el --- post news commands for GNUS newsreader |
08eb386dd0f3
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
2 |
2601
c6fef1c54d00
(gnus-inews-organization): If ORGANIZATION is "", set it to nil.
Roland McGrath <roland@gnu.org>
parents:
2571
diff
changeset
|
3 ;; Copyright (C) 1989, 1990, 1993 Free Software Foundation, Inc. |
846
20674ae6bf52
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
811
diff
changeset
|
4 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
711
diff
changeset
|
5 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet> |
5295
666b3dcc9905
(gnus-post-news): Call gnus-read-distributions-file.
Richard M. Stallman <rms@gnu.org>
parents:
5111
diff
changeset
|
6 ;; Version: $Header: /home/fsf/rms/e19/lisp/RCS/gnuspost.el,v 1.16 1993/11/22 06:44:12 rms Exp $ |
811
e694e0879463
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
807
diff
changeset
|
7 ;; Keywords: news |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
711
diff
changeset
|
8 |
267 | 9 ;; This file is part of GNU Emacs. |
10 | |
711
22b98190b7ef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
11 ;; GNU Emacs is free software; you can redistribute it and/or modify |
22b98190b7ef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
12 ;; 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:
711
diff
changeset
|
13 ;; the Free Software Foundation; either version 2, or (at your option) |
711
22b98190b7ef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
14 ;; any later version. |
267 | 15 |
711
22b98190b7ef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
16 ;; GNU Emacs is distributed in the hope that it will be useful, |
22b98190b7ef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
22b98190b7ef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22b98190b7ef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
19 ;; GNU General Public License for more details. |
22b98190b7ef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
20 |
22b98190b7ef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
21 ;; You should have received a copy of the GNU General Public License |
22b98190b7ef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
22 ;; along with GNU Emacs; see the file COPYING. If not, write to |
22b98190b7ef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
23 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
267 | 24 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
711
diff
changeset
|
25 ;;; Code: |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
711
diff
changeset
|
26 |
267 | 27 (require 'gnus) |
28 | |
29 (defvar gnus-organization-file "/usr/lib/news/organization" | |
30 "*Local news organization file.") | |
31 | |
32 (defvar gnus-post-news-buffer "*post-news*") | |
33 (defvar gnus-winconf-post-news nil) | |
34 | |
35 (autoload 'news-reply-mode "rnewspost") | |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
36 (autoload 'timezone-make-date-arpa-standard "timezone") |
267 | 37 |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
38 ;;; Post news commands of GNUS Group Mode and Summary Mode |
267 | 39 |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
40 (defun gnus-group-post-news () |
267 | 41 "Post an article." |
42 (interactive) | |
43 ;; Save window configuration. | |
44 (setq gnus-winconf-post-news (current-window-configuration)) | |
45 (unwind-protect | |
46 (gnus-post-news) | |
47 (or (and (eq (current-buffer) (get-buffer gnus-post-news-buffer)) | |
48 (not (zerop (buffer-size)))) | |
49 ;; Restore last window configuration. | |
50 (set-window-configuration gnus-winconf-post-news))) | |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
51 ;; We don't want to return to Summary buffer nor Article buffer later. |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
52 (if (get-buffer gnus-summary-buffer) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
53 (bury-buffer gnus-summary-buffer)) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
54 (if (get-buffer gnus-article-buffer) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
55 (bury-buffer gnus-article-buffer))) |
267 | 56 |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
57 (defun gnus-summary-post-news () |
267 | 58 "Post an article." |
59 (interactive) | |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
60 (gnus-summary-select-article t nil) |
267 | 61 ;; Save window configuration. |
62 (setq gnus-winconf-post-news (current-window-configuration)) | |
63 (unwind-protect | |
64 (progn | |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
65 (switch-to-buffer gnus-article-buffer) |
267 | 66 (widen) |
67 (delete-other-windows) | |
68 (gnus-post-news)) | |
69 (or (and (eq (current-buffer) (get-buffer gnus-post-news-buffer)) | |
70 (not (zerop (buffer-size)))) | |
71 ;; Restore last window configuration. | |
72 (set-window-configuration gnus-winconf-post-news))) | |
73 ;; We don't want to return to Article buffer later. | |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
74 (bury-buffer gnus-article-buffer)) |
267 | 75 |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
76 (defun gnus-summary-followup (yank) |
267 | 77 "Post a reply article. |
78 If prefix argument YANK is non-nil, original article is yanked automatically." | |
79 (interactive "P") | |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
80 (gnus-summary-select-article t nil) |
267 | 81 ;; Check Followup-To: poster. |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
82 (set-buffer gnus-article-buffer) |
267 | 83 (if (and gnus-use-followup-to |
84 (string-equal "poster" (gnus-fetch-field "followup-to")) | |
85 (or (not (eq gnus-use-followup-to t)) | |
86 (not (y-or-n-p "Do you want to ignore `Followup-To: poster'? ")))) | |
87 ;; Mail to the poster. GNUS is now RFC1036 compliant. | |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
88 (gnus-summary-reply yank) |
267 | 89 ;; Save window configuration. |
90 (setq gnus-winconf-post-news (current-window-configuration)) | |
91 (unwind-protect | |
92 (progn | |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
93 (switch-to-buffer gnus-article-buffer) |
267 | 94 (widen) |
95 (delete-other-windows) | |
96 (gnus-news-reply yank)) | |
97 (or (and (eq (current-buffer) (get-buffer gnus-post-news-buffer)) | |
98 (not (zerop (buffer-size)))) | |
99 ;; Restore last window configuration. | |
100 (set-window-configuration gnus-winconf-post-news))) | |
101 ;; We don't want to return to Article buffer later. | |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
102 (bury-buffer gnus-article-buffer))) |
267 | 103 |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
104 (defun gnus-summary-followup-with-original () |
267 | 105 "Post a reply article with original article." |
106 (interactive) | |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
107 (gnus-summary-followup t)) |
267 | 108 |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
109 (defun gnus-summary-cancel-article () |
267 | 110 "Cancel an article you posted." |
111 (interactive) | |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
112 (gnus-summary-select-article t nil) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
113 (gnus-eval-in-buffer-window gnus-article-buffer |
267 | 114 (gnus-cancel-news))) |
115 | |
116 | |
117 ;;; Post a News using NNTP | |
118 | |
119 ;;;###autoload | |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
120 (fset 'sendnews 'gnus-post-news) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
121 |
267 | 122 ;;;###autoload |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
123 (fset 'postnews 'gnus-post-news) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
124 |
267 | 125 ;;;###autoload |
126 (defun gnus-post-news () | |
127 "Begin editing a new USENET news article to be posted. | |
128 Type \\[describe-mode] once editing the article to get a list of commands." | |
129 (interactive) | |
130 (if (or (not gnus-novice-user) | |
131 (y-or-n-p "Are you sure you want to post to all of USENET? ")) | |
132 (let ((artbuf (current-buffer)) | |
133 (newsgroups ;Default newsgroup. | |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
134 (if (eq major-mode 'gnus-article-mode) gnus-newsgroup-name)) |
267 | 135 (subject nil) |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
136 ;; Get default distribution. |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
137 (distribution (car gnus-local-distributions))) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
138 ;; Connect to NNTP server if not connected yet, and get |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
139 ;; several information. |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
140 (if (not (gnus-server-opened)) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
141 (progn |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
142 (gnus-start-news-server t) ;Confirm server. |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
143 (gnus-setup-news))) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
144 ;; Get current article information. |
267 | 145 (save-restriction |
146 (and (not (zerop (buffer-size))) | |
147 ;;(equal major-mode 'news-mode) | |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
148 (equal major-mode 'gnus-article-mode) |
267 | 149 (progn |
150 ;;(news-show-all-headers) | |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
151 (gnus-article-show-all-headers) |
267 | 152 (narrow-to-region (point-min) |
153 (progn (goto-char (point-min)) | |
154 (search-forward "\n\n") | |
155 (point))))) | |
156 (setq news-reply-yank-from (mail-fetch-field "from")) | |
157 (setq news-reply-yank-message-id (mail-fetch-field "message-id"))) | |
158 (pop-to-buffer gnus-post-news-buffer) | |
159 (news-reply-mode) | |
160 (gnus-overload-functions) | |
161 (if (and (buffer-modified-p) | |
162 (> (buffer-size) 0) | |
163 (not (y-or-n-p "Unsent article being composed; erase it? "))) | |
164 ;; Continue composition. | |
165 ;; Make news-reply-yank-original work on the current article. | |
166 (setq mail-reply-buffer artbuf) | |
167 (erase-buffer) | |
168 (if gnus-interactive-post | |
169 ;; Newsgroups, subject and distribution are asked for. | |
170 ;; Suggested by yuki@flab.fujitsu.junet. | |
171 (progn | |
172 ;; Subscribed newsgroup names are required for | |
173 ;; completing read of newsgroup. | |
174 (or gnus-newsrc-assoc | |
175 (gnus-read-newsrc-file)) | |
176 ;; Which do you like? (UMERIN) | |
177 ;; (setq newsgroups (read-string "Newsgroups: " "general")) | |
178 (or newsgroups ;Use the default newsgroup. | |
179 (setq newsgroups | |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
180 (completing-read "Newsgroup: " |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
181 gnus-newsrc-assoc |
267 | 182 nil 'require-match |
183 newsgroups ;Default newsgroup. | |
184 ))) | |
185 (setq subject (read-string "Subject: ")) | |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
186 ;; Choose a distribution from gnus-distribution-list. |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
187 ;; completing-read should not be used with |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
188 ;; 'require-match functionality in order to allow use |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
189 ;; of unknow distribution. |
5295
666b3dcc9905
(gnus-post-news): Call gnus-read-distributions-file.
Richard M. Stallman <rms@gnu.org>
parents:
5111
diff
changeset
|
190 (gnus-read-distributions-file) |
267 | 191 (setq distribution |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
192 (if (consp gnus-distribution-list) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
193 (completing-read "Distribution: " |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
194 gnus-distribution-list |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
195 nil nil ;Never 'require-match |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
196 distribution ;Default distribution. |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
197 ) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
198 (read-string "Distribution: "))) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
199 ;; Empty string is okay. |
267 | 200 ;;(if (string-equal distribution "") |
201 ;; (setq distribution nil)) | |
202 )) | |
203 (news-setup () subject () newsgroups artbuf) | |
204 ;; Make sure the article is posted by GNUS. | |
205 ;;(mail-position-on-field "Posting-Software") | |
206 ;;(insert "GNUS: NNTP-based News Reader for GNU Emacs") | |
207 ;; Insert Distribution: field. | |
208 ;; Suggested by ichikawa@flab.fujitsu.junet. | |
209 (mail-position-on-field "Distribution") | |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
210 (insert (or distribution "")) |
267 | 211 ;; Handle author copy using FCC field. |
212 (if gnus-author-copy | |
213 (progn | |
214 (mail-position-on-field "FCC") | |
215 (insert gnus-author-copy))) | |
216 (if gnus-interactive-post | |
217 ;; All fields are filled in. | |
218 (goto-char (point-max)) | |
219 ;; Move point to Newsgroup: field. | |
220 (goto-char (point-min)) | |
221 (end-of-line)) | |
222 )) | |
223 (message ""))) | |
224 | |
225 (defun gnus-news-reply (&optional yank) | |
226 "Compose and post a reply (aka a followup) to the current article on USENET. | |
227 While composing the followup, use \\[news-reply-yank-original] to yank the | |
228 original message into it." | |
229 (interactive) | |
230 (if (or (not gnus-novice-user) | |
231 (y-or-n-p "Are you sure you want to followup to all of USENET? ")) | |
232 (let (from cc subject date to followup-to newsgroups message-of | |
233 references distribution message-id | |
234 (artbuf (current-buffer))) | |
235 (save-restriction | |
236 (and (not (zerop (buffer-size))) | |
237 ;;(equal major-mode 'news-mode) | |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
238 (equal major-mode 'gnus-article-mode) |
267 | 239 (progn |
240 ;; (news-show-all-headers) | |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
241 (gnus-article-show-all-headers) |
267 | 242 (narrow-to-region (point-min) |
243 (progn (goto-char (point-min)) | |
244 (search-forward "\n\n") | |
245 (point))))) | |
246 (setq from (mail-fetch-field "from")) | |
247 (setq news-reply-yank-from from) | |
248 (setq subject (mail-fetch-field "subject")) | |
249 (setq date (mail-fetch-field "date")) | |
250 (setq followup-to (mail-fetch-field "followup-to")) | |
251 ;; Ignore Followup-To: poster. | |
252 (if (or (null gnus-use-followup-to) ;Ignore followup-to: field. | |
253 (string-equal "" followup-to) ;Bogus header. | |
254 (string-equal "poster" followup-to)) | |
255 (setq followup-to nil)) | |
256 (setq newsgroups (or followup-to (mail-fetch-field "newsgroups"))) | |
257 (setq references (mail-fetch-field "references")) | |
258 (setq distribution (mail-fetch-field "distribution")) | |
259 (setq message-id (mail-fetch-field "message-id")) | |
260 (setq news-reply-yank-message-id message-id)) | |
261 (pop-to-buffer gnus-post-news-buffer) | |
262 (news-reply-mode) | |
263 (gnus-overload-functions) | |
264 (if (and (buffer-modified-p) | |
265 (> (buffer-size) 0) | |
266 (not (y-or-n-p "Unsent article being composed; erase it? "))) | |
267 ;; Continue composition. | |
268 ;; Make news-reply-yank-original work on current article. | |
269 (setq mail-reply-buffer artbuf) | |
270 (erase-buffer) | |
271 (and subject | |
272 (setq subject | |
273 (concat "Re: " (gnus-simplify-subject subject 're-only)))) | |
274 (and from | |
275 (progn | |
276 (let ((stop-pos | |
277 (string-match " *at \\| *@ \\| *(\\| *<" from))) | |
278 (setq message-of | |
279 (concat | |
280 (if stop-pos (substring from 0 stop-pos) from) | |
281 "'s message of " | |
282 date))))) | |
283 (news-setup nil subject message-of newsgroups artbuf) | |
284 (if followup-to | |
285 (progn (news-reply-followup-to) | |
286 (insert followup-to))) | |
287 ;; Fold long references line to follow RFC1036. | |
288 (mail-position-on-field "References") | |
289 (let ((begin (point)) | |
290 (fill-column 79) | |
291 (fill-prefix "\t")) | |
292 (if references | |
293 (insert references)) | |
294 (if (and references message-id) | |
295 (insert " ")) | |
296 (if message-id | |
297 (insert message-id)) | |
298 ;; The region must end with a newline to fill the region | |
299 ;; without inserting extra newline. | |
300 (fill-region-as-paragraph begin (1+ (point)))) | |
301 ;; Make sure the article is posted by GNUS. | |
302 ;;(mail-position-on-field "Posting-Software") | |
303 ;;(insert "GNUS: NNTP-based News Reader for GNU Emacs") | |
304 ;; Distribution must be the same as original article. | |
305 (mail-position-on-field "Distribution") | |
306 (insert (or distribution "")) | |
307 ;; Handle author copy using FCC field. | |
308 (if gnus-author-copy | |
309 (progn | |
310 (mail-position-on-field "FCC") | |
311 (insert gnus-author-copy))) | |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
312 ;; Insert To: FROM field, which is expected to mail the |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
313 ;; message to the author of the article too. |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
314 (if (and gnus-auto-mail-to-author from) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
315 (progn |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
316 (goto-char (point-min)) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
317 (insert "To: " from "\n"))) |
267 | 318 (goto-char (point-max))) |
319 ;; Yank original article automatically. | |
320 (if yank | |
321 (let ((last (point))) | |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
322 ;;(goto-char (point-max)) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
323 ;; Insert at current point. |
267 | 324 (news-reply-yank-original nil) |
325 (goto-char last))) | |
326 ) | |
327 (message ""))) | |
328 | |
329 (defun gnus-inews-news () | |
330 "Send a news message." | |
331 (interactive) | |
332 (let* ((case-fold-search nil) | |
333 (server-running (gnus-server-opened))) | |
334 (save-excursion | |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
335 ;; Connect to default NNTP server if necessary. |
267 | 336 ;; Suggested by yuki@flab.fujitsu.junet. |
337 (gnus-start-news-server) ;Use default server. | |
338 ;; NNTP server must be opened before current buffer is modified. | |
339 (widen) | |
340 (goto-char (point-min)) | |
341 (run-hooks 'news-inews-hook) | |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
342 ;; Mail the message too if To: or Cc: exists. |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
343 (if (save-restriction |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
344 (narrow-to-region |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
345 (point-min) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
346 (progn |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
347 (goto-char (point-min)) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
348 (search-forward (concat "\n" mail-header-separator "\n")) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
349 (point))) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
350 (or (mail-fetch-field "to" nil t) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
351 (mail-fetch-field "cc" nil t))) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
352 (if gnus-mail-send-method |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
353 (progn |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
354 (message "Sending via mail...") |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
355 (funcall gnus-mail-send-method) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
356 (message "Sending via mail... done")) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
357 (ding) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
358 (message "No mailer defined. To: and/or Cc: fields ignored.") |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
359 (sit-for 1))) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
360 ;; Send to NNTP server. |
267 | 361 (message "Posting to USENET...") |
362 (if (gnus-inews-article) | |
363 (message "Posting to USENET... done") | |
364 ;; We cannot signal an error. | |
365 (ding) (message "Article rejected: %s" (gnus-status-message))) | |
366 (set-buffer-modified-p nil)) | |
367 ;; If NNTP server is opened by gnus-inews-news, close it by myself. | |
368 (or server-running | |
369 (gnus-close-server)) | |
370 (and (fboundp 'bury-buffer) (bury-buffer)) | |
371 ;; Restore last window configuration. | |
372 (and gnus-winconf-post-news | |
373 (set-window-configuration gnus-winconf-post-news)) | |
374 (setq gnus-winconf-post-news nil) | |
375 )) | |
376 | |
377 (defun gnus-cancel-news () | |
378 "Cancel an article you posted." | |
379 (interactive) | |
380 (if (yes-or-no-p "Do you really want to cancel this article? ") | |
381 (let ((from nil) | |
382 (newsgroups nil) | |
383 (message-id nil) | |
384 (distribution nil)) | |
385 (save-excursion | |
386 ;; Get header info. from original article. | |
387 (save-restriction | |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
388 (gnus-article-show-all-headers) |
267 | 389 (goto-char (point-min)) |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
390 (search-forward "\n\n" nil 'move) |
267 | 391 (narrow-to-region (point-min) (point)) |
392 (setq from (mail-fetch-field "from")) | |
393 (setq newsgroups (mail-fetch-field "newsgroups")) | |
394 (setq message-id (mail-fetch-field "message-id")) | |
395 (setq distribution (mail-fetch-field "distribution"))) | |
396 ;; Verify if the article is absolutely user's by comparing | |
397 ;; user id with value of its From: field. | |
398 (if (not | |
399 (string-equal | |
400 (downcase (mail-strip-quoted-names from)) | |
401 (downcase (mail-strip-quoted-names (gnus-inews-user-name))))) | |
402 (progn | |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
403 (ding) (message "This article is not yours.")) |
267 | 404 ;; Make control article. |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
405 (set-buffer (get-buffer-create " *GNUS-canceling*")) |
267 | 406 (buffer-flush-undo (current-buffer)) |
407 (erase-buffer) | |
408 (insert "Newsgroups: " newsgroups "\n" | |
409 "Subject: cancel " message-id "\n" | |
410 "Control: cancel " message-id "\n" | |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
411 ;; We should not use the first value of |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
412 ;; `gnus-distribution-list' as default value, |
267 | 413 ;; because distribution must be as same as original |
414 ;; article. | |
415 "Distribution: " (or distribution "") "\n" | |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
416 mail-header-separator "\n" |
267 | 417 ) |
418 ;; Send the control article to NNTP server. | |
419 (message "Canceling your article...") | |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
420 (if (gnus-inews-article) |
267 | 421 (message "Canceling your article... done") |
422 (ding) (message "Failed to cancel your article")) | |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
423 ;; Kill the article buffer. |
267 | 424 (kill-buffer (current-buffer)) |
425 ))) | |
426 )) | |
427 | |
428 | |
429 ;;; Lowlevel inews interface | |
430 | |
431 (defun gnus-inews-article () | |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
432 "Post an article in current buffer using NNTP protocol." |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
433 (let ((artbuf (current-buffer)) |
267 | 434 (tmpbuf (get-buffer-create " *GNUS-posting*"))) |
435 (save-excursion | |
436 (set-buffer tmpbuf) | |
437 (buffer-flush-undo (current-buffer)) | |
438 (erase-buffer) | |
439 (insert-buffer-substring artbuf) | |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
440 ;; Remove the header separator. |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
441 (goto-char (point-min)) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
442 (search-forward (concat "\n" mail-header-separator "\n")) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
443 (replace-match "\n\n") |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
444 (goto-char (point-max)) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
445 ;; require a newline at the end for inews to append .signature to |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
446 (or (= (preceding-char) ?\n) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
447 (insert ?\n)) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
448 ;; This hook may insert a signature. |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
449 (run-hooks 'gnus-prepare-article-hook) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
450 ;; Prepare article headers. All message body such as signature |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
451 ;; must be inserted before Lines: field is prepared. |
267 | 452 (save-restriction |
453 (goto-char (point-min)) | |
454 (search-forward "\n\n") | |
455 (narrow-to-region (point-min) (point)) | |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
456 (gnus-inews-insert-headers)) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
457 ;; Run final inews hooks. This hook may do FCC. |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
458 ;; The article must be saved before being posted because |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
459 ;; `gnus-request-post' modifies the buffer. |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
460 (run-hooks 'gnus-inews-article-hook) |
267 | 461 ;; Post an article to NNTP server. |
462 ;; Return NIL if post failed. | |
463 (prog1 | |
464 (gnus-request-post) | |
465 (kill-buffer (current-buffer))) | |
466 ))) | |
467 | |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
468 (defun gnus-inews-insert-headers () |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
469 "Prepare article headers. |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
470 Fields already prepared in the buffer are not modified. |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
471 Fields in gnus-required-headers will be generated." |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
472 (save-excursion |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
473 (let ((date (gnus-inews-date)) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
474 (message-id (gnus-inews-message-id)) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
475 (organization (gnus-inews-organization))) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
476 (goto-char (point-min)) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
477 (or (mail-fetch-field "path") |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
478 (and (memq 'Path gnus-required-headers) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
479 (insert "Path: " (gnus-inews-path) "\n"))) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
480 (or (mail-fetch-field "from") |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
481 (and (memq 'From gnus-required-headers) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
482 (insert "From: " (gnus-inews-user-name) "\n"))) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
483 ;; If there is no subject, make Subject: field. |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
484 (or (mail-fetch-field "subject") |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
485 (and (memq 'Subject gnus-required-headers) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
486 (insert "Subject: \n"))) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
487 ;; If there is no newsgroups, make Newsgroups: field. |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
488 (or (mail-fetch-field "newsgroups") |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
489 (and (memq 'Newsgroups gnus-required-headers) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
490 (insert "Newsgroups: \n"))) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
491 (or (mail-fetch-field "message-id") |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
492 (and message-id |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
493 (memq 'Message-ID gnus-required-headers) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
494 (insert "Message-ID: " message-id "\n"))) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
495 (or (mail-fetch-field "date") |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
496 (and date |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
497 (memq 'Date gnus-required-headers) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
498 (insert "Date: " date "\n"))) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
499 ;; Optional fields in RFC977 and RFC1036 |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
500 (or (mail-fetch-field "organization") |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
501 (and organization |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
502 (memq 'Organization gnus-required-headers) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
503 (let ((begin (point)) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
504 (fill-column 79) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
505 (fill-prefix "\t")) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
506 (insert "Organization: " organization "\n") |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
507 (fill-region-as-paragraph begin (point))))) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
508 (or (mail-fetch-field "distribution") |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
509 (and (memq 'Distribution gnus-required-headers) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
510 (insert "Distribution: \n"))) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
511 (or (mail-fetch-field "lines") |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
512 (and (memq 'Lines gnus-required-headers) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
513 (insert "Lines: " (gnus-inews-lines) "\n"))) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
514 ))) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
515 |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
516 |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
517 ;; Utility functions. |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
518 |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
519 (defun gnus-inews-insert-signature () |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
520 "Insert signature file in current article buffer. |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
521 If there is a file named .signature-DISTRIBUTION, it is used instead |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
522 of usual .signature when the distribution of the article is |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
523 DISTRIBUTION. Set the variable to nil to prevent appending the |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
524 signature file automatically. |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
525 Signature file is specified by the variable gnus-signature-file." |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
526 (save-excursion |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
527 (save-restriction |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
528 ;; Change signature file by distribution. |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
529 ;; Suggested by hyoko@flab.fujitsu.co.jp. |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
530 (let ((signature |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
531 (if gnus-signature-file |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
532 (expand-file-name gnus-signature-file nil))) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
533 (distribution nil)) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
534 (goto-char (point-min)) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
535 (search-forward "\n\n") |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
536 (narrow-to-region (point-min) (point)) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
537 (setq distribution (mail-fetch-field "distribution")) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
538 (widen) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
539 (if signature |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
540 (progn |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
541 (if (file-exists-p (concat signature "-" distribution)) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
542 (setq signature (concat signature "-" distribution))) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
543 ;; Insert signature. |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
544 (if (file-exists-p signature) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
545 (progn |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
546 (goto-char (point-max)) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
547 (insert "--\n") |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
548 (insert-file-contents signature))) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
549 )))))) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
550 |
267 | 551 (defun gnus-inews-do-fcc () |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
552 "Process FCC: fields in current article buffer. |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
553 Unless the first character of the field is `|', the article is saved |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
554 to the specified file using the function specified by the variable |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
555 gnus-author-copy-saver. The default function rmail-output saves in |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
556 Unix mailbox format. |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
557 If the first character is `|', the contents of the article is send to |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
558 a program specified by the rest of the value." |
267 | 559 (let ((fcc-list nil) |
560 (fcc-file nil) | |
561 (case-fold-search t)) ;Should ignore case. | |
562 (save-excursion | |
563 (save-restriction | |
564 (goto-char (point-min)) | |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
565 (search-forward "\n\n") |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
566 (narrow-to-region (point-min) (point)) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
567 (goto-char (point-min)) |
267 | 568 (while (re-search-forward "^FCC:[ \t]*" nil t) |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
569 (setq fcc-list |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
570 (cons (buffer-substring |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
571 (point) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
572 (progn |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
573 (end-of-line) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
574 (skip-chars-backward " \t") |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
575 (point))) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
576 fcc-list)) |
267 | 577 (delete-region (match-beginning 0) |
578 (progn (forward-line 1) (point)))) | |
579 ;; Process FCC operations. | |
580 (widen) | |
581 (while fcc-list | |
582 (setq fcc-file (car fcc-list)) | |
583 (setq fcc-list (cdr fcc-list)) | |
584 (cond ((string-match "^[ \t]*|[ \t]*\\(.*\\)[ \t]*$" fcc-file) | |
585 (let ((program (substring fcc-file | |
586 (match-beginning 1) (match-end 1)))) | |
587 ;; Suggested by yuki@flab.fujitsu.junet. | |
588 ;; Send article to named program. | |
589 (call-process-region (point-min) (point-max) shell-file-name | |
590 nil nil nil "-c" program) | |
591 )) | |
592 (t | |
593 ;; Suggested by hyoko@flab.fujitsu.junet. | |
594 ;; Save article in Unix mail format by default. | |
5111
d9fb93d75f74
(gnus-inews-do-fcc): If gnus-author-copy-saver
Richard M. Stallman <rms@gnu.org>
parents:
5110
diff
changeset
|
595 (if (and gnus-author-copy-saver |
d9fb93d75f74
(gnus-inews-do-fcc): If gnus-author-copy-saver
Richard M. Stallman <rms@gnu.org>
parents:
5110
diff
changeset
|
596 (not (eq gnus-author-copy-saver 'rmail-output))) |
5110
c002b7320691
(gnus-inews-do-fcc): Use gnus-output-to-rmail
Richard M. Stallman <rms@gnu.org>
parents:
4172
diff
changeset
|
597 (funcall gnus-author-copy-saver fcc-file) |
c002b7320691
(gnus-inews-do-fcc): Use gnus-output-to-rmail
Richard M. Stallman <rms@gnu.org>
parents:
4172
diff
changeset
|
598 (if (and (file-readable-p fcc-file) (rmail-file-p fcc-file)) |
c002b7320691
(gnus-inews-do-fcc): Use gnus-output-to-rmail
Richard M. Stallman <rms@gnu.org>
parents:
4172
diff
changeset
|
599 (gnus-output-to-rmail fcc-file) |
c002b7320691
(gnus-inews-do-fcc): Use gnus-output-to-rmail
Richard M. Stallman <rms@gnu.org>
parents:
4172
diff
changeset
|
600 (rmail-output fcc-file 1 t t))) |
267 | 601 )) |
602 ) | |
603 )) | |
604 )) | |
605 | |
606 (defun gnus-inews-path () | |
607 "Return uucp path." | |
608 (let ((login-name (gnus-inews-login-name))) | |
609 (cond ((null gnus-use-generic-path) | |
610 (concat gnus-nntp-server "!" login-name)) | |
611 ((stringp gnus-use-generic-path) | |
612 ;; Support GENERICPATH. Suggested by vixie@decwrl.dec.com. | |
613 (concat gnus-use-generic-path "!" login-name)) | |
614 (t login-name)) | |
615 )) | |
616 | |
617 (defun gnus-inews-user-name () | |
618 "Return user's network address as `NAME@DOMAIN (FULL NAME)'." | |
619 (let ((login-name (gnus-inews-login-name)) | |
620 (full-name (gnus-inews-full-name))) | |
621 (concat login-name "@" (gnus-inews-domain-name gnus-use-generic-from) | |
622 ;; User's full name. | |
623 (cond ((string-equal full-name "") "") | |
624 ((string-equal full-name "&") ;Unix hack. | |
625 (concat " (" login-name ")")) | |
626 (t | |
627 (concat " (" full-name ")"))) | |
628 ))) | |
629 | |
630 (defun gnus-inews-login-name () | |
631 "Return user login name. | |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
632 Got from the variable gnus-user-login-name, the environment variables |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
633 USER and LOGNAME, and the function user-login-name." |
267 | 634 (or gnus-user-login-name |
635 (getenv "USER") (getenv "LOGNAME") (user-login-name))) | |
636 | |
637 (defun gnus-inews-full-name () | |
638 "Return user full name. | |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
639 Got from the variable gnus-user-full-name, the environment variable |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
640 NAME, and the function user-full-name." |
267 | 641 (or gnus-user-full-name |
642 (getenv "NAME") (user-full-name))) | |
643 | |
644 (defun gnus-inews-domain-name (&optional genericfrom) | |
645 "Return user's domain name. | |
646 If optional argument GENERICFROM is a string, use it as the domain | |
647 name; if it is non-nil, strip of local host name from the domain name. | |
648 If the function `system-name' returns full internet name and the | |
649 domain is undefined, the domain name is got from it." | |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
650 ;; Note: compatibility hack. This will be removed in the next version. |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
651 (and (null gnus-local-domain) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
652 (boundp 'gnus-your-domain) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
653 (setq gnus-local-domain gnus-your-domain)) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
654 ;; End of compatibility hack. |
267 | 655 (let ((domain (or (if (stringp genericfrom) genericfrom) |
656 (getenv "DOMAINNAME") | |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
657 gnus-local-domain |
267 | 658 ;; Function `system-name' may return full internet name. |
659 ;; Suggested by Mike DeCorte <mrd@sun.soe.clarkson.edu>. | |
660 (if (string-match "\\." (system-name)) | |
661 (substring (system-name) (match-end 0))) | |
662 (read-string "Domain name (no host): "))) | |
663 (host (or (if (string-match "\\." (system-name)) | |
664 (substring (system-name) 0 (match-beginning 0))) | |
665 (system-name)))) | |
666 (if (string-equal "." (substring domain 0 1)) | |
667 (setq domain (substring domain 1))) | |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
668 (if (null gnus-local-domain) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
669 (setq gnus-local-domain domain)) |
267 | 670 ;; Support GENERICFROM as same as standard Bnews system. |
671 ;; Suggested by ohm@kaba.junet and vixie@decwrl.dec.com. | |
672 (cond ((null genericfrom) | |
673 (concat host "." domain)) | |
674 ;;((stringp genericfrom) genericfrom) | |
675 (t domain)) | |
676 )) | |
677 | |
678 (defun gnus-inews-message-id () | |
679 "Generate unique Message-ID for user." | |
680 ;; Message-ID should not contain a slash and should be terminated by | |
681 ;; a number. I don't know the reason why it is so. | |
682 (concat "<" (gnus-inews-unique-id) "@" (gnus-inews-domain-name) ">")) | |
683 | |
684 (defun gnus-inews-unique-id () | |
685 "Generate unique ID from user name and current time." | |
686 (let ((date (current-time-string)) | |
687 (name (gnus-inews-login-name))) | |
688 (if (string-match "^[^ ]+ \\([^ ]+\\)[ ]+\\([0-9]+\\) \\([0-9]+\\):\\([0-9]+\\):\\([0-9]+\\) [0-9][0-9]\\([0-9][0-9]\\)" | |
689 date) | |
690 (concat (upcase name) "." | |
691 (substring date (match-beginning 6) (match-end 6)) ;Year | |
692 (substring date (match-beginning 1) (match-end 1)) ;Month | |
693 (substring date (match-beginning 2) (match-end 2)) ;Day | |
694 (substring date (match-beginning 3) (match-end 3)) ;Hour | |
695 (substring date (match-beginning 4) (match-end 4)) ;Minute | |
696 (substring date (match-beginning 5) (match-end 5)) ;Second | |
697 ) | |
698 (error "Cannot understand current-time-string: %s." date)) | |
699 )) | |
700 | |
3495
ba3e81f00939
(gnus-current-time-zone): New function, which tries
Richard M. Stallman <rms@gnu.org>
parents:
2843
diff
changeset
|
701 (defun gnus-current-time-zone (time) |
ba3e81f00939
(gnus-current-time-zone): New function, which tries
Richard M. Stallman <rms@gnu.org>
parents:
2843
diff
changeset
|
702 "The local time zone in effect at TIME, or nil if not known." |
4172
33ace0ef7c4d
(gnus-current-time-zone): Fix typo.
Richard M. Stallman <rms@gnu.org>
parents:
3506
diff
changeset
|
703 (let ((z (and (fboundp 'current-time-zone) (current-time-zone time)))) |
3495
ba3e81f00939
(gnus-current-time-zone): New function, which tries
Richard M. Stallman <rms@gnu.org>
parents:
2843
diff
changeset
|
704 (if (and z (car z)) z gnus-local-timezone))) |
ba3e81f00939
(gnus-current-time-zone): New function, which tries
Richard M. Stallman <rms@gnu.org>
parents:
2843
diff
changeset
|
705 |
267 | 706 (defun gnus-inews-date () |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
707 "Date string of today. |
3495
ba3e81f00939
(gnus-current-time-zone): New function, which tries
Richard M. Stallman <rms@gnu.org>
parents:
2843
diff
changeset
|
708 If `current-time-zone' works, or if `gnus-local-timezone' is set correctly, |
ba3e81f00939
(gnus-current-time-zone): New function, which tries
Richard M. Stallman <rms@gnu.org>
parents:
2843
diff
changeset
|
709 this yields a date that conforms to RFC 822. Otherwise a buggy date will |
ba3e81f00939
(gnus-current-time-zone): New function, which tries
Richard M. Stallman <rms@gnu.org>
parents:
2843
diff
changeset
|
710 be generated; this might work with some older news servers." |
ba3e81f00939
(gnus-current-time-zone): New function, which tries
Richard M. Stallman <rms@gnu.org>
parents:
2843
diff
changeset
|
711 (let* ((now (and (fboundp 'current-time) (current-time))) |
ba3e81f00939
(gnus-current-time-zone): New function, which tries
Richard M. Stallman <rms@gnu.org>
parents:
2843
diff
changeset
|
712 (zone (gnus-current-time-zone now))) |
ba3e81f00939
(gnus-current-time-zone): New function, which tries
Richard M. Stallman <rms@gnu.org>
parents:
2843
diff
changeset
|
713 (if zone |
ba3e81f00939
(gnus-current-time-zone): New function, which tries
Richard M. Stallman <rms@gnu.org>
parents:
2843
diff
changeset
|
714 (gnus-inews-valid-date now zone) |
ba3e81f00939
(gnus-current-time-zone): New function, which tries
Richard M. Stallman <rms@gnu.org>
parents:
2843
diff
changeset
|
715 ;; No timezone info. |
ba3e81f00939
(gnus-current-time-zone): New function, which tries
Richard M. Stallman <rms@gnu.org>
parents:
2843
diff
changeset
|
716 (gnus-inews-buggy-date now)))) |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
717 |
3495
ba3e81f00939
(gnus-current-time-zone): New function, which tries
Richard M. Stallman <rms@gnu.org>
parents:
2843
diff
changeset
|
718 (defun gnus-inews-valid-date (&optional time zone) |
ba3e81f00939
(gnus-current-time-zone): New function, which tries
Richard M. Stallman <rms@gnu.org>
parents:
2843
diff
changeset
|
719 "A date string that represents TIME and conforms to the Usenet standard. |
ba3e81f00939
(gnus-current-time-zone): New function, which tries
Richard M. Stallman <rms@gnu.org>
parents:
2843
diff
changeset
|
720 TIME is optional and defaults to the current time. |
ba3e81f00939
(gnus-current-time-zone): New function, which tries
Richard M. Stallman <rms@gnu.org>
parents:
2843
diff
changeset
|
721 Some older versions of Emacs always act as if TIME is nil. |
ba3e81f00939
(gnus-current-time-zone): New function, which tries
Richard M. Stallman <rms@gnu.org>
parents:
2843
diff
changeset
|
722 The optional argument ZONE specifies the local time zone (default GMT)." |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
723 (timezone-make-date-arpa-standard |
3495
ba3e81f00939
(gnus-current-time-zone): New function, which tries
Richard M. Stallman <rms@gnu.org>
parents:
2843
diff
changeset
|
724 (if (fboundp 'current-time) |
ba3e81f00939
(gnus-current-time-zone): New function, which tries
Richard M. Stallman <rms@gnu.org>
parents:
2843
diff
changeset
|
725 (current-time-string time) |
ba3e81f00939
(gnus-current-time-zone): New function, which tries
Richard M. Stallman <rms@gnu.org>
parents:
2843
diff
changeset
|
726 (current-time-string)) |
ba3e81f00939
(gnus-current-time-zone): New function, which tries
Richard M. Stallman <rms@gnu.org>
parents:
2843
diff
changeset
|
727 zone "GMT")) |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
728 |
3495
ba3e81f00939
(gnus-current-time-zone): New function, which tries
Richard M. Stallman <rms@gnu.org>
parents:
2843
diff
changeset
|
729 (defun gnus-inews-buggy-date (&optional time) |
3506
4114a1d07f7c
(gnus-inews-buggy-date): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
3495
diff
changeset
|
730 "A buggy date string that represents TIME. |
3495
ba3e81f00939
(gnus-current-time-zone): New function, which tries
Richard M. Stallman <rms@gnu.org>
parents:
2843
diff
changeset
|
731 TIME is optional and defaults to the current time. |
ba3e81f00939
(gnus-current-time-zone): New function, which tries
Richard M. Stallman <rms@gnu.org>
parents:
2843
diff
changeset
|
732 Some older versions of Emacs always act as if TIME is nil." |
ba3e81f00939
(gnus-current-time-zone): New function, which tries
Richard M. Stallman <rms@gnu.org>
parents:
2843
diff
changeset
|
733 (let ((date (if (fboundp 'current-time) |
ba3e81f00939
(gnus-current-time-zone): New function, which tries
Richard M. Stallman <rms@gnu.org>
parents:
2843
diff
changeset
|
734 (current-time-string time) |
ba3e81f00939
(gnus-current-time-zone): New function, which tries
Richard M. Stallman <rms@gnu.org>
parents:
2843
diff
changeset
|
735 (current-time-string)))) |
267 | 736 (if (string-match "^[^ ]+ \\([^ ]+\\)[ ]+\\([0-9]+\\) \\([0-9:]+\\) [0-9][0-9]\\([0-9][0-9]\\)" |
737 date) | |
738 (concat (substring date (match-beginning 2) (match-end 2)) ;Day | |
739 " " | |
740 (substring date (match-beginning 1) (match-end 1)) ;Month | |
741 " " | |
742 (substring date (match-beginning 4) (match-end 4)) ;Year | |
743 " " | |
744 (substring date (match-beginning 3) (match-end 3))) ;Time | |
745 (error "Cannot understand current-time-string: %s." date)) | |
746 )) | |
747 | |
748 (defun gnus-inews-organization () | |
749 "Return user's organization. | |
750 The ORGANIZATION environment variable is used if defined. | |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
751 If not, the variable gnus-local-organization is used instead. |
267 | 752 If the value begins with a slash, it is taken as the name of a file |
753 containing the organization." | |
754 ;; The organization must be got in this order since the ORGANIZATION | |
755 ;; environment variable is intended for user specific while | |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
756 ;; gnus-local-organization is for machine or organization specific. |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
757 |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
758 ;; Note: compatibility hack. This will be removed in the next version. |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
759 (and (null gnus-local-organization) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
760 (boundp 'gnus-your-organization) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
761 (setq gnus-local-organization gnus-your-organization)) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
762 ;; End of compatibility hack. |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
763 (let* ((private-file (expand-file-name "~/.organization" nil)) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
764 (organization (or (getenv "ORGANIZATION") |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
765 gnus-local-organization |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
766 private-file))) |
267 | 767 (and (stringp organization) |
4172
33ace0ef7c4d
(gnus-current-time-zone): Fix typo.
Richard M. Stallman <rms@gnu.org>
parents:
3506
diff
changeset
|
768 (> (length organization) 0) |
267 | 769 (string-equal (substring organization 0 1) "/") |
770 ;; Get it from the user and system file. | |
771 ;; Suggested by roland@wheaties.ai.mit.edu (Roland McGrath). | |
772 (let ((dist (mail-fetch-field "distribution"))) | |
773 (setq organization | |
774 (cond ((file-exists-p (concat organization "-" dist)) | |
775 (concat organization "-" dist)) | |
776 ((file-exists-p organization) organization) | |
777 ((file-exists-p gnus-organization-file) | |
778 gnus-organization-file) | |
779 (t organization))) | |
780 )) | |
781 (cond ((not (stringp organization)) nil) | |
782 ((and (string-equal (substring organization 0 1) "/") | |
783 (file-exists-p organization)) | |
784 ;; If the first character is `/', assume it is the name of | |
785 ;; a file containing the organization. | |
786 (save-excursion | |
787 (let ((tmpbuf (get-buffer-create " *GNUS organization*"))) | |
788 (set-buffer tmpbuf) | |
789 (erase-buffer) | |
790 (insert-file-contents organization) | |
791 (prog1 (buffer-string) | |
792 (kill-buffer tmpbuf)) | |
793 ))) | |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
794 ((string-equal organization private-file) nil) ;No such file |
267 | 795 (t organization)) |
796 )) | |
584 | 797 |
2843
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
798 (defun gnus-inews-lines () |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
799 "Count the number of lines and return numeric string." |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
800 (save-excursion |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
801 (save-restriction |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
802 (widen) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
803 (goto-char (point-min)) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
804 (search-forward "\n\n" nil 'move) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
805 (int-to-string (count-lines (point) (point-max)))))) |
cd90d49526ae
Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents:
2601
diff
changeset
|
806 |
584 | 807 (provide 'gnuspost) |
660
08eb386dd0f3
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
808 |
08eb386dd0f3
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
809 ;;; gnuspost.el ends here |