-;;; nneething.el --- random file access for Gnus
-;; Copyright (C) 1995 Free Software Foundation, Inc.
+;;; nneething.el --- arbitrary file access for Gnus
-;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
-;; Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
+;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
+;; 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+
+;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
+;; Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
;; Keywords: news, mail
;; This file is part of GNU Emacs.
;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
+;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING. If not, write to
-;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+;; along with GNU Emacs; see the file COPYING. If not, write to the
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
;;; Commentary:
-;; Based on nnspool.el by Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>.
-;; For an overview of what the interface functions do, please see the
-;; Gnus sources.
-
;;; Code:
+(eval-when-compile (require 'cl))
+
(require 'nnheader)
(require 'nnmail)
+(require 'nnoo)
+(require 'gnus-util)
+
+(nnoo-declare nneething)
+
+(defvoo nneething-map-file-directory
+ (nnheader-concat gnus-directory ".nneething/")
+ "Where nneething stores the map files.")
-(defvar nneething-map-file-directory "~/.nneething/"
- "*Map files directory.")
+(defvoo nneething-map-file ".nneething"
+ "Name of the map files.")
-(defvar nneething-exclude-files "~$"
- "*Regexp saying what files to exclude from the group.")
+(defvoo nneething-exclude-files nil
+ "Regexp saying what files to exclude from the group.
+If this variable is nil, no files will be excluded.")
-(defvar nneething-map-file ".nneething"
- "*Name of map files.")
+(defvoo nneething-include-files nil
+ "Regexp saying what files to include in the group.
+If this variable is non-nil, only files matching this regexp will be
+included.")
\f
+;;; Internal variables.
+
(defconst nneething-version "nneething 1.0"
"nneething version.")
-(defvar nneething-current-directory nil
+(defvoo nneething-current-directory nil
"Current news group directory.")
-(defvar nneething-status-string "")
-(defvar nneething-group-alist nil)
+(defvoo nneething-status-string "")
-\f
+(defvoo nneething-work-buffer " *nneething work*")
-(defvar nneething-directory nil)
-(defvar nneething-group nil)
-(defvar nneething-map nil)
-(defvar nneething-read-only nil)
-(defvar nneething-active nil)
-(defvar nneething-server-variables
- (list
- (list 'nneething-directory nneething-directory)
- '(nneething-current-directory nil)
- '(nneething-status-string "")
- '(nneething-group-alist)))
+(defvoo nneething-group nil)
+(defvoo nneething-map nil)
+(defvoo nneething-read-only nil)
+(defvoo nneething-active nil)
+(defvoo nneething-address nil)
\f
;;; Interface functions.
-(defun nneething-retrieve-headers (sequence &optional newsgroup server fetch-old)
- (nneething-possibly-change-directory newsgroup)
+(nnoo-define-basics nneething)
+
+(deffoo nneething-retrieve-headers (articles &optional group server fetch-old)
+ (nneething-possibly-change-directory group)
(save-excursion
(set-buffer nntp-server-buffer)
(erase-buffer)
- (let* ((number (length sequence))
+ (let* ((number (length articles))
(count 0)
(large (and (numberp nnmail-large-newsgroup)
(> number nnmail-large-newsgroup)))
article file)
- (if (stringp (car sequence))
+ (if (stringp (car articles))
'headers
- (while sequence
- (setq article (car sequence))
+ (while (setq article (pop articles))
(setq file (nneething-file-name article))
- (if (and (file-exists-p file)
- (not (zerop (nth 7 (file-attributes file)))))
- (progn
- (insert (format "221 %d Article retrieved.\n" article))
- (nneething-insert-head file)
- (insert ".\n")))
+ (when (and (file-exists-p file)
+ (or (file-directory-p file)
+ (not (zerop (nnheader-file-size file)))))
+ (insert (format "221 %d Article retrieved.\n" article))
+ (nneething-insert-head file)
+ (insert ".\n"))
- (setq sequence (cdr sequence)
- count (1+ count))
+ (incf count)
(and large
(zerop (% count 20))
- (message "nneething: Receiving headers... %d%%"
- (/ (* count 100) number))))
+ (nnheader-message 5 "nneething: Receiving headers... %d%%"
+ (/ (* count 100) number))))
- (and large (message "nneething: Receiving headers...done"))
+ (when large
+ (nnheader-message 5 "nneething: Receiving headers...done"))
- ;; Fold continuation lines.
- (goto-char (point-min))
- (while (re-search-forward "\\(\r?\n[ \t]+\\)+" nil t)
- (replace-match " " t t))
+ (nnheader-fold-continuation-lines)
'headers))))
-(defun nneething-open-server (server &optional defs)
- (setq nneething-status-string "")
- (nnheader-init-server-buffer))
-
-(defun nneething-close-server (&optional server)
- t)
-
-(defun nneething-server-opened (&optional server)
- t)
-
-(defun nneething-status-message (&optional server)
- nneething-status-string)
-
-(defun nneething-request-article (id &optional newsgroup server buffer)
- (nneething-possibly-change-directory newsgroup)
- (let ((file (if (stringp id) nil (nneething-file-name id)))
+(deffoo nneething-request-article (id &optional group server buffer)
+ (nneething-possibly-change-directory group)
+ (let ((file (unless (stringp id)
+ (nneething-file-name id)))
(nntp-server-buffer (or buffer nntp-server-buffer)))
- (and (stringp file) ; We did not request by Message-ID.
+ (and (stringp file) ; We did not request by Message-ID.
(file-exists-p file) ; The file exists.
(not (file-directory-p file)) ; It's not a dir.
(save-excursion
- (nnmail-find-file file) ; Insert the file in the nntp buf.
- (or (nnheader-article-p) ; Either it's a real article...
- (progn
- (goto-char (point-min))
- (nneething-make-head file) ; ... or we fake some headers.
- (insert &q