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))
72 ((not (file-exists-p nndir-directory))
74 (nnheader-report 'nndir "No such file or directory: %s" nndir-directory))
75 ((not (file-directory-p (file-truename nndir-directory)))
77 (nnheader-report 'nndir "Not a directory: %s" nndir-directory))
79 (nnheader-report 'nndir "Opened server %s using directory %s"
80 server nndir-directory)
83 (defun nndir-close-server (&optional server)
84 (setq nndir-current-server nil)
87 (defun nndir-server-opened (&optional server)
88 (and nntp-server-buffer
89 (get-buffer nntp-server-buffer)
91 (equal nndir-current-server server)))
93 (defun nndir-status-message (&optional server)
96 (defun nndir-request-article (id &optional nndir-group server buffer)
97 (nndir-execute-nnmh-command
98 `(nnmh-request-article ,id nndir-group ,server ,buffer)))
100 (defun nndir-request-group (nndir-group &optional server dont-check)
101 (nndir-execute-nnmh-command
102 `(nnmh-request-group nndir-group "" ,dont-check)))
104 (defun nndir-request-list (&optional server dir)
105 (let ((nndir-directory (concat (file-name-as-directory
106 nndir-directory) "dummy")))
107 (nndir-execute-nnmh-command
108 `(nnmh-request-list ,(concat "nndir+" (or server "")) ,dir))))
110 (defun nndir-request-newgroups (date &optional server)
111 (nndir-execute-nnmh-command
112 `(nnmh-request-newgroups ,date ,server)))
114 (defun nndir-request-expire-articles
115 (articles nndir-group &optional server force)
116 (nndir-execute-nnmh-command
117 `(nnmh-request-expire-articles ',articles nndir-group ,server ,force)))
119 (defun nndir-request-accept-article (nndir-group &optional last)
120 (nndir-execute-nnmh-command
121 `(nnmh-request-accept-article nndir-group ,last)))
123 (defun nndir-close-group (nndir-group &optional server)
126 (defun nndir-request-create-group (group &optional server)
127 (if (file-exists-p nndir-directory)
128 (if (file-directory-p nndir-directory)
133 (make-directory nndir-directory t)
138 ;;; Low-Level Interface
140 (defun nndir-execute-nnmh-command (command)
141 (let ((dir (file-name-as-directory (expand-file-name nndir-directory))))
142 (if (or (file-directory-p (concat dir nndir-group))
144 (concat dir (nnheader-replace-chars-in-string
145 nndir-group ?. ?/))))
146 (let ((nnmh-directory nndir-directory)
147 (nnmh-get-new-mail nil))
149 (let ((dir (directory-file-name (expand-file-name nndir-directory))))
150 (string-match "/[^/]+$" dir)
151 (let ((nndir-group (substring dir (1+ (match-beginning 0))))
152 (nnmh-directory (substring dir 0 (1+ (match-beginning 0))))
153 (nnmh-get-new-mail nil))
156 (defun nndir-execute-nnml-command (command)
157 (let ((dir (file-name-as-directory (expand-file-name nndir-directory))))
158 (if (or (file-directory-p (concat dir nndir-group))
160 (concat dir (nnheader-replace-chars-in-string
161 nndir-group ?. ?/))))
162 (let ((nnml-directory nndir-directory)
163 (nnml-nov-is-evil nndir-nov-is-evil)
164 (nnml-get-new-mail nil))
166 (let ((dir (directory-file-name (expand-file-name nndir-directory))))
167 (string-match "/[^/]+$" dir)
168 (let ((nndir-group (substring dir (1+ (match-beginning 0))))
169 (nnml-directory (substring dir 0 (1+ (match-beginning 0))))
170 (nnml-nov-is-evil nndir-nov-is-evil)
171 (nnml-get-new-mail nil))
176 ;;; nndir.el ends here