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