-;;; nneething.el --- random file access for Gnus
-;; Copyright (C) 1995,96 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, 2009, 2010 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
+;; 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)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; 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, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;;; 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 'mailcap)
(require 'nnheader)
(require 'nnmail)
-(eval-when-compile (require 'cl))
+(require 'nnoo)
+(require 'gnus-util)
-(defvar nneething-map-file-directory "~/.nneething/"
- "*Where nneething stores the map files.")
+(nnoo-declare nneething)
-(defvar nneething-map-file ".nneething"
- "*Name of the map files.")
+(defvoo nneething-map-file-directory
+ (nnheader-concat gnus-directory ".nneething/")
+ "Where nneething stores the map files.")
-(defvar nneething-exclude-files nil
- "*Regexp saying what files to exclude from the group.
+(defvoo nneething-map-file ".nneething"
+ "Name of the map files.")
+
+(defvoo nneething-exclude-files nil
+ "Regexp saying what files to exclude from the group.
If this variable is nil, no files will be excluded.")
+(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.
+;;; 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 "")
-(defvar nneething-message-id-number 0)
-(defvar nneething-work-buffer " *nneething work*")
+(defvoo nneething-work-buffer " *nneething work*")
-\f
-
-(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
- `((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 (articles &optional group server fetch-old)
+(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)
+ (with-current-buffer nntp-server-buffer
(erase-buffer)
(let* ((number (length articles))
(count 0)
(when (and (file-exists-p file)
(or (file-directory-p file)
- (not (zerop (nth 7 (file-attributes file))))))
+ (not (zerop (nnheader-file-size file)))))
(insert (format "221 %d Article retrieved.\n" article))
(nneething-insert-head file)
(insert ".\n"))
(and large
(zerop (% count 20))
- (message "nneething: Receiving headers... %d%%"
- (/ (* count 100) number))))
+ (nnheader-message 5 "nneething: Receiving headers... %d%%"
+ (/ (* count 100) number))))
(when large
- (message "nneething: Receiving headers...done"))
+ (nnheader-message 5 "nneething: Receiving headers...done"))
(nnheader-fold-continuation-lines)
'headers))))
-(defun nneething-open-server (server &optional defs)
- (nnheader-report 'nneething "")
- (nnheader-init-server-buffer))
-
-(defun nneething-close-server (&optional server)
- (setq nneething-current-directory nil)
- t)
-
-(defun nneething-server-opened (&optional server)
- nneething-current-directory)
-
-(defun nneething-status-message (&optional server)
- nneething-status-string)
-
-(defun nneething-request-article (id &optional group server buffer)
+(deffoo nneething-request-article (id &optional group server buffer)
(nneething-possibly-change-directory group)
- (let ((file (unless (stringp id) (nneething-file-name id)))
+ (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 "\n")))
+ (let ((nnmail-file-coding-system 'binary))
+ (nnmail-find-file file)) ; Insert the file in the nntp buf.
+ (unless (nnheader-article-p) ; Either it's a real article...
+ (let ((type
+ (unless (file-directory-p file)
+ (or (cdr (assoc (concat "." (file-name-extension file))
+ mailcap-mime-extensions))
+