Mercurial > emacs
annotate lisp/gnus/gnus-bcklg.el @ 19860:c17fd465ea95 libc-970911 libc-970912 libc-970913 libc-970914 libc-970915 libc-970916 libc-970917 libc-970918 libc-970919 libc-970920 libc-970921 libc-970922 libc-970923 libc-970924 libc-970925 libc-970926 libc-970927 libc-970928 libc-970929 libc-970930 libc-971001 libc-971018 libc-971019 libc-971020 libc-971021 libc-971022 libc-971023 libc-971024 libc-971025 libc-971026 libc-971027 libc-971028 libc-971029 libc-971030 libc-971031 libc-971101 libc-971102 libc-971103 libc-971104 libc-971105 libc-971106 libc-971107 libc-971108 libc-971109 libc-971110 libc-971111 libc-971112 libc-971113 libc-971114 libc-971115 libc-971116 libc-971117 libc-971118 libc-971120 libc-971121 libc-971122 libc-971123 libc-971124 libc-971125 libc-971126 libc-971127 libc-971128 libc-971129 libc-971130 libc-971201 libc-971203 libc-971204 libc-971205 libc-971206 libc-971207 libc-971208 libc-971209 libc-971210 libc-971211 libc-971212 libc-971213 libc-971214 libc-971217 libc-971218 libc-971219 libc-971220 libc-971221 libc-971222 libc-971223 libc-971224 libc-971225 libc-971226 libc-971227 libc-971228 libc-971229 libc-971230 libc-971231 libc-980103 libc-980104 libc-980105 libc-980106 libc-980107 libc-980108 libc-980109 libc-980110 libc-980111 libc-980112 libc-980114 libc-980115 libc-980116 libc-980117 libc-980118 libc-980119 libc-980120 libc-980121 libc-980122 libc-980123 libc-980124 libc-980125 libc-980126 libc-980127 libc-980128
typos.
author | Jeff Law <law@redhat.com> |
---|---|
date | Wed, 10 Sep 1997 21:16:20 +0000 |
parents | 8d840c4548c0 |
children | 15fc6acbae7a |
rev | line source |
---|---|
17493 | 1 ;;; gnus-bcklg.el --- backlog functions for Gnus |
2 ;; Copyright (C) 1996,97 Free Software Foundation, Inc. | |
3 | |
4 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no> | |
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 | |
44 (set-buffer (get-buffer-create gnus-backlog-buffer)) | |
45 (buffer-disable-undo (current-buffer)) | |
46 (setq buffer-read-only t) | |
47 (gnus-add-current-to-buffer-list) | |
48 (get-buffer gnus-backlog-buffer)))) | |
49 | |
50 (defun gnus-backlog-setup () | |
51 "Initialize backlog variables." | |
52 (unless gnus-backlog-hashtb | |
53 (setq gnus-backlog-hashtb (gnus-make-hashtable 1024)))) | |
54 | |
55 (gnus-add-shutdown 'gnus-backlog-shutdown 'gnus) | |
56 | |
57 (defun gnus-backlog-shutdown () | |
58 "Clear all backlog variables and buffers." | |
59 (when (get-buffer gnus-backlog-buffer) | |
60 (kill-buffer gnus-backlog-buffer)) | |
61 (setq gnus-backlog-hashtb nil | |
62 gnus-backlog-articles nil)) | |
63 | |
64 (defun gnus-backlog-enter-article (group number buffer) | |
65 (gnus-backlog-setup) | |
66 (let ((ident (intern (concat group ":" (int-to-string number)) | |
67 gnus-backlog-hashtb)) | |
68 b) | |
69 (if (memq ident gnus-backlog-articles) | |
70 () ; It's already kept. | |
71 ;; Remove the oldest article, if necessary. | |
72 (and (numberp gnus-keep-backlog) | |
73 (>= (length gnus-backlog-articles) gnus-keep-backlog) | |
74 (gnus-backlog-remove-oldest-article)) | |
75 (push ident gnus-backlog-articles) | |
76 ;; Insert the new article. | |
77 (save-excursion | |
78 (set-buffer (gnus-backlog-buffer)) | |
79 (let (buffer-read-only) | |
80 (goto-char (point-max)) | |
81 (unless (bolp) | |
82 (insert "\n")) | |
83 (setq b (point)) | |
84 (insert-buffer-substring buffer) | |
85 ;; Tag the beginning of the article with the ident. | |
86 (gnus-put-text-property b (1+ b) 'gnus-backlog ident)))))) | |
87 | |
88 (defun gnus-backlog-remove-oldest-article () | |
89 (save-excursion | |
90 (set-buffer (gnus-backlog-buffer)) | |
91 (goto-char (point-min)) | |
92 (if (zerop (buffer-size)) | |
93 () ; The buffer is empty. | |
94 (let ((ident (get-text-property (point) 'gnus-backlog)) | |
95 buffer-read-only) | |
96 ;; Remove the ident from the list of articles. | |
97 (when ident | |
98 (setq gnus-backlog-articles (delq ident gnus-backlog-articles))) | |
99 ;; Delete the article itself. | |
100 (delete-region | |
101 (point) (next-single-property-change | |
102 (1+ (point)) 'gnus-backlog nil (point-max))))))) | |
103 | |
104 (defun gnus-backlog-remove-article (group number) | |
105 "Remove article NUMBER in GROUP from the backlog." | |
106 (when (numberp number) | |
107 (gnus-backlog-setup) | |
108 (let ((ident (intern (concat group ":" (int-to-string number)) | |
109 gnus-backlog-hashtb)) | |
110 beg end) | |
111 (when (memq ident gnus-backlog-articles) | |
112 ;; It was in the backlog. | |
113 (save-excursion | |
114 (set-buffer (gnus-backlog-buffer)) | |
115 (let (buffer-read-only) | |
116 (when (setq beg (text-property-any | |
117 (point-min) (point-max) 'gnus-backlog | |
118 ident)) | |
119 ;; Find the end (i. e., the beginning of the next article). | |
120 (setq end | |
121 (next-single-property-change | |
122 (1+ beg) 'gnus-backlog (current-buffer) (point-max))) | |
123 (delete-region beg end) | |
124 ;; Return success. | |
125 t))))))) | |
126 | |
127 (defun gnus-backlog-request-article (group number buffer) | |
128 (when (numberp number) | |
129 (gnus-backlog-setup) | |
130 (let ((ident (intern (concat group ":" (int-to-string number)) | |
131 gnus-backlog-hashtb)) | |
132 beg end) | |
133 (when (memq ident gnus-backlog-articles) | |
134 ;; It was in the backlog. | |
135 (save-excursion | |
136 (set-buffer (gnus-backlog-buffer)) | |
137 (if (not (setq beg (text-property-any | |
138 (point-min) (point-max) 'gnus-backlog | |
139 ident))) | |
140 ;; It wasn't in the backlog after all. | |
141 (ignore | |
142 (setq gnus-backlog-articles (delq ident gnus-backlog-articles))) | |
143 ;; Find the end (i. e., the beginning of the next article). | |
144 (setq end | |
145 (next-single-property-change | |
146 (1+ beg) 'gnus-backlog (current-buffer) (point-max))))) | |
147 (let ((buffer-read-only nil)) | |
148 (erase-buffer) | |
149 (insert-buffer-substring gnus-backlog-buffer beg end) | |
150 t))))) | |
151 | |
152 (provide 'gnus-bcklg) | |
153 | |
154 ;;; gnus-bcklg.el ends here |