;;; nnkiboze.el --- select virtual news access for Gnus
-;; Copyright (C) 1995,96,97,98 Free Software Foundation, Inc.
+;; Copyright (C) 1995,96,97,98,99 Free Software Foundation, Inc.
-;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
+;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
;; Keywords: news
;; This file is part of GNU Emacs.
(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))
(nnheader-report 'nnkiboze "Can't select group %s" group)
(nnheader-insert-file-contents nov-file)
;; Remove NOV lines of articles that are marked as read.
(when (and (file-exists-p (nnkiboze-nov-file-name))
nnkiboze-remove-read-articles)
- (nnheader-temp-write (nnkiboze-nov-file-name)
+ (with-temp-file (nnkiboze-nov-file-name)
(let ((cur (current-buffer)))
(nnheader-insert-file-contents (nnkiboze-nov-file-name))
(goto-char (point-min))
(let ((files (nconc
(nnkiboze-score-file group)
(list (nnkiboze-nov-file-name)
- (concat nnkiboze-directory
- (nnheader-translate-file-chars
- (concat group ".newsrc")))))))
+ (nnkiboze-nov-file-name ".newsrc")))))
(while files
(and (file-exists-p (car files))
(file-writable-p (car files))
;;;###autoload
(defun nnkiboze-generate-groups ()
- "Usage: emacs -batch -l nnkiboze -f nnkiboze-generate-groups
+ "\"Usage: emacs -batch -l nnkiboze -f nnkiboze-generate-groups\".
Finds out what articles are to be part of the nnkiboze groups."
(interactive)
(let ((nnmail-spool-file nil)
(defun nnkiboze-generate-group (group)
(let* ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
- (newsrc-file (concat nnkiboze-directory
+ (newsrc-file (concat nnkiboze-directory
(nnheader-translate-file-chars
(concat group ".newsrc"))))
(nov-file (concat nnkiboze-directory
(gnus-verbose (min gnus-verbose 3))
gnus-select-group-hook gnus-summary-prepare-hook
gnus-thread-sort-functions gnus-show-threads
- gnus-visual gnus-suppress-duplicates)
+ gnus-visual gnus-suppress-duplicates num-unread)
(unless info
(error "No such group: %s" group))
;; Load the kiboze newsrc file for this group.
(when (file-exists-p newsrc-file)
(load newsrc-file))
- (nnheader-temp-write nov-file
+ (with-temp-file nov-file
(when (file-exists-p nov-file)
(insert-file-contents nov-file))
(setq nov-buffer (current-buffer))
(gnus-group-jump-to-group (caar newsrc))
(gnus-message 3 "nnkiboze: Checking %s..." (caar newsrc))
(setq ginfo (gnus-get-info (gnus-group-group-name))
- orig-info (gnus-copy-sequence ginfo))
+ orig-info (gnus-copy-sequence ginfo)
+ num-unread (car (gnus-gethash (caar newsrc)
+ gnus-newsrc-hashtb)))
(unwind-protect
(progn
;; We set all list of article marks to nil. Since we operate
(car ginfo)))
0))
(progn
- (ignore-errors
+ (ignore-errors
(gnus-group-select-group nil))
(eq major-mode 'gnus-summary-mode)))
;; We are now in the group where we want to be.
gnus-newsgroup-name))
(setq gnus-newsgroup-scored (cdr gnus-newsgroup-scored)))
;; That's it. We exit this group.
- (gnus-summary-exit-no-update)))
+ (when (eq major-mode 'gnus-summary-mode)
+ (kill-buffer (current-buffer)))))
;; Restore the proper info.
(when ginfo
- (setcdr ginfo (cdr orig-info)))))
+ (setcdr ginfo (cdr orig-info)))
+ (setcar (gnus-gethash (caar newsrc) gnus-newsrc-hashtb)
+ num-unread)))
(setcdr (car newsrc) (car active))
(gnus-message 3 "nnkiboze: Checking %s...done" (caar newsrc))
(setq newsrc (cdr newsrc))))
;; We save the kiboze newsrc for this group.
- (nnheader-temp-write newsrc-file
+ (with-temp-file newsrc-file
(insert "(setq nnkiboze-newsrc '")
(gnus-prin1 nnkiboze-newsrc)
- (insert ")\n"))
- t))
+ (insert ")\n")))
+ (save-excursion
+ (set-buffer gnus-group-buffer)
+ (gnus-group-list-groups))
+ t)
(defun nnkiboze-enter-nov (buffer header group)
(save-excursion
(set-buffer buffer)
(goto-char (point-max))
- (let ((xref (mail-header-xref header))
- (prefix (gnus-group-real-prefix group))
+ (let ((prefix (gnus-group-real-prefix group))
(oheader (copy-sequence header))
- (first t)
article)
(if (zerop (forward-line -1))
(progn
;; The first Xref has to be the group this article
;; really came for - this is the article nnkiboze
;; will request when it is asked for the article.
- (insert group ":"
+ (insert " " group ":"
(int-to-string (mail-header-number header)) " ")
(while (re-search-forward " [^ ]+:[0-9]+" nil t)
(goto-char (1+ (match-beginning 0)))
(insert prefix)))))
-(defun nnkiboze-nov-file-name ()
+(defun nnkiboze-nov-file-name (&optional suffix)
(concat (file-name-as-directory nnkiboze-directory)
(nnheader-translate-file-chars
- (concat (nnkiboze-prefixed-name nnkiboze-current-group) ".nov"))))
+ (concat (nnkiboze-prefixed-name nnkiboze-current-group)
+ (or suffix ".nov")))))
(provide 'nnkiboze)