Mercurial > emacs
comparison lisp/=nnspool.el @ 2843:cd90d49526ae
Version 3.15 from Umeda.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sun, 16 May 1993 22:58:52 +0000 |
parents | bff32d8ecc5e |
children | 507f64624555 |
comparison
equal
deleted
inserted
replaced
2842:b002f2c288d3 | 2843:cd90d49526ae |
---|---|
1 ;;; nnspool.el --- spool access using NNTP for GNU Emacs | 1 ;;; nnspool.el --- spool access using NNTP for GNU Emacs |
2 | 2 |
3 ;; Copyright (C) 1988, 1989, 1990 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1988, 1989, 1990, 1993 Free Software Foundation, Inc. |
4 | 4 |
5 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet> | 5 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet> |
6 ;; Keywords: news | 6 ;; Keywords: news |
7 | 7 |
8 ;; This file is part of GNU Emacs. | 8 ;; This file is part of GNU Emacs. |
35 "*Local news spool directory.") | 35 "*Local news spool directory.") |
36 | 36 |
37 (defvar nnspool-active-file "/usr/lib/news/active" | 37 (defvar nnspool-active-file "/usr/lib/news/active" |
38 "*Local news active file.") | 38 "*Local news active file.") |
39 | 39 |
40 (defvar nnspool-newsgroups-file "/usr/lib/news/newsgroups" | |
41 "*Local news newsgroups file.") | |
42 | |
43 (defvar nnspool-distributions-file "/usr/lib/news/distributions" | |
44 "*Local news distributions file.") | |
45 | |
40 (defvar nnspool-history-file "/usr/lib/news/history" | 46 (defvar nnspool-history-file "/usr/lib/news/history" |
41 "*Local news history file.") | 47 "*Local news history file.") |
42 | 48 |
43 | 49 |
44 | 50 |
45 (defconst nnspool-version "NNSPOOL 1.10" | 51 (defconst nnspool-version "NNSPOOL 1.12" |
46 "Version numbers of this version of NNSPOOL.") | 52 "Version numbers of this version of NNSPOOL.") |
47 | 53 |
48 (defvar nnspool-current-directory nil | 54 (defvar nnspool-current-directory nil |
49 "Current news group directory.") | 55 "Current news group directory.") |
50 | 56 |
54 | 60 |
55 (defun nnspool-retrieve-headers (sequence) | 61 (defun nnspool-retrieve-headers (sequence) |
56 "Return list of article headers specified by SEQUENCE of article id. | 62 "Return list of article headers specified by SEQUENCE of article id. |
57 The format of list is | 63 The format of list is |
58 `([NUMBER SUBJECT FROM XREF LINES DATE MESSAGE-ID REFERENCES] ...)'. | 64 `([NUMBER SUBJECT FROM XREF LINES DATE MESSAGE-ID REFERENCES] ...)'. |
65 If there is no References: field, In-Reply-To: field is used instead. | |
59 Reader macros for the vector are defined as `nntp-header-FIELD'. | 66 Reader macros for the vector are defined as `nntp-header-FIELD'. |
60 Writer macros for the vector are defined as `nntp-set-header-FIELD'. | 67 Writer macros for the vector are defined as `nntp-set-header-FIELD'. |
61 News group must be selected before calling me." | 68 Newsgroup must be selected before calling this." |
62 (save-excursion | 69 (save-excursion |
63 (set-buffer nntp-server-buffer) | 70 (set-buffer nntp-server-buffer) |
64 ;;(erase-buffer) | 71 ;;(erase-buffer) |
65 (let ((file nil) | 72 (let ((file nil) |
66 (number (length sequence)) | 73 (number (length sequence)) |
137 (setq xref (buffer-substring | 144 (setq xref (buffer-substring |
138 (point) | 145 (point) |
139 (save-excursion (end-of-line) (point)))) | 146 (save-excursion (end-of-line) (point)))) |
140 (setq xref nil)) | 147 (setq xref nil)) |
141 ;; Extract References: | 148 ;; Extract References: |
142 (goto-char (point-min)) | 149 ;; If no References: field, use In-Reply-To: field instead. |
143 (if (search-forward "\nReferences: " nil t) | 150 (goto-char (point-min)) |
151 (if (or (search-forward "\nReferences: " nil t) | |
152 (search-forward "\nIn-Reply-To: " nil t)) | |
144 (setq references (buffer-substring | 153 (setq references (buffer-substring |
145 (point) | 154 (point) |
146 (save-excursion (end-of-line) (point)))) | 155 (save-excursion (end-of-line) (point)))) |
147 (setq references nil)) | 156 (setq references nil)) |
148 (setq headers | 157 ;; Collect valid article only. |
149 (cons (vector article subject from | 158 (and article |
150 xref lines date | 159 message-id |
151 message-id references) headers)) | 160 (setq headers |
161 (cons (vector article subject from | |
162 xref lines date | |
163 message-id references) headers))) | |
152 )) | 164 )) |
153 (setq sequence (cdr sequence)) | 165 (setq sequence (cdr sequence)) |
154 (setq count (1+ count)) | 166 (setq count (1+ count)) |
155 (and (numberp nntp-large-newsgroup) | 167 (and (numberp nntp-large-newsgroup) |
156 (> number nntp-large-newsgroup) | 168 (> number nntp-large-newsgroup) |
157 (zerop (% count 20)) | 169 (zerop (% count 20)) |
158 (message "NNSPOOL: %d%% of headers received." | 170 (message "NNSPOOL: Receiving headers... %d%%" |
159 (/ (* count 100) number))) | 171 (/ (* count 100) number))) |
160 ) | 172 ) |
161 (and (numberp nntp-large-newsgroup) | 173 (and (numberp nntp-large-newsgroup) |
162 (> number nntp-large-newsgroup) | 174 (> number nntp-large-newsgroup) |
163 (message "NNSPOOL: 100%% of headers received.")) | 175 (message "NNSPOOL: Receiving headers... done")) |
164 (nreverse headers) | 176 (nreverse headers) |
165 ))) | 177 ))) |
166 | 178 |
167 | 179 |
168 ;;; | 180 ;;; |
173 "Open news server on HOST. | 185 "Open news server on HOST. |
174 If HOST is nil, use value of environment variable `NNTPSERVER'. | 186 If HOST is nil, use value of environment variable `NNTPSERVER'. |
175 If optional argument SERVICE is non-nil, open by the service name." | 187 If optional argument SERVICE is non-nil, open by the service name." |
176 (let ((host (or host (getenv "NNTPSERVER"))) | 188 (let ((host (or host (getenv "NNTPSERVER"))) |
177 (status nil)) | 189 (status nil)) |
178 (setq nntp-status-message-string "") | 190 (setq nntp-status-string "") |
179 (cond ((and (file-directory-p nnspool-spool-directory) | 191 (cond ((and (file-directory-p nnspool-spool-directory) |
180 (file-exists-p nnspool-active-file) | 192 (file-exists-p nnspool-active-file) |
181 (string-equal host (system-name))) | 193 (string-equal host (system-name))) |
182 (setq status (nnspool-open-server-internal host service))) | 194 (setq status (nnspool-open-server-internal host service))) |
183 ((string-equal host (system-name)) | 195 ((string-equal host (system-name)) |
184 (setq nntp-status-message-string | 196 (setq nntp-status-string |
185 (format "%s has no news spool. Goodbye." host))) | 197 (format "%s has no news spool. Goodbye." host))) |
186 ((null host) | 198 ((null host) |
187 (setq nntp-status-message-string "NNTP server is not specified.")) | 199 (setq nntp-status-string "NNTP server is not specified.")) |
188 (t | 200 (t |
189 (setq nntp-status-message-string | 201 (setq nntp-status-string |
190 (format "NNSPOOL: cannot talk to %s." host))) | 202 (format "NNSPOOL: cannot talk to %s." host))) |
191 ) | 203 ) |
192 status | 204 status |
193 )) | 205 )) |
194 | 206 |
204 (and nntp-server-buffer | 216 (and nntp-server-buffer |
205 (get-buffer nntp-server-buffer))) | 217 (get-buffer nntp-server-buffer))) |
206 | 218 |
207 (defun nnspool-status-message () | 219 (defun nnspool-status-message () |
208 "Return server status response as string." | 220 "Return server status response as string." |
209 nntp-status-message-string | 221 nntp-status-string |
210 ) | 222 ) |
211 | 223 |
212 (defun nnspool-request-article (id) | 224 (defun nnspool-request-article (id) |
213 "Select article by message ID (or number)." | 225 "Select article by message ID (or number)." |
214 (let ((file (if (stringp id) | 226 (let ((file (if (stringp id) |
245 ) | 257 ) |
246 )) | 258 )) |
247 | 259 |
248 (defun nnspool-request-stat (id) | 260 (defun nnspool-request-stat (id) |
249 "Select article by message ID (or number)." | 261 "Select article by message ID (or number)." |
250 (error "NNSPOOL: STAT is not implemented.")) | 262 (setq nntp-status-string "NNSPOOL: STAT is not implemented.") |
263 nil | |
264 ) | |
251 | 265 |
252 (defun nnspool-request-group (group) | 266 (defun nnspool-request-group (group) |
253 "Select news GROUP." | 267 "Select news GROUP." |
254 (let ((pathname (nnspool-article-pathname | 268 (let ((pathname (nnspool-article-pathname |
255 (nnspool-replace-chars-in-string group ?. ?/)))) | 269 (nnspool-replace-chars-in-string group ?. ?/)))) |
256 (if (file-directory-p pathname) | 270 (if (file-directory-p pathname) |
257 (setq nnspool-current-directory pathname)) | 271 (setq nnspool-current-directory pathname)) |
258 )) | 272 )) |
259 | 273 |
260 (defun nnspool-request-list () | 274 (defun nnspool-request-list () |
261 "List valid newsgoups." | 275 "List active newsgoups." |
262 (save-excursion | 276 (save-excursion |
263 (nnspool-find-file nnspool-active-file))) | 277 (nnspool-find-file nnspool-active-file))) |
264 | 278 |
279 (defun nnspool-request-list-newsgroups () | |
280 "List newsgroups (defined in NNTP2)." | |
281 (save-excursion | |
282 (nnspool-find-file nnspool-newsgroups-file))) | |
283 | |
284 (defun nnspool-request-list-distributions () | |
285 "List distributions (defined in NNTP2)." | |
286 (save-excursion | |
287 (nnspool-find-file nnspool-distributions-file))) | |
288 | |
265 (defun nnspool-request-last () | 289 (defun nnspool-request-last () |
266 "Set current article pointer to the previous article in the current news group." | 290 "Set current article pointer to the previous article |
267 (error "NNSPOOL: LAST is not implemented.")) | 291 in the current news group." |
292 (setq nntp-status-string "NNSPOOL: LAST is not implemented.") | |
293 nil | |
294 ) | |
268 | 295 |
269 (defun nnspool-request-next () | 296 (defun nnspool-request-next () |
270 "Advance current article pointer." | 297 "Advance current article pointer." |
271 (error "NNSPOOL: NEXT is not implemented.")) | 298 (setq nntp-status-string "NNSPOOL: NEXT is not implemented.") |
299 nil | |
300 ) | |
272 | 301 |
273 (defun nnspool-request-post () | 302 (defun nnspool-request-post () |
274 "Post a new news in current buffer." | 303 "Post a new news in current buffer." |
275 (save-excursion | 304 (save-excursion |
276 ;; We have to work in the server buffer because of NEmacs hack. | 305 ;; We have to work in the server buffer because of NEmacs hack. |
277 (copy-to-buffer nntp-server-buffer (point-min) (point-max)) | 306 (copy-to-buffer nntp-server-buffer (point-min) (point-max)) |
278 (set-buffer nntp-server-buffer) | 307 (set-buffer nntp-server-buffer) |
279 (apply 'call-process-region | 308 (apply (function call-process-region) |
280 (point-min) (point-max) | 309 (point-min) (point-max) |
281 nnspool-inews-program 'delete t nil nnspool-inews-switches) | 310 nnspool-inews-program 'delete t nil nnspool-inews-switches) |
282 (prog1 | 311 (prog1 |
283 (or (zerop (buffer-size)) | 312 (or (zerop (buffer-size)) |
284 ;; If inews returns strings, it must be error message | 313 ;; If inews returns strings, it must be error message |
287 ;; identifying errors when SPOOLNEWS is defined. | 316 ;; identifying errors when SPOOLNEWS is defined. |
288 ;; Suggested by ohm@kaba.junet. | 317 ;; Suggested by ohm@kaba.junet. |
289 (string-match "spooled" (buffer-string))) | 318 (string-match "spooled" (buffer-string))) |
290 ;; Make status message by unfolding lines. | 319 ;; Make status message by unfolding lines. |
291 (subst-char-in-region (point-min) (point-max) ?\n ?\\ 'noundo) | 320 (subst-char-in-region (point-min) (point-max) ?\n ?\\ 'noundo) |
292 (setq nntp-status-message-string (buffer-string)) | 321 (setq nntp-status-string (buffer-string)) |
293 (erase-buffer)) | 322 (erase-buffer)) |
294 )) | 323 )) |
295 | 324 |
296 | 325 |
297 ;;; | 326 ;;; |
325 (kill-buffer nntp-server-buffer)) | 354 (kill-buffer nntp-server-buffer)) |
326 (setq nntp-server-buffer nil) | 355 (setq nntp-server-buffer nil) |
327 (setq nntp-server-process nil)) | 356 (setq nntp-server-process nil)) |
328 | 357 |
329 (defun nnspool-find-article-by-message-id (id) | 358 (defun nnspool-find-article-by-message-id (id) |
330 "Return full pathname of an article identified by message-ID." | 359 "Return full pathname of an artilce identified by message-ID." |
331 (save-excursion | 360 (save-excursion |
332 (let ((buffer (get-file-buffer nnspool-history-file))) | 361 (let ((buffer (get-file-buffer nnspool-history-file))) |
333 (if buffer | 362 (if buffer |
334 (set-buffer buffer) | 363 (set-buffer buffer) |
335 ;; Finding history file may take lots of time. | 364 ;; Finding history file may take lots of time. |