gnu-emacs-sources
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

nnlater 0.1 -- Delay finding message IDs until you are plugged again


From: Michael Schierl
Subject: nnlater 0.1 -- Delay finding message IDs until you are plugged again
Date: Fri, 25 Jun 2004 22:06:31 +0200
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3.50 (windows-nt)

Hi,

after some testing: there are still bugs in it I cannot fix, but
since it is helpful (for me) I will post it anyway.

Michael

(Automatically generated with ges-post.el, version 0.6)

;;; nnlater.el --- Delay finding message IDs until you are plugged again

;; Copyright (C) 2004 Michael Schierl

;; Author: Michael Schierl <address@hidden>
;; Created: 14 March 2004
;; Keywords: gnus, message-id, unplugged
;; Version: 0.1

(defconst nnlater-version "0.1"
  "Version of nnlater.")

;; This file is not part of GNU Emacs.

;; This program 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.

;; This program 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, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.

;;; Commentary:

;; When you are reading news offline with Gnus agent (e.g. in a
;; train...) you might find someone refering to a Message-ID in a
;; post.  Howvery, you are offline and don't happen to have that
;; article in the Agent either (otherwise nnagtfind.el could help
;; you). So you will most probably forget to visit that Message-ID
;; later again.

;; nnlater.el will cache all these Message-IDs (in the
;; `nnlater-mid-cache' variable which is stored in your .newsrc.eld)
;; and fetch them the next time you are running
;; `gnus-agent-fetch-session' (`J s' by default.)

;;; Installation:

;; STEP 1:

;; (Auto)load this file and add (nnlater) somewhere into your
;; `gnus-refer-article-method' variable. If you use both nnagtfind.el
;; and nnlater.el, add nnagtfind first. In any case, nnlater should be
;; before any backends that require to be online (e.g. nntp backends).

;; example:

;; (setq gnus-refer-article-method
;;       '(current
;;         (nnagtfind)
;;         (nnlater)
;;         (nntp "news.individual.net")
;;         (nntp "news.gmane.org")
;;         (nnweb "google" (nnweb-type google))))

;; STEP 2:

;; Create a group called `nnfolder:fetched' and move at least one
;; article into it. Ensure that there will be always at least one
;; article there. (See Bugs). All fetched messages will be stored
;; there - so move it to the top of your group buffer to read them
;; first.

;;; Bugs:

;; - nnlater will not work if nnfolder:fetched is empty.

;; - sometimes you will hear a beep while such an article is fetched -
;;   no idea why.

;;; History:

;; 0.1   initial version

;;; Code:

(require 'gnus)

(defvar nnlater-mid-cache nil)
(add-to-list 'gnus-variable-list 'nnlater-mid-cache t)


(defun nnlater-search-for-article (id to-buffer)
  "Search for article ID and save a dummy into TO-BUFFER.
This will write a dummy article if Gnus is unplugged to prevent
other backends from searching the article."
  (if gnus-plugged
      nil
    (add-to-list 'nnlater-mid-cache id)
    (save-excursion
      (set-buffer (or to-buffer nntp-server-buffer))
      (erase-buffer)
      (insert (format "From: nnagent
Subject: %s Will be fetched later
Message-ID: %s

The article %s will be fetched later.

Current MID cache:

%S" id id id nnlater-mid-cache))
      (cons "dummy.group" 1))))

(defun nnlater-fetch-article (msgid)
  "Fetch article MSGID into the nnfolder:fetched folder."
  (unless (get-buffer "*Group*")
    (error "Gnus is not started"))
  (save-window-excursion
    (save-excursion
      (set-buffer (get-buffer "*Group*"))
      
      (gnus-group-jump-to-group "nnfolder:fetched") ; this folder must
                                        ; exist and have at least one
                                        ; article in it
      (gnus-group-select-group 0)
      (gnus-summary-refer-article msgid)
      (gnus-summary-mark-article nil gnus-unread-mark)
      (let ((gnus-preserve-marks nil))
        (gnus-summary-copy-article 1 "nnfolder:fetched") ; otherwise it is
                                        ; not saved
        )
      (gnus-summary-exit))))
  
(defadvice gnus-agent-fetch-session (before nnlater-gafs-advice activate)
  "Fetch the `nnlater-mid-cache' as well."
(unless gnus-plugged
    (error "Can't fetch articles while Gnus is unplugged"))
  (mapc 'nnlater-fetch-article nnlater-mid-cache)
  (setq nnlater-mid-cache nil))

;;; backend stuff:

(gnus-declare-backend "nnlater" 'none)

(defun nnlater-request-article (article &optional group server to-buffer)
  (nnlater-search-for-article article to-buffer))

(defun nnlater-retrieve-headers (articles &optional group server fetch-old)
  (error "Not implemented"))

(defun nnlater-status-message (&optional server)
  "")


(defun nnlater-ok (&rest args)
  t)

(defun nnlater-undefined (&rest args)
  (error "Not implemented"))

(defalias 'nnlater-open-server   'nnlater-ok)
(defalias 'nnlater-close-server  'nnlater-ok)
(defalias 'nnlater-request-close 'nnlater-ok)
(defalias 'nnlater-server-opened 'nnlater-ok)
(defalias 'nnlater-request-group 'nnlater-undefined)
(defalias 'nnlater-close-group   'nnlater-undefined)
(defalias 'nnlater-request-list  'nnlater-undefined)
(defalias 'nnlater-request-post  'nnlater-undefined)

(provide 'nnlater)

(provide 'nnlater)

;;; nnlater.el ends here


reply via email to

[Prev in Thread] Current Thread [Next in Thread]