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 "")
59 ;;; Interface functions.
62 (defun nndir-retrieve-headers (sequence &optional
63 nndir-group server fetch-old)
64 (nndir-execute-nnml-command
65 `(nnml-retrieve-headers ',sequence nndir-group ,server ,fetch-old)))
67 (defun nndir-open-server (server &optional defs)
68 (nnheader-change-server 'nndir server defs)
69 (unless (assq 'nndir-directory defs)
70 (setq nndir-directory server))
73 ((not (condition-case arg
74 (file-exists-p nndir-directory)
75 (ftp-error (setq err (format "%s" arg)))))
78 'nndir (or err "No such file or directory: %s" nndir-directory)))
79 ((not (file-directory-p (file-truename nndir-directory)))
81 (nnheader-report 'nndir "Not a directory: %s" nndir-directory))
83 (nnheader-report 'nndir "Opened server %s using directory %s"
84 server nndir-directory)
87 (defun nndir-close-server (&optional server)
88 (setq nndir-current-server nil)
91 (defun nndir-server-opened (&optional server)
92 (and nntp-server-buffer
93 (get-buffer nntp-server-buffer)
95 (equal nndir-current-server server)))
97 (defun nndir-status-message (&optional server)
100 (defun nndir-request-article (id &optional nndir-group server buffer)
101 (nndir-execute-nnmh-command
102 `(nnmh-request-article ,id nndir-group ,server ,buffer)))
104 (defun nndir-request-group (nndir-group &optional server dont-check)
105 (nndir-execute-nnmh-command
106 `(nnmh-request-group nndir-group "" ,dont-check)))
108 (defun nndir-request-list (&optional server dir)
109 (let ((nndir-directory (concat (file-name-as-directory
110 nndir-directory) "dummy")))
111 (nndir-execute-nnmh-command
112 `(nnmh-request-list ,(concat "nndir+" (or server "")) ,dir))))
114 (defun nndir-request-newgroups (date &optional server)
115 (nndir-execute-nnmh-command
116 `(nnmh-request-newgroups ,date ,server)))
118 (defun nndir-request-expire-articles
119 (articles nndir-group &optional server force)
120 (nndir-execute-nnmh-command
121 `(nnmh-request-expire-articles ',articles nndir-group ,server ,force)))
123 (defun nndir-request-accept-article (nndir-group &optional last)
124 (nndir-execute-nnmh-command
125 `(nnmh-request-accept-article nndir-group ,last)))
127 (defun nndir-close-group (nndir-group &optional server)
130 (defun nndir-request-create-group (group &optional server)
131 (if (file-exists-p nndir-directory)
132 (if (file-directory-p nndir-directory)
137 (make-directory nndir-directory t)
142 ;;; Low-Level Interface
144 (defun nndir-execute-nnmh-command (command)
145 (let ((dir (file-name-as-directory (expand-file-name nndir-directory))))
146 (if (and (not (file-directory-p nndir-group))
147 (or (file-directory-p (concat dir nndir-group))
149 (concat dir (nnheader-replace-chars-in-string
150 nndir-group ?. ?/)))))
151 (let ((nnmh-directory nndir-directory)
152 (nnmh-get-new-mail nil))
154 (let ((dir (directory-file-name (expand-file-name nndir-directory))))
155 (string-match "/[^/]+$" dir)
156 (let ((nndir-group (substring dir (1+ (match-beginning 0))))
157 (nnmh-directory (substring dir 0 (1+ (match-beginning 0))))
158 (nnmh-get-new-mail nil))
161 (defun nndir-execute-nnml-command (command)
162 (let ((dir (file-name-as-directory (expand-file-name nndir-directory))))
163 (if (and (not (file-directory-p nndir-group))
164 (or (file-directory-p (concat dir nndir-group))
166 (concat dir (nnheader-replace-chars-in-string
167 nndir-group ?. ?/)))))
168 (let ((nnml-directory nndir-directory)
169 (nnml-nov-is-evil nndir-nov-is-evil)
170 (nnml-get-new-mail nil))
172 (let ((dir (directory-file-name (expand-file-name nndir-directory))))
173 (string-match "/[^/]+$" dir)
174 (let ((nndir-group (substring dir (1+ (match-beginning 0))))
175 (nnml-directory (substring dir 0 (1+ (match-beginning 0))))
176 (nnml-nov-is-evil nndir-nov-is-evil)
177 (nnml-get-new-mail nil))
182 ;;; nndir.el ends here