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