;;; nnkiboze.el --- select virtual news access for Gnus
-;; Copyright (C) 1995,96 Free Software Foundation, Inc.
-;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
+;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2002
+;; Free Software Foundation, Inc.
+
+;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
;; Keywords: news
;; This file is part of GNU Emacs.
;;; Commentary:
;; The other access methods (nntp, nnspool, etc) are general news
-;; access methods. This module relies on Gnus and can not be used
+;; access methods. This module relies on Gnus and can't be used
;; separately.
;;; Code:
(require 'gnus)
(require 'gnus-score)
(require 'nnoo)
+(require 'mm-util)
(eval-when-compile (require 'cl))
(nnoo-declare nnkiboze)
-(defvoo nnkiboze-directory gnus-directory
+(defvoo nnkiboze-directory (nnheader-concat gnus-directory "kiboze/")
"nnkiboze will put its files in this directory.")
(defvoo nnkiboze-level 9
- "*The maximum level to be searched for articles.")
+ "The maximum level to be searched for articles.")
(defvoo nnkiboze-remove-read-articles t
- "*If non-nil, nnkiboze will remove read articles from the kiboze group.")
+ "If non-nil, nnkiboze will remove read articles from the kiboze group.")
+
+(defvoo nnkiboze-ephemeral nil
+ "If non-nil, don't store any data anywhere.")
+
+(defvoo nnkiboze-scores nil
+ "Score rules for generating the nnkiboze group.")
+
+(defvoo nnkiboze-regexp nil
+ "Regexp for matching component groups.")
+
+(defvoo nnkiboze-file-coding-system mm-text-coding-system
+ "Coding system for nnkiboze files.")
\f
-(defconst nnkiboze-version "nnkiboze 1.0"
- "Version numbers of this version of nnkiboze.")
+(defconst nnkiboze-version "nnkiboze 1.0")
(defvoo nnkiboze-current-group nil)
-(defvoo nnkiboze-current-score-group "")
(defvoo nnkiboze-status-string "")
+(defvoo nnkiboze-headers nil)
+
\f
;;; Interface functions.
(nnoo-define-basics nnkiboze)
(deffoo nnkiboze-retrieve-headers (articles &optional group server fetch-old)
- (nnkiboze-possibly-change-newsgroups group)
- (if gnus-nov-is-evil
- nil
+ (nnkiboze-possibly-change-group group)
+ (unless gnus-nov-is-evil
(if (stringp (car articles))
'headers
- (let ((first (car articles))
- (last (progn (while (cdr articles) (setq articles (cdr articles)))
- (car articles)))
- (nov (nnkiboze-nov-file-name)))
- (if (file-exists-p nov)
- (save-excursion
- (set-buffer nntp-server-buffer)
- (erase-buffer)
- (insert-file-contents nov)
- (goto-char (point-min))
- (while (and (not (eobp)) (< first (read (current-buffer))))
- (forward-line 1))
- (beginning-of-line)
- (if (not (eobp)) (delete-region 1 (point)))
- (while (and (not (eobp)) (>= last (read (current-buffer))))
- (forward-line 1))
- (beginning-of-line)
- (if (not (eobp)) (delete-region (point) (point-max)))
- 'nov))))))
-
-(deffoo nnkiboze-open-server (newsgroups &optional something)
- (make-directory nnkiboze-directory t)
- (nnheader-init-server-buffer))
-
-(deffoo nnkiboze-server-opened (&optional server)
- (and nntp-server-buffer
- (get-buffer nntp-server-buffer)))
+ (let ((nov (nnkiboze-nov-file-name)))
+ (when (file-exists-p nov)
+ (save-excursion
+ (set-buffer nntp-server-buffer)
+ (erase-buffer)
+ (let ((nnheader-file-coding-system nnkiboze-file-coding-system))
+ (nnheader-insert-file-contents nov))
+ (nnheader-nov-delete-outside-range
+ (car articles) (car (last articles)))
+ 'nov))))))
(deffoo nnkiboze-request-article (article &optional newsgroup server buffer)
- (nnkiboze-possibly-change-newsgroups newsgroup)
+ (nnkiboze-possibly-change-group newsgroup)
(if (not (numberp article))
- ;; This is a real kludge. It might not work at times, but it
- ;; does no harm I think. The only alternative is to offer no
+ ;; This is a real kludge. It might not work at times, but it
+ ;; does no harm I think. The only alternative is to offer no
;; article fetching by message-id at all.
(nntp-request-article article newsgroup gnus-nntp-server buffer)
(let* ((header (gnus-summary-article-header article))
(xref (mail-header-xref header))
- igroup iarticle)
- (or xref (error "nnkiboze: No xref"))
- (or (string-match " \\([^ ]+\\):\\([0-9]+\\)" xref)
- (error "nnkiboze: Malformed xref"))
- (setq igroup (substring xref (match-beginning 1) (match-end 1)))
- (setq iarticle (string-to-int
- (substring xref (match-beginning 2) (match-end 2))))
- (and (gnus-request-group igroup t)
- (gnus-request-article iarticle igroup buffer)))))
+ num group)
+ (unless xref
+ (error "nnkiboze: No xref"))
+ (unless (string-match " \\([^ ]+\\):\\([0-9]+\\)" xref)
+ (error "nnkiboze: Malformed xref"))
+ (setq num (string-to-int (match-string 2 xref))
+ group (match-string 1 xref))
+ (or (with-current-buffer buffer
+ (or (gnus-cache-request-article num group)
+ (gnus-agent-request-article num group)))
+ (gnus-request-article num group buffer)))))
+
+(deffoo nnkiboze-request-scan (&optional group server)
+ (nnkiboze-possibly-change-group group)
+ (nnkiboze-generate-group (concat "nnkiboze:" group)))
(deffoo nnkiboze-request-group (group &optional server dont-check)
"Make GROUP the current newsgroup."
- (nnkiboze-possibly-change-newsgroups group)
+ (nnkiboze-possibly-change-group group)
(if dont-check
- ()
+ t
(let ((nov-file (nnkiboze-nov-file-name))
beg end total)
(save-excursion
(set-buffer nntp-server-buffer)
(erase-buffer)
+ (unless (file-exists-p nov-file)
+ (nnkiboze-request-scan group))
(if (not (file-exists-p nov-file))
- (insert (format "211 0 0 0 %s\n" group))
- (insert-file-contents nov-file)
+ (nnheader-report 'nnkiboze "Can't select group %s" group)
+ (let ((nnheader-file-coding-system nnkiboze-file-coding-system))
+ (nnheader-insert-file-contents nov-file))
(if (zerop (buffer-size))
- (insert (format "211 0 0 0 %s\n" group))
+ (nnheader-insert "211 0 0 0 %s\n" group)
(goto-char (point-min))
- (and (looking-at "[0-9]+") (setq beg (read (current-buffer))))
+ (when (looking-at "[0-9]+")
+ (setq beg (read (current-buffer))))
(goto-char (point-max))
- (and (re-search-backward "^[0-9]" nil t)
- (setq end (read (current-buffer))))
+ &nb