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.
34 (autoload 'mail-send-and-exit "sendmail"))
36 (defvar nndir-directory nil)
40 (defconst nndir-version "nndir 1.0")
42 (defvar nndir-status-string "")
44 (defvar nndir-nov-is-evil nil
45 "*Non-nil means that nndir will never retrieve NOV headers.")
49 (defvar nndir-current-server nil)
50 (defvar nndir-server-alist nil)
51 (defvar nndir-server-variables
53 '(nndir-directory nil)
54 '(nndir-status-string "")
55 '(nndir-group-alist)))
59 ;;; Interface functions.
62 (defun nndir-retrieve-headers (sequence &optional group server fetch-old)
63 (nndir-execute-nnml-command
64 (` (nnml-retrieve-headers
65 (quote (, sequence)) group (, server) (, fetch-old)))))
67 (defun nndir-open-server (server &optional defs)
68 (nnheader-init-server-buffer)
69 (if (equal server nndir-current-server)
71 (if nndir-current-server
72 (setq nndir-server-alist
73 (cons (list nndir-current-server
74 (nnheader-save-variables nndir-server-variables))
76 (let ((state (assoc server nndir-server-alist)))
79 (nnheader-restore-variables (nth 1 state))
80 (setq nndir-server-alist (delq state nndir-server-alist)))
81 (nnheader-set-init-variables nndir-server-variables defs))
82 (or (assq 'nndir-directory defs)
83 (setq nndir-directory server)))
84 (setq nndir-current-server server)))
86 (defun nndir-close-server (&optional server)
89 (defun nndir-server-opened (&optional server)
90 (and nntp-server-buffer
91 (get-buffer nntp-server-buffer)
93 (equal nndir-current-server server)))
95 (defun nndir-status-message (&optional server)
98 (defun nndir-request-article (id &optional group server buffer)
99 (nndir-execute-nnmh-command
100 (` (nnmh-request-article (, id) group (, server) (, buffer)))))
102 (defun nndir-request-group (group &optional server dont-check)
103 (nndir-execute-nnmh-command
104 (` (nnmh-request-group group "" (, dont-check)))))
106 (defun nndir-request-list (&optional server dir)
107 (nndir-execute-nnmh-command
108 (` (nnmh-request-list nil (, dir)))))
110 (defun nndir-request-newgroups (date &optional server)
111 (nndir-execute-nnmh-command
112 (` (nnmh-request-newgroups (, date) (, server)))))
114 (defun nndir-request-post (&optional server)
115 (mail-send-and-exit nil))
117 (defun nndir-request-expire-articles
118 (articles group &optional server force)
119 (nndir-execute-nnmh-command
120 (` (nnmh-request-expire-articles (quote (, articles)) group
121 (, server) (, force)))))
123 (defun nndir-request-accept-article (group &optional last)
124 (nndir-execute-nnmh-command
125 (` (nnmh-request-accept-article group (, last)))))
127 (defun nndir-close-group (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 (expand-file-name nndir-directory)))
146 (and (string-match "/$" dir)
147 (setq dir (substring dir 0 (match-beginning 0))))
148 (string-match "/[^/]+$" dir)
149 (let ((group (substring dir (1+ (match-beginning 0))))
150 (nnmh-directory (substring dir 0 (1+ (match-beginning 0))))
151 (nnmh-get-new-mail nil))
154 (defun nndir-execute-nnml-command (command)
155 (let ((dir (expand-file-name nndir-directory)))
156 (and (string-match "/$" dir)
157 (setq dir (substring dir 0 (match-beginning 0))))
158 (string-match "/[^/]+$" dir)
159 (let ((group (substring dir (1+ (match-beginning 0))))
160 (nnml-directory (substring dir 0 (1+ (match-beginning 0))))
161 (nnml-nov-is-evil nndir-nov-is-evil)
162 (nnml-get-new-mail nil))
167 ;;; nndir.el ends here