1 |
;;; gnus-bcklg.el --- backlog functions for Gnus |
;;; gnus-bcklg.el --- backlog functions for Gnus |
2 |
;; Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. |
;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003 |
3 |
|
;; Free Software Foundation, Inc. |
4 |
|
|
5 |
;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> |
;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> |
6 |
;; Keywords: news |
;; Keywords: news |
56 |
|
|
57 |
(defun gnus-backlog-shutdown () |
(defun gnus-backlog-shutdown () |
58 |
"Clear all backlog variables and buffers." |
"Clear all backlog variables and buffers." |
59 |
|
(interactive) |
60 |
(when (get-buffer gnus-backlog-buffer) |
(when (get-buffer gnus-backlog-buffer) |
61 |
(kill-buffer gnus-backlog-buffer)) |
(gnus-kill-buffer gnus-backlog-buffer)) |
62 |
(setq gnus-backlog-hashtb nil |
(setq gnus-backlog-hashtb nil |
63 |
gnus-backlog-articles nil)) |
gnus-backlog-articles nil)) |
64 |
|
|
65 |
(defun gnus-backlog-enter-article (group number buffer) |
(defun gnus-backlog-enter-article (group number buffer) |
66 |
(gnus-backlog-setup) |
(when (and (numberp number) |
67 |
(let ((ident (intern (concat group ":" (int-to-string number)) |
(not (string-match "^nnvirtual" group))) |
68 |
gnus-backlog-hashtb)) |
(gnus-backlog-setup) |
69 |
b) |
(let ((ident (intern (concat group ":" (int-to-string number)) |
70 |
(if (memq ident gnus-backlog-articles) |
gnus-backlog-hashtb)) |
71 |
() ; It's already kept. |
b) |
72 |
|
(if (memq ident gnus-backlog-articles) |
73 |
|
() ; It's already kept. |
74 |
;; Remove the oldest article, if necessary. |
;; Remove the oldest article, if necessary. |
75 |
(and (numberp gnus-keep-backlog) |
(and (numberp gnus-keep-backlog) |
76 |
(>= (length gnus-backlog-articles) gnus-keep-backlog) |
(>= (length gnus-backlog-articles) gnus-keep-backlog) |
77 |
(gnus-backlog-remove-oldest-article)) |
(gnus-backlog-remove-oldest-article)) |
78 |
(push ident gnus-backlog-articles) |
(push ident gnus-backlog-articles) |
79 |
;; Insert the new article. |
;; Insert the new article. |
80 |
(save-excursion |
(save-excursion |
81 |
(set-buffer (gnus-backlog-buffer)) |
(set-buffer (gnus-backlog-buffer)) |
82 |
(let (buffer-read-only) |
(let (buffer-read-only) |
83 |
(goto-char (point-max)) |
(goto-char (point-max)) |
84 |
(unless (bolp) |
(unless (bolp) |
85 |
(insert "\n")) |
(insert "\n")) |
86 |
(setq b (point)) |
(setq b (point)) |
87 |
(insert-buffer-substring buffer) |
(insert-buffer-substring buffer) |
88 |
;; Tag the beginning of the article with the ident. |
;; Tag the beginning of the article with the ident. |
89 |
(if (> (point-max) b) |
(if (> (point-max) b) |
90 |
(gnus-put-text-property b (1+ b) 'gnus-backlog ident) |
(gnus-put-text-property b (1+ b) 'gnus-backlog ident) |
91 |
(gnus-error 3 "Article %d is blank" number))))))) |
(gnus-error 3 "Article %d is blank" number)))))))) |
92 |
|
|
93 |
(defun gnus-backlog-remove-oldest-article () |
(defun gnus-backlog-remove-oldest-article () |
94 |
(save-excursion |
(save-excursion |
131 |
(setq gnus-backlog-articles (delq ident gnus-backlog-articles))))))) |
(setq gnus-backlog-articles (delq ident gnus-backlog-articles))))))) |
132 |
|
|
133 |
(defun gnus-backlog-request-article (group number &optional buffer) |
(defun gnus-backlog-request-article (group number &optional buffer) |
134 |
(when (numberp number) |
(when (and (numberp number) |
135 |
|
(not (string-match "^nnvirtual" group))) |
136 |
(gnus-backlog-setup) |
(gnus-backlog-setup) |
137 |
(let ((ident (intern (concat group ":" (int-to-string number)) |
(let ((ident (intern (concat group ":" (int-to-string number)) |
138 |
gnus-backlog-hashtb)) |
gnus-backlog-hashtb)) |