Mercurial > emacs
annotate lisp/=gnus.el @ 828:4b56424868f6
*** empty log message ***
author | Eric S. Raymond <esr@snark.thyrsus.com> |
---|---|
date | Tue, 21 Jul 1992 07:57:59 +0000 |
parents | e694e0879463 |
children | 20674ae6bf52 |
rev | line source |
---|---|
660
08eb386dd0f3
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
1 ;;; gnus.el --- GNUS: an NNTP-based News Reader for GNU Emacs |
08eb386dd0f3
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
2 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
716
diff
changeset
|
3 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet> |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
716
diff
changeset
|
4 ;; Last-Modified: 10 Jun 1992 |
811
e694e0879463
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
807
diff
changeset
|
5 ;; Keywords: news |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
716
diff
changeset
|
6 |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
716
diff
changeset
|
7 ;; $Header: gnus.el,v 3.13 90/03/23 13:24:27 umerin Locked $ |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
716
diff
changeset
|
8 |
711
22b98190b7ef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
9 ;; Copyright (C) 1987, 1988, 1989, 1990 Free Software Foundation, Inc. |
257 | 10 |
11 ;; This file is part of GNU Emacs. | |
12 | |
711
22b98190b7ef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
13 ;; GNU Emacs is free software; you can redistribute it and/or modify |
22b98190b7ef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
14 ;; it under the terms of the GNU General Public License as published by |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
716
diff
changeset
|
15 ;; the Free Software Foundation; either version 2, or (at your option) |
711
22b98190b7ef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
16 ;; any later version. |
22b98190b7ef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
17 |
257 | 18 ;; GNU Emacs is distributed in the hope that it will be useful, |
711
22b98190b7ef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
22b98190b7ef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22b98190b7ef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
21 ;; GNU General Public License for more details. |
22b98190b7ef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
22 |
22b98190b7ef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
23 ;; You should have received a copy of the GNU General Public License |
22b98190b7ef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
24 ;; along with GNU Emacs; see the file COPYING. If not, write to |
22b98190b7ef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
25 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
257 | 26 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
716
diff
changeset
|
27 ;;; Commentary: |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
716
diff
changeset
|
28 |
257 | 29 ;; GNUS Mailing List: |
30 ;; There are two mailing lists for GNUS lovers in the world: | |
31 ;; | |
32 ;; info-gnus@flab.fujitsu.co.jp, and | |
33 ;; info-gnus-english@tut.cis.ohio-state.edu. | |
34 ;; | |
35 ;; They are intended to exchange useful information about GNUS, such | |
36 ;; as bug fixes, useful hooks, and extensions. The major difference | |
37 ;; between the lists is what the official language is. Both Japanese | |
38 ;; and English are available in info-gnus, while English is only | |
39 ;; available in info-gnus-english. There is no need to subscribe to | |
40 ;; info-gnus if you cannot read Japanese messages, because most of the | |
41 ;; discussion and important announcements will be sent to | |
42 ;; info-gnus-english. Moreover, if you can read gnu.emacs.gnus | |
43 ;; newsgroup of USENET, you need not, either. info-gnus-english and | |
44 ;; gnu.emacs.gnus are linked each other. | |
45 ;; | |
46 ;; Please send subscription request to: | |
47 ;; | |
48 ;; info-gnus-request@flab.fujitsu.co.jp, or | |
49 ;; info-gnus-english-request@cis.ohio-state.edu | |
50 | |
51 ;; TO DO: | |
52 ;; (1) Incremental update of active info. | |
53 ;; (2) GNUS own poster. | |
54 ;; (3) Multi-GNUS (Talking to many hosts same time). | |
55 ;; (4) Asynchronous transmission of large messages. | |
56 | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
716
diff
changeset
|
57 ;;; Code: |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
716
diff
changeset
|
58 |
257 | 59 (require 'nntp) |
60 (require 'mail-utils) | |
61 | |
716
f11e7af7c0d9
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
711
diff
changeset
|
62 (defvar gnus-nntp-server (or (getenv "NNTPSERVER") |
f11e7af7c0d9
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
711
diff
changeset
|
63 (and (boundp 'gnus-default-nntp-server) |
f11e7af7c0d9
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
711
diff
changeset
|
64 gnus-default-nntp-server)) |
257 | 65 "The name of the host running NNTP server. |
66 If it is a string such as `:DIRECTORY', the user's private DIRECTORY | |
67 is used as a news spool. | |
68 Initialized from the NNTPSERVER environment variable.") | |
69 | |
716
f11e7af7c0d9
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
711
diff
changeset
|
70 (defvar gnus-nntp-service "nntp" |
f11e7af7c0d9
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
711
diff
changeset
|
71 "The name of the network service for GNUS to use. Usually \"nntp\".") |
f11e7af7c0d9
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
711
diff
changeset
|
72 |
257 | 73 (defvar gnus-signature-file "~/.signature" |
74 "*Your .signature file. Use `.signature-DISTRIBUTION' instead if exists.") | |
75 | |
76 (defvar gnus-use-cross-reference t | |
77 "Specifies what to do with cross references (Xref: field). | |
78 If nil, ignore cross references. If t, mark articles as read in subscribed | |
79 newsgroups. Otherwise, mark articles as read in all newsgroups.") | |
80 | |
81 (defvar gnus-use-followup-to t | |
82 "*Specifies what to do with Followup-To: field. | |
83 If nil, ignore followup-to: field. If t, use its value execpt for | |
84 `poster'. Otherewise, if not nil nor t, always use its value.") | |
85 | |
86 (defvar gnus-large-newsgroup 50 | |
87 "*The number of articles which indicates a large newsgroup. | |
88 If the number of articles in a newsgroup is greater than the value, | |
89 confirmation is required for selecting the newsgroup.") | |
90 | |
91 (defvar gnus-author-copy (getenv "AUTHORCOPY") | |
92 "*Filename for saving a copy of an article posted using FCC: field. | |
93 Initialized from the AUTHORCOPY environment variable. | |
94 | |
95 Articles are saved using a function specified by the the variable | |
96 `gnus-author-copy-saver' (`rmail-output' is the default) if a file name | |
97 is given. Instead, if the first character of the name is `|', the | |
98 contents of the article is piped out to the named program. It is | |
99 possible to save an article in an MH folder as follows: | |
100 | |
101 (setq gnus-author-copy \"|/usr/local/lib/mh/rcvstore +Article\")") | |
102 | |
103 (defvar gnus-author-copy-saver (function rmail-output) | |
104 "*A function called with a file name to save an author copy to. | |
105 The default function is `rmail-output' which saves in Unix mailbox format.") | |
106 | |
107 (defvar gnus-use-long-file-name | |
108 (not (memq system-type '(usg-unix-v xenix))) | |
109 "Non-nil means that a newsgroup name is used as a default file name | |
110 to save articles to. If nil, the directory form of a newsgroup is | |
111 used instead.") | |
112 | |
113 (defvar gnus-article-save-directory (getenv "SAVEDIR") | |
114 "*The directory in which to save articles; defaults to ~/News. | |
115 Initialized from the SAVEDIR environment variable.") | |
116 | |
117 (defvar gnus-default-article-saver (function gnus-Subject-save-in-rmail) | |
118 "A function used to save articles in your favorite format. | |
119 The function must be interactively callable (in other words, it must | |
120 be an Emacs command). | |
121 | |
122 GNUS provides the following functions: | |
123 gnus-Subject-save-in-rmail (in Rmail format) | |
124 gnus-Subject-save-in-mail (in Unix mail format) | |
125 gnus-Subject-save-in-folder (in an MH folder) | |
126 gnus-Subject-save-in-file (in article format).") | |
127 | |
128 (defvar gnus-rmail-save-name (function gnus-plain-save-name) | |
129 "A function generating a file name to save articles in Rmail format. | |
130 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.") | |
131 | |
132 (defvar gnus-mail-save-name (function gnus-plain-save-name) | |
133 "A function generating a file name to save articles in Unix mail format. | |
134 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.") | |
135 | |
136 (defvar gnus-folder-save-name (function gnus-folder-save-name) | |
137 "A function generating a file name to save articles in MH folder. | |
138 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.") | |
139 | |
140 (defvar gnus-file-save-name (function gnus-numeric-save-name) | |
141 "A function generating a file name to save articles in article format. | |
142 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.") | |
143 | |
144 (defvar gnus-kill-file-name "KILL" | |
145 "File name of a KILL file.") | |
146 | |
147 (defvar gnus-default-distribution "local" | |
148 "*Use this value as distribution if no distribution is specified.") | |
149 | |
150 (defvar gnus-novice-user t | |
151 "*Non-nil means that you are a novice to USENET. | |
152 If non-nil, verbose messages may be displayed or your confirmation | |
153 may be required.") | |
154 | |
155 (defvar gnus-interactive-post t | |
156 "*Newsgroup, subject, and distribution will be asked for if non-nil.") | |
157 | |
158 (defvar gnus-user-login-name nil | |
159 "*The login name of the user. | |
160 Uses USER and LOGNAME environment variables if undefined.") | |
161 | |
162 (defvar gnus-user-full-name nil | |
163 "*The full name of the user. | |
164 Uses from the NAME environment variable if undefined.") | |
165 | |
166 (defvar gnus-show-threads t | |
167 "*Show conversation threads in Subject Mode if non-nil.") | |
168 | |
169 (defvar gnus-thread-hide-subject t | |
170 "*Non-nil means hide subjects for thread subtrees.") | |
171 | |
172 (defvar gnus-thread-hide-subtree nil | |
173 "*Non-nil means hide thread subtrees initially. | |
174 If non-nil, you have to run the command `gnus-Subject-show-thread' by | |
175 hand or by using `gnus-Select-article-hook' to show hidden threads.") | |
176 | |
177 (defvar gnus-thread-hide-killed t | |
178 "*Non-nil means hide killed thread subtrees automatically.") | |
179 | |
180 (defvar gnus-thread-ignore-subject nil | |
181 "*Don't take care of subject differences, but only references if non-nil. | |
182 If it is non-nil, some commands work with subjects do not work properly.") | |
183 | |
184 (defvar gnus-thread-indent-level 4 | |
185 "Indentation of thread subtrees.") | |
186 | |
187 (defvar gnus-ignored-headers | |
188 "^Path:\\|^Posting-Version:\\|^Article-I.D.:\\|^Expires:\\|^Date-Received:\\|^References:\\|^Control:\\|^Xref:\\|^Lines:\\|^Posted:\\|^Relay-Version:\\|^Message-ID:\\|^Nf-ID:\\|^Nf-From:\\|^Approved:\\|^Sender:\\|^In-Reply-To:" | |
189 "Regexp matching headers not to display in messages.") | |
190 | |
191 (defvar gnus-show-all-headers nil | |
192 "*Show all headers of an article if non-nil.") | |
193 | |
194 (defvar gnus-save-all-headers nil | |
195 "*Save all headers of an article if non-nil.") | |
196 | |
197 (defvar gnus-optional-headers (function gnus-optional-lines-and-from) | |
198 "A function generating a optional string displayed in GNUS Subject | |
199 mode buffer. The function is called with an article HEADER. The | |
200 result must be a string excluding `[' and `]'.") | |
201 | |
202 (defvar gnus-auto-extend-newsgroup t | |
203 "*Extend visible articles to forward and backward if non-nil.") | |
204 | |
205 (defvar gnus-auto-select-first t | |
206 "*Select the first unread article automagically if non-nil. | |
207 If you want to prevent automatic selection of the first unread article | |
208 in some newsgroups, set the variable to nil in `gnus-Select-group-hook' | |
209 or `gnus-Apply-kill-hook'.") | |
210 | |
211 (defvar gnus-auto-select-next t | |
212 "*Select the next newsgroup automagically if non-nil. | |
213 If the value is t and the next newsgroup is empty, GNUS will exit | |
214 Subject mode and go back to Group mode. If the value is neither nil | |
215 nor t, GNUS will select the following unread newsgroup. Especially, if | |
216 the value is the symbol `quietly', the next unread newsgroup will be | |
217 selected without any confirmations.") | |
218 | |
219 (defvar gnus-auto-select-same nil | |
220 "*Select the next article with the same subject automagically if non-nil.") | |
221 | |
222 (defvar gnus-auto-center-subject t | |
223 "*Always center the current subject in GNUS Subject mode window if non-nil.") | |
224 | |
225 (defvar gnus-break-pages t | |
226 "*Break an article into pages if non-nil. | |
227 Page delimiter is specified by the variable `gnus-page-delimiter'.") | |
228 | |
229 (defvar gnus-page-delimiter "^\^L" | |
230 "*Regexp describing line-beginnings that separate pages of news article.") | |
231 | |
232 (defvar gnus-digest-show-summary t | |
233 "*Show a summary of undigestified messages if non-nil.") | |
234 | |
235 (defvar gnus-digest-separator "^Subject:[ \t]" | |
236 "*Regexp that separates messages in a digest article.") | |
237 | |
238 (defvar gnus-use-full-window t | |
239 "*Non-nil means to take up the entire screen of Emacs.") | |
240 | |
241 (defvar gnus-window-configuration | |
242 '((SelectNewsgroup (0 1 0)) | |
243 (ExitNewsgroup (1 0 0)) | |
244 (SelectArticle (0 3 10)) | |
245 (ExpandSubject (0 1 0))) | |
246 "Specify window configurations for each action. | |
247 The format of the variable is a list of (ACTION (G S A)), where | |
248 G, S, and A are the relative height of Group, Subject, and Article | |
249 windows, respectively. ACTION is `SelectNewsgroup', `ExitNewsgroup', | |
250 `SelectArticle', or `ExpandSubject'.") | |
251 | |
252 (defvar gnus-mail-reply-method | |
253 (function gnus-mail-reply-using-mail) | |
254 "A function to compose reply mail. | |
255 The function `gnus-mail-reply-using-mail' uses usual the sendmail mail | |
256 program. The function `gnus-mail-reply-using-mhe' uses the mh-e mail | |
257 program. You can use yet another program by customizing this variable.") | |
258 | |
259 (defvar gnus-mail-other-window-method | |
260 (function gnus-mail-other-window-using-mail) | |
261 "A function to compose mail in other window. | |
262 The function `gnus-mail-other-window-using-mail' uses usual sendmail | |
263 mail program. The function `gnus-mail-other-window-using-mhe' uses mh-e | |
264 mail program. You can use yet another program by customizing this variable.") | |
265 | |
266 (defvar gnus-subscribe-newsgroup-method | |
267 (function | |
268 (lambda (newsgroup) | |
269 (gnus-subscribe-newsgroup newsgroup | |
270 (car (car gnus-newsrc-assoc))))) | |
271 "A function called with a newsgroup name when it is created.") | |
272 | |
273 (defvar gnus-Group-mode-hook nil | |
274 "A hook for GNUS Group Mode.") | |
275 | |
276 (defvar gnus-Subject-mode-hook nil | |
277 "A hook for GNUS Subject Mode.") | |
278 | |
279 (defvar gnus-Article-mode-hook nil | |
280 "A hook for GNUS Article Mode.") | |
281 | |
282 (defvar gnus-Kill-file-mode-hook nil | |
283 "A hook for GNUS KILL File Mode.") | |
284 | |
285 (defvar gnus-Open-server-hook nil | |
286 "A hook called just before opening connection to news server.") | |
287 | |
288 (defvar gnus-Startup-hook nil | |
289 "A hook called at start up time. | |
290 This hook is called after GNUS is connected to the NNTP server. | |
291 So, it is possible to change the behavior of GNUS according to the | |
292 selected NNTP server.") | |
293 | |
294 (defvar gnus-Group-prepare-hook nil | |
295 "A hook called after newsgroup list is created in the Newsgroup buffer. | |
296 If you want to modify the Newsgroup buffer, you can use this hook.") | |
297 | |
298 (defvar gnus-Subject-prepare-hook nil | |
299 "A hook called after subject list is created in the Subject buffer. | |
300 If you want to modify the Subject buffer, you can use this hook.") | |
301 | |
302 (defvar gnus-Article-prepare-hook nil | |
303 "A hook called after an article is prepared in the Article buffer. | |
304 If you want to run a special decoding program like nkf, use this hook.") | |
305 | |
306 (defvar gnus-Select-group-hook nil | |
307 "A hook called when a newsgroup is selected. | |
308 If you want to sort Subject buffer by date and then by subject, you | |
309 can use the following hook: | |
310 | |
311 (setq gnus-Select-group-hook | |
312 '(lambda () | |
313 ;; First of all, sort by date. | |
314 (gnus-sort-headers | |
315 '(lambda (a b) | |
316 (gnus-date-lessp (gnus-header-date a) | |
317 (gnus-header-date b)))) | |
318 ;; Then sort by subject string ignoring `Re:'. | |
319 ;; If case-fold-search is non-nil, case of letters is ignored. | |
320 (gnus-sort-headers | |
321 '(lambda (a b) | |
322 (gnus-string-lessp | |
323 (gnus-simplify-subject (gnus-header-subject a) 're) | |
324 (gnus-simplify-subject (gnus-header-subject b) 're) | |
325 ))))) | |
326 | |
327 If you'd like to simplify subjects like the `gnus-Subject-next-same-subject' | |
328 command does, you can use the following hook: | |
329 | |
330 (setq gnus-Select-group-hook | |
331 '(lambda () | |
332 (mapcar (function | |
333 (lambda (header) | |
334 (nntp-set-header-subject | |
335 header | |
336 (gnus-simplify-subject | |
337 (gnus-header-subject header) 're-only)))) | |
338 gnus-newsgroup-headers))) | |
339 | |
340 In some newsgroups author name is meaningless. It is possible to | |
341 prevent listing author names in the GNUS Subject buffer as follows: | |
342 | |
343 (setq gnus-Select-group-hook | |
344 '(lambda () | |
345 (cond ((string-equal \"comp.sources.unix\" gnus-newsgroup-name) | |
346 (setq gnus-optional-headers | |
347 (function gnus-optional-lines))) | |
348 (t | |
349 (setq gnus-optional-headers | |
350 (function gnus-optional-lines-and-from))))))") | |
351 | |
352 (defvar gnus-Select-article-hook | |
353 (function (lambda () (gnus-Subject-show-thread))) | |
354 "Hook called when an article is selected. | |
355 The default hook automatically shows conversation thread subtrees | |
356 of the selected article as follows: | |
357 | |
358 (setq gnus-Select-article-hook | |
359 '(lambda () | |
360 (gnus-Subject-show-thread))) | |
361 | |
362 If you'd like to run RMAIL on a digest article automagically, you can | |
363 use the following hook: | |
364 | |
365 (setq gnus-Select-article-hook | |
366 '(lambda () | |
367 (gnus-Subject-show-thread) | |
368 (cond ((string-equal \"comp.sys.sun\" gnus-newsgroup-name) | |
369 (gnus-Subject-rmail-digest)) | |
370 ((and (string-equal \"comp.text\" gnus-newsgroup-name) | |
371 (string-match \"^TeXhax Digest\" | |
372 (gnus-header-subject gnus-current-headers))) | |
373 (gnus-Subject-rmail-digest) | |
374 ))))") | |
375 | |
376 (defvar gnus-Select-digest-hook | |
377 (function | |
378 (lambda () | |
379 ;; Reply-To: is required by `undigestify-rmail-message'. | |
380 (or (mail-position-on-field "Reply-to" t) | |
381 (progn | |
382 (mail-position-on-field "Reply-to") | |
383 (insert (gnus-fetch-field "From")))))) | |
384 "A hook called when reading digest messages using Rmail. | |
385 This hook can be used to modify incomplete digest articles as follows | |
386 (this is the default): | |
387 | |
388 (setq gnus-Select-digest-hook | |
389 '(lambda () | |
390 ;; Reply-To: is required by `undigestify-rmail-message'. | |
391 (or (mail-position-on-field \"Reply-to\" t) | |
392 (progn | |
393 (mail-position-on-field \"Reply-to\") | |
394 (insert (gnus-fetch-field \"From\"))))))") | |
395 | |
396 (defvar gnus-Rmail-digest-hook nil | |
397 "A hook called when reading digest messages using Rmail. | |
398 This hook is intended to customize Rmail mode for reading digest articles.") | |
399 | |
400 (defvar gnus-Apply-kill-hook (function gnus-apply-kill-file) | |
401 "A hook called when a newsgroup is selected and subject list is prepared. | |
402 This hook is intended to apply a KILL file to the selected newsgroup. | |
403 The function `gnus-apply-kill-file' is called defaultly. | |
404 | |
405 Since a general KILL file is too heavy to use for only a few | |
406 newsgroups, we recommend you use a lighter hook function. For | |
407 example, if you'd like to apply a KILL file to articles which contains | |
408 a string `rmgroup' in subject in newsgroup `control', you can use the | |
409 following hook: | |
410 | |
411 (setq gnus-Apply-kill-hook | |
412 '(lambda () | |
413 (cond ((string-match \"control\" gnus-newsgroup-name) | |
414 (gnus-kill \"Subject\" \"rmgroup\") | |
415 (gnus-expunge \"X\")))))") | |
416 | |
417 (defvar gnus-Mark-article-hook | |
418 (function | |
419 (lambda () | |
420 (or (memq gnus-current-article gnus-newsgroup-marked) | |
421 (gnus-Subject-mark-as-read gnus-current-article)) | |
422 (gnus-Subject-set-current-mark "+"))) | |
423 "A hook called when an article is selected for the first time. | |
424 The hook is intended to mark an article as read when it is selected. | |
425 If you'd like to mark as unread (-) instead, use the following hook: | |
426 | |
427 (setq gnus-Mark-article-hook | |
428 '(lambda () | |
429 (gnus-Subject-mark-as-unread gnus-current-article) | |
430 (gnus-Subject-set-current-mark \"+\")))") | |
431 | |
432 (defvar gnus-Inews-article-hook nil | |
433 "A hook called before posting an article. | |
434 If you'd like to run a special encoding program, use this hook.") | |
435 | |
436 (defvar gnus-Exit-group-hook nil | |
437 "A hook called when exiting (not quitting) Subject mode. | |
438 If your machine is so slow that exiting from Subject mode takes a | |
439 long time, set the variable `gnus-newsgroup-headers' to nil. This | |
440 inhibits marking articles as read using cross-reference information.") | |
441 | |
442 (defvar gnus-Suspend-gnus-hook nil | |
443 "A hook called when suspending (not exiting) GNUS.") | |
444 | |
445 (defvar gnus-Exit-gnus-hook nil | |
446 "A hook called when exiting (not suspending) GNUS.") | |
447 | |
448 (defvar gnus-Save-newsrc-hook nil | |
449 "A hook called when saving the newsrc file. | |
450 This hook is called before saving .newsrc file.") | |
451 | |
452 (defvar gnus-your-domain nil | |
453 "*Your domain name without your host name like: \"stars.flab.Fujitsu.CO.JP\" | |
454 The environment variable DOMAINNAME is used instead if defined. If | |
455 the function `system-name' returns the full internet name, there is no | |
456 need to define this variable.") | |
457 | |
458 (defvar gnus-your-organization nil | |
459 "*Your organization like: \"Fujitsu Laboratories Ltd., Kawasaki, Japan.\" | |
460 The `ORGANIZATION' environment variable is used instead if defined.") | |
461 | |
462 (defvar gnus-use-generic-from nil | |
463 "*If nil, prepend local host name to the defined domain in the From: | |
464 field; if stringp, use this; if non-nil, strip of the local host name.") | |
465 | |
466 (defvar gnus-use-generic-path nil | |
467 "*If nil, use the NNTP server name in the Path: field; if stringp, | |
468 use this; if non-nil, use no host name (user name only)") | |
469 | |
470 ;; Internal variables. | |
471 | |
472 (defconst gnus-version "GNUS 3.13" | |
473 "Version numbers of this version of GNUS.") | |
474 | |
475 (defvar gnus-Info-nodes | |
476 '((gnus-Group-mode . "(gnus)Newsgroup Commands") | |
477 (gnus-Subject-mode . "(gnus)Subject Commands") | |
478 (gnus-Article-mode . "(gnus)Article Commands") | |
479 (gnus-Kill-file-mode . "(gnus)KILL File") | |
480 (gnus-Browse-killed-mode . "(gnus)Maintenance")) | |
481 "Assoc list of major modes and related Info nodes.") | |
482 | |
483 (defvar gnus-access-methods | |
484 '((nntp | |
485 (gnus-retrieve-headers . nntp-retrieve-headers) | |
486 (gnus-open-server . nntp-open-server) | |
487 (gnus-close-server . nntp-close-server) | |
488 (gnus-server-opened . nntp-server-opened) | |
489 (gnus-status-message . nntp-status-message) | |
490 (gnus-request-article . nntp-request-article) | |
491 (gnus-request-group . nntp-request-group) | |
492 (gnus-request-list . nntp-request-list) | |
493 (gnus-request-post . nntp-request-post)) | |
494 (nnspool | |
495 (gnus-retrieve-headers . nnspool-retrieve-headers) | |
496 (gnus-open-server . nnspool-open-server) | |
497 (gnus-close-server . nnspool-close-server) | |
498 (gnus-server-opened . nnspool-server-opened) | |
499 (gnus-status-message . nnspool-status-message) | |
500 (gnus-request-article . nnspool-request-article) | |
501 (gnus-request-group . nnspool-request-group) | |
502 (gnus-request-list . nnspool-request-list) | |
503 (gnus-request-post . nnspool-request-post)) | |
504 (mhspool | |
505 (gnus-retrieve-headers . mhspool-retrieve-headers) | |
506 (gnus-open-server . mhspool-open-server) | |
507 (gnus-close-server . mhspool-close-server) | |
508 (gnus-server-opened . mhspool-server-opened) | |
509 (gnus-status-message . mhspool-status-message) | |
510 (gnus-request-article . mhspool-request-article) | |
511 (gnus-request-group . mhspool-request-group) | |
512 (gnus-request-list . mhspool-request-list) | |
513 (gnus-request-post . mhspool-request-post))) | |
514 "Access method for NNTP, nnspool, and mhspool.") | |
515 | |
516 (defvar gnus-Group-buffer "*Newsgroup*") | |
517 (defvar gnus-Subject-buffer "*Subject*") | |
518 (defvar gnus-Article-buffer "*Article*") | |
519 (defvar gnus-Digest-buffer "GNUS Digest") | |
520 (defvar gnus-Digest-summary-buffer "GNUS Digest-summary") | |
521 | |
522 (defvar gnus-buffer-list | |
523 (list gnus-Group-buffer gnus-Subject-buffer gnus-Article-buffer | |
524 gnus-Digest-buffer gnus-Digest-summary-buffer) | |
525 "GNUS buffer names which should be killed when exiting.") | |
526 | |
527 (defvar gnus-variable-list | |
528 '(gnus-newsrc-options | |
529 gnus-newsrc-options-n-yes gnus-newsrc-options-n-no | |
530 gnus-newsrc-assoc gnus-killed-assoc gnus-marked-assoc) | |
531 "GNUS variables saved in the quick startup file.") | |
532 | |
533 (defvar gnus-overload-functions | |
534 '((news-inews gnus-inews-news "rnewspost") | |
535 (caesar-region gnus-caesar-region "rnews")) | |
536 "Functions overloaded by gnus. | |
537 It is a list of `(original overload &optional file)'.") | |
538 | |
539 (defvar gnus-newsrc-options nil | |
540 "Options line in the .newsrc file.") | |
541 | |
542 (defvar gnus-newsrc-options-n-yes nil | |
543 "Regexp representing subscribed newsgroups.") | |
544 | |
545 (defvar gnus-newsrc-options-n-no nil | |
546 "Regexp representing unsubscribed newsgroups.") | |
547 | |
548 (defvar gnus-newsrc-assoc nil | |
549 "Assoc list of read articles.") | |
550 | |
551 (defvar gnus-killed-assoc nil | |
552 "Assoc list of newsgroups removed from `gnus-newsrc-assoc'.") | |
553 | |
554 (defvar gnus-marked-assoc nil | |
555 "Assoc list of articles marked as unread.") | |
556 | |
557 (defvar gnus-unread-hashtb nil | |
558 "Hashtable of unread articles.") | |
559 | |
560 (defvar gnus-active-hashtb nil | |
561 "Hashtable of active articles.") | |
562 | |
563 (defvar gnus-octive-hashtb nil | |
564 "Hashtable of OLD active articles.") | |
565 | |
566 (defvar gnus-current-startup-file nil | |
567 "Startup file for the current host.") | |
568 | |
569 (defvar gnus-last-search-regexp nil | |
570 "Default regexp for article search command.") | |
571 | |
572 (defvar gnus-last-shell-command nil | |
573 "Default shell command on article.") | |
574 | |
575 (defvar gnus-have-all-newsgroups nil) | |
576 | |
577 (defvar gnus-newsgroup-name nil) | |
578 (defvar gnus-newsgroup-begin nil) | |
579 (defvar gnus-newsgroup-end nil) | |
580 (defvar gnus-newsgroup-last-rmail nil) | |
581 (defvar gnus-newsgroup-last-mail nil) | |
582 (defvar gnus-newsgroup-last-folder nil) | |
583 (defvar gnus-newsgroup-last-file nil) | |
584 | |
585 (defvar gnus-newsgroup-unreads nil | |
586 "List of unread articles in the current newsgroup.") | |
587 | |
588 (defvar gnus-newsgroup-unselected nil | |
589 "List of unselected unread articles in the current newsgroup.") | |
590 | |
591 (defvar gnus-newsgroup-marked nil | |
592 "List of marked articles in the current newsgroup (a subset of unread art).") | |
593 | |
594 (defvar gnus-newsgroup-headers nil | |
595 "List of article headers in the current newsgroup.") | |
596 | |
597 (defvar gnus-current-article nil) | |
598 (defvar gnus-current-headers nil) | |
599 (defvar gnus-current-history nil) | |
600 (defvar gnus-have-all-headers nil) | |
601 (defvar gnus-last-article nil) | |
602 (defvar gnus-current-kill-article nil) | |
603 | |
604 ;; Save window configuration. | |
605 (defvar gnus-winconf-kill-file nil) | |
606 | |
607 (defvar gnus-Group-mode-map nil) | |
608 (defvar gnus-Subject-mode-map nil) | |
609 (defvar gnus-Article-mode-map nil) | |
610 (defvar gnus-Kill-file-mode-map nil) | |
611 | |
612 (defvar rmail-last-file (expand-file-name "~/XMBOX")) | |
613 (defvar rmail-last-rmail-file (expand-file-name "~/XNEWS")) | |
614 | |
615 ;; Define GNUS Subsystems. | |
616 (autoload 'gnus-Group-post-news "gnuspost" | |
617 "Post an article." t) | |
618 (autoload 'gnus-Subject-post-news "gnuspost" | |
619 "Post an article." t) | |
620 (autoload 'gnus-Subject-post-reply "gnuspost" | |
621 "Post a reply article." t) | |
622 (autoload 'gnus-Subject-post-reply-with-original "gnuspost" | |
623 "Post a reply article with original article." t) | |
624 (autoload 'gnus-Subject-cancel-article "gnuspost" | |
625 "Cancel an article you posted." t) | |
626 | |
627 (autoload 'gnus-Subject-mail-reply "gnusmail" | |
628 "Reply mail to news author." t) | |
629 (autoload 'gnus-Subject-mail-reply-with-original "gnusmail" | |
630 "Reply mail to news author with original article." t) | |
631 (autoload 'gnus-Subject-mail-other-window "gnusmail" | |
632 "Compose mail in other window." t) | |
633 | |
634 (autoload 'gnus-Group-kill-group "gnusmisc" | |
635 "Kill newsgroup on current line." t) | |
636 (autoload 'gnus-Group-yank-group "gnusmisc" | |
637 "Yank the last killed newsgroup on current line." t) | |
638 (autoload 'gnus-Browse-killed-groups "gnusmisc" | |
639 "Browse the killed newsgroups." t) | |
640 | |
641 (autoload 'rmail-output "rmailout" | |
642 "Append this message to Unix mail file named FILE-NAME." t) | |
643 (autoload 'mail-position-on-field "sendmail") | |
644 (autoload 'mh-find-path "mh-e") | |
645 (autoload 'mh-prompt-for-folder "mh-e") | |
646 | |
647 (put 'gnus-Group-mode 'mode-class 'special) | |
648 (put 'gnus-Subject-mode 'mode-class 'special) | |
649 (put 'gnus-Article-mode 'mode-class 'special) | |
650 | |
651 | |
652 ;;(put 'gnus-eval-in-buffer-window 'lisp-indent-function 1) | |
653 | |
654 (defmacro gnus-eval-in-buffer-window (buffer &rest forms) | |
655 "Pop to BUFFER, evaluate FORMS, and then returns to original window." | |
656 (` (let ((GNUSStartBufferWindow (selected-window))) | |
657 (unwind-protect | |
658 (progn | |
659 (pop-to-buffer (, buffer)) | |
660 (,@ forms)) | |
661 (select-window GNUSStartBufferWindow))))) | |
662 | |
663 (defmacro gnus-make-hashtable () | |
664 '(make-abbrev-table)) | |
665 | |
666 (defmacro gnus-gethash (string hashtable) | |
667 "Get hash value of STRING in HASHTABLE." | |
668 ;;(` (symbol-value (abbrev-symbol (, string) (, hashtable)))) | |
669 (` (abbrev-expansion (, string) (, hashtable)))) | |
670 | |
671 (defmacro gnus-sethash (string value hashtable) | |
672 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE." | |
673 ;; We cannot use define-abbrev since it only accepts string as value. | |
674 (` (set (intern (, string) (, hashtable)) (, value)))) | |
675 | |
676 ;; Note: Macros defined here are also defined in nntp.el. I don't like | |
677 ;; to put them here, but many users got troubled with the old | |
678 ;; definitions in nntp.elc. These codes are NNTP 3.10 version. | |
679 | |
680 (defmacro nntp-header-number (header) | |
681 "Return article number in HEADER." | |
682 (` (aref (, header) 0))) | |
683 | |
684 (defmacro nntp-set-header-number (header number) | |
685 "Set article number of HEADER to NUMBER." | |
686 (` (aset (, header) 0 (, number)))) | |
687 | |
688 (defmacro nntp-header-subject (header) | |
689 "Return subject string in HEADER." | |
690 (` (aref (, header) 1))) | |
691 | |
692 (defmacro nntp-set-header-subject (header subject) | |
693 "Set article subject of HEADER to SUBJECT." | |
694 (` (aset (, header) 1 (, subject)))) | |
695 | |
696 (defmacro nntp-header-from (header) | |
697 "Return author string in HEADER." | |
698 (` (aref (, header) 2))) | |
699 | |
700 (defmacro nntp-set-header-from (header from) | |
701 "Set article author of HEADER to FROM." | |
702 (` (aset (, header) 2 (, from)))) | |
703 | |
704 (defmacro nntp-header-xref (header) | |
705 "Return xref string in HEADER." | |
706 (` (aref (, header) 3))) | |
707 | |
708 (defmacro nntp-set-header-xref (header xref) | |
709 "Set article xref of HEADER to xref." | |
710 (` (aset (, header) 3 (, xref)))) | |
711 | |
712 (defmacro nntp-header-lines (header) | |
713 "Return lines in HEADER." | |
714 (` (aref (, header) 4))) | |
715 | |
716 (defmacro nntp-set-header-lines (header lines) | |
717 "Set article lines of HEADER to LINES." | |
718 (` (aset (, header) 4 (, lines)))) | |
719 | |
720 (defmacro nntp-header-date (header) | |
721 "Return date in HEADER." | |
722 (` (aref (, header) 5))) | |
723 | |
724 (defmacro nntp-set-header-date (header date) | |
725 "Set article date of HEADER to DATE." | |
726 (` (aset (, header) 5 (, date)))) | |
727 | |
728 (defmacro nntp-header-id (header) | |
729 "Return Id in HEADER." | |
730 (` (aref (, header) 6))) | |
731 | |
732 (defmacro nntp-set-header-id (header id) | |
733 "Set article Id of HEADER to ID." | |
734 (` (aset (, header) 6 (, id)))) | |
735 | |
736 (defmacro nntp-header-references (header) | |
737 "Return references in HEADER." | |
738 (` (aref (, header) 7))) | |
739 | |
740 (defmacro nntp-set-header-references (header ref) | |
741 "Set article references of HEADER to REF." | |
742 (` (aset (, header) 7 (, ref)))) | |
743 | |
744 | |
745 ;;; | |
746 ;;; GNUS Group Mode | |
747 ;;; | |
748 | |
749 (if gnus-Group-mode-map | |
750 nil | |
751 (setq gnus-Group-mode-map (make-keymap)) | |
752 (suppress-keymap gnus-Group-mode-map) | |
753 (define-key gnus-Group-mode-map " " 'gnus-Group-read-group) | |
754 (define-key gnus-Group-mode-map "=" 'gnus-Group-select-group) | |
755 (define-key gnus-Group-mode-map "j" 'gnus-Group-jump-to-group) | |
756 (define-key gnus-Group-mode-map "n" 'gnus-Group-next-unread-group) | |
757 (define-key gnus-Group-mode-map "p" 'gnus-Group-prev-unread-group) | |
758 (define-key gnus-Group-mode-map "\177" 'gnus-Group-prev-unread-group) | |
759 (define-key gnus-Group-mode-map "N" 'gnus-Group-next-group) | |
760 (define-key gnus-Group-mode-map "P" 'gnus-Group-prev-group) | |
761 (define-key gnus-Group-mode-map "\C-n" 'gnus-Group-next-group) | |
762 (define-key gnus-Group-mode-map "\C-p" 'gnus-Group-prev-group) | |
763 (define-key gnus-Group-mode-map "\r" 'next-line) | |
764 (define-key gnus-Group-mode-map "/" 'isearch-forward) | |
765 (define-key gnus-Group-mode-map "<" 'beginning-of-buffer) | |
766 (define-key gnus-Group-mode-map ">" 'end-of-buffer) | |
767 (define-key gnus-Group-mode-map "u" 'gnus-Group-unsubscribe-current-group) | |
768 (define-key gnus-Group-mode-map "U" 'gnus-Group-unsubscribe-group) | |
769 (define-key gnus-Group-mode-map "c" 'gnus-Group-catch-up) | |
770 (define-key gnus-Group-mode-map "C" 'gnus-Group-catch-up-all) | |
771 (define-key gnus-Group-mode-map "l" 'gnus-Group-list-groups) | |
772 (define-key gnus-Group-mode-map "L" 'gnus-Group-list-all-groups) | |
773 (define-key gnus-Group-mode-map "g" 'gnus-Group-get-new-news) | |
774 (define-key gnus-Group-mode-map "R" 'gnus-Group-restart) | |
775 (define-key gnus-Group-mode-map "b" 'gnus-Group-check-bogus-groups) | |
776 (define-key gnus-Group-mode-map "r" 'gnus-Group-restrict-groups) | |
777 (define-key gnus-Group-mode-map "a" 'gnus-Group-post-news) | |
778 (define-key gnus-Group-mode-map "\ek" 'gnus-Group-edit-local-kill) | |
779 (define-key gnus-Group-mode-map "\eK" 'gnus-Group-edit-global-kill) | |
780 (define-key gnus-Group-mode-map "\C-k" 'gnus-Group-kill-group) | |
781 (define-key gnus-Group-mode-map "\C-y" 'gnus-Group-yank-group) | |
782 (define-key gnus-Group-mode-map "\C-c\C-y" 'gnus-Browse-killed-groups) | |
783 (define-key gnus-Group-mode-map "V" 'gnus-version) | |
784 (define-key gnus-Group-mode-map "x" 'gnus-Group-force-update) | |
785 (define-key gnus-Group-mode-map "s" 'gnus-Group-force-update) | |
786 (define-key gnus-Group-mode-map "z" 'gnus-Group-suspend) | |
787 (define-key gnus-Group-mode-map "q" 'gnus-Group-exit) | |
788 (define-key gnus-Group-mode-map "Q" 'gnus-Group-quit) | |
789 (define-key gnus-Group-mode-map "?" 'gnus-Group-describe-briefly) | |
790 (define-key gnus-Group-mode-map "\C-c\C-i" 'gnus-Info-find-node)) | |
791 | |
792 (defun gnus-Group-mode () | |
793 "Major mode for reading network news. | |
794 All normal editing commands are turned off. | |
795 Instead, these commands are available: | |
796 \\{gnus-Group-mode-map} | |
797 | |
798 The name of the host running NNTP server is asked for if no default | |
799 host is specified. It is also possible to choose another NNTP server | |
800 even when the default server is defined by giving a prefix argument to | |
801 the command `\\[gnus]'. | |
802 | |
803 If an NNTP server is preceded by a colon such as `:Mail', the user's | |
804 private directory `~/Mail' is used as a news spool. This makes it | |
805 possible to read mail stored in MH folders or articles saved by GNUS. | |
806 File names of mail or articles must consist of only numeric | |
807 characters. Otherwise, they are ignored. | |
808 | |
809 If there is a file named `~/.newsrc-SERVER', it is used as the | |
810 startup file instead of standard one when talking to SERVER. It is | |
811 possible to talk to many hosts by using different startup files for | |
812 each. | |
813 | |
814 Option `-n' of the options line in the startup file is recognized | |
815 properly the same as the Bnews system. For example, if the options | |
816 line is `options -n !talk talk.rumors', newsgroups under the `talk' | |
817 hierarchy except for `talk.rumors' are ignored while checking new | |
818 newsgroups. | |
819 | |
820 If there is a file named `~/.signature-DISTRIBUTION', it is used as | |
821 signature file instead of standard one when posting a news in | |
822 DISTRIBUTION. | |
823 | |
824 If an Info file generated from `gnus.texinfo' is installed, you can | |
825 read an appropriate Info node of the Info file according to the | |
826 current major mode of GNUS by \\[gnus-Info-find-node]. | |
827 | |
828 The variable `gnus-version', `nntp-version', `nnspool-version', and | |
829 `mhspool-version' have the version numbers of this version of gnus.el, | |
830 nntp.el, nnspool.el, and mhspoo.el, respectively. | |
831 | |
832 User customizable variables: | |
833 gnus-nntp-server | |
834 Specifies the name of the host running the NNTP server. If its | |
835 value is a string such as `:DIRECTORY', the user's private | |
716
f11e7af7c0d9
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
711
diff
changeset
|
836 DIRECTORY is used as a news spool. If its value is `::', then |
f11e7af7c0d9
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
711
diff
changeset
|
837 the local news spool on the current machine is used directly. |
f11e7af7c0d9
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
711
diff
changeset
|
838 The `NNTPSERVER' environment variable specifies the initial value |
f11e7af7c0d9
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
711
diff
changeset
|
839 for this variable. |
257 | 840 |
841 gnus-nntp-service | |
716
f11e7af7c0d9
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
711
diff
changeset
|
842 Specifies a NNTP service name. It is usually \"nntp\". |
257 | 843 |
844 gnus-startup-file | |
845 Specifies a startup file (.newsrc). If there is a file named | |
846 `.newsrc-SERVER', it's used instead when talking to SERVER. I | |
847 recommend you to use the server specific file, if you'd like to | |
848 talk to many servers. Especially if you'd like to read your | |
849 private directory, the name of the file must be | |
850 `.newsrc-:DIRECTORY'. | |
851 | |
852 gnus-signature-file | |
853 Specifies a signature file (.signature). If there is a file named | |
854 `.signature-DISTRIBUTION', it's used instead when posting an | |
855 article in DISTRIBUTION. Set the variable to nil to prevent | |
856 appending the file automatically. If you use an NNTP inews which | |
857 comes with the NNTP package, you may have to set the variable to | |
858 nil. | |
859 | |
860 gnus-use-cross-reference | |
861 Specifies what to do with cross references (Xref: field). If it | |
862 is nil, cross references are ignored. If it is t, articles in | |
863 subscribed newsgroups are only marked as read. Otherwise, if it | |
864 is not nil nor t, articles in all newsgroups are marked as read. | |
865 | |
866 gnus-use-followup-to | |
867 Specifies what to do with followup-to: field. If it is nil, its | |
868 value is ignored. If it is non-nil, its value is used as followup | |
869 newsgroups. Especially, if it is t and field value is `poster', | |
870 your confirmation is required. | |
871 | |
872 gnus-author-copy | |
873 Specifies a file name to save a copy of article you posted using | |
874 FCC: field. If the first character of the value is `|', the | |
875 contents of the article is piped out to a program specified by the | |
876 rest of the value. The variable is initialized from the | |
877 AUTHORCOPY environment variable. | |
878 | |
879 gnus-author-copy-saver | |
880 Specifies a function to save an author copy. The function is | |
881 called with a file name. The default function `rmail-output' | |
882 saves in Unix mail format. | |
883 | |
884 gnus-kill-file-name | |
885 Use specified file name as a KILL file (default to `KILL'). | |
886 | |
887 gnus-novice-user | |
888 Non-nil means that you are a novice to USENET. If non-nil, | |
889 verbose messages may be displayed or your confirmations may be | |
890 required. | |
891 | |
892 gnus-interactive-post | |
893 Non-nil means that newsgroup, subject and distribution are asked | |
894 for interactively when posting a new article. | |
895 | |
896 gnus-use-full-window | |
897 Non-nil means to take up the entire screen of Emacs. | |
898 | |
899 gnus-window-configuration | |
900 Specifies the configuration of Group, Subject, and Article | |
901 windows. It is a list of (ACTION (G S A)), where G, S, and A are | |
902 the relative height of Group, Subject, and Article windows, | |
903 respectively. ACTION is `SelectNewsgroup', `ExitNewsgroup', | |
904 `SelectArticle', or `ExpandSubject'. | |
905 | |
906 gnus-subscribe-newsgroup-method | |
907 Specifies a function called with a newsgroup name when new | |
908 newsgroup is found. The default definition adds new newsgroup at | |
909 the beginning of other newsgroups. | |
910 | |
911 Various hooks for customization: | |
912 gnus-Group-mode-hook | |
913 Entry to this mode calls the value with no arguments, if that | |
914 value is non-nil. This hook is called before GNUS is connected to | |
915 the NNTP server. So, you can change or define the NNTP server in | |
916 this hook. | |
917 | |
918 gnus-Startup-hook | |
919 Called with no arguments after the NNTP server is selected. It is | |
920 possible to change the behavior of GNUS or initialize the | |
921 variables according to the selected NNTP server. | |
922 | |
923 gnus-Group-prepare-hook | |
924 Called with no arguments after a newsgroup list is created in the | |
925 Newsgroup buffer, if that value is non-nil. | |
926 | |
927 gnus-Save-newsrc-hook | |
928 Called with no arguments when saving newsrc file if that value is | |
929 non-nil. | |
930 | |
931 gnus-Inews-article-hook | |
932 Called with no arguments when posting an article if that value is | |
933 non-nil. This hook is called just before posting an article, while | |
934 `news-inews-hook' is called before preparing article headers. If | |
935 you'd like to convert kanji code of the article, this hook is recommended. | |
936 | |
937 gnus-Suspend-gnus-hook | |
938 Called with no arguments when suspending (not exiting) GNUS, if | |
939 that value is non-nil. | |
940 | |
941 gnus-Exit-gnus-hook | |
942 Called with no arguments when exiting (not suspending) GNUS, if | |
943 that value is non-nil." | |
944 (interactive) | |
945 (kill-all-local-variables) | |
946 ;; Gee. Why don't you upgrade? | |
947 (cond ((boundp 'mode-line-modified) | |
948 (setq mode-line-modified "--- ")) | |
949 ((listp (default-value 'mode-line-format)) | |
950 (setq mode-line-format | |
951 (cons "--- " (cdr (default-value 'mode-line-format))))) | |
952 (t | |
953 (setq mode-line-format | |
954 "--- GNUS: List of Newsgroups %[(%m)%]----%3p-%-"))) | |
955 (setq major-mode 'gnus-Group-mode) | |
956 (setq mode-name "Newsgroup") | |
957 (setq mode-line-buffer-identification "GNUS: List of Newsgroups") | |
958 (setq mode-line-process nil) | |
959 (use-local-map gnus-Group-mode-map) | |
960 (buffer-flush-undo (current-buffer)) | |
961 (setq buffer-read-only t) ;Disable modification | |
962 (run-hooks 'gnus-Group-mode-hook)) | |
963 | |
964 ;;;###autoload | |
965 (defun gnus (&optional confirm) | |
966 "Read network news. | |
967 If optional argument CONFIRM is non-nil, ask NNTP server." | |
968 (interactive "P") | |
969 (unwind-protect | |
970 (progn | |
971 (switch-to-buffer (get-buffer-create gnus-Group-buffer)) | |
972 (gnus-Group-mode) | |
973 (gnus-start-news-server confirm)) | |
974 (if (not (gnus-server-opened)) | |
975 (gnus-Group-quit) | |
976 ;; NNTP server is successfully open. | |
977 (setq mode-line-process (format " {%s}" gnus-nntp-server)) | |
978 (let ((buffer-read-only nil)) | |
979 (erase-buffer) | |
980 (gnus-Group-startup-message) | |
981 (sit-for 0)) | |
982 (run-hooks 'gnus-Startup-hook) | |
983 (gnus-setup-news-info) | |
984 (if gnus-novice-user | |
985 (gnus-Group-describe-briefly)) ;Show brief help message. | |
986 (gnus-Group-list-groups nil) | |
987 ))) | |
988 | |
989 (defun gnus-Group-startup-message () | |
990 "Insert startup message in current buffer." | |
991 ;; Insert the message. | |
992 (insert " | |
993 GNUS Version 3.13 | |
994 | |
995 NNTP-based News Reader for GNU Emacs | |
996 | |
997 | |
998 If you have any trouble with this software, please let me | |
999 know. I will fix your problems in the next release. | |
1000 | |
1001 Comments, suggestions, and bug fixes are welcome. | |
1002 | |
1003 Masanobu UMEDA | |
1004 umerin@tc.Nagasaki.GO.JP") | |
1005 ;; And then hack it. | |
1006 ;; 57 is the longest line. | |
1007 (indent-rigidly (point-min) (point-max) (/ (max (- (window-width) 57) 0) 2)) | |
1008 (goto-char (point-min)) | |
1009 ;; +4 is fuzzy factor. | |
1010 (insert-char ?\n (/ (max (- (window-height) 18) 0) 2))) | |
1011 | |
1012 (defun gnus-Group-list-groups (show-all) | |
1013 "List newsgroups in the Newsgroup buffer. | |
1014 If argument SHOW-ALL is non-nil, unsubscribed groups are also listed." | |
1015 (interactive "P") | |
1016 (let ((last-group ;Current newsgroup. | |
1017 (gnus-Group-group-name)) | |
1018 (next-group ;Next possible newsgroup. | |
1019 (progn | |
1020 (gnus-Group-search-forward nil nil) | |
1021 (gnus-Group-group-name))) | |
1022 (prev-group ;Previous possible newsgroup. | |
1023 (progn | |
1024 (gnus-Group-search-forward t nil) | |
1025 (gnus-Group-group-name)))) | |
1026 (gnus-Group-prepare show-all) | |
1027 (if (zerop (buffer-size)) | |
1028 (message "No news is good news") | |
1029 ;; Go to last newsgroup if possible. If cannot, try next and | |
1030 ;; previous. If all fail, go to first unread newsgroup. | |
1031 (goto-char (point-min)) | |
1032 (or (and last-group | |
1033 (re-search-forward | |
1034 (concat "^.+: " (regexp-quote last-group) "$") nil t)) | |
1035 (and next-group | |
1036 (re-search-forward | |
1037 (concat "^.+: " (regexp-quote next-group) "$") nil t)) | |
1038 (and prev-group | |
1039 (re-search-forward | |
1040 (concat "^.+: " (regexp-quote prev-group) "$") nil t)) | |
1041 (re-search-forward "^[ \t]+[1-9][0-9]*:" nil t)) | |
1042 ;; Adjust cursor point. | |
1043 (beginning-of-line) | |
1044 (search-forward ":" nil t) | |
1045 ))) | |
1046 | |
1047 (defun gnus-Group-prepare (&optional all) | |
1048 "Prepare list of newsgroups in current buffer. | |
1049 If optional argument ALL is non-nil, unsubscribed groups are also listed." | |
1050 (let ((buffer-read-only nil) | |
1051 (newsrc gnus-newsrc-assoc) | |
1052 (group-info nil) | |
1053 (group-name nil) | |
1054 (unread-count 0) | |
1055 ;; This specifies the format of Group buffer. | |
1056 (cntl "%s%s%5d: %s\n")) | |
1057 (erase-buffer) | |
1058 ;; List newsgroups. | |
1059 (while newsrc | |
1060 (setq group-info (car newsrc)) | |
1061 (setq group-name (car group-info)) | |
1062 (setq unread-count (nth 1 (gnus-gethash group-name gnus-unread-hashtb))) | |
1063 (if (or all | |
1064 (and (nth 1 group-info) ;Subscribed. | |
1065 (> unread-count 0))) ;There are unread articles. | |
1066 ;; Yes, I can use gnus-Group-prepare-line, but this is faster. | |
1067 (insert | |
1068 (format cntl | |
1069 ;; Subscribed or not. | |
1070 (if (nth 1 group-info) " " "U") | |
1071 ;; Has new news? | |
1072 (if (and (> unread-count 0) | |
1073 (>= 0 | |
1074 (- unread-count | |
1075 (length | |
1076 (cdr (assoc group-name | |
1077 gnus-marked-assoc)))))) | |
1078 "*" " ") | |
1079 ;; Number of unread articles. | |
1080 unread-count | |
1081 ;; Newsgroup name. | |
1082 group-name)) | |
1083 ) | |
1084 (setq newsrc (cdr newsrc)) | |
1085 ) | |
1086 (setq gnus-have-all-newsgroups all) | |
1087 (goto-char (point-min)) | |
1088 (run-hooks 'gnus-Group-prepare-hook) | |
1089 )) | |
1090 | |
1091 (defun gnus-Group-prepare-line (info) | |
1092 "Return a string for the Newsgroup buffer from INFO. | |
1093 INFO is an element of gnus-newsrc-assoc or gnus-killed-assoc." | |
1094 (let* ((group-name (car info)) | |
1095 (unread-count | |
1096 (or (nth 1 (gnus-gethash group-name gnus-unread-hashtb)) | |
1097 ;; Not in hash table, so compute it now. | |
1098 (gnus-number-of-articles | |
1099 (gnus-difference-of-range | |
1100 (nth 2 (gnus-gethash group-name gnus-active-hashtb)) | |
1101 (nthcdr 2 info))))) | |
1102 ;; This specifies the format of Group buffer. | |
1103 (cntl "%s%s%5d: %s\n")) | |
1104 (format cntl | |
1105 ;; Subscribed or not. | |
1106 (if (nth 1 info) " " "U") | |
1107 ;; Has new news? | |
1108 (if (and (> unread-count 0) | |
1109 (>= 0 | |
1110 (- unread-count | |
1111 (length | |
1112 (cdr (assoc group-name gnus-marked-assoc)))))) | |
1113 "*" " ") | |
1114 ;; Number of unread articles. | |
1115 unread-count | |
1116 ;; Newsgroup name. | |
1117 group-name | |
1118 ))) | |
1119 | |
1120 (defun gnus-Group-update-group (group &optional visible-only) | |
1121 "Update newsgroup info of GROUP. | |
1122 If optional argument VISIBLE-ONLY is non-nil, non displayed group is ignored." | |
1123 (let ((buffer-read-only nil) | |
1124 (visible nil)) | |
1125 ;; Buffer may be narrowed. | |
1126 (save-restriction | |
1127 (widen) | |
1128 ;; Search point to modify. | |
1129 (goto-char (point-min)) | |
1130 (if (re-search-forward (concat "^.+: " (regexp-quote group) "$") nil t) | |
1131 ;; GROUP is listed in current buffer. So, delete old line. | |
1132 (progn | |
1133 (setq visible t) | |
1134 (beginning-of-line) | |
1135 (delete-region (point) (progn (forward-line 1) (point))) | |
1136 )) | |
1137 (if (or visible (not visible-only)) | |
1138 (progn | |
1139 (insert (gnus-Group-prepare-line (assoc group gnus-newsrc-assoc))) | |
1140 (forward-line -1) ;Move point on that line. | |
1141 )) | |
1142 ))) | |
1143 | |
1144 ;; GNUS Group mode command | |
1145 | |
1146 (defun gnus-Group-group-name () | |
1147 "Get newsgroup name around point." | |
1148 (save-excursion | |
1149 (beginning-of-line) | |
1150 (if (looking-at ".[* \t]*[0-9]+:[ \t]+\\([^ \t\n]+\\)$") | |
1151 (buffer-substring (match-beginning 1) (match-end 1)) | |
1152 ))) | |
1153 | |
1154 (defun gnus-Group-read-group (all &optional no-article) | |
1155 "Read news in this newsgroup. | |
1156 If argument ALL is non-nil, already read articles become readable. | |
1157 If optional argument NO-ARTICLE is non-nil, no article body is displayed." | |
1158 (interactive "P") | |
1159 (let ((group (gnus-Group-group-name))) ;Newsgroup name to read. | |
1160 (if group | |
1161 (gnus-Subject-read-group | |
1162 group | |
1163 (or all | |
1164 ;;(not (nth 1 (assoc group gnus-newsrc-assoc))) ;Unsubscribed | |
1165 (zerop | |
1166 (nth 1 (gnus-gethash group gnus-unread-hashtb)))) ;No unread | |
1167 no-article | |
1168 )) | |
1169 )) | |
1170 | |
1171 (defun gnus-Group-select-group (all) | |
1172 "Select this newsgroup. | |
1173 No article is selected automatically. | |
1174 If argument ALL is non-nil, already read articles become readable." | |
1175 (interactive "P") | |
1176 (gnus-Group-read-group all t)) | |
1177 | |
1178 (defun gnus-Group-jump-to-group (group) | |
1179 "Jump to newsgroup GROUP." | |
1180 (interactive | |
1181 (list (completing-read "Newsgroup: " gnus-newsrc-assoc nil 'require-match))) | |
1182 (goto-char (point-min)) | |
1183 (or (re-search-forward (concat "^.+: " (regexp-quote group) "$") nil t) | |
1184 (if (assoc group gnus-newsrc-assoc) | |
1185 ;; Add GROUP entry, then seach again. | |
1186 (gnus-Group-update-group group))) | |
1187 ;; Adjust cursor point. | |
1188 (beginning-of-line) | |
1189 (search-forward ":" nil t)) | |
1190 | |
1191 (defun gnus-Group-search-forward (backward any-group) | |
1192 "Search for newsgroup forward. | |
1193 If first argument BACKWARD is non-nil, search backward instead. | |
1194 If second argument ANY-GROUP is non-nil, unsubscribed or empty | |
1195 group may be selected." | |
1196 (let ((func (if backward 're-search-backward 're-search-forward)) | |
1197 (regexp | |
1198 (format "^%s[ \t]*\\(%s\\):" | |
1199 (if any-group ".." " [ \t]") | |
1200 (if any-group "[0-9]+" "[1-9][0-9]*"))) | |
1201 (found nil)) | |
1202 (if backward | |
1203 (beginning-of-line) | |
1204 (end-of-line)) | |
1205 (setq found (funcall func regexp nil t)) | |
1206 ;; Adjust cursor point. | |
1207 (beginning-of-line) | |
1208 (search-forward ":" nil t) | |
1209 ;; Return T if found. | |
1210 found | |
1211 )) | |
1212 | |
1213 (defun gnus-Group-next-group (n) | |
1214 "Go to next N'th newsgroup." | |
1215 (interactive "p") | |
1216 (while (and (> n 1) | |
1217 (gnus-Group-search-forward nil t)) | |
1218 (setq n (1- n))) | |
1219 (or (gnus-Group-search-forward nil t) | |
1220 (message "No more newsgroups"))) | |
1221 | |
1222 (defun gnus-Group-next-unread-group (n) | |
1223 "Go to next N'th unread newsgroup." | |
1224 (interactive "p") | |
1225 (while (and (> n 1) | |
1226 (gnus-Group-search-forward nil nil)) | |
1227 (setq n (1- n))) | |
1228 (or (gnus-Group-search-forward nil nil) | |
1229 (message "No more unread newsgroups"))) | |
1230 | |
1231 (defun gnus-Group-prev-group (n) | |
1232 "Go to previous N'th newsgroup." | |
1233 (interactive "p") | |
1234 (while (and (> n 1) | |
1235 (gnus-Group-search-forward t t)) | |
1236 (setq n (1- n))) | |
1237 (or (gnus-Group-search-forward t t) | |
1238 (message "No more newsgroups"))) | |
1239 | |
1240 (defun gnus-Group-prev-unread-group (n) | |
1241 "Go to previous N'th unread newsgroup." | |
1242 (interactive "p") | |
1243 (while (and (> n 1) | |
1244 (gnus-Group-search-forward t nil)) | |
1245 (setq n (1- n))) | |
1246 (or (gnus-Group-search-forward t nil) | |
1247 (message "No more unread newsgroups"))) | |
1248 | |
1249 (defun gnus-Group-catch-up (all &optional quietly) | |
1250 "Mark all articles not marked as unread in current newsgroup as read. | |
1251 If prefix argument ALL is non-nil, all articles are marked as read. | |
1252 Cross references (Xref: field) of articles are ignored." | |
1253 (interactive "P") | |
1254 (let* ((group (gnus-Group-group-name)) | |
1255 (marked (if (not all) | |
1256 (cdr (assoc group gnus-marked-assoc))))) | |
1257 (and group | |
1258 (or quietly | |
1259 (y-or-n-p | |
1260 (if all | |
1261 "Do you really want to mark everything as read? " | |
1262 "Delete all articles not marked as read? "))) | |
1263 (progn | |
1264 (message "") ;Erase "Yes or No" question. | |
1265 ;; Any marked articles will be preserved. | |
1266 (gnus-update-unread-articles group marked marked) | |
1267 (gnus-Group-update-group group) | |
1268 (gnus-Group-next-group 1))) | |
1269 )) | |
1270 | |
1271 (defun gnus-Group-catch-up-all (&optional quietly) | |
1272 "Mark all articles in current newsgroup as read. | |
1273 Cross references (Xref: field) of articles are ignored." | |
1274 (interactive) | |
1275 (gnus-Group-catch-up t quietly)) | |
1276 | |
1277 (defun gnus-Group-unsubscribe-current-group () | |
1278 "Toggle subscribe from/to unsubscribe current group." | |
1279 (interactive) | |
1280 (gnus-Group-unsubscribe-group (gnus-Group-group-name)) | |
1281 (gnus-Group-next-group 1)) | |
1282 | |
1283 (defun gnus-Group-unsubscribe-group (group) | |
1284 "Toggle subscribe from/to unsubscribe GROUP. | |
1285 New newsgroup is added to .newsrc automatically." | |
1286 (interactive | |
1287 (list (completing-read "Newsgroup: " | |
1288 gnus-active-hashtb nil 'require-match))) | |
1289 (let ((newsrc (assoc group gnus-newsrc-assoc))) | |
1290 (cond ((not (null newsrc)) | |
1291 ;; Toggle subscription flag. | |
1292 (setcar (nthcdr 1 newsrc) (not (nth 1 newsrc))) | |
1293 (gnus-update-newsrc-buffer group) | |
1294 (gnus-Group-update-group group) | |
1295 ;; Adjust cursor point. | |
1296 (beginning-of-line) | |
1297 (search-forward ":" nil t)) | |
1298 ((and (stringp group) | |
1299 (gnus-gethash group gnus-active-hashtb)) | |
1300 ;; Add new newsgroup. | |
1301 (gnus-add-newsgroup group) | |
1302 (gnus-Group-update-group group) | |
1303 ;; Adjust cursor point. | |
1304 (beginning-of-line) | |
1305 (search-forward ":" nil t)) | |
1306 (t (error "No such newsgroup: %s" group))) | |
1307 )) | |
1308 | |
1309 (defun gnus-Group-list-all-groups () | |
1310 "List all of newsgroups in the Newsgroup buffer." | |
1311 (interactive) | |
1312 (gnus-Group-list-groups t)) | |
1313 | |
1314 (defun gnus-Group-get-new-news () | |
1315 "Get newly arrived articles. In fact, read the active file again." | |
1316 (interactive) | |
1317 (gnus-setup-news-info) | |
1318 (gnus-Group-list-groups gnus-have-all-newsgroups)) | |
1319 | |
1320 (defun gnus-Group-restart () | |
1321 "Force GNUS to read the raw startup file." | |
1322 (interactive) | |
1323 (gnus-save-newsrc-file) | |
1324 (gnus-setup-news-info t) ;Force to read the raw startup file. | |
1325 (gnus-Group-list-groups gnus-have-all-newsgroups)) | |
1326 | |
1327 (defun gnus-Group-check-bogus-groups () | |
1328 "Check bogus newsgroups." | |
1329 (interactive) | |
1330 (gnus-check-bogus-newsgroups t) ;Require confirmation. | |
1331 (gnus-Group-list-groups gnus-have-all-newsgroups)) | |
1332 | |
1333 (defun gnus-Group-restrict-groups (start end) | |
1334 "Restrict visible newsgroups to the current region (START and END). | |
1335 Type \\[widen] to remove restriction." | |
1336 (interactive "r") | |
1337 (save-excursion | |
1338 (narrow-to-region (progn | |
1339 (goto-char start) | |
1340 (beginning-of-line) | |
1341 (point)) | |
1342 (progn | |
1343 (goto-char end) | |
1344 (forward-line 1) | |
1345 (point)))) | |
1346 (message (substitute-command-keys "Type \\[widen] to remove restriction"))) | |
1347 | |
1348 (defun gnus-Group-edit-global-kill () | |
1349 "Edit a global KILL file." | |
1350 (interactive) | |
1351 (setq gnus-current-kill-article nil) ;No articles selected. | |
1352 (gnus-Kill-file-edit-file nil) ;Nil stands for global KILL file. | |
1353 (message | |
1354 (substitute-command-keys | |
1355 "Editing a global KILL file (Type \\[gnus-Kill-file-exit] to exit)"))) | |
1356 | |
1357 (defun gnus-Group-edit-local-kill () | |
1358 "Edit a local KILL file." | |
1359 (interactive) | |
1360 (setq gnus-current-kill-article nil) ;No articles selected. | |
1361 (gnus-Kill-file-edit-file (gnus-Group-group-name)) | |
1362 (message | |
1363 (substitute-command-keys | |
1364 "Editing a local KILL file (Type \\[gnus-Kill-file-exit] to exit)"))) | |
1365 | |
1366 (defun gnus-Group-force-update () | |
1367 "Update .newsrc file." | |
1368 (interactive) | |
1369 (gnus-save-newsrc-file)) | |
1370 | |
1371 (defun gnus-Group-suspend () | |
1372 "Suspend the current GNUS session. | |
1373 In fact, cleanup buffers except for Group Mode buffer. | |
1374 The hook `gnus-Suspend-gnus-hook' is called before actually suspending." | |
1375 (interactive) | |
1376 (run-hooks 'gnus-Suspend-gnus-hook) | |
1377 ;; Kill GNUS buffers except for Group Mode buffer. | |
1378 (let ((buffers gnus-buffer-list)) | |
1379 (while buffers | |
1380 (and (not (eq (car buffers) gnus-Group-buffer)) | |
1381 (get-buffer (car buffers)) | |
1382 (kill-buffer (car buffers))) | |
1383 (setq buffers (cdr buffers)) | |
1384 )) | |
1385 (bury-buffer)) | |
1386 | |
1387 (defun gnus-Group-exit () | |
1388 "Quit reading news after updating .newsrc. | |
1389 The hook `gnus-Exit-gnus-hook' is called before actually quitting." | |
1390 (interactive) | |
1391 (if (or noninteractive ;For gnus-batch-kill | |
1392 (zerop (buffer-size)) ;No news is good news. | |
1393 (not (gnus-server-opened)) ;NNTP connection closed. | |
1394 (y-or-n-p "Are you sure you want to quit reading news? ")) | |
1395 (progn | |
1396 (message "") ;Erase "Yes or No" question. | |
1397 (run-hooks 'gnus-Exit-gnus-hook) | |
1398 (gnus-save-newsrc-file) | |
1399 (gnus-clear-system) | |
1400 (gnus-close-server)) | |
1401 )) | |
1402 | |
1403 (defun gnus-Group-quit () | |
1404 "Quit reading news without updating .newsrc. | |
1405 The hook `gnus-Exit-gnus-hook' is called before actually quitting." | |
1406 (interactive) | |
1407 (if (or (zerop (buffer-size)) | |
1408 (not (gnus-server-opened)) | |
1409 (yes-or-no-p | |
1410 (format "Quit reading news without saving %s? " | |
1411 (file-name-nondirectory gnus-current-startup-file)))) | |
1412 (progn | |
1413 (message "") ;Erase "Yes or No" question. | |
1414 (run-hooks 'gnus-Exit-gnus-hook) | |
1415 (gnus-clear-system) | |
1416 (gnus-close-server)) | |
1417 )) | |
1418 | |
1419 (defun gnus-Group-describe-briefly () | |
1420 "Describe Group mode commands briefly." | |
1421 (interactive) | |
1422 (message | |
1423 (concat | |
1424 (substitute-command-keys "\\[gnus-Group-read-group]:Select ") | |
1425 (substitute-command-keys "\\[gnus-Group-next-unread-group]:Forward ") | |
1426 (substitute-command-keys "\\[gnus-Group-prev-unread-group]:Backward ") | |
1427 (substitute-command-keys "\\[gnus-Group-exit]:Exit ") | |
1428 (substitute-command-keys "\\[gnus-Info-find-node]:Run Info ") | |
1429 (substitute-command-keys "\\[gnus-Group-describe-briefly]:This help") | |
1430 ))) | |
1431 | |
1432 | |
1433 ;;; | |
1434 ;;; GNUS Subject Mode | |
1435 ;;; | |
1436 | |
1437 (if gnus-Subject-mode-map | |
1438 nil | |
1439 (setq gnus-Subject-mode-map (make-keymap)) | |
1440 (suppress-keymap gnus-Subject-mode-map) | |
1441 (define-key gnus-Subject-mode-map " " 'gnus-Subject-next-page) | |
1442 (define-key gnus-Subject-mode-map "\177" 'gnus-Subject-prev-page) | |
1443 (define-key gnus-Subject-mode-map "\r" 'gnus-Subject-scroll-up) | |
1444 (define-key gnus-Subject-mode-map "n" 'gnus-Subject-next-unread-article) | |
1445 (define-key gnus-Subject-mode-map "p" 'gnus-Subject-prev-unread-article) | |
1446 (define-key gnus-Subject-mode-map "N" 'gnus-Subject-next-article) | |
1447 (define-key gnus-Subject-mode-map "P" 'gnus-Subject-prev-article) | |
1448 (define-key gnus-Subject-mode-map "\e\C-n" 'gnus-Subject-next-same-subject) | |
1449 (define-key gnus-Subject-mode-map "\e\C-p" 'gnus-Subject-prev-same-subject) | |
1450 ;;(define-key gnus-Subject-mode-map "\e\C-n" 'gnus-Subject-next-unread-same-subject) | |
1451 ;;(define-key gnus-Subject-mode-map "\e\C-p" 'gnus-Subject-prev-unread-same-subject) | |
1452 (define-key gnus-Subject-mode-map "\C-c\C-n" 'gnus-Subject-next-digest) | |
1453 (define-key gnus-Subject-mode-map "\C-c\C-p" 'gnus-Subject-prev-digest) | |
1454 (define-key gnus-Subject-mode-map "\C-n" 'gnus-Subject-next-subject) | |
1455 (define-key gnus-Subject-mode-map "\C-p" 'gnus-Subject-prev-subject) | |
1456 (define-key gnus-Subject-mode-map "\en" 'gnus-Subject-next-unread-subject) | |
1457 (define-key gnus-Subject-mode-map "\ep" 'gnus-Subject-prev-unread-subject) | |
1458 ;;(define-key gnus-Subject-mode-map "\C-cn" 'gnus-Subject-next-group) | |
1459 ;;(define-key gnus-Subject-mode-map "\C-cp" 'gnus-Subject-prev-group) | |
1460 (define-key gnus-Subject-mode-map "." 'gnus-Subject-first-unread-article) | |
1461 (define-key gnus-Subject-mode-map "/" 'isearch-forward) | |
1462 (define-key gnus-Subject-mode-map "s" 'gnus-Subject-isearch-article) | |
1463 (define-key gnus-Subject-mode-map "\es" 'gnus-Subject-search-article-forward) | |
1464 (define-key gnus-Subject-mode-map "\eS" 'gnus-Subject-search-article-backward) | |
1465 (define-key gnus-Subject-mode-map "<" 'gnus-Subject-beginning-of-article) | |
1466 (define-key gnus-Subject-mode-map ">" 'gnus-Subject-end-of-article) | |
1467 (define-key gnus-Subject-mode-map "j" 'gnus-Subject-goto-subject) | |
1468 (define-key gnus-Subject-mode-map "J" 'gnus-Subject-goto-article) | |
1469 (define-key gnus-Subject-mode-map "l" 'gnus-Subject-goto-last-article) | |
1470 (define-key gnus-Subject-mode-map "^" 'gnus-Subject-refer-parent-article) | |
1471 (define-key gnus-Subject-mode-map "\er" 'gnus-Subject-refer-article) | |
1472 (define-key gnus-Subject-mode-map "u" 'gnus-Subject-mark-as-unread-forward) | |
1473 (define-key gnus-Subject-mode-map "U" 'gnus-Subject-mark-as-unread-backward) | |
1474 (define-key gnus-Subject-mode-map "d" 'gnus-Subject-mark-as-read-forward) | |
1475 (define-key gnus-Subject-mode-map "D" 'gnus-Subject-mark-as-read-backward) | |
1476 (define-key gnus-Subject-mode-map "\eu" 'gnus-Subject-clear-mark-forward) | |
1477 (define-key gnus-Subject-mode-map "\eU" 'gnus-Subject-clear-mark-backward) | |
1478 (define-key gnus-Subject-mode-map "k" 'gnus-Subject-kill-same-subject-and-select) | |
1479 (define-key gnus-Subject-mode-map "\C-k" 'gnus-Subject-kill-same-subject) | |
1480 (define-key gnus-Subject-mode-map "\e\C-t" 'gnus-Subject-toggle-threads) | |
1481 (define-key gnus-Subject-mode-map "\e\C-s" 'gnus-Subject-show-thread) | |
1482 (define-key gnus-Subject-mode-map "\e\C-h" 'gnus-Subject-hide-thread) | |
1483 (define-key gnus-Subject-mode-map "\e\C-f" 'gnus-Subject-next-thread) | |
1484 (define-key gnus-Subject-mode-map "\e\C-b" 'gnus-Subject-prev-thread) | |
1485 (define-key gnus-Subject-mode-map "\e\C-u" 'gnus-Subject-up-thread) | |
1486 (define-key gnus-Subject-mode-map "\e\C-d" 'gnus-Subject-down-thread) | |
1487 (define-key gnus-Subject-mode-map "\e\C-k" 'gnus-Subject-kill-thread) | |
1488 (define-key gnus-Subject-mode-map "&" 'gnus-Subject-execute-command) | |
1489 ;;(define-key gnus-Subject-mode-map "c" 'gnus-Subject-catch-up) | |
1490 ;;(define-key gnus-Subject-mode-map "c" 'gnus-Subject-catch-up-all) | |
1491 (define-key gnus-Subject-mode-map "c" 'gnus-Subject-catch-up-and-exit) | |
1492 ;;(define-key gnus-Subject-mode-map "c" 'gnus-Subject-catch-up-all-and-exit) | |
1493 (define-key gnus-Subject-mode-map "\C-t" 'gnus-Subject-toggle-truncation) | |
1494 (define-key gnus-Subject-mode-map "x" 'gnus-Subject-delete-marked-as-read) | |
1495 (define-key gnus-Subject-mode-map "X" 'gnus-Subject-delete-marked-with) | |
1496 (define-key gnus-Subject-mode-map "\C-c\C-sn" 'gnus-Subject-sort-by-number) | |
1497 (define-key gnus-Subject-mode-map "\C-c\C-sa" 'gnus-Subject-sort-by-author) | |
1498 (define-key gnus-Subject-mode-map "\C-c\C-ss" 'gnus-Subject-sort-by-subject) | |
1499 (define-key gnus-Subject-mode-map "\C-c\C-sd" 'gnus-Subject-sort-by-date) | |
1500 (define-key gnus-Subject-mode-map "\C-c\C-s\C-n" 'gnus-Subject-sort-by-number) | |
1501 (define-key gnus-Subject-mode-map "\C-c\C-s\C-a" 'gnus-Subject-sort-by-author) | |
1502 (define-key gnus-Subject-mode-map "\C-c\C-s\C-s" 'gnus-Subject-sort-by-subject) | |
1503 (define-key gnus-Subject-mode-map "\C-c\C-s\C-d" 'gnus-Subject-sort-by-date) | |
1504 (define-key gnus-Subject-mode-map "=" 'gnus-Subject-expand-window) | |
1505 (define-key gnus-Subject-mode-map "G" 'gnus-Subject-reselect-current-group) | |
1506 (define-key gnus-Subject-mode-map "w" 'gnus-Subject-stop-page-breaking) | |
1507 (define-key gnus-Subject-mode-map "\C-c\C-r" 'gnus-Subject-caesar-message) | |
1508 (define-key gnus-Subject-mode-map "g" 'gnus-Subject-show-article) | |
1509 (define-key gnus-Subject-mode-map "t" 'gnus-Subject-toggle-header) | |
1510 (define-key gnus-Subject-mode-map "v" 'gnus-Subject-show-all-headers) | |
1511 (define-key gnus-Subject-mode-map "\C-d" 'gnus-Subject-rmail-digest) | |
1512 (define-key gnus-Subject-mode-map "a" 'gnus-Subject-post-news) | |
1513 (define-key gnus-Subject-mode-map "f" 'gnus-Subject-post-reply) | |
1514 (define-key gnus-Subject-mode-map "F" 'gnus-Subject-post-reply-with-original) | |
1515 (define-key gnus-Subject-mode-map "C" 'gnus-Subject-cancel-article) | |
1516 (define-key gnus-Subject-mode-map "r" 'gnus-Subject-mail-reply) | |
1517 (define-key gnus-Subject-mode-map "R" 'gnus-Subject-mail-reply-with-original) | |
1518 (define-key gnus-Subject-mode-map "m" 'gnus-Subject-mail-other-window) | |
1519 (define-key gnus-Subject-mode-map "o" 'gnus-Subject-save-article) | |
1520 (define-key gnus-Subject-mode-map "\C-o" 'gnus-Subject-save-in-mail) | |
1521 (define-key gnus-Subject-mode-map "|" 'gnus-Subject-pipe-output) | |
1522 (define-key gnus-Subject-mode-map "\ek" 'gnus-Subject-edit-local-kill) | |
1523 (define-key gnus-Subject-mode-map "\eK" 'gnus-Subject-edit-global-kill) | |
1524 (define-key gnus-Subject-mode-map "V" 'gnus-version) | |
1525 (define-key gnus-Subject-mode-map "q" 'gnus-Subject-exit) | |
1526 (define-key gnus-Subject-mode-map "Q" 'gnus-Subject-quit) | |
1527 (define-key gnus-Subject-mode-map "?" 'gnus-Subject-describe-briefly) | |
1528 (define-key gnus-Subject-mode-map "\C-c\C-i" 'gnus-Info-find-node)) | |
1529 | |
1530 (defun gnus-Subject-mode () | |
1531 "Major mode for reading articles in this newsgroup. | |
1532 All normal editing commands are turned off. | |
1533 Instead, these commands are available: | |
1534 \\{gnus-Subject-mode-map} | |
1535 | |
1536 User customizable variables: | |
1537 gnus-large-newsgroup | |
1538 The number of articles which indicates a large newsgroup. If the | |
1539 number of articles in a newsgroup is greater than the value, the | |
1540 number of articles to be selected is asked for. If the given value | |
1541 N is positive, the last N articles is selected. If N is negative, | |
1542 the first N articles are selected. An empty string means to select | |
1543 all articles. | |
1544 | |
1545 gnus-use-long-file-name | |
1546 Non-nil means that a newsgroup name is used as a default file name | |
1547 to save articles to. If it's nil, the directory form of a | |
1548 newsgroup is used instead. | |
1549 | |
1550 gnus-default-article-saver | |
1551 Specifies your favorite article saver which is interactively | |
1552 funcallable. Following functions are available: | |
1553 | |
1554 gnus-Subject-save-in-rmail (in Rmail format) | |
1555 gnus-Subject-save-in-mail (in Unix mail format) | |
1556 gnus-Subject-save-in-folder (in MH folder) | |
1557 gnus-Subject-save-in-file (in article format). | |
1558 | |
1559 gnus-rmail-save-name | |
1560 gnus-mail-save-name | |
1561 gnus-folder-save-name | |
1562 gnus-file-save-name | |
1563 Specifies a function generating a file name to save articles in | |
1564 specified format. The function is called with NEWSGROUP, HEADERS, | |
1565 and optional LAST-FILE. Access macros to the headers are defined | |
1566 as nntp-header-FIELD, and functions are defined as `gnus-header-FIELD'. | |
1567 | |
1568 gnus-article-save-directory | |
1569 Specifies a directory name to save articles to using the commands | |
1570 `gnus-Subject-save-in-rmail', `gnus-Subject-save-in-mail' and | |
1571 `gnus-Subject-save-in-file'. The variable is initialized from the | |
1572 SAVEDIR environment variable. | |
1573 | |
1574 gnus-show-all-headers | |
1575 Non-nil means that all headers of an article are shown. | |
1576 | |
1577 gnus-save-all-headers | |
1578 Non-nil means that all headers of an article are saved in a file. | |
1579 | |
1580 gnus-show-threads | |
1581 Non-nil means that conversation threads are shown in tree structure. | |
1582 | |
1583 gnus-thread-hide-subject | |
1584 Non-nil means that subjects for thread subtrees are hidden. | |
1585 | |
1586 gnus-thread-hide-subtree | |
1587 Non-nil means that thread subtrees are hidden initially. | |
1588 | |
1589 gnus-thread-hide-killed | |
1590 Non-nil means that killed thread subtrees are hidden automatically. | |
1591 | |
1592 gnus-thread-ignore-subject | |
1593 Non-nil means that subject differences are ignored in constructing | |
1594 thread trees. | |
1595 | |
1596 gnus-thread-indent-level | |
1597 Indentation of thread subtrees. | |
1598 | |
1599 gnus-optional-headers | |
1600 Specifies a function which generates an optional string displayed | |
1601 in the Subject buffer. The function is called with an article | |
1602 HEADERS. The result must be a string excluding `[' and `]'. The | |
1603 default function returns a string like NNN:AUTHOR, where NNN is | |
1604 the number of lines in an article and AUTHOR is the name of the | |
1605 author. | |
1606 | |
1607 gnus-auto-extend-newsgroup | |
1608 Non-nil means visible articles are extended to forward and | |
1609 backward automatically if possible. | |
1610 | |
1611 gnus-auto-select-first | |
1612 Non-nil means the first unread article is selected automagically | |
1613 when a newsgroup is selected normally (by gnus-Group-read-group). | |
1614 If you'd like to prevent automatic selection of the first unread | |
1615 article in some newsgroups, set the variable to nil in | |
1616 gnus-Select-group-hook or gnus-Apply-kill-hook. | |
1617 | |
1618 gnus-auto-select-next | |
1619 Non-nil means the next newsgroup is selected automagically at the | |
1620 end of the newsgroup. If the value is t and the next newsgroup is | |
1621 empty (no unread articles), GNUS will exit Subject mode and go | |
1622 back to Group mode. If the value is neither nil nor t, GNUS won't | |
1623 exit Subject mode but select the following unread newsgroup. | |
1624 Especially, if the value is the symbol `quietly', the next unread | |
1625 newsgroup will be selected without any confirmations. | |
1626 | |
1627 gnus-auto-select-same | |
1628 Non-nil means an article with the same subject as the current | |
1629 article is selected automagically like `rn -S'. | |
1630 | |
1631 gnus-auto-center-subject | |
1632 Non-nil means the point of Subject Mode window is always kept | |
1633 centered. | |
1634 | |
1635 gnus-break-pages | |
1636 Non-nil means an article is broken into pages at page delimiters. | |
1637 This may not work with some versions of GNU Emacs earlier than | |
1638 version 18.50. | |
1639 | |
1640 gnus-page-delimiter | |
1641 Specifies a regexp describing line-beginnings that separate pages | |
1642 of news article. | |
1643 | |
1644 [gnus-more-message is obsolete. overlay-arrow-string interfares | |
1645 with other subsystems, such as dbx mode.] | |
1646 | |
1647 gnus-digest-show-summary | |
1648 Non-nil means that a summary of digest messages is shown when | |
1649 reading a digest article using `gnus-Subject-rmail-digest' command. | |
1650 | |
1651 gnus-digest-separator | |
1652 Specifies a regexp separating messages in a digest article. | |
1653 | |
1654 gnus-mail-reply-method | |
1655 gnus-mail-other-window-method | |
1656 Specifies a function to begin composing mail message using | |
1657 commands gnus-Subject-mail-reply and | |
1658 gnus-Subject-mail-other-window. Functions | |
1659 gnus-mail-reply-using-mail and gnus-mail-reply-using-mhe are | |
1660 available for the value of gnus-mail-reply-method. And functions | |
1661 gnus-mail-other-window-using-mail and | |
1662 gnus-mail-other-window-using-mhe are available for the value of | |
1663 gnus-mail-other-window-method. | |
1664 | |
1665 Various hooks for customization: | |
1666 gnus-Subject-mode-hook | |
1667 Entry to this mode calls the value with no arguments, if that | |
1668 value is non-nil. | |
1669 | |
1670 gnus-Select-group-hook | |
1671 Called with no arguments when newsgroup is selected, if that value | |
1672 is non-nil. It is possible to sort subjects in this hook. See the | |
1673 documentation of this variable for more information. | |
1674 | |
1675 gnus-Subject-prepare-hook | |
1676 Called with no arguments after a subject list is created in the | |
1677 Subject buffer, if that value is non-nil. If you'd like to modify | |
1678 the buffer, you can use this hook. | |
1679 | |
1680 gnus-Select-article-hook | |
1681 Called with no arguments when an article is selected, if that | |
1682 value is non-nil. See the documentation of this variable for | |
1683 more information. | |
1684 | |
1685 gnus-Select-digest-hook | |
1686 Called with no arguments when reading digest messages using Rmail, | |
1687 if that value is non-nil. This hook can be used to modify an | |
1688 article so that Rmail can work with it. See the documentation of | |
1689 the variable for more information. | |
1690 | |
1691 gnus-Rmail-digest-hook | |
1692 Called with no arguments when reading digest messages using Rmail, | |
1693 if that value is non-nil. This hook is intended to customize Rmail | |
1694 mode. | |
1695 | |
1696 gnus-Apply-kill-hook | |
1697 Called with no arguments when a newsgroup is selected and the | |
1698 Subject buffer is prepared. This hook is intended to apply a KILL | |
1699 file to the selected newsgroup. The format of KILL file is | |
1700 completely different from that of version 3.8. You have to rewrite | |
1701 them in the new format. See the documentation of Kill file mode | |
1702 for more information. | |
1703 | |
1704 gnus-Mark-article-hook | |
1705 Called with no arguments when an article is selected at the first | |
1706 time. The hook is intended to mark an article as read (or unread) | |
1707 automatically when it is selected. See the documentation of the | |
1708 variable for more information. | |
1709 | |
1710 gnus-Exit-group-hook | |
1711 Called with no arguments when exiting the current newsgroup, if | |
1712 that value is non-nil. If your machine is so slow that exiting | |
1713 from Subject mode takes very long time, inhibit marking articles | |
1714 as read using cross-references by setting the variable | |
1715 `gnus-newsgroup-headers' to nil in this hook." | |
1716 (interactive) | |
1717 (kill-all-local-variables) | |
1718 ;; Gee. Why don't you upgrade? | |
1719 (cond ((boundp 'mode-line-modified) | |
1720 (setq mode-line-modified "--- ")) | |
1721 ((listp (default-value 'mode-line-format)) | |
1722 (setq mode-line-format | |
1723 (cons "--- " (cdr (default-value 'mode-line-format)))))) | |
1724 (make-local-variable 'global-mode-string) | |
1725 (setq global-mode-string nil) | |
1726 (setq major-mode 'gnus-Subject-mode) | |
1727 (setq mode-name "Subject") | |
1728 ;;(setq mode-line-process '(" " gnus-newsgroup-name)) | |
1729 (make-local-variable 'minor-mode-alist) | |
1730 (or (assq 'gnus-show-threads minor-mode-alist) | |
1731 (setq minor-mode-alist | |
1732 (cons (list 'gnus-show-threads " Thread") minor-mode-alist))) | |
1733 (gnus-Subject-set-mode-line) | |
1734 (use-local-map gnus-Subject-mode-map) | |
1735 (buffer-flush-undo (current-buffer)) | |
1736 (setq buffer-read-only t) ;Disable modification | |
1737 (setq truncate-lines t) ;Stop line folding | |
1738 (setq selective-display t) | |
1739 (setq selective-display-ellipses t) ;Display `...' | |
1740 ;;(setq case-fold-search t) | |
1741 (run-hooks 'gnus-Subject-mode-hook)) | |
1742 | |
1743 (defun gnus-Subject-setup-buffer () | |
1744 "Initialize subject display buffer." | |
1745 (if (get-buffer gnus-Subject-buffer) | |
1746 (set-buffer gnus-Subject-buffer) | |
1747 (set-buffer (get-buffer-create gnus-Subject-buffer)) | |
1748 (gnus-Subject-mode) | |
1749 )) | |
1750 | |
1751 (defun gnus-Subject-read-group (group &optional show-all no-article) | |
1752 "Start reading news in newsgroup GROUP. | |
1753 If optional first argument SHOW-ALL is non-nil, already read articles are | |
1754 also listed. | |
1755 If optional second argument NO-ARTICLE is non-nil, no article is selected | |
1756 initially." | |
1757 (message "Retrieving newsgroup: %s..." group) | |
1758 (if (gnus-select-newsgroup group show-all) | |
1759 (progn | |
1760 ;; Don't switch-to-buffer to prevent displaying old contents | |
1761 ;; of the buffer until new subjects list is created. | |
1762 ;; Suggested by Juha Heinanen <jh@tut.fi> | |
1763 (gnus-Subject-setup-buffer) | |
1764 ;; You can change the order of subjects in this hook. | |
1765 (run-hooks 'gnus-Select-group-hook) | |
1766 (gnus-Subject-prepare) | |
1767 ;; Function `gnus-apply-kill-file' must be called in this hook. | |
1768 (run-hooks 'gnus-Apply-kill-hook) | |
1769 (if (zerop (buffer-size)) | |
1770 ;; This newsgroup is empty. | |
1771 (progn | |
1772 (gnus-Subject-catch-up-and-exit nil t) ;Without confirmations. | |
1773 (message "No unread news")) | |
1774 ;; Hide conversation thread subtrees. We cannot do this in | |
1775 ;; gnus-Subject-prepare-hook since kill processing may not | |
1776 ;; work with hidden articles. | |
1777 (and gnus-show-threads | |
1778 gnus-thread-hide-subtree | |
1779 (gnus-Subject-hide-all-threads)) | |
1780 ;; Show first unread article if requested. | |
1781 (goto-char (point-min)) | |
1782 (if (and (not no-article) | |
1783 gnus-auto-select-first | |
1784 (gnus-Subject-first-unread-article)) | |
1785 ;; Window is configured automatically. | |
1786 ;; Current buffer may be changed as a result of hook | |
1787 ;; evaluation, especially by gnus-Subject-rmail-digest | |
1788 ;; command, so we should adjust cursor point carefully. | |
1789 (if (eq (current-buffer) (get-buffer gnus-Subject-buffer)) | |
1790 (progn | |
1791 ;; Adjust cursor point. | |
1792 (beginning-of-line) | |
1793 (search-forward ":" nil t))) | |
1794 (gnus-configure-windows 'SelectNewsgroup) | |
1795 (pop-to-buffer gnus-Subject-buffer) | |
1796 (gnus-Subject-set-mode-line) | |
1797 ;; I sometime get confused with the old Article buffer. | |
1798 (if (get-buffer gnus-Article-buffer) | |
1799 (if (get-buffer-window gnus-Article-buffer) | |
1800 (save-excursion | |
1801 (set-buffer gnus-Article-buffer) | |
1802 (let ((buffer-read-only nil)) | |
1803 (erase-buffer))) | |
1804 (kill-buffer gnus-Article-buffer))) | |
1805 ;; Adjust cursor point. | |
1806 (beginning-of-line) | |
1807 (search-forward ":" nil t)) | |
1808 )) | |
1809 ;; Cannot select newsgroup GROUP. | |
1810 (if (gnus-gethash group gnus-active-hashtb) | |
1811 (progn | |
1812 ;; If NNTP is used, nntp_access file may not be installed | |
1813 ;; properly. Otherwise, may be active file problem. | |
1814 (ding) | |
1815 (message "Cannot select %s. May be security or active file problem." group) | |
1816 (sit-for 0)) | |
1817 ;; Check bogus newsgroups. | |
1818 ;; We must be in Group Mode buffer. | |
1819 (gnus-Group-check-bogus-groups)) | |
1820 )) | |
1821 | |
1822 (defun gnus-Subject-prepare () | |
1823 "Prepare subject list of current newsgroup in Subject mode buffer." | |
1824 (let ((buffer-read-only nil)) | |
1825 ;; Note: The next codes are not actually used because the user who | |
1826 ;; want it can define them in gnus-Select-group-hook. | |
1827 ;; Print verbose messages if too many articles are selected. | |
1828 ;; (and (numberp gnus-large-newsgroup) | |
1829 ;; (> (length gnus-newsgroup-headers) gnus-large-newsgroup) | |
1830 ;; (message "Preparing headers...")) | |
1831 (erase-buffer) | |
1832 (gnus-Subject-prepare-threads | |
1833 (if gnus-show-threads | |
1834 (gnus-make-threads gnus-newsgroup-headers) | |
1835 gnus-newsgroup-headers) 0) | |
1836 ;; Erase header retrieval message. | |
1837 (message "") | |
1838 ;; Call hooks for modifying Subject mode buffer. | |
1839 ;; Suggested by sven@tde.LTH.Se (Sven Mattisson). | |
1840 (goto-char (point-min)) | |
1841 (run-hooks 'gnus-Subject-prepare-hook) | |
1842 )) | |
1843 | |
1844 ;; Basic ideas by Paul Dworkin <paul@media-lab.media.mit.edu> | |
1845 | |
1846 (defun gnus-Subject-prepare-threads (threads level) | |
1847 "Prepare Subject buffer from THREADS and indentation LEVEL. | |
1848 THREADS is a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...]).'" | |
1849 (let ((thread nil) | |
1850 (header nil) | |
1851 (number nil) | |
1852 ;; `M Indent NUM: [OPT] SUBJECT' | |
1853 (cntl (format "%%s %%s%%%dd: [%%s] %%s\n" | |
1854 (length (prin1-to-string gnus-newsgroup-end))))) | |
1855 (while threads | |
1856 (setq thread (car threads)) | |
1857 (setq threads (cdr threads)) | |
1858 ;; If thread is a cons, hierarchical threads is given. | |
1859 ;; Otherwise, thread itself is header. | |
1860 (if (consp thread) | |
1861 (setq header (car thread)) | |
1862 (setq header thread)) | |
1863 ;; Print valid header only. | |
1864 (if (vectorp header) ;Depends on nntp.el. | |
1865 (progn | |
1866 (setq number (nntp-header-number header)) | |
1867 (insert | |
1868 (format cntl | |
1869 ;; Read or not. | |
1870 (cond ((memq number gnus-newsgroup-marked) "-") | |
1871 ((memq number gnus-newsgroup-unreads) " ") | |
1872 (t "D")) | |
1873 ;; Thread level. | |
1874 (make-string (* level gnus-thread-indent-level) ? ) | |
1875 ;; Article number. | |
1876 number | |
1877 ;; Optional headers. | |
1878 (or (and gnus-optional-headers | |
1879 (funcall gnus-optional-headers header)) "") | |
1880 ;; Its subject string. | |
1881 (concat (if (or (zerop level) | |
1882 (not gnus-thread-hide-subject)) | |
1883 nil | |
1884 (make-string (window-width) ? )) | |
1885 (nntp-header-subject header)) | |
1886 )) | |
1887 )) | |
1888 ;; Print subthreads. | |
1889 (and (consp thread) | |
1890 (cdr thread) | |
1891 (gnus-Subject-prepare-threads (cdr thread) (1+ level))) | |
1892 ))) | |
1893 | |
1894 (defun gnus-Subject-set-mode-line () | |
1895 "Set Subject mode line string." | |
1896 ;; The value must be a string to escape %-constructs. | |
1897 (let ((subject | |
1898 (if gnus-current-headers | |
1899 (nntp-header-subject gnus-current-headers) gnus-newsgroup-name))) | |
1900 (setq mode-line-buffer-identification | |
1901 (concat "GNUS: " | |
1902 subject | |
1903 ;; Enough spaces to pad subject to 17 positions. | |
1904 (make-string (max 0 (- 17 (length subject))) ? )))) | |
1905 (set-buffer-modified-p t)) | |
1906 | |
1907 ;; GNUS Subject mode command. | |
1908 | |
1909 (defun gnus-Subject-search-group (&optional backward) | |
1910 "Search for next unread newsgroup. | |
1911 If optional argument BACKWARD is non-nil, search backward instead." | |
1912 (save-excursion | |
1913 (set-buffer gnus-Group-buffer) | |
1914 (save-excursion | |
1915 ;; We don't want to alter current point of Group mode buffer. | |
1916 (if (gnus-Group-search-forward backward nil) | |
1917 (gnus-Group-group-name)) | |
1918 ))) | |
1919 | |
1920 (defun gnus-Subject-search-subject (backward unread subject) | |
1921 "Search for article forward. | |
1922 If first argument BACKWARD is non-nil, search backward. | |
1923 If second argument UNREAD is non-nil, only unread article is selected. | |
1924 If third argument SUBJECT is non-nil, the article which has | |
1925 the same subject will be searched for." | |
1926 (let ((func (if backward 're-search-backward 're-search-forward)) | |
1927 (article nil) | |
1928 ;; We have to take care of hidden lines. | |
1929 (regexp | |
1930 (format "^%s[ \t]+\\([0-9]+\\):.\\[[^]\r\n]*\\][ \t]+%s" | |
1931 ;;(if unread " " ".") | |
1932 (cond ((eq unread t) " ") (unread "[ ---]") (t ".")) | |
1933 (if subject | |
1934 (concat "\\([Rr][Ee]:[ \t]+\\)*" | |
1935 (regexp-quote (gnus-simplify-subject subject)) | |
1936 ;; Ignore words in parentheses. | |
1937 "\\([ \t]*([^\r\n]*)\\)*[ \t]*\\(\r\\|$\\)") | |
1938 "") | |
1939 ))) | |
1940 (if backward | |
1941 (beginning-of-line) | |
1942 (end-of-line)) | |
1943 (if (funcall func regexp nil t) | |
1944 (setq article | |
1945 (string-to-int | |
1946 (buffer-substring (match-beginning 1) (match-end 1))))) | |
1947 ;; Adjust cursor point. | |
1948 (beginning-of-line) | |
1949 (search-forward ":" nil t) | |
1950 ;; This is the result. | |
1951 article | |
1952 )) | |
1953 | |
1954 (defun gnus-Subject-search-forward (&optional unread subject) | |
1955 "Search for article forward. | |
1956 If first optional argument UNREAD is non-nil, only unread article is selected. | |
1957 If second optional argument SUBJECT is non-nil, the article which has | |
1958 the same subject will be searched for." | |
1959 (gnus-Subject-search-subject nil unread subject)) | |
1960 | |
1961 (defun gnus-Subject-search-backward (&optional unread subject) | |
1962 "Search for article backward. | |
1963 If first optional argument UNREAD is non-nil, only unread article is selected. | |
1964 If second optional argument SUBJECT is non-nil, the article which has | |
1965 the same subject will be searched for." | |
1966 (gnus-Subject-search-subject t unread subject)) | |
1967 | |
1968 (defun gnus-Subject-article-number () | |
1969 "Article number around point. If nothing, return current number." | |
1970 (save-excursion | |
1971 (beginning-of-line) | |
1972 (if (looking-at ".[ \t]+\\([0-9]+\\):") | |
1973 (string-to-int | |
1974 (buffer-substring (match-beginning 1) (match-end 1))) | |
1975 ;; If search fail, return current article number. | |
1976 gnus-current-article | |
1977 ))) | |
1978 | |
1979 (defun gnus-Subject-subject-string () | |
1980 "Return current subject string or nil if nothing." | |
1981 (save-excursion | |
1982 ;; It is possible to implement this function using | |
1983 ;; `gnus-Subject-article-number' and `gnus-newsgroup-headers'. | |
1984 (beginning-of-line) | |
1985 ;; We have to take care of hidden lines. | |
1986 (if (looking-at ".[ \t]+[0-9]+:.\\[[^]\r\n]*\\][ \t]+\\([^\r\n]*\\)[\r\n]") | |
1987 (buffer-substring (match-beginning 1) (match-end 1))) | |
1988 )) | |
1989 | |
1990 (defun gnus-Subject-goto-subject (article) | |
1991 "Move point to ARTICLE's subject." | |
1992 (interactive | |
1993 (list | |
1994 (string-to-int | |
1995 (completing-read "Article number: " | |
1996 (mapcar | |
1997 (function | |
1998 (lambda (headers) | |
1999 (list | |
2000 (int-to-string (nntp-header-number headers))))) | |
2001 gnus-newsgroup-headers) | |
2002 nil 'require-match)))) | |
2003 (let ((current (point))) | |
2004 (goto-char (point-min)) | |
2005 (or (and article (re-search-forward (format "^.[ \t]+%d:" article) nil t)) | |
2006 (progn (goto-char current) nil)) | |
2007 )) | |
2008 | |
2009 (defun gnus-Subject-recenter () | |
2010 "Center point in Subject mode window." | |
2011 ;; Scroll window so as to cursor comes center of Subject mode window | |
2012 ;; only when article is displayed. | |
2013 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle). | |
2014 ;; Recenter only when requested. | |
2015 ;; Suggested by popovich@park.cs.columbia.edu | |
2016 (and gnus-auto-center-subject | |
2017 (get-buffer-window gnus-Article-buffer) | |
2018 (< (/ (- (window-height) 1) 2) | |
2019 (count-lines (point) (point-max))) | |
2020 (recenter (/ (- (window-height) 2) 2)))) | |
2021 | |
2022 ;; Walking around Group mode buffer. | |
2023 | |
2024 (defun gnus-Subject-jump-to-group (newsgroup) | |
2025 "Move point to NEWSGROUP in Group mode buffer." | |
2026 ;; Keep update point of Group mode buffer if visible. | |
2027 (if (eq (current-buffer) | |
2028 (get-buffer gnus-Group-buffer)) | |
2029 (save-window-excursion | |
2030 ;; Take care of tree window mode. | |
2031 (if (get-buffer-window gnus-Group-buffer) | |
2032 (pop-to-buffer gnus-Group-buffer)) | |
2033 (gnus-Group-jump-to-group newsgroup)) | |
2034 (save-excursion | |
2035 ;; Take care of tree window mode. | |
2036 (if (get-buffer-window gnus-Group-buffer) | |
2037 (pop-to-buffer gnus-Group-buffer) | |
2038 (set-buffer gnus-Group-buffer)) | |
2039 (gnus-Group-jump-to-group newsgroup)))) | |
2040 | |
2041 (defun gnus-Subject-next-group (no-article) | |
2042 "Exit current newsgroup and then select next unread newsgroup. | |
2043 If prefix argument NO-ARTICLE is non-nil, no article is selected initially." | |
2044 (interactive "P") | |
2045 ;; Make sure Group mode buffer point is on current newsgroup. | |
2046 (gnus-Subject-jump-to-group gnus-newsgroup-name) | |
2047 (let ((group (gnus-Subject-search-group))) | |
2048 (if (null group) | |
2049 (progn | |
2050 (message "Exiting %s..." gnus-newsgroup-name) | |
2051 (gnus-Subject-exit) | |
2052 (message "")) | |
2053 (message "Selecting %s..." group) | |
2054 (gnus-Subject-exit t) ;Exit Subject mode temporary. | |
2055 ;; We are now in Group mode buffer. | |
2056 ;; Make sure Group mode buffer point is on GROUP. | |
2057 (gnus-Subject-jump-to-group group) | |
2058 (gnus-Subject-read-group group nil no-article) | |
2059 (or (eq (current-buffer) | |
2060 (get-buffer gnus-Subject-buffer)) | |
2061 (eq gnus-auto-select-next t) | |
2062 ;; Expected newsgroup has nothing to read since the articles | |
2063 ;; are marked as read by cross-referencing. So, try next | |
2064 ;; newsgroup. (Make sure we are in Group mode buffer now.) | |
2065 (and (eq (current-buffer) | |
2066 (get-buffer gnus-Group-buffer)) | |
2067 (gnus-Group-group-name) | |
2068 (gnus-Subject-read-group | |
2069 (gnus-Group-group-name) nil no-article)) | |
2070 ) | |
2071 ))) | |
2072 | |
2073 (defun gnus-Subject-prev-group (no-article) | |
2074 "Exit current newsgroup and then select previous unread newsgroup. | |
2075 If prefix argument NO-ARTICLE is non-nil, no article is selected initially." | |
2076 (interactive "P") | |
2077 ;; Make sure Group mode buffer point is on current newsgroup. | |
2078 (gnus-Subject-jump-to-group gnus-newsgroup-name) | |
2079 (let ((group (gnus-Subject-search-group t))) | |
2080 (if (null group) | |
2081 (progn | |
2082 (message "Exiting %s..." gnus-newsgroup-name) | |
2083 (gnus-Subject-exit) | |
2084 (message "")) | |
2085 (message "Selecting %s..." group) | |
2086 (gnus-Subject-exit t) ;Exit Subject mode temporary. | |
2087 ;; We are now in Group mode buffer. | |
2088 ;; We have to adjust point of Group mode buffer because current | |
2089 ;; point is moved to next unread newsgroup by exiting. | |
2090 (gnus-Subject-jump-to-group group) | |
2091 (gnus-Subject-read-group group nil no-article) | |
2092 (or (eq (current-buffer) | |
2093 (get-buffer gnus-Subject-buffer)) | |
2094 (eq gnus-auto-select-next t) | |
2095 ;; Expected newsgroup has nothing to read since the articles | |
2096 ;; are marked as read by cross-referencing. So, try next | |
2097 ;; newsgroup. (Make sure we are in Group mode buffer now.) | |
2098 (and (eq (current-buffer) | |
2099 (get-buffer gnus-Group-buffer)) | |
2100 (gnus-Subject-search-group t) | |
2101 (gnus-Subject-read-group | |
2102 (gnus-Subject-search-group t) nil no-article)) | |
2103 ) | |
2104 ))) | |
2105 | |
2106 ;; Walking around subject lines. | |
2107 | |
2108 (defun gnus-Subject-next-subject (n &optional unread) | |
2109 "Go to next N'th subject line. | |
2110 If optional argument UNREAD is non-nil, only unread article is selected." | |
2111 (interactive "p") | |
2112 (while (and (> n 1) | |
2113 (gnus-Subject-search-forward unread)) | |
2114 (setq n (1- n))) | |
2115 (cond ((gnus-Subject-search-forward unread) | |
2116 (gnus-Subject-recenter)) | |
2117 (unread | |
2118 (message "No more unread articles")) | |
2119 (t | |
2120 (message "No more articles")) | |
2121 )) | |
2122 | |
2123 (defun gnus-Subject-next-unread-subject (n) | |
2124 "Go to next N'th unread subject line." | |
2125 (interactive "p") | |
2126 (gnus-Subject-next-subject n t)) | |
2127 | |
2128 (defun gnus-Subject-prev-subject (n &optional unread) | |
2129 "Go to previous N'th subject line. | |
2130 If optional argument UNREAD is non-nil, only unread article is selected." | |
2131 (interactive "p") | |
2132 (while (and (> n 1) | |
2133 (gnus-Subject-search-backward unread)) | |
2134 (setq n (1- n))) | |
2135 (cond ((gnus-Subject-search-backward unread) | |
2136 (gnus-Subject-recenter)) | |
2137 (unread | |
2138 (message "No more unread articles")) | |
2139 (t | |
2140 (message "No more articles")) | |
2141 )) | |
2142 | |
2143 (defun gnus-Subject-prev-unread-subject (n) | |
2144 "Go to previous N'th unread subject line." | |
2145 (interactive "p") | |
2146 (gnus-Subject-prev-subject n t)) | |
2147 | |
2148 ;; Walking around subject lines with displaying articles. | |
2149 | |
2150 (defun gnus-Subject-expand-window () | |
2151 "Expand Subject window to show headers full window." | |
2152 (interactive) | |
2153 (gnus-configure-windows 'ExpandSubject) | |
2154 (pop-to-buffer gnus-Subject-buffer)) | |
2155 | |
2156 (defun gnus-Subject-display-article (article &optional all-header) | |
2157 "Display ARTICLE in Article buffer." | |
2158 (if (null article) | |
2159 nil | |
2160 (gnus-configure-windows 'SelectArticle) | |
2161 (pop-to-buffer gnus-Subject-buffer) | |
2162 (gnus-Article-prepare article all-header) | |
2163 (gnus-Subject-recenter) | |
2164 (gnus-Subject-set-mode-line) | |
2165 (run-hooks 'gnus-Select-article-hook) | |
2166 ;; Successfully display article. | |
2167 t | |
2168 )) | |
2169 | |
2170 (defun gnus-Subject-select-article (&optional all-headers force) | |
2171 "Select the current article. | |
2172 Optional argument ALL-HEADERS is non-nil, show all headers." | |
2173 (let ((article (gnus-Subject-article-number))) | |
2174 (if (or (null gnus-current-article) | |
2175 (/= article gnus-current-article) | |
2176 (and force (not (eq all-headers gnus-have-all-headers)))) | |
2177 ;; The selected subject is different from that of the current article. | |
2178 (gnus-Subject-display-article article all-headers) | |
2179 (gnus-configure-windows 'SelectArticle) | |
2180 (pop-to-buffer gnus-Subject-buffer)) | |
2181 )) | |
2182 | |
2183 (defun gnus-Subject-set-current-mark (&optional current-mark) | |
2184 "Put `+' at the current article. | |
2185 Optional argument specifies CURRENT-MARK instead of `+'." | |
2186 (save-excursion | |
2187 (set-buffer gnus-Subject-buffer) | |
2188 (let ((buffer-read-only nil)) | |
2189 (goto-char (point-min)) | |
2190 ;; First of all clear mark at last article. | |
2191 (if (re-search-forward "^.[ \t]+[0-9]+:[^ \t]" nil t) | |
2192 (progn | |
2193 (delete-char -1) | |
2194 (insert " ") | |
2195 (goto-char (point-min)))) | |
2196 (if (re-search-forward (format "^.[ \t]+%d:" gnus-current-article) nil t) | |
2197 (progn | |
2198 (delete-char 1) | |
2199 (insert (or current-mark "+")))) | |
2200 ))) | |
2201 | |
2202 (defun gnus-Subject-next-article (unread &optional subject) | |
2203 "Select article after current one. | |
2204 If argument UNREAD is non-nil, only unread article is selected." | |
2205 (interactive "P") | |
2206 (let ((header nil)) | |
2207 (cond ((gnus-Subject-display-article | |
2208 (gnus-Subject-search-forward unread subject))) | |
2209 ((and subject | |
2210 gnus-auto-select-same | |
2211 (gnus-set-difference gnus-newsgroup-unreads | |
2212 gnus-newsgroup-marked) | |
2213 (memq this-command | |
2214 '(gnus-Subject-next-unread-article | |
2215 gnus-Subject-next-page | |
2216 gnus-Subject-kill-same-subject-and-select | |
2217 ;;gnus-Subject-next-article | |
2218 ;;gnus-Subject-next-same-subject | |
2219 ;;gnus-Subject-next-unread-same-subject | |
2220 ))) | |
2221 ;; Wrap article pointer if there are unread articles. | |
2222 ;; Hook function, such as gnus-Subject-rmail-digest, may | |
2223 ;; change current buffer, so need check. | |
2224 (let ((buffer (current-buffer)) | |
2225 (last-point (point))) | |
2226 ;; No more articles with same subject, so jump to the first | |
2227 ;; unread article. | |
2228 (gnus-Subject-first-unread-article) | |
2229 ;;(and (eq buffer (current-buffer)) | |
2230 ;; (= (point) last-point) | |
2231 ;; ;; Ignore given SUBJECT, and try again. | |
2232 ;; (gnus-Subject-next-article unread nil)) | |
2233 (and (eq buffer (current-buffer)) | |
2234 (< (point) last-point) | |
2235 (message "Wrapped")) | |
2236 )) | |
2237 ((and (not unread) | |
2238 gnus-auto-extend-newsgroup | |
2239 (setq header (gnus-more-header-forward))) | |
2240 ;; Extend to next article if possible. | |
2241 ;; Basic ideas by himacdonald@watdragon.waterloo.edu | |
2242 (gnus-extend-newsgroup header nil) | |
2243 ;; Threads feature must be turned off. | |
2244 (let ((buffer-read-only nil)) | |
2245 (goto-char (point-max)) | |
2246 (gnus-Subject-prepare-threads (list header) 0)) | |
2247 (gnus-Subject-goto-article gnus-newsgroup-end)) | |
2248 (t | |
2249 ;; Select next newsgroup automatically if requested. | |
2250 (let ((cmd (string-to-char (this-command-keys))) | |
2251 (group (gnus-Subject-search-group)) | |
2252 (auto-select | |
2253 (and gnus-auto-select-next | |
2254 ;;(null (gnus-set-difference gnus-newsgroup-unreads | |
2255 ;; gnus-newsgroup-marked)) | |
2256 (memq this-command | |
2257 '(gnus-Subject-next-unread-article | |
2258 gnus-Subject-next-article | |
2259 gnus-Subject-next-page | |
2260 gnus-Subject-next-same-subject | |
2261 gnus-Subject-next-unread-same-subject | |
2262 gnus-Subject-kill-same-subject | |
2263 gnus-Subject-kill-same-subject-and-select | |
2264 )) | |
2265 ;; Ignore characters typed ahead. | |
2266 (not (input-pending-p)) | |
2267 ))) | |
2268 (message "No more%s articles%s" | |
2269 (if unread " unread" "") | |
2270 (if (and auto-select | |
2271 (not (eq gnus-auto-select-next 'quietly))) | |
2272 (if group | |
2273 (format " (Type %s to %s [%d])" | |
2274 (key-description (char-to-string cmd)) | |
2275 group | |
2276 (nth 1 (gnus-gethash group | |
2277 gnus-unread-hashtb))) | |
2278 (format " (Type %s to exit %s)" | |
2279 (key-description (char-to-string cmd)) | |
2280 gnus-newsgroup-name | |
2281 )) | |
2282 "")) | |
2283 ;; Select next unread newsgroup automagically. | |
2284 (cond ((and auto-select | |
2285 (eq gnus-auto-select-next 'quietly)) | |
2286 ;; Select quietly. | |
2287 (gnus-Subject-next-group nil)) | |
2288 (auto-select | |
2289 ;; Confirm auto selection. | |
2290 (let ((char (read-char))) | |
2291 (if (= char cmd) | |
2292 (gnus-Subject-next-group nil) | |
2293 (setq unread-command-char char)))) | |
2294 ) | |
2295 )) | |
2296 ))) | |
2297 | |
2298 (defun gnus-Subject-next-unread-article () | |
2299 "Select unread article after current one." | |
2300 (interactive) | |
2301 (gnus-Subject-next-article t (and gnus-auto-select-same | |
2302 (gnus-Subject-subject-string)))) | |
2303 | |
2304 (defun gnus-Subject-prev-article (unread &optional subject) | |
2305 "Select article before current one. | |
2306 If argument UNREAD is non-nil, only unread article is selected." | |
2307 (interactive "P") | |
2308 (let ((header nil)) | |
2309 (cond ((gnus-Subject-display-article | |
2310 (gnus-Subject-search-backward unread subject))) | |
2311 ((and subject | |
2312 gnus-auto-select-same | |
2313 (gnus-set-difference gnus-newsgroup-unreads | |
2314 gnus-newsgroup-marked) | |
2315 (memq this-command | |
2316 '(gnus-Subject-prev-unread-article | |
2317 ;;gnus-Subject-prev-page | |
2318 ;;gnus-Subject-prev-article | |
2319 ;;gnus-Subject-prev-same-subject | |
2320 ;;gnus-Subject-prev-unread-same-subject | |
2321 ))) | |
2322 ;; Ignore given SUBJECT, and try again. | |
2323 (gnus-Subject-prev-article unread nil)) | |
2324 (unread | |
2325 (message "No more unread articles")) | |
2326 ((and gnus-auto-extend-newsgroup | |
2327 (setq header (gnus-more-header-backward))) | |
2328 ;; Extend to previous article if possible. | |
2329 ;; Basic ideas by himacdonald@watdragon.waterloo.edu | |
2330 (gnus-extend-newsgroup header t) | |
2331 (let ((buffer-read-only nil)) | |
2332 (goto-char (point-min)) | |
2333 (gnus-Subject-prepare-threads (list header) 0)) | |
2334 (gnus-Subject-goto-article gnus-newsgroup-begin)) | |
2335 (t | |
2336 (message "No more articles")) | |
2337 ))) | |
2338 | |
2339 (defun gnus-Subject-prev-unread-article () | |
2340 "Select unred article before current one." | |
2341 (interactive) | |
2342 (gnus-Subject-prev-article t (and gnus-auto-select-same | |
2343 (gnus-Subject-subject-string)))) | |
2344 | |
2345 (defun gnus-Subject-next-page (lines) | |
2346 "Show next page of selected article. | |
2347 If end of artile, select next article. | |
2348 Argument LINES specifies lines to be scrolled up." | |
2349 (interactive "P") | |
2350 (let ((article (gnus-Subject-article-number)) | |
2351 (endp nil)) | |
2352 (if (or (null gnus-current-article) | |
2353 (/= article gnus-current-article)) | |
2354 ;; Selected subject is different from current article's. | |
2355 (gnus-Subject-display-article article) | |
2356 (gnus-configure-windows 'SelectArticle) | |
2357 (pop-to-buffer gnus-Subject-buffer) | |
2358 (gnus-eval-in-buffer-window gnus-Article-buffer | |
2359 (setq endp (gnus-Article-next-page lines))) | |
2360 (cond ((and endp lines) | |
2361 (message "End of message")) | |
2362 ((and endp (null lines)) | |
2363 (gnus-Subject-next-unread-article))) | |
2364 ))) | |
2365 | |
2366 (defun gnus-Subject-prev-page (lines) | |
2367 "Show previous page of selected article. | |
2368 Argument LINES specifies lines to be scrolled down." | |
2369 (interactive "P") | |
2370 (let ((article (gnus-Subject-article-number))) | |
2371 (if (or (null gnus-current-article) | |
2372 (/= article gnus-current-article)) | |
2373 ;; Selected subject is different from current article's. | |
2374 (gnus-Subject-display-article article) | |
2375 (gnus-configure-windows 'SelectArticle) | |
2376 (pop-to-buffer gnus-Subject-buffer) | |
2377 (gnus-eval-in-buffer-window gnus-Article-buffer | |
2378 (gnus-Article-prev-page lines)) | |
2379 ))) | |
2380 | |
2381 (defun gnus-Subject-scroll-up (lines) | |
2382 "Scroll up (or down) one line current article. | |
2383 Argument LINES specifies lines to be scrolled up (or down if negative)." | |
2384 (interactive "p") | |
2385 (gnus-Subject-select-article) | |
2386 (gnus-eval-in-buffer-window gnus-Article-buffer | |
2387 (cond ((> lines 0) | |
2388 (if (gnus-Article-next-page lines) | |
2389 (message "End of message"))) | |
2390 ((< lines 0) | |
2391 (gnus-Article-prev-page (- 0 lines)))) | |
2392 )) | |
2393 | |
2394 (defun gnus-Subject-next-same-subject () | |
2395 "Select next article which has the same subject as current one." | |
2396 (interactive) | |
2397 (gnus-Subject-next-article nil (gnus-Subject-subject-string))) | |
2398 | |
2399 (defun gnus-Subject-prev-same-subject () | |
2400 "Select previous article which has the same subject as current one." | |
2401 (interactive) | |
2402 (gnus-Subject-prev-article nil (gnus-Subject-subject-string))) | |
2403 | |
2404 (defun gnus-Subject-next-unread-same-subject () | |
2405 "Select next unread article which has the same subject as current one." | |
2406 (interactive) | |
2407 (gnus-Subject-next-article t (gnus-Subject-subject-string))) | |
2408 | |
2409 (defun gnus-Subject-prev-unread-same-subject () | |
2410 "Select previous unread article which has the same subject as current one." | |
2411 (interactive) | |
2412 (gnus-Subject-prev-article t (gnus-Subject-subject-string))) | |
2413 | |
2414 (defun gnus-Subject-refer-parent-article (child) | |
2415 "Refer parent article of current article. | |
2416 If a prefix argument CHILD is non-nil, go back to the child article | |
2417 using internally maintained articles history. | |
2418 NOTE: This command may not work with nnspool.el." | |
2419 (interactive "P") | |
2420 (gnus-Subject-select-article t t) ;Request all headers. | |
2421 (let ((referenced-id nil)) ;Message-id of parent or child article. | |
2422 (if child | |
2423 ;; Go back to child article using history. | |
2424 (gnus-Subject-refer-article nil) | |
2425 (gnus-eval-in-buffer-window gnus-Article-buffer | |
2426 ;; Look for parent Message-ID. | |
2427 ;; We cannot use gnus-current-headers to get references | |
2428 ;; because we may be looking at parent or refered article. | |
2429 (let ((references (gnus-fetch-field "References"))) | |
2430 ;; Get the last message-id in the references. | |
2431 (and references | |
2432 (string-match "\\(<[^<>]+>\\)[^>]*\\'" references) | |
2433 (setq referenced-id | |
2434 (substring references | |
2435 (match-beginning 1) (match-end 1)))) | |
2436 )) | |
2437 (if (stringp referenced-id) | |
2438 (gnus-Subject-refer-article referenced-id) | |
2439 (error "No more parents")) | |
2440 ))) | |
2441 | |
2442 (defun gnus-Subject-refer-article (message-id) | |
2443 "Refer article specified by MESSAGE-ID. | |
2444 If MESSAGE-ID is nil or an empty string, it is popped from an | |
2445 internally maintained articles history. | |
2446 NOTE: This command may not work with nnspool.el." | |
2447 (interactive "sMessage-ID: ") | |
2448 ;; Make sure that this command depends on the fact that article | |
2449 ;; related information is not updated when an article is retrieved | |
2450 ;; by Message-ID. | |
2451 (gnus-Subject-select-article t t) ;Request all headers. | |
2452 (if (and (stringp message-id) | |
2453 (> (length message-id) 0)) | |
2454 (gnus-eval-in-buffer-window gnus-Article-buffer | |
2455 ;; Construct the correct Message-ID if necessary. | |
2456 ;; Suggested by tale@pawl.rpi.edu. | |
2457 (or (string-match "^<" message-id) | |
2458 (setq message-id (concat "<" message-id))) | |
2459 (or (string-match ">$" message-id) | |
2460 (setq message-id (concat message-id ">"))) | |
2461 ;; Push current message-id on history. | |
2462 ;; We cannot use gnus-current-headers to get current | |
2463 ;; message-id because we may be looking at parent or refered | |
2464 ;; article. | |
2465 (let ((current (gnus-fetch-field "Message-ID"))) | |
2466 (or (equal current message-id) ;Nothing to do. | |
2467 (equal current (car gnus-current-history)) | |
2468 (setq gnus-current-history | |
2469 (cons current gnus-current-history))) | |
2470 )) | |
2471 ;; Pop message-id from history. | |
2472 (setq message-id (car gnus-current-history)) | |
2473 (setq gnus-current-history (cdr gnus-current-history))) | |
2474 (if (stringp message-id) | |
2475 ;; Retrieve article by message-id. This may not work with nnspool. | |
2476 (gnus-Article-prepare message-id t) | |
2477 (error "No such references")) | |
2478 ) | |
2479 | |
2480 (defun gnus-Subject-next-digest (nth) | |
2481 "Move to head of NTH next digested message." | |
2482 (interactive "p") | |
2483 (gnus-Subject-select-article) | |
2484 (gnus-eval-in-buffer-window gnus-Article-buffer | |
2485 (gnus-Article-next-digest (or nth 1)) | |
2486 )) | |
2487 | |
2488 (defun gnus-Subject-prev-digest (nth) | |
2489 "Move to head of NTH previous digested message." | |
2490 (interactive "p") | |
2491 (gnus-Subject-select-article) | |
2492 (gnus-eval-in-buffer-window gnus-Article-buffer | |
2493 (gnus-Article-prev-digest (or nth 1)) | |
2494 )) | |
2495 | |
2496 (defun gnus-Subject-first-unread-article () | |
2497 "Select first unread article. Return non-nil if successfully selected." | |
2498 (interactive) | |
2499 (let ((begin (point))) | |
2500 (goto-char (point-min)) | |
2501 (if (re-search-forward "^ [ \t]+[0-9]+:" nil t) | |
2502 (gnus-Subject-display-article (gnus-Subject-article-number)) | |
2503 ;; If there is no unread articles, stay there. | |
2504 (goto-char begin) | |
2505 ;;(gnus-Subject-display-article (gnus-Subject-article-number)) | |
2506 (message "No more unread articles") | |
2507 nil | |
2508 ) | |
2509 )) | |
2510 | |
2511 (defun gnus-Subject-isearch-article () | |
2512 "Do incremental search forward on current article." | |
2513 (interactive) | |
2514 (gnus-Subject-select-article) | |
2515 (gnus-eval-in-buffer-window gnus-Article-buffer | |
2516 (call-interactively 'isearch-forward) | |
2517 )) | |
2518 | |
2519 (defun gnus-Subject-search-article-forward (regexp) | |
2520 "Search for an article containing REGEXP forward. | |
2521 `gnus-Select-article-hook' is not called during the search." | |
2522 (interactive | |
2523 (list (read-string | |
2524 (concat "Search forward (regexp): " | |
2525 (if gnus-last-search-regexp | |
2526 (concat "(default " gnus-last-search-regexp ") ")))))) | |
2527 (if (string-equal regexp "") | |
2528 (setq regexp (or gnus-last-search-regexp "")) | |
2529 (setq gnus-last-search-regexp regexp)) | |
2530 (if (gnus-Subject-search-article regexp nil) | |
2531 (gnus-eval-in-buffer-window gnus-Article-buffer | |
2532 (recenter 0) | |
2533 ;;(sit-for 1) | |
2534 ) | |
2535 (error "Search failed: \"%s\"" regexp) | |
2536 )) | |
2537 | |
2538 (defun gnus-Subject-search-article-backward (regexp) | |
2539 "Search for an article containing REGEXP backward. | |
2540 `gnus-Select-article-hook' is not called during the search." | |
2541 (interactive | |
2542 (list (read-string | |
2543 (concat "Search backward (regexp): " | |
2544 (if gnus-last-search-regexp | |
2545 (concat "(default " gnus-last-search-regexp ") ")))))) | |
2546 (if (string-equal regexp "") | |
2547 (setq regexp (or gnus-last-search-regexp "")) | |
2548 (setq gnus-last-search-regexp regexp)) | |
2549 (if (gnus-Subject-search-article regexp t) | |
2550 (gnus-eval-in-buffer-window gnus-Article-buffer | |
2551 (recenter 0) | |
2552 ;;(sit-for 1) | |
2553 ) | |
2554 (error "Search failed: \"%s\"" regexp) | |
2555 )) | |
2556 | |
2557 (defun gnus-Subject-search-article (regexp &optional backward) | |
2558 "Search for an article containing REGEXP. | |
2559 Optional argument BACKWARD means do search for backward. | |
2560 `gnus-Select-article-hook' is not called during the search." | |
2561 (let ((gnus-Select-article-hook nil) ;Disable hook. | |
2562 (gnus-Mark-article-hook nil) ;Inhibit marking as read. | |
2563 (re-search | |
2564 (if backward | |
2565 (function re-search-backward) (function re-search-forward))) | |
2566 (found nil) | |
2567 (last nil)) | |
2568 ;; Hidden thread subtrees must be searched for ,too. | |
2569 (gnus-Subject-show-all-threads) | |
2570 ;; First of all, search current article. | |
2571 ;; We don't want to read article again from NNTP server nor reset | |
2572 ;; current point. | |
2573 (gnus-Subject-select-article) | |
2574 (message "Searching article: %d..." gnus-current-article) | |
2575 (setq last gnus-current-article) | |
2576 (gnus-eval-in-buffer-window gnus-Article-buffer | |
2577 (save-restriction | |
2578 (widen) | |
2579 ;; Begin search from current point. | |
2580 (setq found (funcall re-search regexp nil t)))) | |
2581 ;; Then search next articles. | |
2582 (while (and (not found) | |
2583 (gnus-Subject-display-article | |
2584 (gnus-Subject-search-subject backward nil nil))) | |
2585 (message "Searching article: %d..." gnus-current-article) | |
2586 (gnus-eval-in-buffer-window gnus-Article-buffer | |
2587 (save-restriction | |
2588 (widen) | |
2589 (goto-char (if backward (point-max) (point-min))) | |
2590 (setq found (funcall re-search regexp nil t))) | |
2591 )) | |
2592 (message "") | |
2593 ;; Adjust article pointer. | |
2594 (or (eq last gnus-current-article) | |
2595 (setq gnus-last-article last)) | |
2596 ;; Return T if found such article. | |
2597 found | |
2598 )) | |
2599 | |
2600 (defun gnus-Subject-execute-command (field regexp command &optional backward) | |
2601 "If FIELD of article header matches REGEXP, execute COMMAND string. | |
2602 If FIELD is an empty string (or nil), entire article body is searched for. | |
2603 If optional (prefix) argument BACKWARD is non-nil, do backward instead." | |
2604 (interactive | |
2605 (list (let ((completion-ignore-case t)) | |
2606 (completing-read "Field name: " | |
2607 '(("Number")("Subject")("From") | |
2608 ("Lines")("Date")("Id") | |
2609 ("Xref")("References")) | |
2610 nil 'require-match)) | |
2611 (read-string "Regexp: ") | |
2612 (read-key-sequence "Command: ") | |
2613 current-prefix-arg)) | |
2614 ;; Hidden thread subtrees must be searched for ,too. | |
2615 (gnus-Subject-show-all-threads) | |
2616 ;; We don't want to change current point nor window configuration. | |
2617 (save-excursion | |
2618 (save-window-excursion | |
2619 (message "Executing %s..." (key-description command)) | |
2620 ;; We'd like to execute COMMAND interactively so as to give arguments. | |
2621 (gnus-execute field regexp | |
2622 (` (lambda () | |
2623 (call-interactively '(, (key-binding command))))) | |
2624 backward) | |
2625 (message "Executing %s... done" (key-description command))))) | |
2626 | |
2627 (defun gnus-Subject-beginning-of-article () | |
2628 "Go to beginning of article body" | |
2629 (interactive) | |
2630 (gnus-Subject-select-article) | |
2631 (gnus-eval-in-buffer-window gnus-Article-buffer | |
2632 (widen) | |
2633 (beginning-of-buffer) | |
2634 (if gnus-break-pages | |
2635 (gnus-narrow-to-page)) | |
2636 )) | |
2637 | |
2638 (defun gnus-Subject-end-of-article () | |
2639 "Go to end of article body" | |
2640 (interactive) | |
2641 (gnus-Subject-select-article) | |
2642 (gnus-eval-in-buffer-window gnus-Article-buffer | |
2643 (widen) | |
2644 (end-of-buffer) | |
2645 (if gnus-break-pages | |
2646 (gnus-narrow-to-page)) | |
2647 )) | |
2648 | |
2649 (defun gnus-Subject-goto-article (article &optional all-headers) | |
2650 "Read ARTICLE if exists. | |
2651 Optional argument ALL-HEADERS means all headers are shown." | |
2652 (interactive | |
2653 (list | |
2654 (string-to-int | |
2655 (completing-read "Article number: " | |
2656 (mapcar | |
2657 (function | |
2658 (lambda (headers) | |
2659 (list | |
2660 (int-to-string (nntp-header-number headers))))) | |
2661 gnus-newsgroup-headers) | |
2662 nil 'require-match)))) | |
2663 (if (gnus-Subject-goto-subject article) | |
2664 (gnus-Subject-display-article article all-headers))) | |
2665 | |
2666 (defun gnus-Subject-goto-last-article () | |
2667 "Go to last subject line." | |
2668 (interactive) | |
2669 (if gnus-last-article | |
2670 (gnus-Subject-goto-article gnus-last-article))) | |
2671 | |
2672 (defun gnus-Subject-show-article () | |
2673 "Force to show current article." | |
2674 (interactive) | |
2675 ;; The following is a trick to force to read the current article again. | |
2676 (setq gnus-have-all-headers (not gnus-have-all-headers)) | |
2677 (gnus-Subject-select-article (not gnus-have-all-headers) t)) | |
2678 | |
2679 (defun gnus-Subject-toggle-header (arg) | |
2680 "Show original header if pruned header currently shown, or vice versa. | |
2681 With arg, show original header iff arg is positive." | |
2682 (interactive "P") | |
2683 ;; Variable gnus-show-all-headers must be NIL to toggle really. | |
2684 (let ((gnus-show-all-headers nil) | |
2685 (all-headers | |
2686 (if (null arg) (not gnus-have-all-headers) | |
2687 (> (prefix-numeric-value arg) 0)))) | |
2688 (gnus-Subject-select-article all-headers t))) | |
2689 | |
2690 (defun gnus-Subject-show-all-headers () | |
2691 "Show original article header." | |
2692 (interactive) | |
2693 (gnus-Subject-select-article t t)) | |
2694 | |
2695 (defun gnus-Subject-stop-page-breaking () | |
2696 "Stop page breaking by linefeed temporary (Widen article buffer)." | |
2697 (interactive) | |
2698 (gnus-Subject-select-article) | |
2699 (gnus-eval-in-buffer-window gnus-Article-buffer | |
2700 (widen))) | |
2701 | |
2702 (defun gnus-Subject-kill-same-subject-and-select (unmark) | |
2703 "Mark articles which has the same subject as read, and then select next. | |
2704 If argument UNMARK is positive, remove any kinds of marks. | |
2705 If argument UNMARK is negative, mark articles as unread instead." | |
2706 (interactive "P") | |
2707 (if unmark | |
2708 (setq unmark (prefix-numeric-value unmark))) | |
2709 (let ((count | |
2710 (gnus-Subject-mark-same-subject | |
2711 (gnus-Subject-subject-string) unmark))) | |
2712 ;; Select next unread article. If auto-select-same mode, should | |
2713 ;; select the first unread article. | |
2714 (gnus-Subject-next-article t (and gnus-auto-select-same | |
2715 (gnus-Subject-subject-string))) | |
2716 (message "%d articles are marked as %s" | |
2717 count (if unmark "unread" "read")) | |
2718 )) | |
2719 | |
2720 (defun gnus-Subject-kill-same-subject (unmark) | |
2721 "Mark articles which has the same subject as read. | |
2722 If argument UNMARK is positive, remove any kinds of marks. | |
2723 If argument UNMARK is negative, mark articles as unread instead." | |
2724 (interactive "P") | |
2725 (if unmark | |
2726 (setq unmark (prefix-numeric-value unmark))) | |
2727 (let ((count | |
2728 (gnus-Subject-mark-same-subject | |
2729 (gnus-Subject-subject-string) unmark))) | |
2730 ;; If marked as read, go to next unread subject. | |
2731 (if (null unmark) | |
2732 ;; Go to next unread subject. | |
2733 (gnus-Subject-next-subject 1 t)) | |
2734 (message "%d articles are marked as %s" | |
2735 count (if unmark "unread" "read")) | |
2736 )) | |
2737 | |
2738 (defun gnus-Subject-mark-same-subject (subject &optional unmark) | |
2739 "Mark articles with same SUBJECT as read, and return marked number. | |
2740 If optional argument UNMARK is positive, remove any kinds of marks. | |
2741 If optional argument UNMARK is negative, mark articles as unread instead." | |
2742 (let ((count 1)) | |
2743 (save-excursion | |
2744 (cond ((null unmark) | |
2745 (gnus-Subject-mark-as-read nil "K")) | |
2746 ((> unmark 0) | |
2747 (gnus-Subject-mark-as-unread nil t)) | |
2748 (t | |
2749 (gnus-Subject-mark-as-unread))) | |
2750 (while (and subject | |
2751 (gnus-Subject-search-forward nil subject)) | |
2752 (cond ((null unmark) | |
2753 (gnus-Subject-mark-as-read nil "K")) | |
2754 ((> unmark 0) | |
2755 (gnus-Subject-mark-as-unread nil t)) | |
2756 (t | |
2757 (gnus-Subject-mark-as-unread))) | |
2758 (setq count (1+ count)) | |
2759 )) | |
2760 ;; Hide killed thread subtrees. Does not work properly always. | |
2761 ;;(and (null unmark) | |
2762 ;; gnus-thread-hide-killed | |
2763 ;; (gnus-Subject-hide-thread)) | |
2764 ;; Return number of articles marked as read. | |
2765 count | |
2766 )) | |
2767 | |
2768 (defun gnus-Subject-mark-as-unread-forward (count) | |
2769 "Mark current article as unread, and then go forward. | |
2770 Argument COUNT specifies number of articles marked as unread." | |
2771 (interactive "p") | |
2772 (while (> count 0) | |
2773 (gnus-Subject-mark-as-unread nil nil) | |
2774 (gnus-Subject-next-subject 1 nil) | |
2775 (setq count (1- count)))) | |
2776 | |
2777 (defun gnus-Subject-mark-as-unread-backward (count) | |
2778 "Mark current article as unread, and then go backward. | |
2779 Argument COUNT specifies number of articles marked as unread." | |
2780 (interactive "p") | |
2781 (while (> count 0) | |
2782 (gnus-Subject-mark-as-unread nil nil) | |
2783 (gnus-Subject-prev-subject 1 nil) | |
2784 (setq count (1- count)))) | |
2785 | |
2786 (defun gnus-Subject-mark-as-unread (&optional article clear-mark) | |
2787 "Mark current article as unread. | |
2788 Optional first argument ARTICLE specifies article number to be | |
2789 marked as unread. Optional second argument CLEAR-MARK removes | |
2790 any kind of mark." | |
2791 (save-excursion | |
2792 (set-buffer gnus-Subject-buffer) | |
2793 ;; First of all, show hidden thread subtrees. | |
2794 (gnus-Subject-show-thread) | |
2795 (let* ((buffer-read-only nil) | |
2796 (current (gnus-Subject-article-number)) | |
2797 (article (or article current))) | |
2798 (gnus-mark-article-as-unread article clear-mark) | |
2799 (if (or (eq article current) | |
2800 (gnus-Subject-goto-subject article)) | |
2801 (progn | |
2802 (beginning-of-line) | |
2803 (delete-char 1) | |
2804 (insert (if clear-mark " " "-")))) | |
2805 ))) | |
2806 | |
2807 (defun gnus-Subject-mark-as-read-forward (count) | |
2808 "Mark current article as read, and then go forward. | |
2809 Argument COUNT specifies number of articles marked as read" | |
2810 (interactive "p") | |
2811 (while (> count 0) | |
2812 (gnus-Subject-mark-as-read) | |
2813 (gnus-Subject-next-subject 1 'unread-only) | |
2814 (setq count (1- count)))) | |
2815 | |
2816 (defun gnus-Subject-mark-as-read-backward (count) | |
2817 "Mark current article as read, and then go backward. | |
2818 Argument COUNT specifies number of articles marked as read" | |
2819 (interactive "p") | |
2820 (while (> count 0) | |
2821 (gnus-Subject-mark-as-read) | |
2822 (gnus-Subject-prev-subject 1 'unread-only) | |
2823 (setq count (1- count)))) | |
2824 | |
2825 (defun gnus-Subject-mark-as-read (&optional article mark) | |
2826 "Mark current article as read. | |
2827 Optional first argument ARTICLE specifies article number to be marked as read. | |
2828 Optional second argument MARK specifies a string inserted at beginning of line. | |
2829 Any kind of string (length 1) except for a space and `-' is ok." | |
2830 (save-excursion | |
2831 (set-buffer gnus-Subject-buffer) | |
2832 ;; First of all, show hidden thread subtrees. | |
2833 (gnus-Subject-show-thread) | |
2834 (let* ((buffer-read-only nil) | |
2835 (mark (or mark "D")) ;Default mark is `D'. | |
2836 (current (gnus-Subject-article-number)) | |
2837 (article (or article current))) | |
2838 (gnus-mark-article-as-read article) | |
2839 (if (or (eq article current) | |
2840 (gnus-Subject-goto-subject article)) | |
2841 (progn | |
2842 (beginning-of-line) | |
2843 (delete-char 1) | |
2844 (insert mark))) | |
2845 ))) | |
2846 | |
2847 (defun gnus-Subject-clear-mark-forward (count) | |
2848 "Remove current article's mark, and go forward. | |
2849 Argument COUNT specifies number of articles unmarked" | |
2850 (interactive "p") | |
2851 (while (> count 0) | |
2852 (gnus-Subject-mark-as-unread nil t) | |
2853 (gnus-Subject-next-subject 1 nil) | |
2854 (setq count (1- count)))) | |
2855 | |
2856 (defun gnus-Subject-clear-mark-backward (count) | |
2857 "Remove current article's mark, and go backward. | |
2858 Argument COUNT specifies number of articles unmarked" | |
2859 (interactive "p") | |
2860 (while (> count 0) | |
2861 (gnus-Subject-mark-as-unread nil t) | |
2862 (gnus-Subject-prev-subject 1 nil) | |
2863 (setq count (1- count)))) | |
2864 | |
2865 (defun gnus-Subject-delete-marked-as-read () | |
2866 "Delete lines which are marked as read." | |
2867 (interactive) | |
2868 (if gnus-newsgroup-unreads | |
2869 (let ((buffer-read-only nil)) | |
2870 (save-excursion | |
2871 (goto-char (point-min)) | |
2872 (delete-non-matching-lines "^[ ---]")) | |
2873 ;; Adjust point. | |
2874 (if (eobp) | |
2875 (gnus-Subject-prev-subject 1) | |
2876 (beginning-of-line) | |
2877 (search-forward ":" nil t))) | |
2878 ;; It is not so good idea to make the buffer empty. | |
2879 (message "All articles are marked as read") | |
2880 )) | |
2881 | |
2882 (defun gnus-Subject-delete-marked-with (marks) | |
2883 "Delete lines which are marked with MARKS (e.g. \"DK\")." | |
2884 (interactive "sMarks: ") | |
2885 (let ((buffer-read-only nil)) | |
2886 (save-excursion | |
2887 (goto-char (point-min)) | |
2888 (delete-matching-lines (concat "^[" marks "]"))) | |
2889 ;; Adjust point. | |
2890 (or (zerop (buffer-size)) | |
2891 (if (eobp) | |
2892 (gnus-Subject-prev-subject 1) | |
2893 (beginning-of-line) | |
2894 (search-forward ":" nil t))) | |
2895 )) | |
2896 | |
2897 ;; Thread-based commands. | |
2898 | |
2899 (defun gnus-Subject-toggle-threads (arg) | |
2900 "Toggle showing conversation threads. | |
2901 With arg, turn showing conversation threads on iff arg is positive." | |
2902 (interactive "P") | |
2903 (let ((current (gnus-Subject-article-number))) | |
2904 (setq gnus-show-threads | |
2905 (if (null arg) (not gnus-show-threads) | |
2906 (> (prefix-numeric-value arg) 0))) | |
2907 (gnus-Subject-prepare) | |
2908 (gnus-Subject-goto-subject current) | |
2909 )) | |
2910 | |
2911 (defun gnus-Subject-show-all-threads () | |
2912 "Show all thread subtrees." | |
2913 (interactive) | |
2914 (if gnus-show-threads | |
2915 (save-excursion | |
2916 (let ((buffer-read-only nil)) | |
2917 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t) | |
2918 )))) | |
2919 | |
2920 (defun gnus-Subject-show-thread () | |
2921 "Show thread subtrees." | |
2922 (interactive) | |
2923 (if gnus-show-threads | |
2924 (save-excursion | |
2925 (let ((buffer-read-only nil)) | |
2926 (subst-char-in-region (progn | |
2927 (beginning-of-line) (point)) | |
2928 (progn | |
2929 (end-of-line) (point)) | |
2930 ?\^M ?\n t) | |
2931 )))) | |
2932 | |
2933 (defun gnus-Subject-hide-all-threads () | |
2934 "Hide all thread subtrees." | |
2935 (interactive) | |
2936 (if gnus-show-threads | |
2937 (save-excursion | |
2938 ;; Adjust cursor point. | |
2939 (goto-char (point-min)) | |
2940 (search-forward ":" nil t) | |
2941 (let ((level (current-column))) | |
2942 (gnus-Subject-hide-thread) | |
2943 (while (gnus-Subject-search-forward) | |
2944 (and (>= level (current-column)) | |
2945 (gnus-Subject-hide-thread))) | |
2946 )))) | |
2947 | |
2948 (defun gnus-Subject-hide-thread () | |
2949 "Hide thread subtrees." | |
2950 (interactive) | |
2951 (if gnus-show-threads | |
2952 (save-excursion | |
2953 ;; Adjust cursor point. | |
2954 (beginning-of-line) | |
2955 (search-forward ":" nil t) | |
2956 (let ((buffer-read-only nil) | |
2957 (init (point)) | |
2958 (last (point)) | |
2959 (level (current-column))) | |
2960 (while (and (gnus-Subject-search-forward) | |
2961 (< level (current-column))) | |
2962 ;; Interested in lower levels. | |
2963 (if (< level (current-column)) | |
2964 (progn | |
2965 (setq last (point)) | |
2966 )) | |
2967 ) | |
2968 (subst-char-in-region init last ?\n ?\^M t) | |
2969 )))) | |
2970 | |
2971 (defun gnus-Subject-next-thread (n) | |
2972 "Go to the same level next thread. | |
2973 Argument N specifies the number of threads." | |
2974 (interactive "p") | |
2975 ;; Adjust cursor point. | |
2976 (beginning-of-line) | |
2977 (search-forward ":" nil t) | |
2978 (let ((init (point)) | |
2979 (last (point)) | |
2980 (level (current-column))) | |
2981 (while (and (> n 0) | |
2982 (gnus-Subject-search-forward) | |
2983 (<= level (current-column))) | |
2984 ;; We have to skip lower levels. | |
2985 (if (= level (current-column)) | |
2986 (progn | |
2987 (setq last (point)) | |
2988 (setq n (1- n)) | |
2989 )) | |
2990 ) | |
2991 ;; Return non-nil if successfully move to the next. | |
2992 (prog1 (not (= init last)) | |
2993 (goto-char last)) | |
2994 )) | |
2995 | |
2996 (defun gnus-Subject-prev-thread (n) | |
2997 "Go to the same level previous thread. | |
2998 Argument N specifies the number of threads." | |
2999 (interactive "p") | |
3000 ;; Adjust cursor point. | |
3001 (beginning-of-line) | |
3002 (search-forward ":" nil t) | |
3003 (let ((init (point)) | |
3004 (last (point)) | |
3005 (level (current-column))) | |
3006 (while (and (> n 0) | |
3007 (gnus-Subject-search-backward) | |
3008 (<= level (current-column))) | |
3009 ;; We have to skip lower levels. | |
3010 (if (= level (current-column)) | |
3011 (progn | |
3012 (setq last (point)) | |
3013 (setq n (1- n)) | |
3014 )) | |
3015 ) | |
3016 ;; Return non-nil if successfully move to the previous. | |
3017 (prog1 (not (= init last)) | |
3018 (goto-char last)) | |
3019 )) | |
3020 | |
3021 (defun gnus-Subject-down-thread (d) | |
3022 "Go downward current thread. | |
3023 Argument D specifies the depth goes down." | |
3024 (interactive "p") | |
3025 ;; Adjust cursor point. | |
3026 (beginning-of-line) | |
3027 (search-forward ":" nil t) | |
3028 (let ((last (point)) | |
3029 (level (current-column))) | |
3030 (while (and (> d 0) | |
3031 (gnus-Subject-search-forward) | |
3032 (<= level (current-column))) ;<= can be <. Which do you like? | |
3033 ;; We have to skip the same levels. | |
3034 (if (< level (current-column)) | |
3035 (progn | |
3036 (setq last (point)) | |
3037 (setq level (current-column)) | |
3038 (setq d (1- d)) | |
3039 )) | |
3040 ) | |
3041 (goto-char last) | |
3042 )) | |
3043 | |
3044 (defun gnus-Subject-up-thread (d) | |
3045 "Go upward current thread. | |
3046 Argument D specifies the depth goes up." | |
3047 (interactive "p") | |
3048 ;; Adjust cursor point. | |
3049 (beginning-of-line) | |
3050 (search-forward ":" nil t) | |
3051 (let ((last (point)) | |
3052 (level (current-column))) | |
3053 (while (and (> d 0) | |
3054 (gnus-Subject-search-backward)) | |
3055 ;; We have to skip the same levels. | |
3056 (if (> level (current-column)) | |
3057 (progn | |
3058 (setq last (point)) | |
3059 (setq level (current-column)) | |
3060 (setq d (1- d)) | |
3061 )) | |
3062 ) | |
3063 (goto-char last) | |
3064 )) | |
3065 | |
3066 (defun gnus-Subject-kill-thread (unmark) | |
3067 "Mark articles under current thread as read. | |
3068 If argument UNMARK is positive, remove any kinds of marks. | |
3069 If argument UNMARK is negative, mark articles as unread instead." | |
3070 (interactive "P") | |
3071 (if unmark | |
3072 (setq unmark (prefix-numeric-value unmark))) | |
3073 ;; Adjust cursor point. | |
3074 (beginning-of-line) | |
3075 (search-forward ":" nil t) | |
3076 (save-excursion | |
3077 (let ((level (current-column))) | |
3078 ;; Mark current article. | |
3079 (cond ((null unmark) | |
3080 (gnus-Subject-mark-as-read nil "K")) | |
3081 ((> unmark 0) | |
3082 (gnus-Subject-mark-as-unread nil t)) | |
3083 (t | |
3084 (gnus-Subject-mark-as-unread)) | |
3085 ) | |
3086 ;; Mark following articles. | |
3087 (while (and (gnus-Subject-search-forward) | |
3088 (< level (current-column))) | |
3089 (cond ((null unmark) | |
3090 (gnus-Subject-mark-as-read nil "K")) | |
3091 ((> unmark 0) | |
3092 (gnus-Subject-mark-as-unread nil t)) | |
3093 (t | |
3094 (gnus-Subject-mark-as-unread)) | |
3095 )) | |
3096 )) | |
3097 ;; Hide killed subtrees. | |
3098 (and (null unmark) | |
3099 gnus-thread-hide-killed | |
3100 (gnus-Subject-hide-thread)) | |
3101 ;; If marked as read, go to next unread subject. | |
3102 (if (null unmark) | |
3103 ;; Go to next unread subject. | |
3104 (gnus-Subject-next-subject 1 t)) | |
3105 ) | |
3106 | |
3107 (defun gnus-Subject-toggle-truncation (arg) | |
3108 "Toggle truncation of subject lines. | |
3109 With ARG, turn line truncation on iff ARG is positive." | |
3110 (interactive "P") | |
3111 (setq truncate-lines | |
3112 (if (null arg) (not truncate-lines) | |
3113 (> (prefix-numeric-value arg) 0))) | |
3114 (redraw-display)) | |
3115 | |
3116 (defun gnus-Subject-sort-by-number (reverse) | |
3117 "Sort subject display buffer by article number. | |
3118 Argument REVERSE means reverse order." | |
3119 (interactive "P") | |
3120 (gnus-Subject-sort-subjects | |
3121 (function | |
3122 (lambda (a b) | |
3123 (< (nntp-header-number a) (nntp-header-number b)))) | |
3124 reverse | |
3125 )) | |
3126 | |
3127 (defun gnus-Subject-sort-by-author (reverse) | |
3128 "Sort subject display buffer by author name alphabetically. | |
3129 If case-fold-search is non-nil, case of letters is ignored. | |
3130 Argument REVERSE means reverse order." | |
3131 (interactive "P") | |
3132 (gnus-Subject-sort-subjects | |
3133 (function | |
3134 (lambda (a b) | |
3135 (gnus-string-lessp (nntp-header-from a) (nntp-header-from b)))) | |
3136 reverse | |
3137 )) | |
3138 | |
3139 (defun gnus-Subject-sort-by-subject (reverse) | |
3140 "Sort subject display buffer by subject alphabetically. `Re:'s are ignored. | |
3141 If case-fold-search is non-nil, case of letters is ignored. | |
3142 Argument REVERSE means reverse order." | |
3143 (interactive "P") | |
3144 (gnus-Subject-sort-subjects | |
3145 (function | |
3146 (lambda (a b) | |
3147 (gnus-string-lessp | |
3148 (gnus-simplify-subject (nntp-header-subject a) 're-only) | |
3149 (gnus-simplify-subject (nntp-header-subject b) 're-only)))) | |
3150 reverse | |
3151 )) | |
3152 | |
3153 (defun gnus-Subject-sort-by-date (reverse) | |
3154 "Sort subject display buffer by posted date. | |
3155 Argument REVERSE means reverse order." | |
3156 (interactive "P") | |
3157 (gnus-Subject-sort-subjects | |
3158 (function | |
3159 (lambda (a b) | |
3160 (gnus-date-lessp (nntp-header-date a) (nntp-header-date b)))) | |
3161 reverse | |
3162 )) | |
3163 | |
3164 (defun gnus-Subject-sort-subjects (predicate &optional reverse) | |
3165 "Sort subject display buffer by PREDICATE. | |
3166 Optional argument REVERSE means reverse order." | |
3167 (let ((current (gnus-Subject-article-number))) | |
3168 (gnus-sort-headers predicate reverse) | |
3169 (gnus-Subject-prepare) | |
3170 (gnus-Subject-goto-subject current) | |
3171 )) | |
3172 | |
3173 (defun gnus-Subject-reselect-current-group (show-all) | |
3174 "Once exit and then reselect the current newsgroup. | |
3175 Prefix argument SHOW-ALL means to select all articles." | |
3176 (interactive "P") | |
3177 (let ((current-subject (gnus-Subject-article-number))) | |
3178 (gnus-Subject-exit t) | |
3179 ;; We have to adjust the point of Group mode buffer because the | |
3180 ;; current point was moved to the next unread newsgroup by | |
3181 ;; exiting. | |
3182 (gnus-Subject-jump-to-group gnus-newsgroup-name) | |
3183 (gnus-Group-read-group show-all t) | |
3184 (gnus-Subject-goto-subject current-subject) | |
3185 )) | |
3186 | |
3187 (defun gnus-Subject-caesar-message (rotnum) | |
3188 "Caesar rotates all letters of current message by 13/47 places. | |
3189 With prefix arg, specifies the number of places to rotate each letter forward. | |
3190 Caesar rotates Japanese letters by 47 places in any case." | |
3191 (interactive "P") | |
3192 (gnus-Subject-select-article) | |
3193 (gnus-overload-functions) | |
3194 (gnus-eval-in-buffer-window gnus-Article-buffer | |
3195 (save-restriction | |
3196 (widen) | |
3197 ;; We don't want to jump to the beginning of the message. | |
3198 ;; `save-excursion' does not do its job. | |
3199 (move-to-window-line 0) | |
3200 (let ((last (point))) | |
3201 (news-caesar-buffer-body rotnum) | |
3202 (goto-char last) | |
3203 (recenter 0) | |
3204 )) | |
3205 )) | |
3206 | |
3207 (defun gnus-Subject-rmail-digest () | |
3208 "Run RMAIL on current digest article. | |
3209 `gnus-Select-digest-hook' will be called with no arguments, if that | |
3210 value is non-nil. It is possible to modify the article so that Rmail | |
3211 can work with it. | |
3212 | |
3213 `gnus-Rmail-digest-hook' will be called with no arguments, if that value | |
3214 is non-nil. The hook is intended to customize Rmail mode." | |
3215 (interactive) | |
3216 (gnus-Subject-select-article) | |
3217 (require 'rmail) | |
3218 (let ((artbuf gnus-Article-buffer) | |
3219 (digbuf (get-buffer-create gnus-Digest-buffer)) | |
3220 (mail-header-separator "")) | |
3221 (set-buffer digbuf) | |
3222 (buffer-flush-undo (current-buffer)) | |
3223 (setq buffer-read-only nil) | |
3224 (erase-buffer) | |
3225 (insert-buffer-substring artbuf) | |
3226 (run-hooks 'gnus-Select-digest-hook) | |
3227 (gnus-convert-article-to-rmail) | |
3228 (goto-char (point-min)) | |
3229 ;; Rmail initializations. | |
3230 (rmail-insert-rmail-file-header) | |
3231 (rmail-mode) | |
3232 (rmail-set-message-counters) | |
3233 (rmail-show-message) | |
3234 (condition-case () | |
3235 (progn | |
3236 (undigestify-rmail-message) | |
3237 (rmail-expunge) ;Delete original message. | |
3238 ;; File name is meaningless but `save-buffer' requires it. | |
3239 (setq buffer-file-name "GNUS Digest") | |
3240 (setq mode-line-buffer-identification | |
3241 (concat "Digest: " | |
3242 (nntp-header-subject gnus-current-headers))) | |
3243 ;; There is no need to write this buffer to a file. | |
3244 (make-local-variable 'write-file-hooks) | |
3245 (setq write-file-hooks | |
3246 (list (function | |
3247 (lambda () | |
3248 (set-buffer-modified-p nil) | |
3249 (message "(No changes need to be saved)") | |
3250 'no-need-to-write-this-buffer)))) | |
3251 ;; Default file name saving digest messages. | |
3252 (setq rmail-last-rmail-file | |
3253 (funcall gnus-rmail-save-name | |
3254 gnus-newsgroup-name | |
3255 gnus-current-headers | |
3256 gnus-newsgroup-last-rmail | |
3257 )) | |
3258 (setq rmail-last-file | |
3259 (funcall gnus-mail-save-name | |
3260 gnus-newsgroup-name | |
3261 gnus-current-headers | |
3262 gnus-newsgroup-last-mail | |
3263 )) | |
3264 ;; Prevent generating new buffer named ***<N> each time. | |
3265 (setq rmail-summary-buffer | |
3266 (get-buffer-create gnus-Digest-summary-buffer)) | |
3267 (run-hooks 'gnus-Rmail-digest-hook) | |
3268 ;; Take all windows safely. | |
3269 (gnus-configure-windows '(1 0 0)) | |
3270 (pop-to-buffer gnus-Group-buffer) | |
3271 ;; Use Subject and Article windows for Digest summary and | |
3272 ;; Digest buffers. | |
3273 (if gnus-digest-show-summary | |
3274 (let ((gnus-Subject-buffer gnus-Digest-summary-buffer) | |
3275 (gnus-Article-buffer gnus-Digest-buffer)) | |
3276 (gnus-configure-windows 'SelectArticle) | |
3277 (pop-to-buffer gnus-Digest-buffer) | |
3278 (rmail-summary) | |
3279 (pop-to-buffer gnus-Digest-summary-buffer) | |
3280 (message (substitute-command-keys | |
3281 "Type \\[rmail-summary-quit] to return to GNUS"))) | |
3282 (let ((gnus-Subject-buffer gnus-Digest-buffer)) | |
3283 (gnus-configure-windows 'ExpandSubject) | |
3284 (pop-to-buffer gnus-Digest-buffer) | |
3285 (message (substitute-command-keys | |
3286 "Type \\[rmail-quit] to return to GNUS"))) | |
3287 ) | |
3288 ;; Move the buffers to the end of buffer list. | |
3289 (bury-buffer gnus-Article-buffer) | |
3290 (bury-buffer gnus-Group-buffer) | |
3291 (bury-buffer gnus-Digest-summary-buffer) | |
3292 (bury-buffer gnus-Digest-buffer)) | |
3293 (error (set-buffer-modified-p nil) | |
3294 (kill-buffer digbuf) | |
3295 ;; This command should not signal an error because the | |
3296 ;; command is called from hooks. | |
3297 (ding) (message "Article is not a digest"))) | |
3298 )) | |
3299 | |
3300 (defun gnus-Subject-save-article () | |
3301 "Save this article using default saver function. | |
3302 Variable `gnus-default-article-saver' specifies the saver function." | |
3303 (interactive) | |
3304 (gnus-Subject-select-article | |
3305 (not (null gnus-save-all-headers)) gnus-save-all-headers) | |
3306 (if gnus-default-article-saver | |
3307 (call-interactively gnus-default-article-saver) | |
3308 (error "No default saver is defined."))) | |
3309 | |
3310 (defun gnus-Subject-save-in-rmail (&optional filename) | |
3311 "Append this article to Rmail file. | |
3312 Optional argument FILENAME specifies file name. | |
3313 Directory to save to is default to `gnus-article-save-directory' which | |
3314 is initialized from the SAVEDIR environment variable." | |
3315 (interactive) | |
3316 (gnus-Subject-select-article | |
3317 (not (null gnus-save-all-headers)) gnus-save-all-headers) | |
3318 (gnus-eval-in-buffer-window gnus-Article-buffer | |
3319 (save-excursion | |
3320 (save-restriction | |
3321 (widen) | |
3322 (let ((default-name | |
3323 (funcall gnus-rmail-save-name | |
3324 gnus-newsgroup-name | |
3325 gnus-current-headers | |
3326 gnus-newsgroup-last-rmail | |
3327 ))) | |
3328 (or filename | |
3329 (setq filename | |
3330 (read-file-name | |
3331 (concat "Save article in Rmail file: (default " | |
3332 (file-name-nondirectory default-name) | |
3333 ") ") | |
3334 (file-name-directory default-name) | |
3335 default-name))) | |
3336 (gnus-make-directory (file-name-directory filename)) | |
3337 (gnus-output-to-rmail filename) | |
3338 ;; Remember the directory name to save articles. | |
3339 (setq gnus-newsgroup-last-rmail filename) | |
3340 ))) | |
3341 )) | |
3342 | |
3343 (defun gnus-Subject-save-in-mail (&optional filename) | |
3344 "Append this article to Unix mail file. | |
3345 Optional argument FILENAME specifies file name. | |
3346 Directory to save to is default to `gnus-article-save-directory' which | |
3347 is initialized from the SAVEDIR environment variable." | |
3348 (interactive) | |
3349 (gnus-Subject-select-article | |
3350 (not (null gnus-save-all-headers)) gnus-save-all-headers) | |
3351 (gnus-eval-in-buffer-window gnus-Article-buffer | |
3352 (save-excursion | |
3353 (save-restriction | |
3354 (widen) | |
3355 (let ((default-name | |
3356 (funcall gnus-mail-save-name | |
3357 gnus-newsgroup-name | |
3358 gnus-current-headers | |
3359 gnus-newsgroup-last-mail | |
3360 ))) | |
3361 (or filename | |
3362 (setq filename | |
3363 (read-file-name | |
3364 (concat "Save article in Unix mail file: (default " | |
3365 (file-name-nondirectory default-name) | |
3366 ") ") | |
3367 (file-name-directory default-name) | |
3368 default-name))) | |
3369 (gnus-make-directory (file-name-directory filename)) | |
3370 (rmail-output filename) | |
3371 ;; Remember the directory name to save articles. | |
3372 (setq gnus-newsgroup-last-mail filename) | |
3373 ))) | |
3374 )) | |
3375 | |
3376 (defun gnus-Subject-save-in-file (&optional filename) | |
3377 "Append this article to file. | |
3378 Optional argument FILENAME specifies file name. | |
3379 Directory to save to is default to `gnus-article-save-directory' which | |
3380 is initialized from the SAVEDIR environment variable." | |
3381 (interactive) | |
3382 (gnus-Subject-select-article | |
3383 (not (null gnus-save-all-headers)) gnus-save-all-headers) | |
3384 (gnus-eval-in-buffer-window gnus-Article-buffer | |
3385 (save-excursion | |
3386 (save-restriction | |
3387 (widen) | |
3388 (let ((default-name | |
3389 (funcall gnus-file-save-name | |
3390 gnus-newsgroup-name | |
3391 gnus-current-headers | |
3392 gnus-newsgroup-last-file | |
3393 ))) | |
3394 (or filename | |
3395 (setq filename | |
3396 (read-file-name | |
3397 (concat "Save article in file: (default " | |
3398 (file-name-nondirectory default-name) | |
3399 ") ") | |
3400 (file-name-directory default-name) | |
3401 default-name))) | |
3402 (gnus-make-directory (file-name-directory filename)) | |
3403 (gnus-output-to-file filename) | |
3404 ;; Remember the directory name to save articles. | |
3405 (setq gnus-newsgroup-last-file filename) | |
3406 ))) | |
3407 )) | |
3408 | |
3409 (defun gnus-Subject-save-in-folder (&optional folder) | |
3410 "Save this article to MH folder (using `rcvstore' in MH library). | |
3411 Optional argument FOLDER specifies folder name." | |
3412 (interactive) | |
3413 (gnus-Subject-select-article | |
3414 (not (null gnus-save-all-headers)) gnus-save-all-headers) | |
3415 (gnus-eval-in-buffer-window gnus-Article-buffer | |
3416 (save-restriction | |
3417 (widen) | |
3418 ;; Thanks to yuki@flab.Fujitsu.JUNET and ohm@kaba.junet. | |
3419 (mh-find-path) | |
3420 (let ((folder | |
3421 (or folder | |
3422 (mh-prompt-for-folder "Save article in" | |
3423 (funcall gnus-folder-save-name | |
3424 gnus-newsgroup-name | |
3425 gnus-current-headers | |
3426 gnus-newsgroup-last-folder | |
3427 ) | |
3428 t | |
3429 ))) | |
3430 (errbuf (get-buffer-create " *GNUS rcvstore*"))) | |
3431 (unwind-protect | |
3432 (call-process-region (point-min) (point-max) | |
3433 (expand-file-name "rcvstore" mh-lib) | |
3434 nil errbuf nil folder) | |
3435 (set-buffer errbuf) | |
3436 (if (zerop (buffer-size)) | |
3437 (message "Article saved in folder: %s" folder) | |
3438 (message "%s" (buffer-string))) | |
3439 (kill-buffer errbuf) | |
3440 (setq gnus-newsgroup-last-folder folder)) | |
3441 )) | |
3442 )) | |
3443 | |
3444 (defun gnus-Subject-pipe-output () | |
3445 "Pipe this article to subprocess." | |
3446 (interactive) | |
3447 ;; Ignore `gnus-save-all-headers' since this is not save command. | |
3448 (gnus-Subject-select-article) | |
3449 (gnus-eval-in-buffer-window gnus-Article-buffer | |
3450 (save-restriction | |
3451 (widen) | |
3452 (let ((command (read-string "Shell command on article: " | |
3453 gnus-last-shell-command))) | |
3454 (if (string-equal command "") | |
3455 (setq command gnus-last-shell-command)) | |
3456 (shell-command-on-region (point-min) (point-max) command nil) | |
3457 (setq gnus-last-shell-command command) | |
3458 )) | |
3459 )) | |
3460 | |
3461 (defun gnus-Subject-catch-up (all &optional quietly) | |
3462 "Mark all articles not marked as unread in this newsgroup as read. | |
3463 If prefix argument ALL is non-nil, all articles are marked as read." | |
3464 (interactive "P") | |
3465 (if (or quietly | |
3466 (y-or-n-p | |
3467 (if all | |
3468 "Do you really want to mark everything as read? " | |
3469 "Delete all articles not marked as unread? "))) | |
3470 (let ((unmarked | |
3471 (gnus-set-difference gnus-newsgroup-unreads | |
3472 (if (not all) gnus-newsgroup-marked)))) | |
3473 (message "") ;Erase "Yes or No" question. | |
3474 (while unmarked | |
3475 (gnus-Subject-mark-as-read (car unmarked) "C") | |
3476 (setq unmarked (cdr unmarked)) | |
3477 )) | |
3478 )) | |
3479 | |
3480 (defun gnus-Subject-catch-up-all (&optional quietly) | |
3481 "Mark all articles in this newsgroup as read." | |
3482 (interactive) | |
3483 (gnus-Subject-catch-up t quietly)) | |
3484 | |
3485 (defun gnus-Subject-catch-up-and-exit (all &optional quietly) | |
3486 "Mark all articles not marked as unread in this newsgroup as read, then exit. | |
3487 If prefix argument ALL is non-nil, all articles are marked as read." | |
3488 (interactive "P") | |
3489 (if (or quietly | |
3490 (y-or-n-p | |
3491 (if all | |
3492 "Do you really want to mark everything as read? " | |
3493 "Delete all articles not marked as unread? "))) | |
3494 (let ((unmarked | |
3495 (gnus-set-difference gnus-newsgroup-unreads | |
3496 (if (not all) gnus-newsgroup-marked)))) | |
3497 (message "") ;Erase "Yes or No" question. | |
3498 (while unmarked | |
3499 (gnus-mark-article-as-read (car unmarked)) | |
3500 (setq unmarked (cdr unmarked))) | |
3501 ;; Select next newsgroup or exit. | |
3502 (cond ((eq gnus-auto-select-next 'quietly) | |
3503 ;; Select next newsgroup quietly. | |
3504 (gnus-Subject-next-group nil)) | |
3505 (t | |
3506 (gnus-Subject-exit))) | |
3507 ))) | |
3508 | |
3509 (defun gnus-Subject-catch-up-all-and-exit (&optional quietly) | |
3510 "Mark all articles in this newsgroup as read, and then exit." | |
3511 (interactive) | |
3512 (gnus-Subject-catch-up-and-exit t quietly)) | |
3513 | |
3514 (defun gnus-Subject-edit-global-kill () | |
3515 "Edit a global KILL file." | |
3516 (interactive) | |
3517 (setq gnus-current-kill-article (gnus-Subject-article-number)) | |
3518 (gnus-Kill-file-edit-file nil) ;Nil stands for global KILL file. | |
3519 (message | |
3520 (substitute-command-keys | |
3521 "Editing a global KILL file (Type \\[gnus-Kill-file-exit] to exit)"))) | |
3522 | |
3523 (defun gnus-Subject-edit-local-kill () | |
3524 "Edit a local KILL file applied to the current newsgroup." | |
3525 (interactive) | |
3526 (setq gnus-current-kill-article (gnus-Subject-article-number)) | |
3527 (gnus-Kill-file-edit-file gnus-newsgroup-name) | |
3528 (message | |
3529 (substitute-command-keys | |
3530 "Editing a local KILL file (Type \\[gnus-Kill-file-exit] to exit)"))) | |
3531 | |
3532 (defun gnus-Subject-exit (&optional temporary) | |
3533 "Exit reading current newsgroup, and then return to group selection mode. | |
3534 gnus-Exit-group-hook is called with no arguments if that value is non-nil." | |
3535 (interactive) | |
3536 (let ((updated nil) | |
3537 (gnus-newsgroup-headers gnus-newsgroup-headers) | |
3538 (gnus-newsgroup-unreads gnus-newsgroup-unreads) | |
3539 (gnus-newsgroup-unselected gnus-newsgroup-unselected) | |
3540 (gnus-newsgroup-marked gnus-newsgroup-marked)) | |
3541 ;; Important internal variables are save, so we can reenter | |
3542 ;; Subject Mode buffer even if hook changes them. | |
3543 (run-hooks 'gnus-Exit-group-hook) | |
3544 (gnus-update-unread-articles gnus-newsgroup-name | |
3545 (append gnus-newsgroup-unselected | |
3546 gnus-newsgroup-unreads) | |
3547 gnus-newsgroup-marked) | |
3548 ;; T means ignore unsubscribed newsgroups. | |
3549 (if gnus-use-cross-reference | |
3550 (setq updated | |
3551 (gnus-mark-as-read-by-xref gnus-newsgroup-name | |
3552 gnus-newsgroup-headers | |
3553 gnus-newsgroup-unreads | |
3554 (eq gnus-use-cross-reference t) | |
3555 ))) | |
3556 ;; Do not switch windows but change the buffer to work. | |
3557 (set-buffer gnus-Group-buffer) | |
3558 ;; Update cross referenced group info. | |
3559 (while updated | |
3560 (gnus-Group-update-group (car updated) t) ;Ignore invisible group. | |
3561 (setq updated (cdr updated))) | |
3562 (gnus-Group-update-group gnus-newsgroup-name)) | |
3563 ;; Make sure where I was, and go to next newsgroup. | |
3564 (gnus-Group-jump-to-group gnus-newsgroup-name) | |
3565 (gnus-Group-next-unread-group 1) | |
3566 (if temporary | |
3567 ;; If exiting temporary, caller should adjust Group mode | |
3568 ;; buffer point by itself. | |
3569 nil ;Nothing to do. | |
3570 ;; Return to Group mode buffer. | |
3571 (if (get-buffer gnus-Subject-buffer) | |
3572 (bury-buffer gnus-Subject-buffer)) | |
3573 (if (get-buffer gnus-Article-buffer) | |
3574 (bury-buffer gnus-Article-buffer)) | |
3575 (gnus-configure-windows 'ExitNewsgroup) | |
3576 (pop-to-buffer gnus-Group-buffer))) | |
3577 | |
3578 (defun gnus-Subject-quit () | |
3579 "Quit reading current newsgroup without updating read article info." | |
3580 (interactive) | |
3581 (if (y-or-n-p "Do you really wanna quit reading this group? ") | |
3582 (progn | |
3583 (message "") ;Erase "Yes or No" question. | |
3584 ;; Return to Group selection mode. | |
3585 (if (get-buffer gnus-Subject-buffer) | |
3586 (bury-buffer gnus-Subject-buffer)) | |
3587 (if (get-buffer gnus-Article-buffer) | |
3588 (bury-buffer gnus-Article-buffer)) | |
3589 (gnus-configure-windows 'ExitNewsgroup) | |
3590 (pop-to-buffer gnus-Group-buffer) | |
3591 (gnus-Group-jump-to-group gnus-newsgroup-name) ;Make sure where I was. | |
3592 (gnus-Group-next-group 1) ;(gnus-Group-next-unread-group 1) | |
3593 ))) | |
3594 | |
3595 (defun gnus-Subject-describe-briefly () | |
3596 "Describe Subject mode commands briefly." | |
3597 (interactive) | |
3598 (message | |
3599 (concat | |
3600 (substitute-command-keys "\\[gnus-Subject-next-page]:Select ") | |
3601 (substitute-command-keys "\\[gnus-Subject-next-unread-article]:Forward ") | |
3602 (substitute-command-keys "\\[gnus-Subject-prev-unread-article]:Backward ") | |
3603 (substitute-command-keys "\\[gnus-Subject-exit]:Exit ") | |
3604 (substitute-command-keys "\\[gnus-Info-find-node]:Run Info ") | |
3605 (substitute-command-keys "\\[gnus-Subject-describe-briefly]:This help") | |
3606 ))) | |
3607 | |
3608 | |
3609 ;;; | |
3610 ;;; GNUS Article Mode | |
3611 ;;; | |
3612 | |
3613 (if gnus-Article-mode-map | |
3614 nil | |
3615 (setq gnus-Article-mode-map (make-keymap)) | |
3616 (suppress-keymap gnus-Article-mode-map) | |
3617 (define-key gnus-Article-mode-map " " 'gnus-Article-next-page) | |
3618 (define-key gnus-Article-mode-map "\177" 'gnus-Article-prev-page) | |
3619 (define-key gnus-Article-mode-map "r" 'gnus-Article-refer-article) | |
3620 (define-key gnus-Article-mode-map "o" 'gnus-Article-pop-article) | |
3621 (define-key gnus-Article-mode-map "h" 'gnus-Article-show-subjects) | |
3622 (define-key gnus-Article-mode-map "s" 'gnus-Article-show-subjects) | |
3623 (define-key gnus-Article-mode-map "?" 'gnus-Article-describe-briefly) | |
3624 (define-key gnus-Article-mode-map "\C-c\C-i" 'gnus-Info-find-node)) | |
3625 | |
3626 (defun gnus-Article-mode () | |
3627 "Major mode for browsing through an article. | |
3628 All normal editing commands are turned off. | |
3629 Instead, these commands are available: | |
3630 \\{gnus-Article-mode-map} | |
3631 | |
3632 Various hooks for customization: | |
3633 gnus-Article-mode-hook | |
3634 Entry to this mode calls the value with no arguments, if that | |
3635 value is non-nil. | |
3636 | |
3637 gnus-Article-prepare-hook | |
3638 Called with no arguments after an article is prepared for reading, | |
3639 if that value is non-nil." | |
3640 (interactive) | |
3641 (kill-all-local-variables) | |
3642 ;; Gee. Why don't you upgrade? | |
3643 (cond ((boundp 'mode-line-modified) | |
3644 (setq mode-line-modified "--- ")) | |
3645 ((listp (default-value 'mode-line-format)) | |
3646 (setq mode-line-format | |
3647 (cons "--- " (cdr (default-value 'mode-line-format)))))) | |
3648 (make-local-variable 'global-mode-string) | |
3649 (setq global-mode-string nil) | |
3650 (setq major-mode 'gnus-Article-mode) | |
3651 (setq mode-name "Article") | |
3652 (gnus-Article-set-mode-line) | |
3653 (use-local-map gnus-Article-mode-map) | |
3654 (make-local-variable 'page-delimiter) | |
3655 (setq page-delimiter gnus-page-delimiter) | |
3656 (make-local-variable 'mail-header-separator) | |
3657 (setq mail-header-separator "") ;For caesar function. | |
3658 (buffer-flush-undo (current-buffer)) | |
3659 (setq buffer-read-only t) ;Disable modification | |
3660 (run-hooks 'gnus-Article-mode-hook)) | |
3661 | |
3662 (defun gnus-Article-setup-buffer () | |
3663 "Initialize Article mode buffer." | |
3664 (or (get-buffer gnus-Article-buffer) | |
3665 (save-excursion | |
3666 (set-buffer (get-buffer-create gnus-Article-buffer)) | |
3667 (gnus-Article-mode)) | |
3668 )) | |
3669 | |
3670 (defun gnus-Article-prepare (article &optional all-headers) | |
3671 "Prepare ARTICLE in Article mode buffer. | |
3672 If optional argument ALL-HEADERS is non-nil, all headers are inserted." | |
3673 (save-excursion | |
3674 (set-buffer gnus-Article-buffer) | |
3675 (let ((buffer-read-only nil)) | |
3676 (erase-buffer) | |
3677 (if (gnus-request-article article) | |
3678 (progn | |
3679 ;; Prepare article buffer | |
3680 (insert-buffer-substring nntp-server-buffer) | |
3681 (setq gnus-have-all-headers (or all-headers gnus-show-all-headers)) | |
3682 (if (and (numberp article) | |
3683 (not (eq article gnus-current-article))) | |
3684 ;; Seems me that a new article is selected. | |
3685 (progn | |
3686 ;; gnus-current-article must be an article number. | |
3687 (setq gnus-last-article gnus-current-article) | |
3688 (setq gnus-current-article article) | |
3689 (setq gnus-current-headers | |
3690 (gnus-find-header-by-number gnus-newsgroup-headers | |
3691 gnus-current-article)) | |
3692 ;; Clear articles history only when articles are | |
3693 ;; retrieved by article numbers. | |
3694 (setq gnus-current-history nil) | |
3695 (run-hooks 'gnus-Mark-article-hook) | |
3696 )) | |
3697 ;; Hooks for modifying contents of the article. This hook | |
3698 ;; must be called before being narrowed. | |
3699 (run-hooks 'gnus-Article-prepare-hook) | |
3700 ;; Delete unnecessary headers. | |
3701 (or gnus-have-all-headers | |
3702 (gnus-Article-delete-headers)) | |
3703 ;; Do page break. | |
3704 (goto-char (point-min)) | |
3705 (if gnus-break-pages | |
3706 (gnus-narrow-to-page)) | |
3707 ;; Next function must be called after setting | |
3708 ;; `gnus-current-article' variable and narrowed to page. | |
3709 (gnus-Article-set-mode-line) | |
3710 ) | |
3711 (if (numberp article) | |
3712 (gnus-Subject-mark-as-read article)) | |
3713 (ding) (message "No such article (may be canceled)")) | |
3714 ))) | |
3715 | |
3716 (defun gnus-Article-show-all-headers () | |
3717 "Show all article headers in Article mode buffer." | |
3718 (or gnus-have-all-headers | |
3719 (gnus-Article-prepare gnus-current-article t))) | |
3720 | |
3721 ;;(defun gnus-Article-set-mode-line () | |
3722 ;; "Set Article mode line string." | |
3723 ;; (setq mode-line-buffer-identification | |
3724 ;; (list 17 | |
3725 ;; (format "GNUS: %s {%d-%d} %d" | |
3726 ;; gnus-newsgroup-name | |
3727 ;; gnus-newsgroup-begin | |
3728 ;; gnus-newsgroup-end | |
3729 ;; gnus-current-article | |
3730 ;; ))) | |
3731 ;; (set-buffer-modified-p t)) | |
3732 | |
3733 (defun gnus-Article-set-mode-line () | |
3734 "Set Article mode line string." | |
3735 (let ((unmarked | |
3736 (- (length gnus-newsgroup-unreads) | |
3737 (length (gnus-intersection | |
3738 gnus-newsgroup-unreads gnus-newsgroup-marked)))) | |
3739 (unselected | |
3740 (- (length gnus-newsgroup-unselected) | |
3741 (length (gnus-intersection | |
3742 gnus-newsgroup-unselected gnus-newsgroup-marked))))) | |
3743 (setq mode-line-buffer-identification | |
3744 (list 17 | |
3745 (format "GNUS: %s{%d} %s" | |
3746 gnus-newsgroup-name | |
3747 gnus-current-article | |
3748 ;; This is proposed by tale@pawl.rpi.edu. | |
3749 (cond ((and (zerop unmarked) | |
3750 (zerop unselected)) | |
3751 " ") | |
3752 ((zerop unselected) | |
3753 (format "%d more" unmarked)) | |
3754 (t | |
3755 (format "%d(+%d) more" unmarked unselected))) | |
3756 )))) | |
3757 (set-buffer-modified-p t)) | |
3758 | |
3759 (defun gnus-Article-delete-headers () | |
3760 "Delete unnecessary headers." | |
3761 (save-excursion | |
3762 (save-restriction | |
3763 (goto-char (point-min)) | |
3764 (narrow-to-region (point-min) | |
3765 (progn (search-forward "\n\n" nil 'move) (point))) | |
3766 (goto-char (point-min)) | |
3767 (and (stringp gnus-ignored-headers) | |
3768 (while (re-search-forward gnus-ignored-headers nil t) | |
3769 (beginning-of-line) | |
3770 (delete-region (point) | |
3771 (progn (re-search-forward "\n[^ \t]") | |
3772 (forward-char -1) | |
3773 (point))))) | |
3774 ))) | |
3775 | |
3776 ;; Working on article's buffer | |
3777 | |
3778 (defun gnus-Article-next-page (lines) | |
3779 "Show next page of current article. | |
3780 If end of article, return non-nil. Otherwise return nil. | |
3781 Argument LINES specifies lines to be scrolled up." | |
3782 (interactive "P") | |
3783 (move-to-window-line -1) | |
3784 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo) | |
3785 (if (save-excursion | |
3786 (end-of-line) | |
3787 (and (pos-visible-in-window-p) ;Not continuation line. | |
3788 (eobp))) | |
3789 ;; Nothing in this page. | |
3790 (if (or (not gnus-break-pages) | |
3791 (save-excursion | |
3792 (save-restriction | |
3793 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer? | |
3794 t ;Nothing more. | |
3795 (gnus-narrow-to-page 1) ;Go to next page. | |
3796 nil | |
3797 ) | |
3798 ;; More in this page. | |
3799 (condition-case () | |
3800 (scroll-up lines) | |
3801 (end-of-buffer | |
3802 ;; Long lines may cause an end-of-buffer error. | |
3803 (goto-char (point-max)))) | |
3804 nil | |
3805 )) | |
3806 | |
3807 (defun gnus-Article-prev-page (lines) | |
3808 "Show previous page of current article. | |
3809 Argument LINES specifies lines to be scrolled down." | |
3810 (interactive "P") | |
3811 (move-to-window-line 0) | |
3812 (if (and gnus-break-pages | |
3813 (bobp) | |
3814 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer? | |
3815 (progn | |
3816 (gnus-narrow-to-page -1) ;Go to previous page. | |
3817 (goto-char (point-max)) | |
3818 (recenter -1)) | |
3819 (scroll-down lines))) | |
3820 | |
3821 (defun gnus-Article-next-digest (nth) | |
3822 "Move to head of NTH next digested message. | |
3823 Set mark at end of digested message." | |
3824 ;; Stop page breaking in digest mode. | |
3825 (widen) | |
3826 (end-of-line) | |
3827 ;; Skip NTH - 1 digest. | |
3828 ;; Suggested by Khalid Sattar <admin@cs.exeter.ac.uk>. | |
3829 ;; Digest separator is customizable. | |
3830 ;; Suggested by Skip Montanaro <montanaro@sprite.crd.ge.com>. | |
3831 (while (and (> nth 1) | |
3832 (re-search-forward gnus-digest-separator nil 'move)) | |
3833 (setq nth (1- nth))) | |
3834 (if (re-search-forward gnus-digest-separator nil t) | |
3835 (let ((begin (point))) | |
3836 ;; Search for end of this message. | |
3837 (end-of-line) | |
3838 (if (re-search-forward gnus-digest-separator nil t) | |
3839 (progn | |
3840 (search-backward "\n\n") ;This may be incorrect. | |
3841 (forward-line 1)) | |
3842 (goto-char (point-max))) | |
3843 (push-mark) ;Set mark at end of digested message. | |
3844 (goto-char begin) | |
3845 (beginning-of-line) | |
3846 ;; Show From: and Subject: fields. | |
3847 (recenter 1)) | |
3848 (message "End of message") | |
3849 )) | |
3850 | |
3851 (defun gnus-Article-prev-digest (nth) | |
3852 "Move to head of NTH previous digested message." | |
3853 ;; Stop page breaking in digest mode. | |
3854 (widen) | |
3855 (beginning-of-line) | |
3856 ;; Skip NTH - 1 digest. | |
3857 ;; Suggested by Khalid Sattar <admin@cs.exeter.ac.uk>. | |
3858 ;; Digest separator is customizable. | |
3859 ;; Suggested by Skip Montanaro <montanaro@sprite.crd.ge.com>. | |
3860 (while (and (> nth 1) | |
3861 (re-search-backward gnus-digest-separator nil 'move)) | |
3862 (setq nth (1- nth))) | |
3863 (if (re-search-backward gnus-digest-separator nil t) | |
3864 (let ((begin (point))) | |
3865 ;; Search for end of this message. | |
3866 (end-of-line) | |
3867 (if (re-search-forward gnus-digest-separator nil t) | |
3868 (progn | |
3869 (search-backward "\n\n") ;This may be incorrect. | |
3870 (forward-line 1)) | |
3871 (goto-char (point-max))) | |
3872 (push-mark) ;Set mark at end of digested message. | |
3873 (goto-char begin) | |
3874 ;; Show From: and Subject: fields. | |
3875 (recenter 1)) | |
3876 (goto-char (point-min)) | |
3877 (message "Top of message") | |
3878 )) | |
3879 | |
3880 (defun gnus-Article-refer-article () | |
3881 "Read article specified by message-id around point." | |
3882 (interactive) | |
3883 (save-window-excursion | |
3884 (save-excursion | |
3885 (re-search-forward ">" nil t) ;Move point to end of "<....>". | |
3886 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t) | |
3887 (let ((message-id | |
3888 (buffer-substring (match-beginning 1) (match-end 1)))) | |
3889 (set-buffer gnus-Subject-buffer) | |
3890 (gnus-Subject-refer-article message-id)) | |
3891 (error "No references around point")) | |
3892 ))) | |
3893 | |
3894 (defun gnus-Article-pop-article () | |
3895 "Pop up article history." | |
3896 (interactive) | |
3897 (save-window-excursion | |
3898 (set-buffer gnus-Subject-buffer) | |
3899 (gnus-Subject-refer-article nil))) | |
3900 | |
3901 (defun gnus-Article-show-subjects () | |
3902 "Reconfigure windows to show headers." | |
3903 (interactive) | |
3904 (gnus-configure-windows 'SelectArticle) | |
3905 (pop-to-buffer gnus-Subject-buffer) | |
3906 (gnus-Subject-goto-subject gnus-current-article)) | |
3907 | |
3908 (defun gnus-Article-describe-briefly () | |
3909 "Describe Article mode commands briefly." | |
3910 (interactive) | |
3911 (message | |
3912 (concat | |
3913 (substitute-command-keys "\\[gnus-Article-next-page]:Next page ") | |
3914 (substitute-command-keys "\\[gnus-Article-prev-page]:Prev page ") | |
3915 (substitute-command-keys "\\[gnus-Article-show-subjects]:Show headers ") | |
3916 (substitute-command-keys "\\[gnus-Info-find-node]:Run Info ") | |
3917 (substitute-command-keys "\\[gnus-Article-describe-briefly]:This help") | |
3918 ))) | |
3919 | |
3920 | |
3921 ;;; | |
3922 ;;; GNUS KILL-File Mode | |
3923 ;;; | |
3924 | |
3925 (if gnus-Kill-file-mode-map | |
3926 nil | |
3927 (setq gnus-Kill-file-mode-map (copy-keymap emacs-lisp-mode-map)) | |
3928 (define-key gnus-Kill-file-mode-map "\C-c\C-k\C-s" 'gnus-Kill-file-kill-by-subject) | |
3929 (define-key gnus-Kill-file-mode-map "\C-c\C-k\C-a" 'gnus-Kill-file-kill-by-author) | |
3930 (define-key gnus-Kill-file-mode-map "\C-c\C-a" 'gnus-Kill-file-apply-buffer) | |
3931 (define-key gnus-Kill-file-mode-map "\C-c\C-e" 'gnus-Kill-file-apply-last-sexp) | |
3932 (define-key gnus-Kill-file-mode-map "\C-c\C-c" 'gnus-Kill-file-exit) | |
3933 (define-key gnus-Kill-file-mode-map "\C-c\C-i" 'gnus-Info-find-node)) | |
3934 | |
3935 (defun gnus-Kill-file-mode () | |
3936 "Major mode for editing KILL file. | |
3937 | |
3938 In addition to Emacs-Lisp Mode, the following commands are available: | |
3939 | |
3940 \\[gnus-Kill-file-kill-by-subject] Insert KILL command for current subject. | |
3941 \\[gnus-Kill-file-kill-by-author] Insert KILL command for current author. | |
3942 \\[gnus-Kill-file-apply-buffer] Apply current buffer to selected newsgroup. | |
3943 \\[gnus-Kill-file-apply-last-sexp] Apply sexp before point to selected newsgroup. | |
3944 \\[gnus-Kill-file-exit] Save file and exit editing KILL file. | |
3945 \\[gnus-Info-find-node] Read Info about KILL file. | |
3946 | |
3947 A KILL file contains lisp expressions to be applied to a selected | |
3948 newsgroup. The purpose is to mark articles as read on the basis of | |
3949 some set of regexps. A global KILL file is applied to every newsgroup, | |
3950 and a local KILL file is applied to a specified newsgroup. Since a | |
3951 global KILL file is applied to every newsgroup, for better performance | |
3952 use a local one. | |
3953 | |
3954 A KILL file can contain any kind of Emacs lisp expressions expected | |
3955 to be evaluated in the Subject buffer. Writing lisp programs for this | |
3956 purpose is not so easy because the internal working of GNUS must be | |
3957 well-known. For this reason, GNUS provides a general function which | |
3958 does this easily for non-Lisp programmers. | |
3959 | |
3960 The `gnus-kill' function executes commands available in Subject Mode | |
3961 by their key sequences. `gnus-kill' should be called with FIELD, | |
3962 REGEXP and optional COMMAND and ALL. FIELD is a string representing | |
3963 the header field or an empty string. If FIELD is an empty string, the | |
3964 entire article body is searched for. REGEXP is a string which is | |
3965 compared with FIELD value. COMMAND is a string representing a valid | |
3966 key sequence in Subject Mode or Lisp expression. COMMAND is default to | |
3967 '(gnus-Subject-mark-as-read nil \"X\"). Make sure that COMMAND is | |
3968 executed in the Subject buffer. If the second optional argument ALL | |
3969 is non-nil, the COMMAND is applied to articles which are already | |
3970 marked as read or unread. Articles which are marked are skipped over | |
3971 by default. | |
3972 | |
3973 For example, if you want to mark articles of which subjects contain | |
3974 the string `AI' as read, a possible KILL file may look like: | |
3975 | |
3976 (gnus-kill \"Subject\" \"AI\") | |
3977 | |
3978 If you want to mark articles with `D' instead of `X', you can use | |
3979 the following expression: | |
3980 | |
3981 (gnus-kill \"Subject\" \"AI\" \"d\") | |
3982 | |
3983 In this example it is assumed that the command | |
3984 `gnus-Subject-mark-as-read-forward' is assigned to `d' in Subject Mode. | |
3985 | |
3986 It is possible to delete unnecessary headers which are marked with | |
3987 `X' in a KILL file as follows: | |
3988 | |
3989 (gnus-expunge \"X\") | |
3990 | |
3991 If the Subject buffer is empty after applying KILL files, GNUS will | |
3992 exit the selected newsgroup normally. If headers which are marked | |
3993 with `D' are deleted in a KILL file, it is impossible to read articles | |
3994 which are marked as read in the previous GNUS sessions. Marks other | |
3995 than `D' should be used for articles which should really be deleted. | |
3996 | |
3997 Entry to this mode calls emacs-lisp-mode-hook and | |
3998 gnus-Kill-file-mode-hook with no arguments, if that value is non-nil." | |
3999 (interactive) | |
4000 (kill-all-local-variables) | |
4001 (use-local-map gnus-Kill-file-mode-map) | |
4002 (set-syntax-table emacs-lisp-mode-syntax-table) | |
4003 (setq major-mode 'gnus-Kill-file-mode) | |
4004 (setq mode-name "KILL-File") | |
4005 (lisp-mode-variables nil) | |
4006 (run-hooks 'emacs-lisp-mode-hook 'gnus-Kill-file-mode-hook)) | |
4007 | |
4008 (defun gnus-Kill-file-edit-file (newsgroup) | |
4009 "Begin editing a KILL file of NEWSGROUP. | |
4010 If NEWSGROUP is nil, the global KILL file is selected." | |
4011 (interactive "sNewsgroup: ") | |
4012 (let ((file (gnus-newsgroup-kill-file newsgroup))) | |
4013 (gnus-make-directory (file-name-directory file)) | |
4014 ;; Save current window configuration if this is first invocation. | |
4015 (or (and (get-file-buffer file) | |
4016 (get-buffer-window (get-file-buffer file))) | |
4017 (setq gnus-winconf-kill-file (current-window-configuration))) | |
4018 ;; Hack windows. | |
4019 (let ((buffer (find-file-noselect file))) | |
4020 (cond ((get-buffer-window buffer) | |
4021 (pop-to-buffer buffer)) | |
4022 ((eq major-mode 'gnus-Group-mode) | |
4023 (gnus-configure-windows '(1 0 0)) ;Take all windows. | |
4024 (pop-to-buffer gnus-Group-buffer) | |
4025 (let ((gnus-Subject-buffer buffer)) | |
4026 (gnus-configure-windows '(1 1 0)) ;Split into two. | |
4027 (pop-to-buffer buffer))) | |
4028 ((eq major-mode 'gnus-Subject-mode) | |
4029 (gnus-configure-windows 'SelectArticle) | |
4030 (pop-to-buffer gnus-Article-buffer) | |
4031 (bury-buffer gnus-Article-buffer) | |
4032 (switch-to-buffer buffer)) | |
4033 (t ;No good rules. | |
4034 (find-file-other-window file)) | |
4035 )) | |
4036 (gnus-Kill-file-mode) | |
4037 )) | |
4038 | |
4039 (defun gnus-Kill-file-kill-by-subject () | |
4040 "Insert KILL command for current subject." | |
4041 (interactive) | |
4042 (insert | |
4043 (format "(gnus-kill \"Subject\" %s)\n" | |
4044 (prin1-to-string | |
4045 (if gnus-current-kill-article | |
4046 (regexp-quote | |
4047 (nntp-header-subject | |
4048 (gnus-find-header-by-number gnus-newsgroup-headers | |
4049 gnus-current-kill-article))) | |
4050 ""))))) | |
4051 | |
4052 (defun gnus-Kill-file-kill-by-author () | |
4053 "Insert KILL command for current author." | |
4054 (interactive) | |
4055 (insert | |
4056 (format "(gnus-kill \"From\" %s)\n" | |
4057 (prin1-to-string | |
4058 (if gnus-current-kill-article | |
4059 (regexp-quote | |
4060 (nntp-header-from | |
4061 (gnus-find-header-by-number gnus-newsgroup-headers | |
4062 gnus-current-kill-article))) | |
4063 ""))))) | |
4064 | |
4065 (defun gnus-Kill-file-apply-buffer () | |
4066 "Apply current buffer to current newsgroup." | |
4067 (interactive) | |
4068 (if (and gnus-current-kill-article | |
4069 (get-buffer gnus-Subject-buffer)) | |
4070 ;; Assume newsgroup is selected. | |
4071 (let ((string (concat "(progn \n" (buffer-string) "\n)" ))) | |
4072 (save-excursion | |
4073 (save-window-excursion | |
4074 (pop-to-buffer gnus-Subject-buffer) | |
4075 (eval (car (read-from-string string)))))) | |
4076 (ding) (message "No newsgroup is selected."))) | |
4077 | |
4078 (defun gnus-Kill-file-apply-last-sexp () | |
4079 "Apply sexp before point in current buffer to current newsgroup." | |
4080 (interactive) | |
4081 (if (and gnus-current-kill-article | |
4082 (get-buffer gnus-Subject-buffer)) | |
4083 ;; Assume newsgroup is selected. | |
4084 (let ((string | |
4085 (buffer-substring | |
4086 (save-excursion (forward-sexp -1) (point)) (point)))) | |
4087 (save-excursion | |
4088 (save-window-excursion | |
4089 (pop-to-buffer gnus-Subject-buffer) | |
4090 (eval (car (read-from-string string)))))) | |
4091 (ding) (message "No newsgroup is selected."))) | |
4092 | |
4093 (defun gnus-Kill-file-exit () | |
4094 "Save a KILL file, then return to the previous buffer." | |
4095 (interactive) | |
4096 (save-buffer) | |
4097 (let ((killbuf (current-buffer))) | |
4098 ;; We don't want to return to Article buffer. | |
4099 (and (get-buffer gnus-Article-buffer) | |
4100 (bury-buffer (get-buffer gnus-Article-buffer))) | |
4101 ;; Delete the KILL file windows. | |
4102 (delete-windows-on killbuf) | |
4103 ;; Restore last window configuration if available. | |
4104 (and gnus-winconf-kill-file | |
4105 (set-window-configuration gnus-winconf-kill-file)) | |
4106 (setq gnus-winconf-kill-file nil) | |
4107 ;; Kill the KILL file buffer. Suggested by tale@pawl.rpi.edu. | |
4108 (kill-buffer killbuf))) | |
4109 | |
4110 | |
4111 ;;; | |
4112 ;;; Utility functions | |
4113 ;;; | |
4114 | |
4115 ;; Basic ideas by emv@math.lsa.umich.edu (Edward Vielmetti) | |
4116 | |
4117 (defun gnus-batch-kill () | |
4118 "Run batched KILL. | |
4119 Usage: emacs -batch -l gnus -f gnus-batch-kill NEWSGROUP ..." | |
4120 (if (not noninteractive) | |
4121 (error "gnus-batch-kill is to be used only with -batch")) | |
4122 (let* ((group nil) | |
4123 (subscribed nil) | |
4124 (newsrc nil) | |
4125 (yes-and-no | |
4126 (gnus-parse-n-options | |
4127 (apply (function concat) | |
4128 (mapcar (function (lambda (g) (concat g " "))) | |
4129 command-line-args-left)))) | |
4130 (yes (car yes-and-no)) | |
4131 (no (cdr yes-and-no)) | |
4132 ;; Disable verbose message. | |
4133 (gnus-novice-user nil) | |
4134 (gnus-large-newsgroup nil) | |
4135 (nntp-large-newsgroup nil)) | |
4136 ;; Eat all arguments. | |
4137 (setq command-line-args-left nil) | |
4138 ;; Startup GNUS. | |
4139 (gnus) | |
4140 ;; Apply kills to specified newsgroups in command line arguments. | |
4141 (setq newsrc (copy-sequence gnus-newsrc-assoc)) | |
4142 (while newsrc | |
4143 (setq group (car (car newsrc))) | |
4144 (setq subscribed (nth 1 (car newsrc))) | |
4145 (setq newsrc (cdr newsrc)) | |
4146 (if (and subscribed | |
4147 (not (zerop (nth 1 (gnus-gethash group gnus-unread-hashtb)))) | |
4148 (if yes | |
4149 (string-match yes group) t) | |
4150 (or (null no) | |
4151 (not (string-match no group)))) | |
4152 (progn | |
4153 (gnus-Subject-read-group group nil t) | |
4154 (if (eq (current-buffer) (get-buffer gnus-Subject-buffer)) | |
4155 (gnus-Subject-exit t)) | |
4156 )) | |
4157 ) | |
4158 ;; Finally, exit Emacs. | |
4159 (set-buffer gnus-Group-buffer) | |
4160 (gnus-Group-exit) | |
4161 )) | |
4162 | |
4163 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file) | |
4164 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE. | |
4165 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num. | |
4166 Otherwise, it is like ~/News/news/group/num." | |
4167 (let ((default | |
4168 (expand-file-name | |
4169 (concat (if gnus-use-long-file-name | |
4170 (capitalize newsgroup) | |
4171 (gnus-newsgroup-directory-form newsgroup)) | |
4172 "/" (int-to-string (nntp-header-number headers))) | |
4173 (or gnus-article-save-directory "~/News")))) | |
4174 (if (and last-file | |
4175 (string-equal (file-name-directory default) | |
4176 (file-name-directory last-file)) | |
4177 (string-match "^[0-9]+$" (file-name-nondirectory last-file))) | |
4178 default | |
4179 (or last-file default)))) | |
4180 | |
4181 (defun gnus-numeric-save-name (newsgroup headers &optional last-file) | |
4182 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE. | |
4183 If variable `gnus-use-long-file-name' is nil, it is ~/News/news.group/num. | |
4184 Otherwise, it is like ~/News/news/group/num." | |
4185 (let ((default | |
4186 (expand-file-name | |
4187 (concat (if gnus-use-long-file-name | |
4188 newsgroup | |
4189 (gnus-newsgroup-directory-form newsgroup)) | |
4190 "/" (int-to-string (nntp-header-number headers))) | |
4191 (or gnus-article-save-directory "~/News")))) | |
4192 (if (and last-file | |
4193 (string-equal (file-name-directory default) | |
4194 (file-name-directory last-file)) | |
4195 (string-match "^[0-9]+$" (file-name-nondirectory last-file))) | |
4196 default | |
4197 (or last-file default)))) | |
4198 | |
4199 (defun gnus-Plain-save-name (newsgroup headers &optional last-file) | |
4200 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE. | |
4201 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group. | |
4202 Otherwise, it is like ~/News/news/group/news." | |
4203 (or last-file | |
4204 (expand-file-name | |
4205 (if gnus-use-long-file-name | |
4206 (capitalize newsgroup) | |
4207 (concat (gnus-newsgroup-directory-form newsgroup) "/news")) | |
4208 (or gnus-article-save-directory "~/News")))) | |
4209 | |
4210 (defun gnus-plain-save-name (newsgroup headers &optional last-file) | |
4211 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE. | |
4212 If variable `gnus-use-long-file-name' is nil, it is ~/News/news.group. | |
4213 Otherwise, it is like ~/News/news/group/news." | |
4214 (or last-file | |
4215 (expand-file-name | |
4216 (if gnus-use-long-file-name | |
4217 newsgroup | |
4218 (concat (gnus-newsgroup-directory-form newsgroup) "/news")) | |
4219 (or gnus-article-save-directory "~/News")))) | |
4220 | |
4221 (defun gnus-Folder-save-name (newsgroup headers &optional last-folder) | |
4222 "Generate folder name from NEWSGROUP, HEADERS, and optional LAST-FOLDER. | |
4223 If variable `gnus-use-long-file-name' is nil, it is +News.group. | |
4224 Otherwise, it is like +news/group." | |
4225 (or last-folder | |
4226 (concat "+" | |
4227 (if gnus-use-long-file-name | |
4228 (capitalize newsgroup) | |
4229 (gnus-newsgroup-directory-form newsgroup))))) | |
4230 | |
4231 (defun gnus-folder-save-name (newsgroup headers &optional last-folder) | |
4232 "Generate folder name from NEWSGROUP, HEADERS, and optional LAST-FOLDER. | |
4233 If variable `gnus-use-long-file-name' is nil, it is +news.group. | |
4234 Otherwise, it is like +news/group." | |
4235 (or last-folder | |
4236 (concat "+" | |
4237 (if gnus-use-long-file-name | |
4238 newsgroup | |
4239 (gnus-newsgroup-directory-form newsgroup))))) | |
4240 | |
4241 (defun gnus-apply-kill-file () | |
4242 "Apply KILL file to the current newsgroup." | |
4243 ;; Apply the global KILL file. | |
4244 (load (gnus-newsgroup-kill-file nil) t nil t) | |
4245 ;; And then apply the local KILL file. | |
4246 (load (gnus-newsgroup-kill-file gnus-newsgroup-name) t nil t)) | |
4247 | |
4248 (defun gnus-Newsgroup-kill-file (newsgroup) | |
4249 "Return the name of a KILL file of NEWSGROUP. | |
4250 If NEWSGROUP is nil, return the global KILL file instead." | |
4251 (cond ((or (null newsgroup) | |
4252 (string-equal newsgroup "")) | |
4253 ;; The global KILL file is placed at top of the directory. | |
4254 (expand-file-name gnus-kill-file-name | |
4255 (or gnus-article-save-directory "~/News"))) | |
4256 (gnus-use-long-file-name | |
4257 ;; Append ".KILL" to capitalized newsgroup name. | |
4258 (expand-file-name (concat (capitalize newsgroup) | |
4259 "." gnus-kill-file-name) | |
4260 (or gnus-article-save-directory "~/News"))) | |
4261 (t | |
4262 ;; Place "KILL" under the hierarchical directory. | |
4263 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup) | |
4264 "/" gnus-kill-file-name) | |
4265 (or gnus-article-save-directory "~/News"))) | |
4266 )) | |
4267 | |
4268 (defun gnus-newsgroup-kill-file (newsgroup) | |
4269 "Return the name of a KILL file of NEWSGROUP. | |
4270 If NEWSGROUP is nil, return the global KILL file instead." | |
4271 (cond ((or (null newsgroup) | |
4272 (string-equal newsgroup "")) | |
4273 ;; The global KILL file is placed at top of the directory. | |
4274 (expand-file-name gnus-kill-file-name | |
4275 (or gnus-article-save-directory "~/News"))) | |
4276 (gnus-use-long-file-name | |
4277 ;; Append ".KILL" to newsgroup name. | |
4278 (expand-file-name (concat newsgroup "." gnus-kill-file-name) | |
4279 (or gnus-article-save-directory "~/News"))) | |
4280 (t | |
4281 ;; Place "KILL" under the hierarchical directory. | |
4282 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup) | |
4283 "/" gnus-kill-file-name) | |
4284 (or gnus-article-save-directory "~/News"))) | |
4285 )) | |
4286 | |
4287 (defun gnus-newsgroup-directory-form (newsgroup) | |
4288 "Make hierarchical directory name from NEWSGROUP name." | |
4289 (let ((newsgroup (substring newsgroup 0)) ;Copy string. | |
4290 (len (length newsgroup)) | |
4291 (idx 0)) | |
4292 ;; Replace all occurence of `.' with `/'. | |
4293 (while (< idx len) | |
4294 (if (= (aref newsgroup idx) ?.) | |
4295 (aset newsgroup idx ?/)) | |
4296 (setq idx (1+ idx))) | |
4297 newsgroup | |
4298 )) | |
4299 | |
4300 (defun gnus-make-directory (directory) | |
4301 "Make DIRECTORY recursively." | |
4302 (let ((directory (expand-file-name directory default-directory))) | |
4303 (or (file-exists-p directory) | |
4304 (gnus-make-directory-1 "" directory)) | |
4305 )) | |
4306 | |
4307 (defun gnus-make-directory-1 (head tail) | |
4308 (cond ((string-match "^/\\([^/]+\\)" tail) | |
4309 (setq head | |
4310 (concat (file-name-as-directory head) | |
4311 (substring tail (match-beginning 1) (match-end 1)))) | |
4312 (or (file-exists-p head) | |
4313 (call-process "mkdir" nil nil nil head)) | |
4314 (gnus-make-directory-1 head (substring tail (match-end 1)))) | |
4315 ((string-equal tail "") t) | |
4316 )) | |
4317 | |
4318 (defun gnus-simplify-subject (subject &optional re-only) | |
4319 "Remove `Re:' and words in parentheses. | |
4320 If optional argument RE-ONLY is non-nil, strip `Re:' only." | |
4321 (let ((case-fold-search t)) ;Ignore case. | |
4322 ;; Remove `Re:' and `Re^N:'. | |
4323 (if (string-match "\\`\\(re\\(\\^[0-9]+\\)?:[ \t]+\\)+" subject) | |
4324 (setq subject (substring subject (match-end 0)))) | |
4325 ;; Remove words in parentheses from end. | |
4326 (or re-only | |
4327 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject) | |
4328 (setq subject (substring subject 0 (match-beginning 0))))) | |
4329 ;; Return subject string. | |
4330 subject | |
4331 )) | |
4332 | |
4333 (defun gnus-optional-lines-and-from (header) | |
4334 "Return a string like `NNN:AUTHOR' from HEADER." | |
4335 (let ((name-length (length "umerin@photon"))) | |
4336 (substring (format "%3d:%s" | |
4337 ;; Lines of the article. | |
4338 ;; Suggested by dana@bellcore.com. | |
4339 (nntp-header-lines header) | |
4340 ;; Its author. | |
4341 (concat (mail-strip-quoted-names | |
4342 (nntp-header-from header)) | |
4343 (make-string name-length ? ))) | |
4344 ;; 4 stands for length of `NNN:'. | |
4345 0 (+ 4 name-length)))) | |
4346 | |
4347 (defun gnus-optional-lines (header) | |
4348 "Return a string like `NNN' from HEADER." | |
4349 (format "%4d" (nntp-header-lines header))) | |
4350 | |
4351 (defun gnus-sort-headers (predicate &optional reverse) | |
4352 "Sort current group headers by PREDICATE safely. | |
4353 *Safely* means C-g quitting is disabled during sorting. | |
4354 Optional argument REVERSE means reverse order." | |
4355 (let ((inhibit-quit t)) | |
4356 (setq gnus-newsgroup-headers | |
4357 (if reverse | |
4358 (nreverse (sort (nreverse gnus-newsgroup-headers) predicate)) | |
4359 (sort gnus-newsgroup-headers predicate))) | |
4360 )) | |
4361 | |
4362 (defun gnus-string-lessp (a b) | |
4363 "Return T if first arg string is less than second in lexicographic order. | |
4364 If case-fold-search is non-nil, case of letters is ignored." | |
4365 (if case-fold-search | |
4366 (string-lessp (downcase a) (downcase b)) (string-lessp a b))) | |
4367 | |
4368 (defun gnus-date-lessp (date1 date2) | |
4369 "Return T if DATE1 is earlyer than DATE2." | |
4370 (string-lessp (gnus-comparable-date date1) | |
4371 (gnus-comparable-date date2))) | |
4372 | |
4373 (defun gnus-comparable-date (date) | |
4374 "Make comparable string by string-lessp from DATE." | |
4375 (let ((month '(("JAN" . " 1")("FEB" . " 2")("MAR" . " 3") | |
4376 ("APR" . " 4")("MAY" . " 5")("JUN" . " 6") | |
4377 ("JUL" . " 7")("AUG" . " 8")("SEP" . " 9") | |
4378 ("OCT" . "10")("NOV" . "11")("DEC" . "12"))) | |
4379 (date (or date ""))) | |
4380 ;; Can understand the following styles: | |
4381 ;; (1) 14 Apr 89 03:20:12 GMT | |
4382 ;; (2) Fri, 17 Mar 89 4:01:33 GMT | |
4383 (if (string-match | |
4384 "\\([0-9]+\\) \\([^ ,]+\\) \\([0-9]+\\) \\([0-9:]+\\)" date) | |
4385 (concat | |
4386 ;; Year | |
4387 (substring date (match-beginning 3) (match-end 3)) | |
4388 ;; Month | |
4389 (cdr | |
4390 (assoc | |
4391 (upcase (substring date (match-beginning 2) (match-end 2))) month)) | |
4392 ;; Day | |
4393 (format "%2d" (string-to-int | |
4394 (substring date | |
4395 (match-beginning 1) (match-end 1)))) | |
4396 ;; Time | |
4397 (substring date (match-beginning 4) (match-end 4))) | |
4398 ;; Cannot understand DATE string. | |
4399 date | |
4400 ) | |
4401 )) | |
4402 | |
4403 (defun gnus-fetch-field (field) | |
4404 "Return the value of the header FIELD of current article." | |
4405 (save-excursion | |
4406 (save-restriction | |
4407 (widen) | |
4408 (goto-char (point-min)) | |
4409 (narrow-to-region (point-min) | |
4410 (progn (search-forward "\n\n" nil 'move) (point))) | |
4411 (mail-fetch-field field)))) | |
4412 | |
4413 (fset 'gnus-expunge 'gnus-Subject-delete-marked-with) | |
4414 | |
4415 (defun gnus-kill (field regexp &optional command all) | |
4416 "If FIELD of an article matches REGEXP, execute COMMAND. | |
4417 Optional third argument COMMAND is default to | |
4418 (gnus-Subject-mark-as-read nil \"X\"). | |
4419 If optional fourth argument ALL is non-nil, articles marked are also applied | |
4420 to. If FIELD is an empty string (or nil), entire article body is searched for. | |
4421 COMMAND must be a lisp expression or a string representing a key sequence." | |
4422 ;; We don't want to change current point nor window configuration. | |
4423 (save-excursion | |
4424 (save-window-excursion | |
4425 ;; Selected window must be Subject mode buffer to execute | |
4426 ;; keyboard macros correctly. See command_loop_1. | |
4427 (switch-to-buffer gnus-Subject-buffer 'norecord) | |
4428 (goto-char (point-min)) ;From the beginning. | |
4429 (if (null command) | |
4430 (setq command '(gnus-Subject-mark-as-read nil "X"))) | |
4431 (gnus-execute field regexp command nil (not all)) | |
4432 ))) | |
4433 | |
4434 (defun gnus-execute (field regexp form &optional backward ignore-marked) | |
4435 "If FIELD of article header matches REGEXP, execute lisp FORM (or a string). | |
4436 If FIELD is an empty string (or nil), entire article body is searched for. | |
4437 If optional fifth argument BACKWARD is non-nil, do backward instead. | |
4438 If optional sixth argument IGNORE-MARKED is non-nil, articles which are | |
4439 marked as read or unread are ignored." | |
4440 (let ((function nil) | |
4441 (header nil) | |
4442 (article nil)) | |
4443 (if (string-equal field "") | |
4444 (setq field nil)) | |
4445 (if (null field) | |
4446 nil | |
4447 (or (stringp field) | |
4448 (setq field (symbol-name field))) | |
4449 ;; Get access function of header filed. | |
4450 (setq function (intern-soft (concat "gnus-header-" (downcase field)))) | |
4451 (if (and function (fboundp function)) | |
4452 (setq function (symbol-function function)) | |
4453 (error "Unknown header field: \"%s\"" field))) | |
4454 ;; Make FORM funcallable. | |
4455 (if (and (listp form) (not (eq (car form) 'lambda))) | |
4456 (setq form (list 'lambda nil form))) | |
4457 ;; Starting from the current article. | |
4458 (or (and ignore-marked | |
4459 ;; Articles marked as read and unread should be ignored. | |
4460 (setq article (gnus-Subject-article-number)) | |
4461 (or (not (memq article gnus-newsgroup-unreads)) ;Marked as read. | |
4462 (memq article gnus-newsgroup-marked) ;Marked as unread. | |
4463 )) | |
4464 (gnus-execute-1 function regexp form)) | |
4465 (while (gnus-Subject-search-subject backward ignore-marked nil) | |
4466 (gnus-execute-1 function regexp form)) | |
4467 )) | |
4468 | |
4469 (defun gnus-execute-1 (function regexp form) | |
4470 (save-excursion | |
4471 ;; The point of Subject mode buffer must be saved during execution. | |
4472 (let ((article (gnus-Subject-article-number))) | |
4473 (if (null article) | |
4474 nil ;Nothing to do. | |
4475 (if function | |
4476 ;; Compare with header field. | |
4477 (let ((header (gnus-find-header-by-number | |
4478 gnus-newsgroup-headers article)) | |
4479 (value nil)) | |
4480 (and header | |
4481 (progn | |
4482 (setq value (funcall function header)) | |
4483 ;; Number (Lines:) or symbol must be converted to string. | |
4484 (or (stringp value) | |
4485 (setq value (prin1-to-string value))) | |
4486 (string-match regexp value)) | |
4487 (if (stringp form) ;Keyboard macro. | |
4488 (execute-kbd-macro form) | |
4489 (funcall form)))) | |
4490 ;; Search article body. | |
4491 (let ((gnus-current-article nil) ;Save article pointer. | |
4492 (gnus-last-article nil) | |
4493 (gnus-break-pages nil) ;No need to break pages. | |
4494 (gnus-Mark-article-hook nil)) ;Inhibit marking as read. | |
4495 (message "Searching for article: %d..." article) | |
4496 (gnus-Article-setup-buffer) | |
4497 (gnus-Article-prepare article t) | |
4498 (if (save-excursion | |
4499 (set-buffer gnus-Article-buffer) | |
4500 (goto-char (point-min)) | |
4501 (re-search-forward regexp nil t)) | |
4502 (if (stringp form) ;Keyboard macro. | |
4503 (execute-kbd-macro form) | |
4504 (funcall form)))) | |
4505 )) | |
4506 ))) | |
4507 | |
4508 ;;; caesar-region written by phr@prep.ai.mit.edu Nov 86 | |
4509 ;;; modified by tower@prep Nov 86 | |
4510 ;;; Modified by umerin@flab.flab.Fujitsu.JUNET for ROT47. | |
4511 | |
4512 (defun gnus-caesar-region (&optional n) | |
4513 "Caesar rotation of region by N, default 13, for decrypting netnews. | |
4514 ROT47 will be performed for Japanese text in any case." | |
4515 (interactive (if current-prefix-arg ; Was there a prefix arg? | |
4516 (list (prefix-numeric-value current-prefix-arg)) | |
4517 (list nil))) | |
4518 (cond ((not (numberp n)) (setq n 13)) | |
4519 ((< n 0) (setq n (- 26 (% (- n) 26)))) | |
4520 (t (setq n (% n 26)))) ;canonicalize N | |
4521 (if (not (zerop n)) ; no action needed for a rot of 0 | |
4522 (progn | |
4523 (if (or (not (boundp 'caesar-translate-table)) | |
4524 (/= (aref caesar-translate-table ?a) (+ ?a n))) | |
4525 (let ((i 0) (lower "abcdefghijklmnopqrstuvwxyz") upper) | |
4526 (message "Building caesar-translate-table...") | |
4527 (setq caesar-translate-table (make-vector 256 0)) | |
4528 (while (< i 256) | |
4529 (aset caesar-translate-table i i) | |
4530 (setq i (1+ i))) | |
4531 (setq lower (concat lower lower) upper (upcase lower) i 0) | |
4532 (while (< i 26) | |
4533 (aset caesar-translate-table (+ ?a i) (aref lower (+ i n))) | |
4534 (aset caesar-translate-table (+ ?A i) (aref upper (+ i n))) | |
4535 (setq i (1+ i))) | |
4536 ;; ROT47 for Japanese text. | |
4537 ;; Thanks to ichikawa@flab.fujitsu.junet. | |
4538 (setq i 161) | |
4539 (let ((t1 (logior ?O 128)) | |
4540 (t2 (logior ?! 128)) | |
4541 (t3 (logior ?~ 128))) | |
4542 (while (< i 256) | |
4543 (aset caesar-translate-table i | |
4544 (let ((v (aref caesar-translate-table i))) | |
4545 (if (<= v t1) (if (< v t2) v (+ v 47)) | |
4546 (if (<= v t3) (- v 47) v)))) | |
4547 (setq i (1+ i)))) | |
4548 (message "Building caesar-translate-table... done"))) | |
4549 (let ((from (region-beginning)) | |
4550 (to (region-end)) | |
4551 (i 0) str len) | |
4552 (setq str (buffer-substring from to)) | |
4553 (setq len (length str)) | |
4554 (while (< i len) | |
4555 (aset str i (aref caesar-translate-table (aref str i))) | |
4556 (setq i (1+ i))) | |
4557 (goto-char from) | |
4558 (delete-region from to) | |
4559 (insert str))))) | |
4560 | |
4561 ;; Functions accessing headers. | |
4562 ;; Functions are more convenient than macros in some case. | |
4563 | |
4564 (defun gnus-header-number (header) | |
4565 "Return article number in HEADER." | |
4566 (nntp-header-number header)) | |
4567 | |
4568 (defun gnus-header-subject (header) | |
4569 "Return subject string in HEADER." | |
4570 (nntp-header-subject header)) | |
4571 | |
4572 (defun gnus-header-from (header) | |
4573 "Return author string in HEADER." | |
4574 (nntp-header-from header)) | |
4575 | |
4576 (defun gnus-header-xref (header) | |
4577 "Return xref string in HEADER." | |
4578 (nntp-header-xref header)) | |
4579 | |
4580 (defun gnus-header-lines (header) | |
4581 "Return lines in HEADER." | |
4582 (nntp-header-lines header)) | |
4583 | |
4584 (defun gnus-header-date (header) | |
4585 "Return date in HEADER." | |
4586 (nntp-header-date header)) | |
4587 | |
4588 (defun gnus-header-id (header) | |
4589 "Return Id in HEADER." | |
4590 (nntp-header-id header)) | |
4591 | |
4592 (defun gnus-header-references (header) | |
4593 "Return references in HEADER." | |
4594 (nntp-header-references header)) | |
4595 | |
4596 | |
4597 ;;; | |
4598 ;;; Article savers. | |
4599 ;;; | |
4600 | |
4601 (defun gnus-output-to-rmail (file-name) | |
4602 "Append the current article to an Rmail file named FILE-NAME." | |
4603 (require 'rmail) | |
4604 ;; Most of these codes are borrowed from rmailout.el. | |
4605 (setq file-name (expand-file-name file-name)) | |
4606 (setq rmail-last-rmail-file file-name) | |
4607 (let ((artbuf (current-buffer)) | |
4608 (tmpbuf (get-buffer-create " *GNUS-output*"))) | |
4609 (save-excursion | |
4610 (or (get-file-buffer file-name) | |
4611 (file-exists-p file-name) | |
4612 (if (yes-or-no-p | |
4613 (concat "\"" file-name "\" does not exist, create it? ")) | |
4614 (let ((file-buffer (create-file-buffer file-name))) | |
4615 (save-excursion | |
4616 (set-buffer file-buffer) | |
4617 (rmail-insert-rmail-file-header) | |
4618 (let ((require-final-newline nil)) | |
4619 (write-region (point-min) (point-max) file-name t 1))) | |
4620 (kill-buffer file-buffer)) | |
4621 (error "Output file does not exist"))) | |
4622 (set-buffer tmpbuf) | |
4623 (buffer-flush-undo (current-buffer)) | |
4624 (erase-buffer) | |
4625 (insert-buffer-substring artbuf) | |
4626 (gnus-convert-article-to-rmail) | |
4627 ;; Decide whether to append to a file or to an Emacs buffer. | |
4628 (let ((outbuf (get-file-buffer file-name))) | |
4629 (if (not outbuf) | |
4630 (append-to-file (point-min) (point-max) file-name) | |
4631 ;; File has been visited, in buffer OUTBUF. | |
4632 (set-buffer outbuf) | |
4633 (let ((buffer-read-only nil) | |
4634 (msg (and (boundp 'rmail-current-message) | |
4635 rmail-current-message))) | |
4636 ;; If MSG is non-nil, buffer is in RMAIL mode. | |
4637 (if msg | |
4638 (progn (widen) | |
4639 (narrow-to-region (point-max) (point-max)))) | |
4640 (insert-buffer-substring tmpbuf) | |
4641 (if msg | |
4642 (progn | |
4643 (goto-char (point-min)) | |
4644 (widen) | |
4645 (search-backward "\^_") | |
4646 (narrow-to-region (point) (point-max)) | |
4647 (goto-char (1+ (point-min))) | |
4648 (rmail-count-new-messages t) | |
4649 (rmail-show-message msg)))))) | |
4650 ) | |
4651 (kill-buffer tmpbuf) | |
4652 )) | |
4653 | |
4654 (defun gnus-output-to-file (file-name) | |
4655 "Append the current article to a file named FILE-NAME." | |
4656 (setq file-name (expand-file-name file-name)) | |
4657 (let ((artbuf (current-buffer)) | |
4658 (tmpbuf (get-buffer-create " *GNUS-output*"))) | |
4659 (save-excursion | |
4660 (set-buffer tmpbuf) | |
4661 (buffer-flush-undo (current-buffer)) | |
4662 (erase-buffer) | |
4663 (insert-buffer-substring artbuf) | |
4664 ;; Append newline at end of the buffer as separator, and then | |
4665 ;; save it to file. | |
4666 (goto-char (point-max)) | |
4667 (insert "\n") | |
4668 (append-to-file (point-min) (point-max) file-name)) | |
4669 (kill-buffer tmpbuf) | |
4670 )) | |
4671 | |
4672 (defun gnus-convert-article-to-rmail () | |
4673 "Convert article in current buffer to Rmail message format." | |
4674 (let ((buffer-read-only nil)) | |
4675 ;; Convert article directly into Babyl format. | |
4676 ;; Suggested by Rob Austein <sra@lcs.mit.edu> | |
4677 (goto-char (point-min)) | |
4678 (insert "\^L\n0, unseen,,\n*** EOOH ***\n") | |
4679 (while (search-forward "\n\^_" nil t) ;single char | |
4680 (replace-match "\n^_")) ;2 chars: "^" and "_" | |
4681 (goto-char (point-max)) | |
4682 (insert "\^_"))) | |
4683 | |
4684 ;;(defun gnus-convert-article-to-rmail () | |
4685 ;; "Convert article in current buffer to Rmail message format." | |
4686 ;; (let ((buffer-read-only nil)) | |
4687 ;; ;; Insert special header of Unix mail. | |
4688 ;; (goto-char (point-min)) | |
4689 ;; (insert "From " | |
4690 ;; (or (mail-strip-quoted-names (mail-fetch-field "from")) | |
4691 ;; "unknown") | |
4692 ;; " " (current-time-string) "\n") | |
4693 ;; ;; Stop quoting `From' since this seems unnecessary in most cases. | |
4694 ;; ;; ``Quote'' "\nFrom " as "\n>From " | |
4695 ;; ;;(while (search-forward "\nFrom " nil t) | |
4696 ;; ;; (forward-char -5) | |
4697 ;; ;; (insert ?>)) | |
4698 ;; ;; Convert article to babyl format. | |
4699 ;; (rmail-convert-to-babyl-format) | |
4700 ;; )) | |
4701 | |
4702 | |
4703 ;;; | |
4704 ;;; Internal functions. | |
4705 ;;; | |
4706 | |
4707 (defun gnus-start-news-server (&optional confirm) | |
4708 "Open network stream to remote NNTP server. | |
4709 If optional argument CONFIRM is non-nil, ask you host that NNTP server | |
4710 is running even if it is defined. | |
4711 Run gnus-Open-server-hook just before opening news server." | |
4712 (if (gnus-server-opened) | |
4713 ;; Stream is already opened. | |
4714 nil | |
4715 ;; Open NNTP server. | |
4716 (if (or confirm | |
4717 (null gnus-nntp-server)) | |
4718 (if (and (boundp 'gnus-secondary-servers) gnus-secondary-servers) | |
4719 ;; Read server name with completion. | |
4720 (setq gnus-nntp-server | |
4721 (completing-read "NNTP server: " | |
4722 (cons (list gnus-nntp-server) | |
4723 gnus-secondary-servers) | |
4724 nil nil gnus-nntp-server)) | |
4725 (setq gnus-nntp-server | |
4726 (read-string "NNTP server: " gnus-nntp-server)))) | |
4727 ;; If no server name is given, local host is assumed. | |
4728 (if (string-equal gnus-nntp-server "") | |
4729 (setq gnus-nntp-server (system-name))) | |
716
f11e7af7c0d9
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
711
diff
changeset
|
4730 (cond ((string= gnus-nntp-server) "::") |
f11e7af7c0d9
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
711
diff
changeset
|
4731 (require 'nnspool) |
f11e7af7c0d9
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
711
diff
changeset
|
4732 (gnus-define-access-method 'nnspool) |
f11e7af7c0d9
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
711
diff
changeset
|
4733 (message "Looking up local news spool...")) |
f11e7af7c0d9
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
711
diff
changeset
|
4734 ((string-match ":" gnus-nntp-server) |
257 | 4735 ;; :DIRECTORY |
4736 (require 'mhspool) | |
4737 (gnus-define-access-method 'mhspool) | |
4738 (message "Looking up private directory...")) | |
4739 (t | |
4740 (gnus-define-access-method 'nntp) | |
4741 (message "Connecting to NNTP server on %s..." gnus-nntp-server))) | |
4742 (run-hooks 'gnus-Open-server-hook) | |
4743 (cond ((gnus-open-server gnus-nntp-server gnus-nntp-service)) | |
4744 ((and (stringp (gnus-status-message)) | |
4745 (> (length (gnus-status-message)) 0)) | |
4746 ;; Show valuable message if available. | |
4747 (error (gnus-status-message))) | |
4748 (t (error "Cannot open NNTP server on %s" gnus-nntp-server))) | |
4749 )) | |
4750 | |
4751 ;; Dummy functions used only once. Should return nil. | |
4752 (defun gnus-server-opened () nil) | |
4753 (defun gnus-close-server () nil) | |
4754 | |
4755 (defun gnus-define-access-method (method &optional access-methods) | |
4756 "Define access functions for the access METHOD. | |
4757 Methods defintion is taken from optional argument ACCESS-METHODS or | |
4758 the variable gnus-access-methods." | |
4759 (let ((bindings | |
4760 (cdr (assoc method (or access-methods gnus-access-methods))))) | |
4761 (if (null bindings) | |
4762 (error "Unknown access method: %s" method) | |
4763 ;; Should not use symbol-function here since overload does not work. | |
4764 (while bindings | |
4765 (fset (car (car bindings)) (cdr (car bindings))) | |
4766 (setq bindings (cdr bindings))) | |
4767 ))) | |
4768 | |
4769 (defun gnus-select-newsgroup (group &optional show-all) | |
4770 "Select newsgroup GROUP. | |
4771 If optional argument SHOW-ALL is non-nil, all of articles in the group | |
4772 are selected." | |
4773 (if (gnus-request-group group) | |
4774 (let ((articles nil)) | |
4775 (setq gnus-newsgroup-name group) | |
4776 (setq gnus-newsgroup-unreads | |
4777 (gnus-uncompress-sequence | |
4778 (nthcdr 2 (gnus-gethash group gnus-unread-hashtb)))) | |
4779 (cond (show-all | |
4780 ;; Select all active articles. | |
4781 (setq articles | |
4782 (gnus-uncompress-sequence | |
4783 (nthcdr 2 (gnus-gethash group gnus-active-hashtb))))) | |
4784 (t | |
4785 ;; Select unread articles only. | |
4786 (setq articles gnus-newsgroup-unreads))) | |
4787 ;; Require confirmation if selecting large newsgroup. | |
4788 (setq gnus-newsgroup-unselected nil) | |
4789 (if (not (numberp gnus-large-newsgroup)) | |
4790 nil | |
4791 (let ((selected nil) | |
4792 (number (length articles))) | |
4793 (if (> number gnus-large-newsgroup) | |
4794 (progn | |
4795 (condition-case () | |
4796 (let ((input | |
4797 (read-string | |
4798 (format | |
4799 "How many articles from %s (default %d): " | |
4800 gnus-newsgroup-name number)))) | |
4801 (setq selected | |
4802 (if (string-equal input "") | |
4803 number (string-to-int input)))) | |
4804 (quit | |
4805 (setq selected 0))) | |
4806 (cond ((and (> selected 0) | |
4807 (< selected number)) | |
4808 ;; Select last N articles. | |
4809 (setq articles (nthcdr (- number selected) articles))) | |
4810 ((and (< selected 0) | |
4811 (< (- 0 selected) number)) | |
4812 ;; Select first N articles. | |
4813 (setq selected (- 0 selected)) | |
4814 (setq articles (copy-sequence articles)) | |
4815 (setcdr (nthcdr (1- selected) articles) nil)) | |
4816 ((zerop selected) | |
4817 (setq articles nil)) | |
4818 ;; Otherwise select all. | |
4819 ) | |
4820 ;; Get unselected unread articles. | |
4821 (setq gnus-newsgroup-unselected | |
4822 (gnus-set-difference gnus-newsgroup-unreads articles)) | |
4823 )) | |
4824 )) | |
4825 ;; Get headers list. | |
4826 (setq gnus-newsgroup-headers (gnus-retrieve-headers articles)) | |
4827 ;; UNREADS may contain expired articles, so we have to remove | |
4828 ;; them from the list. | |
4829 (setq gnus-newsgroup-unreads | |
4830 (gnus-intersection gnus-newsgroup-unreads | |
4831 (mapcar | |
4832 (function | |
4833 (lambda (header) | |
4834 (nntp-header-number header))) | |
4835 gnus-newsgroup-headers))) | |
4836 ;; Marked article must be a subset of unread articles. | |
4837 (setq gnus-newsgroup-marked | |
4838 (gnus-intersection (append gnus-newsgroup-unselected | |
4839 gnus-newsgroup-unreads) | |
4840 (cdr (assoc group gnus-marked-assoc)))) | |
4841 ;; First and last article in this newsgroup. | |
4842 (setq gnus-newsgroup-begin | |
4843 (if gnus-newsgroup-headers | |
4844 (nntp-header-number (car gnus-newsgroup-headers)) | |
4845 0 | |
4846 )) | |
4847 (setq gnus-newsgroup-end | |
4848 (if gnus-newsgroup-headers | |
4849 (nntp-header-number | |
4850 (gnus-last-element gnus-newsgroup-headers)) | |
4851 0 | |
4852 )) | |
4853 ;; File name that an article was saved last. | |
4854 (setq gnus-newsgroup-last-rmail nil) | |
4855 (setq gnus-newsgroup-last-mail nil) | |
4856 (setq gnus-newsgroup-last-folder nil) | |
4857 (setq gnus-newsgroup-last-file nil) | |
4858 ;; Reset article pointer etc. | |
4859 (setq gnus-current-article nil) | |
4860 (setq gnus-current-headers nil) | |
4861 (setq gnus-current-history nil) | |
4862 (setq gnus-have-all-headers nil) | |
4863 (setq gnus-last-article nil) | |
4864 ;; GROUP is successfully selected. | |
4865 t | |
4866 ) | |
4867 )) | |
4868 | |
4869 (defun gnus-more-header-backward () | |
4870 "Find new header backward." | |
4871 (let ((first | |
4872 (car (nth 2 (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))) | |
4873 (artnum gnus-newsgroup-begin) | |
4874 (header nil)) | |
4875 (while (and (not header) | |
4876 (> artnum first)) | |
4877 (setq artnum (1- artnum)) | |
4878 (setq header (car (gnus-retrieve-headers (list artnum))))) | |
4879 header | |
4880 )) | |
4881 | |
4882 (defun gnus-more-header-forward () | |
4883 "Find new header forward." | |
4884 (let ((last | |
4885 (cdr (nth 2 (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))) | |
4886 (artnum gnus-newsgroup-end) | |
4887 (header nil)) | |
4888 (while (and (not header) | |
4889 (< artnum last)) | |
4890 (setq artnum (1+ artnum)) | |
4891 (setq header (car (gnus-retrieve-headers (list artnum))))) | |
4892 header | |
4893 )) | |
4894 | |
4895 (defun gnus-extend-newsgroup (header &optional backward) | |
4896 "Extend newsgroup selection with HEADER. | |
4897 Optional argument BACKWARD means extend toward backward." | |
4898 (if header | |
4899 (let ((artnum (nntp-header-number header))) | |
4900 (setq gnus-newsgroup-headers | |
4901 (if backward | |
4902 (cons header gnus-newsgroup-headers) | |
4903 (append gnus-newsgroup-headers (list header)))) | |
4904 ;; We have to update unreads and unselected, but don't have to | |
4905 ;; care about gnus-newsgroup-marked. | |
4906 (if (memq artnum gnus-newsgroup-unselected) | |
4907 (setq gnus-newsgroup-unreads | |
4908 (cons artnum gnus-newsgroup-unreads))) | |
4909 (setq gnus-newsgroup-unselected | |
4910 (delq artnum gnus-newsgroup-unselected)) | |
4911 (setq gnus-newsgroup-begin (min gnus-newsgroup-begin artnum)) | |
4912 (setq gnus-newsgroup-end (max gnus-newsgroup-end artnum)) | |
4913 ))) | |
4914 | |
4915 (defun gnus-mark-article-as-read (article) | |
4916 "Remember that ARTICLE is marked as read." | |
4917 ;; Remove from unread and marked list. | |
4918 (setq gnus-newsgroup-unreads | |
4919 (delq article gnus-newsgroup-unreads)) | |
4920 (setq gnus-newsgroup-marked | |
4921 (delq article gnus-newsgroup-marked))) | |
4922 | |
4923 (defun gnus-mark-article-as-unread (article &optional clear-mark) | |
4924 "Remember that ARTICLE is marked as unread. | |
4925 Optional argument CLEAR-MARK means ARTICLE should not be remembered | |
4926 that it was marked as read once." | |
4927 ;; Add to unread list. | |
4928 (or (memq article gnus-newsgroup-unreads) | |
4929 (setq gnus-newsgroup-unreads | |
4930 (cons article gnus-newsgroup-unreads))) | |
4931 ;; If CLEAR-MARK is non-nil, the article must be removed from marked | |
4932 ;; list. Otherwise, it must be added to the list. | |
4933 (if clear-mark | |
4934 (setq gnus-newsgroup-marked | |
4935 (delq article gnus-newsgroup-marked)) | |
4936 (or (memq article gnus-newsgroup-marked) | |
4937 (setq gnus-newsgroup-marked | |
4938 (cons article gnus-newsgroup-marked))))) | |
4939 | |
4940 (defun gnus-clear-system () | |
4941 "Clear all variables and buffer." | |
4942 ;; Clear GNUS variables. | |
4943 (let ((variables gnus-variable-list)) | |
4944 (while variables | |
4945 (set (car variables) nil) | |
4946 (setq variables (cdr variables)))) | |
4947 ;; Clear other internal variables. | |
4948 (setq gnus-active-hashtb nil) | |
4949 (setq gnus-unread-hashtb nil) | |
4950 ;; Kill the startup file. | |
4951 (and gnus-current-startup-file | |
4952 (get-file-buffer gnus-current-startup-file) | |
4953 (kill-buffer (get-file-buffer gnus-current-startup-file))) | |
4954 (setq gnus-current-startup-file nil) | |
4955 ;; Kill GNUS buffers. | |
4956 (let ((buffers gnus-buffer-list)) | |
4957 (while buffers | |
4958 (if (get-buffer (car buffers)) | |
4959 (kill-buffer (car buffers))) | |
4960 (setq buffers (cdr buffers)) | |
4961 ))) | |
4962 | |
4963 (defun gnus-configure-windows (action) | |
4964 "Configure GNUS windows according to the next ACTION. | |
4965 The ACTION is either a symbol, such as `SelectNewsgroup', or a | |
4966 configuration list such as `(1 1 2)'. If ACTION is not a list, | |
4967 configuration list is got from the variable gnus-window-configuration." | |
4968 (let* ((windows | |
4969 (if (listp action) | |
4970 action (car (cdr (assq action gnus-window-configuration))))) | |
4971 (grpwin (get-buffer-window gnus-Group-buffer)) | |
4972 (subwin (get-buffer-window gnus-Subject-buffer)) | |
4973 (artwin (get-buffer-window gnus-Article-buffer)) | |
4974 (winsum nil) | |
4975 (height nil) | |
4976 (grpheight 0) | |
4977 (subheight 0) | |
4978 (artheight 0)) | |
4979 (if (or (null windows) ;No configuration is specified. | |
4980 (and (eq (null grpwin) | |
4981 (zerop (nth 0 windows))) | |
4982 (eq (null subwin) | |
4983 (zerop (nth 1 windows))) | |
4984 (eq (null artwin) | |
4985 (zerop (nth 2 windows))))) | |
4986 ;; No need to change window configuration. | |
4987 nil | |
4988 (select-window (or grpwin subwin artwin (selected-window))) | |
4989 ;; First of all, compute the height of each window. | |
4990 (cond (gnus-use-full-window | |
4991 ;; Take up the entire screen. | |
4992 (delete-other-windows) | |
4993 (setq height (window-height (selected-window)))) | |
4994 (t | |
4995 (setq height (+ (if grpwin (window-height grpwin) 0) | |
4996 (if subwin (window-height subwin) 0) | |
4997 (if artwin (window-height artwin) 0))))) | |
4998 ;; The Newsgroup buffer exits always. So, use it to extend the | |
4999 ;; Group window so as to get enough window space. | |
5000 (switch-to-buffer gnus-Group-buffer 'norecord) | |
5001 (and (get-buffer gnus-Subject-buffer) | |
5002 (delete-windows-on gnus-Subject-buffer)) | |
5003 (and (get-buffer gnus-Article-buffer) | |
5004 (delete-windows-on gnus-Article-buffer)) | |
5005 ;; Compute expected window height. | |
5006 (setq winsum (apply (function +) windows)) | |
5007 (if (not (zerop (nth 0 windows))) | |
5008 (setq grpheight (max window-min-height | |
5009 (/ (* height (nth 0 windows)) winsum)))) | |
5010 (if (not (zerop (nth 1 windows))) | |
5011 (setq subheight (max window-min-height | |
5012 (/ (* height (nth 1 windows)) winsum)))) | |
5013 (if (not (zerop (nth 2 windows))) | |
5014 (setq artheight (max window-min-height | |
5015 (/ (* height (nth 2 windows)) winsum)))) | |
5016 (setq height (+ grpheight subheight artheight)) | |
5017 (enlarge-window (max 0 (- height (window-height (selected-window))))) | |
5018 ;; Then split the window. | |
5019 (and (not (zerop artheight)) | |
5020 (or (not (zerop grpheight)) | |
5021 (not (zerop subheight))) | |
5022 (split-window-vertically (+ grpheight subheight))) | |
5023 (and (not (zerop grpheight)) | |
5024 (not (zerop subheight)) | |
5025 (split-window-vertically grpheight)) | |
5026 ;; Then select buffers in each window. | |
5027 (and (not (zerop grpheight)) | |
5028 (progn | |
5029 (switch-to-buffer gnus-Group-buffer 'norecord) | |
5030 (other-window 1))) | |
5031 (and (not (zerop subheight)) | |
5032 (progn | |
5033 (switch-to-buffer gnus-Subject-buffer 'norecord) | |
5034 (other-window 1))) | |
5035 (and (not (zerop artheight)) | |
5036 (progn | |
5037 ;; If Article buffer does not exist, it will be created | |
5038 ;; and initialized. | |
5039 (gnus-Article-setup-buffer) | |
5040 (switch-to-buffer gnus-Article-buffer 'norecord))) | |
5041 ) | |
5042 )) | |
5043 | |
5044 (defun gnus-find-header-by-number (headers number) | |
5045 "Return a header which is a element of HEADERS and has NUMBER." | |
5046 (let ((found nil)) | |
5047 (while (and headers (not found)) | |
5048 ;; We cannot use `=' to accept non-numeric NUMBER. | |
5049 (if (eq number (nntp-header-number (car headers))) | |
5050 (setq found (car headers))) | |
5051 (setq headers (cdr headers))) | |
5052 found | |
5053 )) | |
5054 | |
5055 (defun gnus-find-header-by-id (headers id) | |
5056 "Return a header which is a element of HEADERS and has Message-ID." | |
5057 (let ((found nil)) | |
5058 (while (and headers (not found)) | |
5059 (if (string-equal id (nntp-header-id (car headers))) | |
5060 (setq found (car headers))) | |
5061 (setq headers (cdr headers))) | |
5062 found | |
5063 )) | |
5064 | |
5065 (defun gnus-version () | |
5066 "Version numbers of this version of GNUS." | |
5067 (interactive) | |
5068 (cond ((and (boundp 'mhspool-version) (boundp 'nnspool-version)) | |
5069 (message "%s; %s; %s; %s" | |
5070 gnus-version nntp-version nnspool-version mhspool-version)) | |
5071 ((boundp 'mhspool-version) | |
5072 (message "%s; %s; %s" | |
5073 gnus-version nntp-version mhspool-version)) | |
5074 ((boundp 'nnspool-version) | |
5075 (message "%s; %s; %s" | |
5076 gnus-version nntp-version nnspool-version)) | |
5077 (t | |
5078 (message "%s; %s" gnus-version nntp-version)))) | |
5079 | |
5080 (defun gnus-Info-find-node () | |
5081 "Find Info documentation of GNUS." | |
5082 (interactive) | |
5083 (require 'info) | |
5084 ;; Enlarge info window if needed. | |
5085 (cond ((eq major-mode 'gnus-Group-mode) | |
5086 (gnus-configure-windows '(1 0 0)) ;Take all windows. | |
5087 (pop-to-buffer gnus-Group-buffer)) | |
5088 ((eq major-mode 'gnus-Subject-mode) | |
5089 (gnus-configure-windows '(0 1 0)) ;Take all windows. | |
5090 (pop-to-buffer gnus-Subject-buffer))) | |
5091 (Info-goto-node (cdr (assq major-mode gnus-Info-nodes)))) | |
5092 | |
5093 (defun gnus-overload-functions (&optional overloads) | |
5094 "Overload functions specified by optional argument OVERLOADS. | |
5095 If nothing is specified, use the variable gnus-overload-functions." | |
5096 (let ((defs nil) | |
5097 (overloads (or overloads gnus-overload-functions))) | |
5098 (while overloads | |
5099 (setq defs (car overloads)) | |
5100 (setq overloads (cdr overloads)) | |
5101 ;; Load file before overloading function if necessary. Make | |
5102 ;; sure we cannot use `requre' always. | |
5103 (and (not (fboundp (car defs))) | |
5104 (car (cdr (cdr defs))) | |
5105 (load (car (cdr (cdr defs))) nil 'nomessage)) | |
5106 (fset (car defs) (car (cdr defs))) | |
5107 ))) | |
5108 | |
5109 (defun gnus-make-threads (newsgroup-headers) | |
5110 "Make conversation threads tree from NEWSGROUP-HEADERS." | |
5111 (let ((headers newsgroup-headers) | |
5112 (h nil) | |
5113 (d nil) | |
5114 (roots nil) | |
5115 (dependencies nil)) | |
5116 ;; Make message dependency alist. | |
5117 (while headers | |
5118 (setq h (car headers)) | |
5119 (setq headers (cdr headers)) | |
5120 ;; Ignore invalid headers. | |
5121 (if (vectorp h) ;Depends on nntp.el. | |
5122 (progn | |
5123 ;; Ignore broken references, e.g "<123@a.b.c". | |
5124 (setq d (and (nntp-header-references h) | |
5125 (string-match "\\(<[^<>]+>\\)[^>]*$" | |
5126 (nntp-header-references h)) | |
5127 (gnus-find-header-by-id | |
5128 newsgroup-headers | |
5129 (substring (nntp-header-references h) | |
5130 (match-beginning 1) (match-end 1))))) | |
5131 ;; Check subject equality. | |
5132 (or gnus-thread-ignore-subject | |
5133 (null d) | |
5134 (string-equal (gnus-simplify-subject | |
5135 (nntp-header-subject h) 're) | |
5136 (gnus-simplify-subject | |
5137 (nntp-header-subject d) 're)) | |
5138 ;; H should be a thread root. | |
5139 (setq d nil)) | |
5140 ;; H depends on D. | |
5141 (setq dependencies | |
5142 (cons (cons h d) dependencies)) | |
5143 ;; H is a thread root. | |
5144 (if (null d) | |
5145 (setq roots (cons h roots))) | |
5146 )) | |
5147 ) | |
5148 ;; Make complete threads from the roots. | |
5149 ;; Note: dependencies are in reverse order, but | |
5150 ;; gnus-make-threads-1 processes it in reverse order again. So, | |
5151 ;; we don't have to worry about it. | |
5152 (mapcar | |
5153 (function | |
5154 (lambda (root) | |
5155 (gnus-make-threads-1 root dependencies))) (nreverse roots)) | |
5156 )) | |
5157 | |
5158 (defun gnus-make-threads-1 (parent dependencies) | |
5159 (let ((children nil) | |
5160 (d nil) | |
5161 (depends dependencies)) | |
5162 ;; Find children. | |
5163 (while depends | |
5164 (setq d (car depends)) | |
5165 (setq depends (cdr depends)) | |
5166 (and (cdr d) | |
5167 (eq (nntp-header-id parent) (nntp-header-id (cdr d))) | |
5168 (setq children (cons (car d) children)))) | |
5169 ;; Go down. | |
5170 (cons parent | |
5171 (mapcar | |
5172 (function | |
5173 (lambda (child) | |
5174 (gnus-make-threads-1 child dependencies))) children)) | |
5175 )) | |
5176 | |
5177 (defun gnus-narrow-to-page (&optional arg) | |
5178 "Make text outside current page invisible except for page delimiter. | |
5179 A numeric arg specifies to move forward or backward by that many pages, | |
5180 thus showing a page other than the one point was originally in." | |
5181 (interactive "P") | |
5182 (setq arg (if arg (prefix-numeric-value arg) 0)) | |
5183 (save-excursion | |
5184 (forward-page -1) ;Beginning of current page. | |
5185 (widen) | |
5186 (if (> arg 0) | |
5187 (forward-page arg) | |
5188 (if (< arg 0) | |
5189 (forward-page (1- arg)))) | |
5190 ;; Find the end of the page. | |
5191 (forward-page) | |
5192 ;; If we stopped due to end of buffer, stay there. | |
5193 ;; If we stopped after a page delimiter, put end of restriction | |
5194 ;; at the beginning of that line. | |
5195 ;; These are commented out. | |
5196 ;; (if (save-excursion (beginning-of-line) | |
5197 ;; (looking-at page-delimiter)) | |
5198 ;; (beginning-of-line)) | |
5199 (narrow-to-region (point) | |
5200 (progn | |
5201 ;; Find the top of the page. | |
5202 (forward-page -1) | |
5203 ;; If we found beginning of buffer, stay there. | |
5204 ;; If extra text follows page delimiter on same line, | |
5205 ;; include it. | |
5206 ;; Otherwise, show text starting with following line. | |
5207 (if (and (eolp) (not (bobp))) | |
5208 (forward-line 1)) | |
5209 (point))) | |
5210 )) | |
5211 | |
5212 (defun gnus-last-element (list) | |
5213 "Return last element of LIST." | |
5214 (let ((last nil)) | |
5215 (while list | |
5216 (if (null (cdr list)) | |
5217 (setq last (car list))) | |
5218 (setq list (cdr list))) | |
5219 last | |
5220 )) | |
5221 | |
5222 (defun gnus-set-difference (list1 list2) | |
5223 "Return a list of elements of LIST1 that do not appear in LIST2." | |
5224 (let ((list1 (copy-sequence list1))) | |
5225 (while list2 | |
5226 (setq list1 (delq (car list2) list1)) | |
5227 (setq list2 (cdr list2))) | |
5228 list1 | |
5229 )) | |
5230 | |
5231 (defun gnus-intersection (list1 list2) | |
5232 "Return a list of elements that appear in both LIST1 and LIST2." | |
5233 (let ((result nil)) | |
5234 (while list2 | |
5235 (if (memq (car list2) list1) | |
5236 (setq result (cons (car list2) result))) | |
5237 (setq list2 (cdr list2))) | |
5238 result | |
5239 )) | |
5240 | |
5241 | |
5242 ;;; | |
5243 ;;; Get information about active articles, already read articles, and | |
5244 ;;; still unread articles. | |
5245 ;;; | |
5246 | |
5247 ;; GNUS internal format of gnus-newsrc-assoc and gnus-killed-assoc: | |
5248 ;; (("general" t (1 . 1)) | |
5249 ;; ("misc" t (1 . 10) (12 . 15)) | |
5250 ;; ("test" nil (1 . 99)) ...) | |
5251 ;; GNUS internal format of gnus-marked-assoc: | |
5252 ;; (("general" 1 2 3) | |
5253 ;; ("misc" 2) ...) | |
5254 ;; GNUS internal format of gnus-active-hashtb: | |
5255 ;; (("general" t (1 . 1)) | |
5256 ;; ("misc" t (1 . 10)) | |
5257 ;; ("test" nil (1 . 99)) ...) | |
5258 ;; GNUS internal format of gnus-unread-hashtb: | |
5259 ;; (("general" 1 (1 . 1)) | |
5260 ;; ("misc" 14 (1 . 10) (12 . 15)) | |
5261 ;; ("test" 99 (1 . 99)) ...) | |
5262 | |
5263 (defun gnus-setup-news-info (&optional rawfile) | |
5264 "Setup news information. | |
5265 If optional argument RAWFILE is non-nil, force to read raw startup file." | |
5266 (let ((init (not (and gnus-newsrc-assoc | |
5267 gnus-active-hashtb | |
5268 gnus-unread-hashtb | |
5269 (not rawfile) | |
5270 )))) | |
5271 ;; We have to clear some variables to re-initialize news info. | |
5272 (if init | |
5273 (setq gnus-newsrc-assoc nil | |
5274 gnus-active-hashtb nil | |
5275 gnus-unread-hashtb nil)) | |
5276 (if init | |
5277 (gnus-read-newsrc-file rawfile)) | |
5278 (gnus-read-active-file) | |
5279 (gnus-expire-marked-articles) | |
5280 (gnus-get-unread-articles) | |
5281 ;; Check new newsgroups and subscribe them. | |
5282 (if init | |
5283 (let ((new-newsgroups (gnus-find-new-newsgroups))) | |
5284 (while new-newsgroups | |
5285 (funcall gnus-subscribe-newsgroup-method (car new-newsgroups)) | |
5286 (setq new-newsgroups (cdr new-newsgroups)) | |
5287 ))) | |
5288 )) | |
5289 | |
5290 (defun gnus-subscribe-newsgroup (newsgroup &optional next) | |
5291 "Subscribe new NEWSGROUP. | |
5292 If optional argument NEXT is non-nil, it is inserted before NEXT." | |
5293 (gnus-insert-newsgroup (list newsgroup t) next) | |
5294 (message "Newsgroup %s is subscribed" newsgroup)) | |
5295 | |
5296 (defun gnus-add-newsgroup (newsgroup) | |
5297 "Subscribe new NEWSGROUP safely and put it at top." | |
5298 (and (null (assoc newsgroup gnus-newsrc-assoc)) ;Really new? | |
5299 (gnus-gethash newsgroup gnus-active-hashtb) ;Really exist? | |
5300 (gnus-insert-newsgroup (or (assoc newsgroup gnus-killed-assoc) | |
5301 (list newsgroup t)) | |
5302 (car (car gnus-newsrc-assoc))))) | |
5303 | |
5304 (defun gnus-find-new-newsgroups () | |
5305 "Looking for new newsgroups and return names. | |
5306 `-n' option of options line in .newsrc file is recognized." | |
5307 (let ((group nil) | |
5308 (new-newsgroups nil)) | |
5309 (mapatoms | |
5310 (function | |
5311 (lambda (sym) | |
5312 (setq group (symbol-name sym)) | |
5313 ;; Taking account of `-n' option. | |
5314 (and (or (null gnus-newsrc-options-n-no) | |
5315 (not (string-match gnus-newsrc-options-n-no group)) | |
5316 (and gnus-newsrc-options-n-yes | |
5317 (string-match gnus-newsrc-options-n-yes group))) | |
5318 (null (assoc group gnus-killed-assoc)) ;Ignore killed. | |
5319 (null (assoc group gnus-newsrc-assoc)) ;Really new. | |
5320 ;; Find new newsgroup. | |
5321 (setq new-newsgroups | |
5322 (cons group new-newsgroups))) | |
5323 )) | |
5324 gnus-active-hashtb) | |
5325 ;; Return new newsgroups. | |
5326 new-newsgroups | |
5327 )) | |
5328 | |
5329 (defun gnus-kill-newsgroup (group) | |
5330 "Kill GROUP from gnus-newsrc-assoc, .newsrc and gnus-unread-hashtb." | |
5331 (let ((info (assoc group gnus-newsrc-assoc))) | |
5332 (if (null info) | |
5333 nil | |
5334 ;; Delete from gnus-newsrc-assoc | |
5335 (setq gnus-newsrc-assoc (delq info gnus-newsrc-assoc)) | |
5336 ;; Add to gnus-killed-assoc. | |
5337 (setq gnus-killed-assoc | |
5338 (cons info | |
5339 (delq (assoc group gnus-killed-assoc) gnus-killed-assoc))) | |
5340 ;; Clear unread hashtable. | |
5341 ;; Thanks cwitty@csli.Stanford.EDU (Carl Witty). | |
5342 (gnus-sethash group nil gnus-unread-hashtb) | |
5343 ;; Then delete from .newsrc | |
5344 (gnus-update-newsrc-buffer group 'delete) | |
5345 ;; Return the deleted newsrc entry. | |
5346 info | |
5347 ))) | |
5348 | |
5349 (defun gnus-insert-newsgroup (info &optional next) | |
5350 "Insert newsrc INFO entry before NEXT. | |
5351 If optional argument NEXT is nil, appended to the last." | |
5352 (if (null info) | |
5353 (error "Invalid argument: %s" info)) | |
5354 (let* ((group (car info)) ;Newsgroup name. | |
5355 (range | |
5356 (gnus-difference-of-range | |
5357 (nth 2 (gnus-gethash group gnus-active-hashtb)) (nthcdr 2 info)))) | |
5358 ;; Check duplication. | |
5359 (if (assoc group gnus-newsrc-assoc) | |
5360 (error "Duplicated: %s" group)) | |
5361 ;; Insert to gnus-newsrc-assoc. | |
5362 (if (string-equal next (car (car gnus-newsrc-assoc))) | |
5363 (setq gnus-newsrc-assoc | |
5364 (cons info gnus-newsrc-assoc)) | |
5365 (let ((found nil) | |
5366 (rest gnus-newsrc-assoc) | |
5367 (tail (cons nil gnus-newsrc-assoc))) | |
5368 ;; Seach insertion point. | |
5369 (while (and (not found) rest) | |
5370 (if (string-equal next (car (car rest))) | |
5371 (setq found t) | |
5372 (setq rest (cdr rest)) | |
5373 (setq tail (cdr tail)) | |
5374 )) | |
5375 ;; Find it. | |
5376 (setcdr tail nil) | |
5377 (setq gnus-newsrc-assoc | |
5378 (append gnus-newsrc-assoc (cons info rest))) | |
5379 )) | |
5380 ;; Delete from gnus-killed-assoc. | |
5381 (setq gnus-killed-assoc | |
5382 (delq (assoc group gnus-killed-assoc) gnus-killed-assoc)) | |
5383 ;; Then insert to .newsrc. | |
5384 (gnus-update-newsrc-buffer group nil next) | |
5385 ;; Add to gnus-unread-hashtb. | |
5386 (gnus-sethash group | |
5387 (cons group ;Newsgroup name. | |
5388 (cons (gnus-number-of-articles range) range)) | |
5389 gnus-unread-hashtb) | |
5390 )) | |
5391 | |
5392 (defun gnus-check-killed-newsgroups () | |
5393 "Check consistency between gnus-newsrc-assoc and gnus-killed-assoc." | |
5394 (let ((group nil) | |
5395 (new-killed nil) | |
5396 (old-killed gnus-killed-assoc)) | |
5397 (while old-killed | |
5398 (setq group (car (car old-killed))) | |
5399 (and (or (null gnus-newsrc-options-n-no) | |
5400 (not (string-match gnus-newsrc-options-n-no group)) | |
5401 (and gnus-newsrc-options-n-yes | |
5402 (string-match gnus-newsrc-options-n-yes group))) | |
5403 (null (assoc group gnus-newsrc-assoc)) ;No duplication. | |
5404 ;; Subscribed in options line and not in gnus-newsrc-assoc. | |
5405 (setq new-killed | |
5406 (cons (car old-killed) new-killed))) | |
5407 (setq old-killed (cdr old-killed)) | |
5408 ) | |
5409 (setq gnus-killed-assoc (nreverse new-killed)) | |
5410 )) | |
5411 | |
5412 (defun gnus-check-bogus-newsgroups (&optional confirm) | |
5413 "Delete bogus newsgroups. | |
5414 If optional argument CONFIRM is non-nil, confirm deletion of newsgroups." | |
5415 (let ((group nil) ;Newsgroup name temporary used. | |
5416 (old-newsrc gnus-newsrc-assoc) | |
5417 (new-newsrc nil) | |
5418 (bogus nil) ;List of bogus newsgroups. | |
5419 (old-killed gnus-killed-assoc) | |
5420 (new-killed nil) | |
5421 (old-marked gnus-marked-assoc) | |
5422 (new-marked nil)) | |
5423 (message "Checking bogus newsgroups...") | |
5424 ;; Update gnus-newsrc-assoc. | |
5425 (while old-newsrc | |
5426 (setq group (car (car old-newsrc))) | |
5427 (if (or (gnus-gethash group gnus-active-hashtb) | |
5428 (and confirm | |
5429 (not (y-or-n-p | |
5430 (format "Delete bogus newsgroup: %s " group))))) | |
5431 ;; Active newsgroup. | |
5432 (setq new-newsrc (cons (car old-newsrc) new-newsrc)) | |
5433 ;; Found a bogus newsgroup. | |
5434 (setq bogus (cons group bogus))) | |
5435 (setq old-newsrc (cdr old-newsrc)) | |
5436 ) | |
5437 (setq gnus-newsrc-assoc (nreverse new-newsrc)) | |
5438 ;; Update gnus-killed-assoc. | |
5439 ;; The killed newsgroups are deleted without any confirmations. | |
5440 (while old-killed | |
5441 (setq group (car (car old-killed))) | |
5442 (and (gnus-gethash group gnus-active-hashtb) | |
5443 (null (assoc group gnus-newsrc-assoc)) | |
5444 ;; Active and really killed newsgroup. | |
5445 (setq new-killed (cons (car old-killed) new-killed))) | |
5446 (setq old-killed (cdr old-killed)) | |
5447 ) | |
5448 (setq gnus-killed-assoc (nreverse new-killed)) | |
5449 ;; Remove BOGUS from .newsrc file. | |
5450 (while bogus | |
5451 (gnus-update-newsrc-buffer (car bogus) 'delete) | |
5452 (setq bogus (cdr bogus))) | |
5453 ;; Update gnus-marked-assoc. | |
5454 (while old-marked | |
5455 (setq group (car (car old-marked))) | |
5456 (if (and (cdr (car old-marked)) ;Non-empty? | |
5457 (assoc group gnus-newsrc-assoc)) ;Not bogus? | |
5458 (setq new-marked (cons (car old-marked) new-marked))) | |
5459 (setq old-marked (cdr old-marked))) | |
5460 (setq gnus-marked-assoc new-marked) | |
5461 (message "Checking bogus newsgroups... done") | |
5462 )) | |
5463 | |
5464 (defun gnus-get-unread-articles () | |
5465 "Compute diffs between active and read articles." | |
5466 (let ((read gnus-newsrc-assoc) | |
5467 (group-info nil) | |
5468 (group-name nil) | |
5469 (active nil) | |
5470 (range nil)) | |
5471 (message "Checking new news...") | |
5472 (or gnus-unread-hashtb | |
5473 (setq gnus-unread-hashtb (gnus-make-hashtable))) | |
5474 (while read | |
5475 (setq group-info (car read)) ;About one newsgroup | |
5476 (setq group-name (car group-info)) | |
5477 (setq active (nth 2 (gnus-gethash group-name gnus-active-hashtb))) | |
5478 (if (and gnus-octive-hashtb | |
5479 ;; Is nothing changed? | |
5480 (equal active | |
5481 (nth 2 (gnus-gethash group-name gnus-octive-hashtb))) | |
5482 ;; Is this newsgroup in the unread hash table? | |
5483 (gnus-gethash group-name gnus-unread-hashtb) | |
5484 ) | |
5485 nil ;Nothing to do. | |
5486 (setq range (gnus-difference-of-range active (nthcdr 2 group-info))) | |
5487 (gnus-sethash group-name | |
5488 (cons group-name ;Group name | |
5489 (cons (gnus-number-of-articles range) | |
5490 range)) ;Range of unread articles | |
5491 gnus-unread-hashtb) | |
5492 ) | |
5493 (setq read (cdr read)) | |
5494 ) | |
5495 (message "Checking new news... done") | |
5496 )) | |
5497 | |
5498 (defun gnus-expire-marked-articles () | |
5499 "Check expired article which is marked as unread." | |
5500 (let ((marked-assoc gnus-marked-assoc) | |
5501 (updated-assoc nil) | |
5502 (marked nil) ;Current marked info. | |
5503 (articles nil) ;List of marked articles. | |
5504 (updated nil) ;List of real marked. | |
5505 (begin nil)) | |
5506 (while marked-assoc | |
5507 (setq marked (car marked-assoc)) | |
5508 (setq articles (cdr marked)) | |
5509 (setq updated nil) | |
5510 (setq begin | |
5511 (car (nth 2 (gnus-gethash (car marked) gnus-active-hashtb)))) | |
5512 (while (and begin articles) | |
5513 (if (>= (car articles) begin) | |
5514 ;; This article is still active. | |
5515 (setq updated (cons (car articles) updated))) | |
5516 (setq articles (cdr articles))) | |
5517 (if updated | |
5518 (setq updated-assoc | |
5519 (cons (cons (car marked) updated) updated-assoc))) | |
5520 (setq marked-assoc (cdr marked-assoc))) | |
5521 (setq gnus-marked-assoc updated-assoc) | |
5522 )) | |
5523 | |
5524 (defun gnus-mark-as-read-by-xref | |
5525 (group headers unreads &optional subscribed-only) | |
5526 "Mark articles as read using cross references and return updated newsgroups. | |
5527 Arguments are GROUP, HEADERS, UNREADS, and optional SUBSCRIBED-ONLY." | |
5528 (let ((xref-list nil) | |
5529 (header nil) | |
5530 (xrefs nil) ;One Xref: field info. | |
5531 (xref nil) ;(NEWSGROUP . ARTICLE) | |
5532 (gname nil) ;Newsgroup name | |
5533 (article nil)) ;Article number | |
5534 (while headers | |
5535 (setq header (car headers)) | |
5536 (if (memq (nntp-header-number header) unreads) | |
5537 ;; This article is not yet marked as read. | |
5538 nil | |
5539 (setq xrefs (gnus-parse-xref-field (nntp-header-xref header))) | |
5540 ;; For each cross reference info. in one Xref: field. | |
5541 (while xrefs | |
5542 (setq xref (car xrefs)) | |
5543 (setq gname (car xref)) ;Newsgroup name | |
5544 (setq article (cdr xref)) ;Article number | |
5545 (or (string-equal group gname) ;Ignore current newsgroup. | |
5546 ;; Ignore unsubscribed newsgroup if requested. | |
5547 (and subscribed-only | |
5548 (not (nth 1 (assoc gname gnus-newsrc-assoc)))) | |
5549 ;; Ignore article marked as unread. | |
5550 (memq article (cdr (assoc gname gnus-marked-assoc))) | |
5551 (let ((group-xref (assoc gname xref-list))) | |
5552 (if group-xref | |
5553 (if (memq article (cdr group-xref)) | |
5554 nil ;Alread marked. | |
5555 (setcdr group-xref (cons article (cdr group-xref)))) | |
5556 ;; Create new assoc entry for GROUP. | |
5557 (setq xref-list (cons (list gname article) xref-list))) | |
5558 )) | |
5559 (setq xrefs (cdr xrefs)) | |
5560 )) | |
5561 (setq headers (cdr headers))) | |
5562 ;; Mark cross referenced articles as read. | |
5563 (gnus-mark-xrefed-as-read xref-list) | |
5564 ;;(message "%s %s" (prin1-to-string unreads) (prin1-to-string xref-list)) | |
5565 ;; Return list of updated group name. | |
5566 (mapcar (function car) xref-list) | |
5567 )) | |
5568 | |
5569 (defun gnus-parse-xref-field (xref-value) | |
5570 "Parse Xref: field value, and return list of `(group . article-id)'." | |
5571 (let ((xref-list nil) | |
5572 (xref-value (or xref-value ""))) | |
5573 ;; Remove server host name. | |
5574 (if (string-match "^[ \t]*[^ \t,]+[ \t,]+\\(.*\\)$" xref-value) | |
5575 (setq xref-value (substring xref-value (match-beginning 1))) | |
5576 (setq xref-value nil)) | |
5577 ;; Process each xref info. | |
5578 (while xref-value | |
5579 (if (string-match | |
5580 "^[ \t,]*\\([^ \t,]+\\):\\([0-9]+\\)[^0-9]*" xref-value) | |
5581 (progn | |
5582 (setq xref-list | |
5583 (cons | |
5584 (cons | |
5585 ;; Group name | |
5586 (substring xref-value (match-beginning 1) (match-end 1)) | |
5587 ;; Article-ID | |
5588 (string-to-int | |
5589 (substring xref-value (match-beginning 2) (match-end 2)))) | |
5590 xref-list)) | |
5591 (setq xref-value (substring xref-value (match-end 2)))) | |
5592 (setq xref-value nil))) | |
5593 ;; Return alist. | |
5594 xref-list | |
5595 )) | |
5596 | |
5597 (defun gnus-mark-xrefed-as-read (xrefs) | |
5598 "Update unread article information using XREFS alist." | |
5599 (let ((group nil) | |
5600 (idlist nil) | |
5601 (unread nil)) | |
5602 (while xrefs | |
5603 (setq group (car (car xrefs))) | |
5604 (setq idlist (cdr (car xrefs))) | |
5605 (setq unread (gnus-uncompress-sequence | |
5606 (nthcdr 2 (gnus-gethash group gnus-unread-hashtb)))) | |
5607 (while idlist | |
5608 (setq unread (delq (car idlist) unread)) | |
5609 (setq idlist (cdr idlist))) | |
5610 (gnus-update-unread-articles group unread 'ignore) | |
5611 (setq xrefs (cdr xrefs)) | |
5612 ))) | |
5613 | |
5614 (defun gnus-update-unread-articles (group unread-list marked-list) | |
5615 "Update unread articles of GROUP using UNREAD-LIST and MARKED-LIST." | |
5616 (let ((active (nth 2 (gnus-gethash group gnus-active-hashtb))) | |
5617 (unread (gnus-gethash group gnus-unread-hashtb))) | |
5618 (if (or (null active) (null unread)) | |
5619 ;; Ignore unknown newsgroup. | |
5620 nil | |
5621 ;; Update gnus-unread-hashtb. | |
5622 (if unread-list | |
5623 (setcdr (cdr unread) | |
5624 (gnus-compress-sequence unread-list)) | |
5625 ;; All of the articles are read. | |
5626 (setcdr (cdr unread) '((0 . 0)))) | |
5627 ;; Number of unread articles. | |
5628 (setcar (cdr unread) | |
5629 (gnus-number-of-articles (nthcdr 2 unread))) | |
5630 ;; Update gnus-newsrc-assoc. | |
5631 (if (> (car active) 0) | |
5632 ;; Articles from 1 to N are not active. | |
5633 (setq active (cons 1 (cdr active)))) | |
5634 (setcdr (cdr (assoc group gnus-newsrc-assoc)) | |
5635 (gnus-difference-of-range active (nthcdr 2 unread))) | |
5636 ;; Update .newsrc buffer. | |
5637 (gnus-update-newsrc-buffer group) | |
5638 ;; Update gnus-marked-assoc. | |
5639 (if (listp marked-list) ;Includes NIL. | |
5640 (let ((marked (assoc group gnus-marked-assoc))) | |
5641 (cond (marked | |
5642 (setcdr marked marked-list)) | |
5643 (marked-list ;Non-NIL. | |
5644 (setq gnus-marked-assoc | |
5645 (cons (cons group marked-list) | |
5646 gnus-marked-assoc))) | |
5647 ))) | |
5648 ))) | |
5649 | |
5650 (defun gnus-read-active-file () | |
5651 "Get active file from NNTP server." | |
5652 (message "Reading active file...") | |
5653 (if (gnus-request-list) ;Get active file from server | |
5654 (save-excursion | |
5655 (set-buffer nntp-server-buffer) | |
5656 ;; Save OLD active info. | |
5657 (setq gnus-octive-hashtb gnus-active-hashtb) | |
5658 (setq gnus-active-hashtb (gnus-make-hashtable)) | |
5659 (gnus-active-to-gnus-format) | |
5660 (message "Reading active file... done")) | |
5661 (error "Cannot read active file from NNTP server."))) | |
5662 | |
5663 (defun gnus-active-to-gnus-format () | |
5664 "Convert active file format to internal format." | |
5665 ;; Delete unnecessary lines. | |
5666 (goto-char (point-min)) | |
5667 (delete-matching-lines "^to\\..*$") | |
5668 ;; Store active file in hashtable. | |
5669 (goto-char (point-min)) | |
5670 (while | |
5671 (re-search-forward | |
5672 "^\\([^ \t]+\\)[ \t]+\\([0-9]+\\)[ \t]+\\([0-9]+\\)[ \t]+\\([ymn]\\).*$" | |
5673 nil t) | |
5674 (gnus-sethash | |
5675 (buffer-substring (match-beginning 1) (match-end 1)) | |
5676 (list (buffer-substring (match-beginning 1) (match-end 1)) | |
5677 (string-equal | |
5678 "y" (buffer-substring (match-beginning 4) (match-end 4))) | |
5679 (cons (string-to-int | |
5680 (buffer-substring (match-beginning 3) (match-end 3))) | |
5681 (string-to-int | |
5682 (buffer-substring (match-beginning 2) (match-end 2))))) | |
5683 gnus-active-hashtb))) | |
5684 | |
5685 (defun gnus-read-newsrc-file (&optional rawfile) | |
5686 "Read startup FILE. | |
5687 If optional argument RAWFILE is non-nil, the raw startup file is read." | |
5688 (setq gnus-current-startup-file | |
5689 (let* ((file (expand-file-name gnus-startup-file nil)) | |
5690 (real-file (concat file "-" gnus-nntp-server))) | |
5691 (if (file-exists-p real-file) | |
5692 real-file file))) | |
5693 ;; Reset variables which may be included in the quick startup file. | |
5694 (let ((variables gnus-variable-list)) | |
5695 (while variables | |
5696 (set (car variables) nil) | |
5697 (setq variables (cdr variables)))) | |
5698 (let* ((newsrc-file gnus-current-startup-file) | |
5699 (quick-file (concat newsrc-file ".el")) | |
5700 (quick-loaded nil) | |
5701 (newsrc-mod (nth 5 (file-attributes newsrc-file))) | |
5702 (quick-mod (nth 5 (file-attributes quick-file)))) | |
5703 (save-excursion | |
5704 ;; Prepare .newsrc buffer. | |
5705 (set-buffer (find-file-noselect newsrc-file)) | |
5706 ;; It is not so good idea turning off undo. | |
5707 ;;(buffer-flush-undo (current-buffer)) | |
5708 ;; Load quick .newsrc to restore gnus-marked-assoc and | |
5709 ;; gnus-killed-assoc even if gnus-newsrc-assoc is out of date. | |
5710 (condition-case nil | |
5711 (setq quick-loaded (load quick-file t t t)) | |
5712 (error nil)) | |
5713 (cond ((and (not rawfile) ;Not forced to read the raw file. | |
5714 (or (and (fboundp 'file-newer-than-file-p) | |
5715 (file-newer-than-file-p quick-file newsrc-file)) | |
5716 (and newsrc-mod quick-mod | |
5717 ;; .newsrc.el is newer than .newsrc. | |
5718 ;; Some older version does not support function | |
5719 ;; `file-newer-than-file-p'. | |
5720 (or (< (car newsrc-mod) (car quick-mod)) | |
5721 (and (= (car newsrc-mod) (car quick-mod)) | |
5722 (<= (nth 1 newsrc-mod) (nth 1 quick-mod)))) | |
5723 )) | |
5724 quick-loaded | |
5725 gnus-newsrc-assoc ;Really loaded? | |
5726 ) | |
5727 ;; We don't have to read the raw startup file. | |
5728 ) | |
5729 (t | |
5730 ;; Since .newsrc file is newer than quick file, read it. | |
5731 (message "Reading %s..." newsrc-file) | |
5732 (gnus-newsrc-to-gnus-format) | |
5733 (gnus-check-killed-newsgroups) | |
5734 (message "Reading %s... Done" newsrc-file))) | |
5735 ))) | |
5736 | |
5737 (defun gnus-make-newsrc-file (file) | |
5738 "Make server dependent file name by catenating FILE and server host name." | |
5739 (let* ((file (expand-file-name file nil)) | |
5740 (real-file (concat file "-" gnus-nntp-server))) | |
5741 (if (file-exists-p real-file) | |
5742 real-file file) | |
5743 )) | |
5744 | |
5745 (defun gnus-newsrc-to-gnus-format () | |
5746 "Parse current buffer as .newsrc file." | |
5747 (let ((newsgroup nil) | |
5748 (subscribe nil) | |
5749 (ranges nil) | |
5750 (subrange nil) | |
5751 (read-list nil)) | |
5752 ;; We have to re-initialize these variable (except for | |
5753 ;; gnus-marked-assoc and gnus-killed-assoc) because quick startup | |
5754 ;; file may contain bogus values. | |
5755 (setq gnus-newsrc-options nil) | |
5756 (setq gnus-newsrc-options-n-yes nil) | |
5757 (setq gnus-newsrc-options-n-no nil) | |
5758 (setq gnus-newsrc-assoc nil) | |
5759 ;; Save options line to variable. | |
5760 ;; Lines beginning with white spaces are treated as continuation | |
5761 ;; line. Refer man page of newsrc(5). | |
5762 (goto-char (point-min)) | |
5763 (if (re-search-forward | |
5764 "^[ \t]*options[ \t]*\\(.*\\(\n[ \t]+.*\\)*\\)[ \t]*$" nil t) | |
5765 (progn | |
5766 ;; Save entire options line. | |
5767 (setq gnus-newsrc-options | |
5768 (buffer-substring (match-beginning 1) (match-end 1))) | |
5769 ;; Compile "-n" option. | |
5770 (if (string-match "\\(^\\|[ \t\n]\\)-n" gnus-newsrc-options) | |
5771 (let ((yes-and-no | |
5772 (gnus-parse-n-options | |
5773 (substring gnus-newsrc-options (match-end 0))))) | |
5774 (setq gnus-newsrc-options-n-yes (car yes-and-no)) | |
5775 (setq gnus-newsrc-options-n-no (cdr yes-and-no)) | |
5776 )) | |
5777 )) | |
5778 ;; Parse body of .newsrc file | |
5779 ;; Options line continuation lines must be also considered here. | |
5780 ;; Before supporting continuation lines, " newsgroup ! 1-5" was | |
5781 ;; okay, but now it is invalid. It should be "newsgroup! 1-5". | |
5782 (goto-char (point-min)) | |
5783 ;; Due to overflows in regex.c, change the following regexp: | |
5784 ;; "^\\([^:! \t\n]+\\)\\([:!]\\)[ \t]*\\(.*\\)$" | |
5785 ;; Suggested by composer@bucsf.bu.edu (Jeff Kellem). | |
5786 (while (re-search-forward | |
5787 "^\\([^:! \t\n]+\\)\\([:!]\\)[ \t]*\\(\\(...\\)*.*\\)$" nil t) | |
5788 (setq newsgroup (buffer-substring (match-beginning 1) (match-end 1))) | |
5789 ;; Check duplications of newsgroups. | |
5790 ;; Note: Checking the duplications takes very long time. | |
5791 (if (assoc newsgroup gnus-newsrc-assoc) | |
5792 (message "Ignore duplicated newsgroup: %s" newsgroup) | |
5793 (setq subscribe | |
5794 (string-equal | |
5795 ":" (buffer-substring (match-beginning 2) (match-end 2)))) | |
5796 (setq ranges (buffer-substring (match-beginning 3) (match-end 3))) | |
5797 (setq read-list nil) | |
5798 (while (string-match "^[, \t]*\\([0-9-]+\\)" ranges) | |
5799 (setq subrange (substring ranges (match-beginning 1) (match-end 1))) | |
5800 (setq ranges (substring ranges (match-end 1))) | |
5801 (cond ((string-match "^\\([0-9]+\\)-\\([0-9]+\\)$" subrange) | |
5802 (setq read-list | |
5803 (cons | |
5804 (cons (string-to-int | |
5805 (substring subrange | |
5806 (match-beginning 1) (match-end 1))) | |
5807 (string-to-int | |
5808 (substring subrange | |
5809 (match-beginning 2) (match-end 2)))) | |
5810 read-list))) | |
5811 ((string-match "^[0-9]+$" subrange) | |
5812 (setq read-list | |
5813 (cons (cons (string-to-int subrange) | |
5814 (string-to-int subrange)) | |
5815 read-list))) | |
5816 (t | |
5817 (ding) (message "Ignoring bogus lines of %s" newsgroup) | |
5818 (sit-for 0)) | |
5819 )) | |
5820 (setq gnus-newsrc-assoc | |
5821 (cons (cons newsgroup (cons subscribe (nreverse read-list))) | |
5822 gnus-newsrc-assoc)) | |
5823 )) | |
5824 (setq gnus-newsrc-assoc | |
5825 (nreverse gnus-newsrc-assoc)) | |
5826 )) | |
5827 | |
5828 (defun gnus-parse-n-options (options) | |
5829 "Parse -n NEWSGROUPS options and return a cons of YES and NO regexps." | |
5830 (let ((yes nil) | |
5831 (no nil) | |
5832 (yes-or-no nil) ;`!' or not. | |
5833 (newsgroup nil)) | |
5834 ;; Parse each newsgroup description such as "comp.all". Commas | |
5835 ;; and white spaces can be a newsgroup separator. | |
5836 (while | |
5837 (string-match "^[ \t\n,]*\\(!?\\)\\([^--- \t\n,][^ \t\n,]*\\)" options) | |
5838 (setq yes-or-no | |
5839 (substring options (match-beginning 1) (match-end 1))) | |
5840 (setq newsgroup | |
5841 (regexp-quote | |
5842 (substring options | |
5843 (match-beginning 2) (match-end 2)))) | |
5844 (setq options (substring options (match-end 2))) | |
5845 ;; Rewrite "all" to ".+" not ".*". ".+" requires at least one | |
5846 ;; character. | |
5847 (while (string-match "\\(^\\|\\\\[.]\\)all\\(\\\\[.]\\|$\\)" newsgroup) | |
5848 (setq newsgroup | |
5849 (concat (substring newsgroup 0 (match-end 1)) | |
5850 ".+" | |
5851 (substring newsgroup (match-beginning 2))))) | |
5852 (cond ((string-equal yes-or-no "!") | |
5853 (setq no (cons newsgroup no))) | |
5854 ((string-equal newsgroup ".+")) ;Ignore `all'. | |
5855 (t | |
5856 (setq yes (cons newsgroup yes))) | |
5857 )) | |
5858 ;; Make a cons of regexps from parsing result. | |
5859 (cons (if yes | |
5860 (concat "^\\(" | |
5861 (apply (function concat) | |
5862 (mapcar | |
5863 (function | |
5864 (lambda (newsgroup) | |
5865 (concat newsgroup "\\|"))) | |
5866 (cdr yes))) | |
5867 (car yes) "\\)")) | |
5868 (if no | |
5869 (concat "^\\(" | |
5870 (apply (function concat) | |
5871 (mapcar | |
5872 (function | |
5873 (lambda (newsgroup) | |
5874 (concat newsgroup "\\|"))) | |
5875 (cdr no))) | |
5876 (car no) "\\)"))) | |
5877 )) | |
5878 | |
5879 (defun gnus-save-newsrc-file () | |
5880 "Save to .newsrc FILE." | |
5881 ;; Note: We cannot save .newsrc file if all newsgroups are removed | |
5882 ;; from the variable gnus-newsrc-assoc. | |
5883 (and (or gnus-newsrc-assoc gnus-killed-assoc) | |
5884 gnus-current-startup-file | |
5885 (save-excursion | |
5886 ;; A buffer containing .newsrc file may be deleted. | |
5887 (set-buffer (find-file-noselect gnus-current-startup-file)) | |
5888 (if (not (buffer-modified-p)) | |
5889 (message "(No changes need to be saved)") | |
5890 (message "Saving %s..." gnus-current-startup-file) | |
5891 (let ((make-backup-files t) | |
5892 (version-control nil) | |
5893 (require-final-newline t)) ;Don't ask even if requested. | |
5894 ;; Make backup file of master newsrc. | |
5895 ;; You can stop or change version control of backup file. | |
5896 ;; Suggested by jason@violet.berkeley.edu. | |
5897 (run-hooks 'gnus-Save-newsrc-hook) | |
5898 (save-buffer)) | |
5899 ;; Quickly loadable .newsrc. | |
5900 (set-buffer (get-buffer-create " *GNUS-newsrc*")) | |
5901 (buffer-flush-undo (current-buffer)) | |
5902 (erase-buffer) | |
5903 (gnus-gnus-to-quick-newsrc-format) | |
5904 (let ((make-backup-files nil) | |
5905 (version-control nil) | |
5906 (require-final-newline t)) ;Don't ask even if requested. | |
5907 (write-file (concat gnus-current-startup-file ".el"))) | |
5908 (kill-buffer (current-buffer)) | |
5909 (message "Saving %s... Done" gnus-current-startup-file) | |
5910 )) | |
5911 )) | |
5912 | |
5913 (defun gnus-update-newsrc-buffer (group &optional delete next) | |
5914 "Incrementally update .newsrc buffer about GROUP. | |
5915 If optional second argument DELETE is non-nil, delete the group. | |
5916 If optional third argument NEXT is non-nil, inserted before it." | |
5917 (save-excursion | |
5918 ;; Taking account of the killed startup file. | |
5919 ;; Suggested by tale@pawl.rpi.edu. | |
5920 (set-buffer (or (get-file-buffer gnus-current-startup-file) | |
5921 (find-file-noselect gnus-current-startup-file))) | |
5922 ;; Options line continuation lines must be also considered here. | |
5923 ;; Before supporting continuation lines, " newsgroup ! 1-5" was | |
5924 ;; okay, but now it is invalid. It should be "newsgroup! 1-5". | |
5925 (let ((deleted nil) | |
5926 (buffer-read-only nil)) ;May be not modifiable. | |
5927 ;; Delete ALL entries which match for GROUP. | |
5928 (goto-char (point-min)) | |
5929 (while (re-search-forward | |
5930 (concat "^" (regexp-quote group) "[:!]") nil t) | |
5931 (beginning-of-line) | |
5932 (delete-region (point) (progn (forward-line 1) (point))) | |
5933 (setq deleted t) ;Old entry is deleted. | |
5934 ) | |
5935 (if delete | |
5936 nil | |
5937 ;; Insert group entry. | |
5938 (let ((newsrc (assoc group gnus-newsrc-assoc))) | |
5939 (if (null newsrc) | |
5940 nil | |
5941 ;; Find insertion point. | |
5942 (cond (deleted nil) ;Insert here. | |
5943 ((and (stringp next) | |
5944 (progn | |
5945 (goto-char (point-min)) | |
5946 (re-search-forward | |
5947 (concat "^" (regexp-quote next) "[:!]") nil t))) | |
5948 (beginning-of-line)) | |
5949 (t | |
5950 (goto-char (point-max)) | |
5951 (or (bolp) | |
5952 (insert "\n")))) | |
5953 ;; Insert after options line. | |
5954 (if (looking-at "^[ \t]*options\\([ \t]\\|$\\)") | |
5955 (progn | |
5956 (forward-line 1) | |
5957 ;; Skip continuation lines. | |
5958 (while (and (not (eobp)) | |
5959 (looking-at "^[ \t]+")) | |
5960 (forward-line 1)))) | |
5961 (insert group ;Group name | |
5962 (if (nth 1 newsrc) ": " "! ")) ;Subscribed? | |
5963 (gnus-ranges-to-newsrc-format (nthcdr 2 newsrc)) ;Read articles | |
5964 (insert "\n") | |
5965 ))) | |
5966 ))) | |
5967 | |
5968 (defun gnus-gnus-to-quick-newsrc-format () | |
5969 "Insert GNUS variables such as `gnus-newsrc-assoc' in Lisp format." | |
5970 (insert ";; GNUS internal format of .newsrc.\n") | |
5971 (insert ";; Touch .newsrc instead if you think to remove this file.\n") | |
5972 (let ((variable nil) | |
5973 (variables gnus-variable-list) | |
5974 ;; Temporary rebind to make changes invisible. | |
5975 (gnus-killed-assoc gnus-killed-assoc)) | |
5976 ;; Remove duplicated or unsubscribed newsgroups in gnus-killed-assoc. | |
5977 (gnus-check-killed-newsgroups) | |
5978 ;; Then, insert lisp expressions. | |
5979 (while variables | |
5980 (setq variable (car variables)) | |
5981 (and (boundp variable) | |
5982 (symbol-value variable) | |
5983 (insert "(setq " (symbol-name variable) " '" | |
5984 (prin1-to-string (symbol-value variable)) | |
5985 ")\n")) | |
5986 (setq variables (cdr variables))) | |
5987 )) | |
5988 | |
5989 (defun gnus-ranges-to-newsrc-format (ranges) | |
5990 "Insert ranges of read articles." | |
5991 (let ((range nil)) ;Range is a pair of BEGIN and END. | |
5992 (while ranges | |
5993 (setq range (car ranges)) | |
5994 (setq ranges (cdr ranges)) | |
5995 (cond ((= (car range) (cdr range)) | |
5996 (if (= (car range) 0) | |
5997 (setq ranges nil) ;No unread articles. | |
5998 (insert (int-to-string (car range))) | |
5999 (if ranges (insert ",")) | |
6000 )) | |
6001 (t | |
6002 (insert (int-to-string (car range)) | |
6003 "-" | |
6004 (int-to-string (cdr range))) | |
6005 (if ranges (insert ",")) | |
6006 )) | |
6007 ))) | |
6008 | |
6009 (defun gnus-compress-sequence (numbers) | |
6010 "Convert list of sorted numbers to ranges." | |
6011 (let* ((numbers (sort (copy-sequence numbers) (function <))) | |
6012 (first (car numbers)) | |
6013 (last (car numbers)) | |
6014 (result nil)) | |
6015 (while numbers | |
6016 (cond ((= last (car numbers)) nil) ;Omit duplicated number | |
6017 ((= (1+ last) (car numbers)) ;Still in sequence | |
6018 (setq last (car numbers))) | |
6019 (t ;End of one sequence | |
6020 (setq result (cons (cons first last) result)) | |
6021 (setq first (car numbers)) | |
6022 (setq last (car numbers))) | |
6023 ) | |
6024 (setq numbers (cdr numbers)) | |
6025 ) | |
6026 (nreverse (cons (cons first last) result)) | |
6027 )) | |
6028 | |
6029 (defun gnus-uncompress-sequence (ranges) | |
6030 "Expand compressed format of sequence." | |
6031 (let ((first nil) | |
6032 (last nil) | |
6033 (result nil)) | |
6034 (while ranges | |
6035 (setq first (car (car ranges))) | |
6036 (setq last (cdr (car ranges))) | |
6037 (while (< first last) | |
6038 (setq result (cons first result)) | |
6039 (setq first (1+ first))) | |
6040 (setq result (cons first result)) | |
6041 (setq ranges (cdr ranges)) | |
6042 ) | |
6043 (nreverse result) | |
6044 )) | |
6045 | |
6046 (defun gnus-number-of-articles (range) | |
6047 "Compute number of articles from RANGE `((beg1 . end1) (beg2 . end2) ...)'." | |
6048 (let ((count 0)) | |
6049 (while range | |
6050 (if (/= (cdr (car range)) 0) | |
6051 ;; If end1 is 0, it must be skipped. Usually no articles in | |
6052 ;; this group. | |
6053 (setq count (+ count 1 (- (cdr (car range)) (car (car range)))))) | |
6054 (setq range (cdr range)) | |
6055 ) | |
6056 count ;Result | |
6057 )) | |
6058 | |
6059 (defun gnus-difference-of-range (src obj) | |
6060 "Compute (SRC - OBJ) on range. | |
6061 Range of SRC is expressed as `(beg . end)'. | |
6062 Range of OBJ is expressed as `((beg1 . end1) (beg2 . end2) ...)." | |
6063 (let ((beg (car src)) | |
6064 (end (cdr src)) | |
6065 (range nil)) ;This is result. | |
6066 ;; Src may be nil. | |
6067 (while (and src obj) | |
6068 (let ((beg1 (car (car obj))) | |
6069 (end1 (cdr (car obj)))) | |
6070 (cond ((> beg end) | |
6071 (setq obj nil)) ;Terminate loop | |
6072 ((< beg beg1) | |
6073 (setq range (cons (cons beg (min (1- beg1) end)) range)) | |
6074 (setq beg (1+ end1))) | |
6075 ((>= beg beg1) | |
6076 (setq beg (max beg (1+ end1)))) | |
6077 ) | |
6078 (setq obj (cdr obj)) ;Next OBJ | |
6079 )) | |
6080 ;; Src may be nil. | |
6081 (if (and src (<= beg end)) | |
6082 (setq range (cons (cons beg end) range))) | |
6083 ;; Result | |
6084 (if range | |
6085 (nreverse range) | |
6086 (list (cons 0 0))) | |
6087 )) | |
6088 | |
6089 | |
6090 ;;Local variables: | |
6091 ;;eval: (put 'gnus-eval-in-buffer-window 'lisp-indent-function 1) | |
6092 ;;end: | |
584 | 6093 |
6094 (provide 'gnus) | |
660
08eb386dd0f3
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
6095 |
08eb386dd0f3
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
6096 ;;; gnus.el ends here |