1 ;;; nndir.el --- single directory newsgroup access for Gnus
2 ;; Copyright (C) 1995 Free Software Foundation, Inc.
4 ;; Author: Lars Ingebrigtsen <larsi@ifi.uio.no>
5 ;; Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
6 ;; Keywords: news, mail
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
34 (defconst nndir-version "nndir 0.0")
36 (defvar nndir-current-directory nil
37 "Current news group directory.")
39 (defvar nndir-status-string "")
41 (defvar nndir-nov-is-evil nil
42 "*Non-nil means that nndir will never retrieve NOV headers.")
46 ;;; Interface functions.
49 (defun nndir-retrieve-headers (sequence &optional newsgroup server)
50 (nndir-execute-nnml-command
51 '(nnml-retrieve-headers sequence group server) server))
53 (defun nndir-open-server (host &optional service)
55 (setq nndir-status-string "")
56 (nndir-open-server-internal host service))
58 (defun nndir-close-server (&optional server)
60 (nndir-close-server-internal))
62 (defalias 'nndir-request-quit 'nndir-close-server)
64 (defun nndir-server-opened (&optional server)
65 "Return server process status, T or NIL.
66 If the stream is opened, return T, otherwise return NIL."
67 (and nntp-server-buffer
68 (get-buffer nntp-server-buffer)))
70 (defun nndir-status-message ()
71 "Return server status response as string."
74 (defun nndir-request-article (id &optional newsgroup server buffer)
75 (nndir-execute-nnmh-command
76 '(nnmh-request-article id group server buffer) server))
78 (defun nndir-request-group (group &optional server dont-check)
80 (nndir-execute-nnmh-command
81 '(nnmh-request-group group "" dont-check) server))
83 (defun nndir-request-list (&optional server dir)
84 "Get list of active articles in all newsgroups."
85 (nndir-execute-nnmh-command
86 '(nnmh-request-list nil dir) server))
88 (defun nndir-request-newgroups (date &optional server)
89 (nndir-execute-nnmh-command
90 '(nnmh-request-newgroups date server) server))
92 (defun nndir-request-post (&optional server)
93 "Post a new news in current buffer."
94 (mail-send-and-exit nil))
96 (fset 'nndir-request-post-buffer 'nnmail-request-post-buffer)
98 (defun nndir-request-expire-articles (articles newsgroup &optional server force)
99 "Expire all articles in the ARTICLES list in group GROUP."
100 (setq nndir-status-string "nndir: expire not possible")
103 (defun nndir-close-group (group &optional server)
106 (defun nndir-request-move-article (article group server accept-form)
107 (setq nndir-status-string "nndir: move not possible")
110 (defun nndir-request-accept-article (group)
111 (setq nndir-status-string "nndir: accept not possible")
115 ;;; Low-Level Interface
117 (defun nndir-open-server-internal (host &optional service)
118 "Open connection to news server on HOST by SERVICE."
120 ;; Initialize communication buffer.
121 (setq nntp-server-buffer (get-buffer-create " *nntpd*"))
122 (set-buffer nntp-server-buffer)
123 (buffer-disable-undo (current-buffer))
125 (kill-all-local-variables)
126 (setq case-fold-search t) ;Should ignore case.
129 (defun nndir-close-server-internal ()
130 "Close connection to news server."
133 (defun nndir-execute-nnmh-command (command server)
134 (let ((dir (expand-file-name server)))
135 (and (string-match "/$" dir)
136 (setq dir (substring dir 0 (match-beginning 0))))
137 (string-match "/[^/]+$" dir)
138 (let ((group (substring dir (1+ (match-beginning 0))))
139 (nnmh-directory (substring dir 0 (1+ (match-beginning 0))))
140 (nnmh-get-new-mail nil))
143 (defun nndir-execute-nnml-command (command server)
144 (let ((dir (expand-file-name server)))
145 (and (string-match "/$" dir)
146 (setq dir (substring dir 0 (match-beginning 0))))
147 (string-match "/[^/]+$" dir)
148 (let ((group (substring dir (1+ (match-beginning 0))))
149 (nnml-directory (substring dir 0 (1+ (match-beginning 0))))
150 (nnml-nov-is-evil nndir-nov-is-evil)
151 (nnml-get-new-mail nil))
156 ;;; nndir.el ends here