1 ;;; nndir.el --- single directory newsgroup access for Gnus
2 ;; Copyright (C) 1995 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
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
33 (autoload 'mail-send-and-exit "sendmail"))
35 (defvar nndir-directory nil)
39 (defconst nndir-version "nndir 1.0")
41 (defvar nndir-status-string "")
43 (defvar nndir-nov-is-evil nil
44 "*Non-nil means that nndir will never retrieve NOV headers.")
48 (defvar nndir-current-server nil)
49 (defvar nndir-server-alist nil)
50 (defvar nndir-server-variables
52 '(nndir-directory nil)
53 '(nndir-status-string "")
54 '(nndir-group-alist)))
58 ;;; Interface functions.
61 (defun nndir-retrieve-headers (sequence &optional group server fetch-old)
62 (nndir-execute-nnml-command
63 (` (nnml-retrieve-headers
64 (quote (, sequence)) (, group) (, server) (, fetch-old)))))
66 (defun nndir-open-server (server &optional defs)
67 (nnheader-init-server-buffer)
68 (if (equal server nndir-current-server)
70 (if nndir-current-server
71 (setq nndir-server-alist
72 (cons (list nndir-current-server
73 (nnheader-save-variables nndir-server-variables))
75 (let ((state (assoc server nndir-server-alist)))
78 (nnheader-restore-variables (nth 1 state))
79 (setq nndir-server-alist (delq state nndir-server-alist)))
80 (nnheader-set-init-variables nndir-server-variables defs))
81 (or (assq 'nndir-directory defs)
82 (setq nndir-directory server)))
83 (setq nndir-current-server server)))
85 (defun nndir-close-server (&optional server)
88 (defun nndir-server-opened (&optional server)
89 (and nntp-server-buffer
90 (get-buffer nntp-server-buffer)
92 (equal nndir-current-server server)))
94 (defun nndir-status-message (&optional server)
97 (defun nndir-request-article (id &optional group server buffer)
98 (nndir-execute-nnmh-command
99 (` (nnmh-request-article (, id) (, group) (, server) (, buffer)))))
101 (defun nndir-request-group (group &optional server dont-check)
102 (nndir-execute-nnmh-command
103 (` (nnmh-request-group (, group) "" (, dont-check)))))
105 (defun nndir-request-list (&optional server dir)
106 (nndir-execute-nnmh-command
107 (` (nnmh-request-list nil (, dir)))))
109 (defun nndir-request-newgroups (date &optional server)
110 (nndir-execute-nnmh-command
111 (` (nnmh-request-newgroups (, date) (, server)))))
113 (defun nndir-request-post (&optional server)
114 (mail-send-and-exit nil))
116 (defalias 'nndir-request-post-buffer 'nnmail-request-post-buffer)
118 (defun nndir-request-expire-articles
119 (articles group &optional server force)
120 (nndir-execute-nnmh-command
121 (` (nnmh-request-expire-articles (, articles) (, group)
122 (, server) (, force)))))
124 (defun nndir-request-accept-article (group &optional last)
125 (nndir-execute-nnmh-command
126 (` (nnmh-request-accept-article (, group) (, last)))))
128 (defun nndir-close-group (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 (expand-file-name nndir-directory)))
147 (and (string-match "/$" dir)
148 (setq dir (substring dir 0 (match-beginning 0))))
149 (string-match "/[^/]+$" dir)
150 (let ((group (substring dir (1+ (match-beginning 0))))
151 (nnmh-directory (substring dir 0 (1+ (match-beginning 0))))
152 (nnmh-get-new-mail nil))
155 (defun nndir-execute-nnml-command (command)
156 (let ((dir (expand-file-name nndir-directory)))
157 (and (string-match "/$" dir)
158 (setq dir (substring dir 0 (match-beginning 0))))
159 (string-match "/[^/]+$" dir)
160 (let ((group (substring dir (1+ (match-beginning 0))))
161 (nnml-directory (substring dir 0 (1+ (match-beginning 0))))
162 (nnml-nov-is-evil nndir-nov-is-evil)
163 (nnml-get-new-mail nil))
168 ;;; nndir.el ends here