1 ;;; nndir.el --- single directory newsgroup access for Gnus
2 ;; Copyright (C) 1995,96 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
5 ;; Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
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 the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
32 (eval-when-compile (require 'cl))
34 (defvar nndir-directory nil
35 "Where nndir will look for groups.")
37 (defvar nndir-nov-is-evil nil
38 "*Non-nil means that nndir will never retrieve NOV headers.")
42 (defconst nndir-version "nndir 1.0")
44 (defvar nndir-status-string "")
46 (defvar nndir-group "blououUOUOuuubhbh")
50 (defvar nndir-current-server nil)
51 (defvar nndir-server-alist nil)
52 (defvar nndir-server-variables
53 `((nndir-directory nil)
54 (nndir-status-string "")
55 (nndir-nov-is-evil ,nndir-nov-is-evil)
56 (nndir-group-alist nil)))
60 ;;; Interface functions.
63 (defun nndir-retrieve-headers (sequence &optional
64 nndir-group server fetch-old)
65 (nndir-execute-nnml-command
66 `(nnml-retrieve-headers ',sequence nndir-group ,server ,fetch-old)))
68 (defun nndir-open-server (server &optional defs)
69 (nnheader-change-server 'nndir server defs)
70 (unless (assq 'nndir-directory defs)
71 (setq nndir-directory server))
74 ((not (condition-case arg
75 (file-exists-p nndir-directory)
76 (ftp-error (setq err (format "%s" arg)))))
79 'nndir (or err "No such file or directory: %s" nndir-directory)))
80 ((not (file-directory-p (file-truename nndir-directory)))
82 (nnheader-report 'nndir "Not a directory: %s" nndir-directory))
84 (nnheader-report 'nndir "Opened server %s using directory %s"
85 server nndir-directory)
88 (defun nndir-close-server (&optional server)
89 (setq nndir-current-server nil)
92 (defun nndir-server-opened (&optional server)
93 (and nntp-server-buffer
94 (get-buffer nntp-server-buffer)
96 (equal nndir-current-server server)))
98 (defun nndir-status-message (&optional server)
101 (defun nndir-request-article (id &optional nndir-group server buffer)
102 (nndir-execute-nnmh-command
103 `(nnmh-request-article ,id nndir-group ,server ,buffer)))
105 (defun nndir-request-group (nndir-group &optional server dont-check)
106 (nndir-execute-nnmh-command
107 `(nnmh-request-group nndir-group "" ,dont-check)))
109 (defun nndir-request-list (&optional server dir)
110 (let ((nndir-directory (concat (file-name-as-directory
111 nndir-directory) "dummy")))
112 (nndir-execute-nnmh-command
113 `(nnmh-request-list ,(concat "nndir+" (or server "")) ,dir))))
115 (defun nndir-request-newgroups (date &optional server)
116 (nndir-execute-nnmh-command
117 `(nnmh-request-newgroups ,date ,server)))
119 (defun nndir-request-expire-articles
120 (articles nndir-group &optional server force)
121 (nndir-execute-nnmh-command
122 `(nnmh-request-expire-articles ',articles nndir-group ,server ,force)))
124 (defun nndir-request-accept-article (nndir-group &optional last)
125 (nndir-execute-nnmh-command
126 `(nnmh-request-accept-article nndir-group ,last)))
128 (defun nndir-close-group (nndir-group &optional server)
131 (defun nndir-request-create-group (group &optional server)
132 (if (file-exists-p nndir-directory)
133 (if (file-directory-p nndir-directory)
138 (make-directory nndir-directory t)
143 ;;; Low-Level Interface
145 (defun nndir-execute-nnmh-command (command)
146 (let ((dir (file-name-as-directory (expand-file-name nndir-directory))))
147 (if (and (not (file-directory-p nndir-group))
148 (or (file-directory-p (concat dir nndir-group))
150 (concat dir (nnheader-replace-chars-in-string
151 nndir-group ?. ?/)))))
152 (let ((nnmh-directory nndir-directory)
153 (nnmh-get-new-mail nil))
155 (let ((dir (directory-file-name (expand-file-name nndir-directory))))
156 (string-match "/[^/]+$" dir)
157 (let ((nndir-group (substring dir (1+ (match-beginning 0))))
158 (nnmh-directory (substring dir 0 (1+ (match-beginning 0))))
159 (nnmh-get-new-mail nil))
162 (defun nndir-execute-nnml-command (command)
163 (let ((dir (file-name-as-directory (expand-file-name nndir-directory))))
164 (if (and (not (file-directory-p nndir-group))
165 (or (file-directory-p (concat dir nndir-group))
167 (concat dir (nnheader-replace-chars-in-string
168 nndir-group ?. ?/)))))
169 (let ((nnml-directory nndir-directory)
170 (nnml-nov-is-evil nndir-nov-is-evil)
171 (nnml-get-new-mail nil))
173 (let ((dir (directory-file-name (expand-file-name nndir-directory))))
174 (string-match "/[^/]+$" dir)
175 (let ((nndir-group (substring dir (1+ (match-beginning 0))))
176 (nnml-directory (substring dir 0 (1+ (match-beginning 0))))
177 (nnml-nov-is-evil nndir-nov-is-evil)
178 (nnml-get-new-mail nil))
183 ;;; nndir.el ends here