Mercurial > emacs
annotate lisp/gnus/gnus-bcklg.el @ 48800:4ba3749055f0
Fix URL.
author | Pavel Janík <Pavel@Janik.cz> |
---|---|
date | Wed, 11 Dec 2002 06:53:24 +0000 |
parents | 9968f55ad26e |
children | 695cf19ef79e d7ddb3e565de |
rev | line source |
---|---|
17493 | 1 ;;; gnus-bcklg.el --- backlog functions for Gnus |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. |
17493 | 3 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19493
diff
changeset
|
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> |
17493 | 5 ;; Keywords: news |
6 | |
7 ;; This file is part of GNU Emacs. | |
8 | |
9 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
10 ;; it under the terms of the GNU General Public License as published by | |
11 ;; the Free Software Foundation; either version 2, or (at your option) | |
12 ;; any later version. | |
13 | |
14 ;; GNU Emacs is distributed in the hope that it will be useful, | |
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 ;; GNU General Public License for more details. | |
18 | |
19 ;; You should have received a copy of the GNU General Public License | |
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
22 ;; Boston, MA 02111-1307, USA. | |
23 | |
24 ;;; Commentary: | |
25 | |
26 ;;; Code: | |
27 | |
19493
8d840c4548c0
Require cl at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
17493
diff
changeset
|
28 (eval-when-compile (require 'cl)) |
8d840c4548c0
Require cl at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
17493
diff
changeset
|
29 |
17493 | 30 (require 'gnus) |
31 | |
32 ;;; | |
33 ;;; Buffering of read articles. | |
34 ;;; | |
35 | |
36 (defvar gnus-backlog-buffer " *Gnus Backlog*") | |
37 (defvar gnus-backlog-articles nil) | |
38 (defvar gnus-backlog-hashtb nil) | |
39 | |
40 (defun gnus-backlog-buffer () | |
41 "Return the backlog buffer." | |
42 (or (get-buffer gnus-backlog-buffer) | |
43 (save-excursion | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19493
diff
changeset
|
44 (set-buffer (gnus-get-buffer-create gnus-backlog-buffer)) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
45 (buffer-disable-undo) |
17493 | 46 (setq buffer-read-only t) |
47 (get-buffer gnus-backlog-buffer)))) | |
48 | |
49 (defun gnus-backlog-setup () | |
50 "Initialize backlog variables." | |
51 (unless gnus-backlog-hashtb | |
52 (setq gnus-backlog-hashtb (gnus-make-hashtable 1024)))) | |
53 | |
54 (gnus-add-shutdown 'gnus-backlog-shutdown 'gnus) | |
55 | |
56 (defun gnus-backlog-shutdown () | |
57 "Clear all backlog variables and buffers." | |
58 (when (get-buffer gnus-backlog-buffer) | |
59 (kill-buffer gnus-backlog-buffer)) | |
60 (setq gnus-backlog-hashtb nil | |
61 gnus-backlog-articles nil)) | |
62 | |
63 (defun gnus-backlog-enter-article (group number buffer) | |
64 (gnus-backlog-setup) | |
65 (let ((ident (intern (concat group ":" (int-to-string number)) | |
66 gnus-backlog-hashtb)) | |
67 b) | |
68 (if (memq ident gnus-backlog-articles) | |
69 () ; It's already kept. | |
70 ;; Remove the oldest article, if necessary. | |
71 (and (numberp gnus-keep-backlog) | |
72 (>= (length gnus-backlog-articles) gnus-keep-backlog) | |
73 (gnus-backlog-remove-oldest-article)) | |
74 (push ident gnus-backlog-articles) | |
75 ;; Insert the new article. | |
76 (save-excursion | |
77 (set-buffer (gnus-backlog-buffer)) | |
78 (let (buffer-read-only) | |
79 (goto-char (point-max)) | |
80 (unless (bolp) | |
81 (insert "\n")) | |
82 (setq b (point)) | |
83 (insert-buffer-substring buffer) | |
84 ;; Tag the beginning of the article with the ident. | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
85 (if (> (point-max) b) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
86 (gnus-put-text-property b (1+ b) 'gnus-backlog ident) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
87 (gnus-error 3 "Article %d is blank" number))))))) |
17493 | 88 |
89 (defun gnus-backlog-remove-oldest-article () | |
90 (save-excursion | |
91 (set-buffer (gnus-backlog-buffer)) | |
92 (goto-char (point-min)) | |
93 (if (zerop (buffer-size)) | |
94 () ; The buffer is empty. | |
95 (let ((ident (get-text-property (point) 'gnus-backlog)) | |
96 buffer-read-only) | |
97 ;; Remove the ident from the list of articles. | |
98 (when ident | |
99 (setq gnus-backlog-articles (delq ident gnus-backlog-articles))) | |
100 ;; Delete the article itself. | |
101 (delete-region | |
102 (point) (next-single-property-change | |
103 (1+ (point)) 'gnus-backlog nil (point-max))))))) | |
104 | |
105 (defun gnus-backlog-remove-article (group number) | |
106 "Remove article NUMBER in GROUP from the backlog." | |
107 (when (numberp number) | |
108 (gnus-backlog-setup) | |
109 (let ((ident (intern (concat group ":" (int-to-string number)) | |
110 gnus-backlog-hashtb)) | |
111 beg end) | |
112 (when (memq ident gnus-backlog-articles) | |
113 ;; It was in the backlog. | |
114 (save-excursion | |
115 (set-buffer (gnus-backlog-buffer)) | |
116 (let (buffer-read-only) | |
117 (when (setq beg (text-property-any | |
118 (point-min) (point-max) 'gnus-backlog | |
119 ident)) | |
120 ;; Find the end (i. e., the beginning of the next article). | |
121 (setq end | |
122 (next-single-property-change | |
123 (1+ beg) 'gnus-backlog (current-buffer) (point-max))) | |
124 (delete-region beg end) | |
125 ;; Return success. | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19493
diff
changeset
|
126 t)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19493
diff
changeset
|
127 (setq gnus-backlog-articles (delq ident gnus-backlog-articles))))))) |
17493 | 128 |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
129 (defun gnus-backlog-request-article (group number &optional buffer) |
17493 | 130 (when (numberp number) |
131 (gnus-backlog-setup) | |
132 (let ((ident (intern (concat group ":" (int-to-string number)) | |
133 gnus-backlog-hashtb)) | |
134 beg end) | |
135 (when (memq ident gnus-backlog-articles) | |
136 ;; It was in the backlog. | |
137 (save-excursion | |
138 (set-buffer (gnus-backlog-buffer)) | |
139 (if (not (setq beg (text-property-any | |
140 (point-min) (point-max) 'gnus-backlog | |
141 ident))) | |
142 ;; It wasn't in the backlog after all. | |
143 (ignore | |
144 (setq gnus-backlog-articles (delq ident gnus-backlog-articles))) | |
145 ;; Find the end (i. e., the beginning of the next article). | |
146 (setq end | |
147 (next-single-property-change | |
148 (1+ beg) 'gnus-backlog (current-buffer) (point-max))))) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
149 (save-excursion |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
150 (and buffer (set-buffer buffer)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
151 (let ((buffer-read-only nil)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
152 (erase-buffer) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
153 (insert-buffer-substring gnus-backlog-buffer beg end))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
154 t)))) |
17493 | 155 |
156 (provide 'gnus-bcklg) | |
157 | |
158 ;;; gnus-bcklg.el ends here |