I'm sure somebody's done this already, but I chose to spend my
afternoon doing it again instead of surfing in search of somebody
else's code. What it is, is a mod to gnus to make it quicker over a
slow nntp connection. I'm using gnus-4.1, which queries the server
for *all* the active & newsgroup description data when it starts --
well over a megabyte from my provider. The code below just replaces
the gnus-request-list and gnus-request-list-newsgroups functions with
functions that only get new-news data for newsfroups in a local
.active file, or in your .newsrc. So if you trim your .active or
.newsrc to be just the set of groups you want, gnus is much quicker to
start up. The drawback is that you can't subscribe to new groups just
by jumping to them; you have to edit your .newsrc or .active so that
gnus retrieves the data. Maybe I'll make that easier some time (when
doing it the hard way it annoys me enough :-) Oh yeah, the function
request-list-newsgroups (to get the newsgroup descriptions) doesn't
do anything at all. I'd thought about doing something with a local
description file, but I already knew what groups I wanted to read, so
the descriptions were an unnecessary feeping creature.
d.
;;; gnooze.el --- mods to gnus to make reading news over a slow
;; nntp connection more pleasant
;;
;; Copyright (C) 1995 dave madden
;; Author: dave madden <d...@vheissu.iii.net>
;; Keywords: news slow nntp
;; gnooze 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.
;; gnooze is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; 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.
;;; Commentary:
;; You can activate gnooze by adding this line to your .emacs file:
;;
;; (autoload 'gnooze "gnooze" "Read network news over a slow connection." t)
;;
;; Then, instead of "M-x gnus", you should use "M-x gnooze" to start gnus.
;;; Code:
(require 'gnus)
(defvar gnooze-local-active "~/.active"
"Your local `.active' file. Uses `.active-SERVER' instead if it exists,
or simply takes the newsfroup names from gnus-startup-file if neither is
found.")
(defvar gnooze-local-newsgroups "~/.newsgroups"
"Your local `.newsgroups' file. Uses `.newsgroups-SERVER' instead if
it exists.")
(defun gnooze-setup ()
(fset 'gnus-request-list 'gnooze-request-list)
(fset 'gnus-request-list-newsgroups 'gnooze-request-list-newsgroups))
(defun gnooze (&optional confirm)
"Read network news over a slow connection. Doesn't do those time-consuming
queries for the full set of active groups and their group descriptions. You
only find out about groups in your .active, .active-server, or .newsrc files."
(interactive "P")
(add-hook 'gnus-open-server-hook 'gnooze-setup)
(gnus confirm))
(defun gnooze-request-list ()
"Get info about the newsfroups listed in a local active file. The nntp
server is only queried for status of those groups."
(let ((active-file (gnus-make-newsrc-file gnooze-local-active))
(newsfroup-file (gnus-make-newsrc-file gnus-startup-file))
(active-buffer (get-buffer-create " *active*")))
(save-excursion
(set-buffer active-buffer)
(erase-buffer)
;;
;; Get the local active file or read .newsrc and edit it so it
;; *looks* like an active file
;;
(if (file-readable-p active-file)
(insert-file-contents active-file)
(if (file-readable-p newsfroup-file)
(progn
(insert-file-contents newsfroup-file)
(goto-char (point-min))
(while (re-search-forward "[!:].*$" nil t)
(replace-match " 0 0 y")))))
;;
;; Replace the bogus article ID numbers with the numbers the server
;; really has...
;;
(gnus-start-news-server)
(goto-char (point-min))
(while (< (point) (point-max))
(let ((bol (point))
ng min-article max-article)
(skip-chars-forward "^ \n")
(setq min-article nil max-article nil)
(if (gnus-request-group (setq ng (buffer-substring bol (point))))
(progn
(save-excursion
(set-buffer nntp-server-buffer)
(goto-char (point-min))
(if (looking-at "[0-9]+\\s-+[0-9]+\\s-+\\([0-9]+\\)\\s-+\\([0-9]+\\)")
(setq min-article (buffer-substring
(match-beginning 1)
(match-end 1))
max-article (buffer-substring
(match-beginning 2)
(match-end 2))))))
(message (concat "Newsgroup \"" ng "\" not found")))
(or (and min-article max-article)
(setq min-article "1" max-article "1"))
(if (looking-at "\\s-+[0-9]+\\s-+[0-9]+")
(replace-match (concat " " max-article " 1" )))
(forward-line)))
(set-buffer nntp-server-buffer)
(erase-buffer)
(insert-buffer active-buffer))
t))
(defun gnooze-request-list-newsgroups ()
"Get newsgroup descriptions from a local newsgroups file (default
~/.newsgroup)"
(save-excursion
(set-buffer nntp-server-buffer)
(erase-buffer))
nil)
--
finger d...@vheissu.iii.net or d...@iii.net for pgp public key
- - -
key fingerprint = A3 CD FF 60 A7 62 81 BB 67 E3 EC 4A D3 22 DE 3B