Mercurial > emacs
annotate lisp/gnus.el @ 13699:e8358f30c41c
(gnus-group-set-mode-line): Allow user defined specs in the group
format mode line.
author | Lars Magne Ingebrigtsen <larsi@gnus.org> |
---|---|
date | Fri, 08 Dec 1995 05:11:19 +0000 |
parents | 73433c3071a5 |
children | 7cbb1453aefd |
rev | line source |
---|---|
13401 | 1 ;;; gnus.el --- a newsreader for GNU Emacs |
2 ;; Copyright (C) 1987,88,89,90,93,94,95 Free Software Foundation, Inc. | |
3 | |
4 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet> | |
5 ;; Lars Magne Ingebrigtsen <larsi@ifi.uio.no> | |
6 ;; Keywords: news | |
7 | |
8 ;; This file is part of GNU Emacs. | |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
12 ;; the Free Software Foundation; either version 2, or (at your option) | |
13 ;; any later version. | |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
23 | |
24 ;;; Commentary: | |
25 | |
26 ;; Although Gnus looks suspiciously like GNUS, it isn't quite the same | |
27 ;; beast. Most internal structures have been changed. If you have | |
28 ;; written packages that depend on any of the hash tables, | |
29 ;; `gnus-newsrc-alist', `gnus-killed-assoc', marked lists, the .newsrc | |
30 ;; buffer, or internal knowledge of the `nntp-header-' macros, or | |
31 ;; dependence on the buffers having a certain format, your code will | |
32 ;; fail. | |
33 | |
34 ;;; Code: | |
35 | |
36 (eval '(run-hooks 'gnus-load-hook)) | |
37 | |
38 (require 'mail-utils) | |
39 (require 'timezone) | |
40 (require 'nnheader) | |
41 | |
42 ;; Site dependent variables. These variables should be defined in | |
43 ;; paths.el. | |
44 | |
45 (defvar gnus-default-nntp-server nil | |
46 "Specify a default NNTP server. | |
47 This variable should be defined in paths.el, and should never be set | |
48 by the user. | |
49 If you want to change servers, you should use `gnus-select-method'. | |
50 See the documentation to that variable.") | |
51 | |
52 (defconst gnus-backup-default-subscribed-newsgroups | |
53 '("news.announce.newusers" "news.groups.questions" "gnu.emacs.gnus") | |
54 "Default default new newsgroups the first time Gnus is run. | |
55 Should be set in paths.el, and shouldn't be touched by the user.") | |
56 | |
57 (defvar gnus-local-domain nil | |
58 "Local domain name without a host name. | |
59 The DOMAINNAME environment variable is used instead if it is defined. | |
60 If the `system-name' function returns the full Internet name, there is | |
61 no need to set this variable.") | |
62 | |
63 (defvar gnus-local-organization nil | |
64 "String with a description of what organization (if any) the user belongs to. | |
65 The ORGANIZATION environment variable is used instead if it is defined. | |
66 If this variable contains a function, this function will be called | |
67 with the current newsgroup name as the argument. The function should | |
68 return a string. | |
69 | |
70 In any case, if the string (either in the variable, in the environment | |
71 variable, or returned by the function) is a file name, the contents of | |
72 this file will be used as the organization.") | |
73 | |
74 (defvar gnus-use-generic-from nil | |
75 "If nil, the full host name will be the system name prepended to the domain name. | |
76 If this is a string, the full host name will be this string. | |
77 If this is non-nil, non-string, the domain name will be used as the | |
78 full host name.") | |
79 | |
80 (defvar gnus-use-generic-path nil | |
81 "If nil, use the NNTP server name in the Path header. | |
82 If stringp, use this; if non-nil, use no host name (user name only).") | |
83 | |
84 | |
85 ;; Customization variables | |
86 | |
87 ;; Don't touch this variable. | |
88 (defvar gnus-nntp-service "nntp" | |
89 "*NNTP service name (\"nntp\" or 119). | |
90 This is an obsolete variable, which is scarcely used. If you use an | |
91 nntp server for your newsgroup and want to change the port number | |
92 used to 899, you would say something along these lines: | |
93 | |
94 (setq gnus-select-method '(nntp \"my.nntp.server\" (nntp-port-number 899)))") | |
95 | |
96 (defvar gnus-select-method | |
97 (nconc | |
98 (list 'nntp (or (getenv "NNTPSERVER") | |
99 (if (and gnus-default-nntp-server | |
100 (not (string= gnus-default-nntp-server ""))) | |
101 gnus-default-nntp-server) | |
102 (system-name))) | |
103 (if (or (null gnus-nntp-service) | |
104 (equal gnus-nntp-service "nntp")) | |
105 nil | |
106 (list gnus-nntp-service))) | |
107 "*Default method for selecting a newsgroup. | |
108 This variable should be a list, where the first element is how the | |
109 news is to be fetched, the second is the address. | |
110 | |
111 For instance, if you want to get your news via NNTP from | |
112 \"flab.flab.edu\", you could say: | |
113 | |
114 (setq gnus-select-method '(nntp \"flab.flab.edu\")) | |
115 | |
116 If you want to use your local spool, say: | |
117 | |
118 (setq gnus-select-method (list 'nnspool (system-name))) | |
119 | |
120 If you use this variable, you must set `gnus-nntp-server' to nil. | |
121 | |
122 There is a lot more to know about select methods and virtual servers - | |
123 see the manual for details.") | |
124 | |
125 ;; Added by Sudish Joseph <joseph@cis.ohio-state.edu>. | |
126 (defvar gnus-post-method nil | |
127 "*Preferred method for posting USENET news. | |
128 If this variable is nil, Gnus will use the current method to decide | |
129 which method to use when posting. If it is non-nil, it will override | |
130 the current method. This method will not be used in mail groups and | |
131 the like, only in \"real\" newsgroups. | |
132 | |
133 The value must be a valid method as discussed in the documentation of | |
134 `gnus-select-method'.") | |
135 | |
136 (defvar gnus-refer-article-method nil | |
137 "*Preferred method for fetching an article by Message-ID. | |
138 If you are reading news from the local spool (with nnspool), fetching | |
139 articles by Message-ID is painfully slow. By setting this method to an | |
140 nntp method, you might get acceptable results. | |
141 | |
142 The value of this variable must be a valid select method as discussed | |
143 in the documentation of `gnus-select-method'") | |
144 | |
145 (defvar gnus-secondary-select-methods nil | |
146 "*A list of secondary methods that will be used for reading news. | |
147 This is a list where each element is a complete select method (see | |
148 `gnus-select-method'). | |
149 | |
150 If, for instance, you want to read your mail with the nnml backend, | |
151 you could set this variable: | |
152 | |
153 (setq gnus-secondary-select-methods '((nnml \"\")))") | |
154 | |
155 (defvar gnus-secondary-servers nil | |
156 "*List of NNTP servers that the user can choose between interactively. | |
157 To make Gnus query you for a server, you have to give `gnus' a | |
158 non-numeric prefix - `C-u M-x gnus', in short.") | |
159 | |
160 (defvar gnus-nntp-server nil | |
161 "*The name of the host running the NNTP server. | |
162 This variable is semi-obsolete. Use the `gnus-select-method' | |
163 variable instead.") | |
164 | |
165 (defvar gnus-startup-file "~/.newsrc" | |
166 "*Your `.newsrc' file. | |
167 `.newsrc-SERVER' will be used instead if that exists.") | |
168 | |
169 (defvar gnus-init-file "~/.gnus" | |
170 "*Your Gnus elisp startup file. | |
171 If a file with the .el or .elc suffixes exist, it will be read | |
172 instead.") | |
173 | |
174 (defvar gnus-group-faq-directory | |
175 "/ftp@mirrors.aol.com:/pub/rtfm/usenet/" | |
176 "*Directory where the group FAQs are stored. | |
177 This will most commonly be on a remote machine, and the file will be | |
178 fetched by ange-ftp. | |
179 | |
180 Note that Gnus uses an aol machine as the default directory. If this | |
181 feels fundamentally unclean, just think of it as a way to finally get | |
182 something of value back from them. | |
183 | |
184 If the default site is too slow, try one of these: | |
185 | |
186 North America: ftp.uu.net /usenet/news.answers | |
187 mirrors.aol.com /pub/rtfm/usenet | |
188 ftp.seas.gwu.edu /pub/rtfm | |
189 rtfm.mit.edu /pub/usenet/news.answers | |
190 Europe: ftp.uni-paderborn.de /pub/FAQ | |
191 ftp.Germany.EU.net /pub/newsarchive/news.answers | |
192 ftp.sunet.se /pub/usenet | |
193 Asia: nctuccca.edu.tw /USENET/FAQ | |
194 hwarang.postech.ac.kr /pub/usenet/news.answers | |
195 ftp.hk.super.net /mirror/faqs") | |
196 | |
197 (defvar gnus-group-archive-directory | |
198 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/" | |
199 "*The address of the (ding) archives.") | |
200 | |
201 (defvar gnus-group-recent-archive-directory | |
202 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/" | |
203 "*The address of the most recent (ding) articles.") | |
204 | |
205 (defvar gnus-default-subscribed-newsgroups nil | |
206 "*This variable lists what newsgroups should be subscribed the first time Gnus is used. | |
207 It should be a list of strings. | |
208 If it is `t', Gnus will not do anything special the first time it is | |
209 started; it'll just use the normal newsgroups subscription methods.") | |
210 | |
211 (defvar gnus-use-cross-reference t | |
212 "*Non-nil means that cross referenced articles will be marked as read. | |
213 If nil, ignore cross references. If t, mark articles as read in | |
214 subscribed newsgroups. If neither t nor nil, mark as read in all | |
215 newsgroups.") | |
216 | |
217 (defvar gnus-use-dribble-file t | |
218 "*Non-nil means that Gnus will use a dribble file to store user updates. | |
219 If Emacs should crash without saving the .newsrc files, complete | |
220 information can be restored from the dribble file.") | |
221 | |
222 (defvar gnus-asynchronous nil | |
223 "*If non-nil, Gnus will supply backends with data needed for async article fetching.") | |
224 | |
225 (defvar gnus-asynchronous-article-function nil | |
226 "*Function for picking articles to pre-fetch, possibly.") | |
227 | |
228 (defvar gnus-score-file-single-match-alist nil | |
229 "*Alist mapping regexps to lists of score files. | |
230 Each element of this alist should be of the form | |
231 (\"REGEXP\" [ \"SCORE-FILE-1\" ] [ \"SCORE-FILE-2\" ] ... ) | |
232 | |
233 If the name of a group is matched by REGEXP, the corresponding scorefiles | |
234 will be used for that group. | |
235 The first match found is used, subsequent matching entries are ignored (to | |
236 use multiple matches, see gnus-score-file-multiple-match-alist). | |
237 | |
238 These score files are loaded in addition to any files returned by | |
239 gnus-score-find-score-files-function (which see).") | |
240 | |
241 (defvar gnus-score-file-multiple-match-alist nil | |
242 "*Alist mapping regexps to lists of score files. | |
243 Each element of this alist should be of the form | |
244 (\"REGEXP\" [ \"SCORE-FILE-1\" ] [ \"SCORE-FILE-2\" ] ... ) | |
245 | |
246 If the name of a group is matched by REGEXP, the corresponding scorefiles | |
247 will be used for that group. | |
248 If multiple REGEXPs match a group, the score files corresponding to each | |
249 match will be used (for only one match to be used, see | |
250 gnus-score-file-single-match-alist). | |
251 | |
252 These score files are loaded in addition to any files returned by | |
253 gnus-score-find-score-files-function (which see).") | |
254 | |
255 | |
256 (defvar gnus-score-file-suffix "SCORE" | |
257 "*Suffix of the score files.") | |
258 | |
259 (defvar gnus-adaptive-file-suffix "ADAPT" | |
260 "*Suffix of the adaptive score files.") | |
261 | |
262 (defvar gnus-score-find-score-files-function 'gnus-score-find-bnews | |
263 "*Function used to find score files. | |
264 The function will be called with the group name as the argument, and | |
265 should return a list of score files to apply to that group. The score | |
266 files do not actually have to exist. | |
267 | |
268 Predefined values are: | |
269 | |
270 gnus-score-find-single: Only apply the group's own score file. | |
271 gnus-score-find-hierarchical: Also apply score files from parent groups. | |
272 gnus-score-find-bnews: Apply score files whose names matches. | |
273 | |
274 See the documentation to these functions for more information. | |
275 | |
276 This variable can also be a list of functions to be called. Each | |
277 function should either return a list of score files, or a list of | |
278 score alists.") | |
279 | |
280 (defvar gnus-score-interactive-default-score 1000 | |
281 "*Scoring commands will raise/lower the score with this number as the default.") | |
282 | |
283 (defvar gnus-large-newsgroup 200 | |
284 "*The number of articles which indicates a large newsgroup. | |
285 If the number of articles in a newsgroup is greater than this value, | |
286 confirmation is required for selecting the newsgroup.") | |
287 | |
288 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>. | |
289 (defvar gnus-no-groups-message "No news is horrible news" | |
290 "*Message displayed by Gnus when no groups are available.") | |
291 | |
292 (defvar gnus-use-long-file-name (not (memq system-type '(usg-unix-v xenix))) | |
293 "*Non-nil means that the default name of a file to save articles in is the group name. | |
294 If it's nil, the directory form of the group name is used instead. | |
295 | |
296 If this variable is a list, and the list contains the element | |
297 `not-score', long file names will not be used for score files; if it | |
298 contains the element `not-save', long file names will not be used for | |
299 saving; and if it contains the element `not-kill', long file names | |
300 will not be used for kill files.") | |
301 | |
302 (defvar gnus-article-save-directory (or (getenv "SAVEDIR") "~/News/") | |
303 "*Name of the directory articles will be saved in (default \"~/News\"). | |
304 Initialized from the SAVEDIR environment variable.") | |
305 | |
306 (defvar gnus-kill-files-directory (or (getenv "SAVEDIR") "~/News/") | |
307 "*Name of the directory where kill files will be stored (default \"~/News\"). | |
308 Initialized from the SAVEDIR environment variable.") | |
309 | |
310 (defvar gnus-default-article-saver 'gnus-summary-save-in-rmail | |
311 "*A function to save articles in your favorite format. | |
312 The function must be interactively callable (in other words, it must | |
313 be an Emacs command). | |
314 | |
315 Gnus provides the following functions: | |
316 | |
317 * gnus-summary-save-in-rmail (Rmail format) | |
318 * gnus-summary-save-in-mail (Unix mail format) | |
319 * gnus-summary-save-in-folder (MH folder) | |
320 * gnus-summary-save-in-file (article format). | |
321 * gnus-summary-save-in-vm (use VM's folder format).") | |
322 | |
323 (defvar gnus-rmail-save-name (function gnus-plain-save-name) | |
324 "*A function generating a file name to save articles in Rmail format. | |
325 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.") | |
326 | |
327 (defvar gnus-mail-save-name (function gnus-plain-save-name) | |
328 "*A function generating a file name to save articles in Unix mail format. | |
329 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.") | |
330 | |
331 (defvar gnus-folder-save-name (function gnus-folder-save-name) | |
332 "*A function generating a file name to save articles in MH folder. | |
333 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.") | |
334 | |
335 (defvar gnus-file-save-name (function gnus-numeric-save-name) | |
336 "*A function generating a file name to save articles in article format. | |
337 The function is called with NEWSGROUP, HEADERS, and optional | |
338 LAST-FILE.") | |
339 | |
340 (defvar gnus-split-methods nil | |
341 "*Variable used to suggest where articles are to be saved. | |
342 The syntax of this variable is the same as `nnmail-split-methods'. | |
343 | |
344 For instance, if you would like to save articles related to Gnus in | |
345 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\", | |
346 you could set this variable to something like: | |
347 | |
348 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\") | |
349 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))") | |
350 | |
351 (defvar gnus-save-score nil | |
352 "*If non-nil, save group scoring info.") | |
353 | |
354 (defvar gnus-use-adaptive-scoring nil | |
355 "*If non-nil, use some adaptive scoring scheme.") | |
356 | |
357 (defvar gnus-use-cache nil | |
358 "*If non-nil, Gnus will cache (some) articles locally.") | |
359 | |
360 (defvar gnus-use-scoring t | |
361 "*If non-nil, enable scoring.") | |
362 | |
363 (defvar gnus-fetch-old-headers nil | |
364 "*Non-nil means that Gnus will try to build threads by grabbing old headers. | |
365 If an unread article in the group refers to an older, already read (or | |
366 just marked as read) article, the old article will not normally be | |
367 displayed in the Summary buffer. If this variable is non-nil, Gnus | |
368 will attempt to grab the headers to the old articles, and thereby | |
369 build complete threads. If it has the value `some', only enough | |
370 headers to connect otherwise loose threads will be displayed. | |
371 | |
372 The server has to support XOVER for any of this to work.") | |
373 | |
374 ;see gnus-cus.el | |
375 ;(defvar gnus-visual t | |
376 ; "*If non-nil, will do various highlighting. | |
377 ;If nil, no mouse highlights (or any other highlights) will be | |
378 ;performed. This might speed up Gnus some when generating large group | |
379 ;and summary buffers.") | |
380 | |
381 (defvar gnus-novice-user t | |
382 "*Non-nil means that you are a usenet novice. | |
383 If non-nil, verbose messages may be displayed and confirmations may be | |
384 required.") | |
385 | |
386 (defvar gnus-expert-user nil | |
387 "*Non-nil means that you will never be asked for confirmation about anything. | |
388 And that means *anything*.") | |
389 | |
390 (defvar gnus-verbose 7 | |
391 "*Integer that says how verbose Gnus should be. | |
392 The higher the number, the more messages Gnus will flash to say what | |
393 it's doing. At zero, Gnus will be totally mute; at five, Gnus will | |
394 display most important messages; and at ten, Gnus will keep on | |
395 jabbering all the time.") | |
396 | |
397 (defvar gnus-keep-same-level nil | |
398 "*Non-nil means that the next newsgroup after the current will be on the same level. | |
399 When you type, for instance, `n' after reading the last article in the | |
400 current newsgroup, you will go to the next newsgroup. If this variable | |
401 is nil, the next newsgroup will be the next from the group | |
402 buffer. | |
403 If this variable is non-nil, Gnus will either put you in the | |
404 next newsgroup with the same level, or, if no such newsgroup is | |
405 available, the next newsgroup with the lowest possible level higher | |
406 than the current level. | |
407 If this variable is `best', Gnus will make the next newsgroup the one | |
408 with the best level.") | |
409 | |
410 (defvar gnus-summary-make-false-root 'adopt | |
411 "*nil means that Gnus won't gather loose threads. | |
412 If the root of a thread has expired or been read in a previous | |
413 session, the information necessary to build a complete thread has been | |
414 lost. Instead of having many small sub-threads from this original thread | |
415 scattered all over the summary buffer, Gnus can gather them. | |
416 | |
417 If non-nil, Gnus will try to gather all loose sub-threads from an | |
418 original thread into one large thread. | |
419 | |
420 If this variable is non-nil, it should be one of `none', `adopt', | |
421 `dummy' or `empty'. | |
422 | |
423 If this variable is `none', Gnus will not make a false root, but just | |
424 present the sub-threads after another. | |
425 If this variable is `dummy', Gnus will create a dummy root that will | |
426 have all the sub-threads as children. | |
427 If this variable is `adopt', Gnus will make one of the \"children\" | |
428 the parent and mark all the step-children as such. | |
429 If this variable is `empty', the \"children\" are printed with empty | |
430 subject fields. (Or rather, they will be printed with a string | |
431 given by the `gnus-summary-same-subject' variable.)") | |
432 | |
433 (defvar gnus-summary-gather-subject-limit nil | |
434 "*Maximum length of subject comparisons when gathering loose threads. | |
435 Use nil to compare full subjects. Setting this variable to a low | |
436 number will help gather threads that have been corrupted by | |
437 newsreaders chopping off subject lines, but it might also mean that | |
438 unrelated articles that have subject that happen to begin with the | |
439 same few characters will be incorrectly gathered. | |
440 | |
441 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when | |
442 comparing subjects.") | |
443 | |
444 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>. | |
445 (defvar gnus-summary-same-subject "" | |
446 "*String indicating that the current article has the same subject as the previous. | |
447 This variable will only be used if the value of | |
448 `gnus-summary-make-false-root' is `empty'.") | |
449 | |
450 (defvar gnus-summary-goto-unread t | |
451 "*If non-nil, marking commands will go to the next unread article.") | |
452 | |
453 (defvar gnus-group-goto-unread t | |
454 "*If non-nil, movement commands will go to the next unread and subscribed group.") | |
455 | |
456 (defvar gnus-check-new-newsgroups t | |
457 "*Non-nil means that Gnus will add new newsgroups at startup. | |
458 If this variable is `ask-server', Gnus will ask the server for new | |
459 groups since the last time it checked. This means that the killed list | |
460 is no longer necessary, so you could set `gnus-save-killed-list' to | |
461 nil. | |
462 | |
463 A variant is to have this variable be a list of select methods. Gnus | |
464 will then use the `ask-server' method on all these select methods to | |
465 query for new groups from all those servers. | |
466 | |
467 Eg. | |
468 (setq gnus-check-new-newsgroups | |
469 '((nntp \"some.server\") (nntp \"other.server\"))) | |
470 | |
471 If this variable is nil, then you have to tell Gnus explicitly to | |
472 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].") | |
473 | |
474 (defvar gnus-check-bogus-newsgroups nil | |
475 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup. | |
476 If this variable is nil, then you have to tell Gnus explicitly to | |
477 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].") | |
478 | |
479 (defvar gnus-read-active-file t | |
480 "*Non-nil means that Gnus will read the entire active file at startup. | |
481 If this variable is nil, Gnus will only know about the groups in your | |
482 `.newsrc' file. | |
483 | |
484 If this variable is `some', Gnus will try to only read the relevant | |
485 parts of the active file from the server. Not all servers support | |
486 this, and it might be quite slow with other servers, but this should | |
487 generally be faster than both the t and nil value. | |
488 | |
489 If you set this variable to nil or `some', you probably still want to | |
490 be told about new newsgroups that arrive. To do that, set | |
491 `gnus-check-new-newsgroups' to `ask-server'. This may not work | |
492 properly with all servers.") | |
493 | |
494 (defvar gnus-level-subscribed 5 | |
495 "*Groups with levels less than or equal to this variable are subscribed.") | |
496 | |
497 (defvar gnus-level-unsubscribed 7 | |
498 "*Groups with levels less than or equal to this variable are unsubscribed. | |
499 Groups with levels less than `gnus-level-subscribed', which should be | |
500 less than this variable, are subscribed.") | |
501 | |
502 (defvar gnus-level-zombie 8 | |
503 "*Groups with this level are zombie groups.") | |
504 | |
505 (defvar gnus-level-killed 9 | |
506 "*Groups with this level are killed.") | |
507 | |
508 (defvar gnus-level-default-subscribed 3 | |
509 "*New subscribed groups will be subscribed at this level.") | |
510 | |
511 (defvar gnus-level-default-unsubscribed 6 | |
512 "*New unsubscribed groups will be unsubscribed at this level.") | |
513 | |
514 (defvar gnus-activate-foreign-newsgroups 4 | |
515 "*If nil, Gnus will not check foreign newsgroups at startup. | |
516 If it is non-nil, it should be a number between one and nine. Foreign | |
517 newsgroups that have a level lower or equal to this number will be | |
518 activated on startup. For instance, if you want to active all | |
519 subscribed newsgroups, but not the rest, you'd set this variable to | |
520 `gnus-level-subscribed'. | |
521 | |
522 If you subscribe to lots of newsgroups from different servers, startup | |
523 might take a while. By setting this variable to nil, you'll save time, | |
524 but you won't be told how many unread articles there are in the | |
525 groups.") | |
526 | |
527 (defvar gnus-save-newsrc-file t | |
528 "*Non-nil means that Gnus will save the `.newsrc' file. | |
529 Gnus always saves its own startup file, which is called | |
530 \".newsrc.eld\". The file called \".newsrc\" is in a format that can | |
531 be readily understood by other newsreaders. If you don't plan on | |
532 using other newsreaders, set this variable to nil to save some time on | |
533 exit.") | |
534 | |
535 (defvar gnus-save-killed-list t | |
536 "*If non-nil, save the list of killed groups to the startup file. | |
537 This will save both time (when starting and quitting) and space (both | |
538 memory and disk), but it will also mean that Gnus has no record of | |
539 which groups are new and which are old, so the automatic new | |
540 newsgroups subscription methods become meaningless. You should always | |
541 set `gnus-check-new-newsgroups' to `ask-server' or nil if you set this | |
542 variable to nil.") | |
543 | |
544 (defvar gnus-interactive-catchup t | |
545 "*If non-nil, require your confirmation when catching up a group.") | |
546 | |
547 (defvar gnus-interactive-post t | |
548 "*If non-nil, group name will be asked for when posting.") | |
549 | |
550 (defvar gnus-interactive-exit t | |
551 "*If non-nil, require your confirmation when exiting Gnus.") | |
552 | |
553 (defvar gnus-kill-killed t | |
554 "*If non-nil, Gnus will apply kill files to already killed articles. | |
555 If it is nil, Gnus will never apply kill files to articles that have | |
556 already been through the scoring process, which might very well save lots | |
557 of time.") | |
558 | |
559 (defvar gnus-extract-address-components 'gnus-extract-address-components | |
560 "*Function for extracting address components from a From header. | |
561 Two pre-defined function exist: `gnus-extract-address-components', | |
562 which is the default, quite fast, and too simplistic solution, and | |
563 `mail-extract-address-components', which works much better, but is | |
564 slower.") | |
565 | |
566 (defvar gnus-summary-default-score 0 | |
567 "*Default article score level. | |
568 If this variable is nil, scoring will be disabled.") | |
569 | |
570 (defvar gnus-summary-zcore-fuzz 0 | |
571 "*Fuzziness factor for the zcore in the summary buffer. | |
572 Articles with scores closer than this to `gnus-summary-default-score' | |
573 will not be marked.") | |
574 | |
575 (defvar gnus-simplify-subject-fuzzy-regexp nil | |
576 "*Regular expression that will be removed from subject strings if | |
577 fuzzy subject simplification is selected.") | |
578 | |
579 (defvar gnus-group-default-list-level gnus-level-subscribed | |
580 "*Default listing level. | |
581 Ignored if `gnus-group-use-permanent-levels' is non-nil.") | |
582 | |
583 (defvar gnus-group-use-permanent-levels nil | |
584 "*If non-nil, once you set a level, Gnus will use this level.") | |
585 | |
586 (defvar gnus-show-mime nil | |
587 "*If non-nil, do mime processing of articles. | |
588 The articles will simply be fed to the function given by | |
589 `gnus-show-mime-method'.") | |
590 | |
591 (defvar gnus-strict-mime t | |
592 "*If nil, decode MIME header even if there is not Mime-Version field.") | |
593 | |
594 (defvar gnus-show-mime-method (function metamail-buffer) | |
595 "*Function to process a MIME message. | |
596 The function is called from the article buffer.") | |
597 | |
598 (defvar gnus-show-threads t | |
599 "*If non-nil, display threads in summary mode.") | |
600 | |
601 (defvar gnus-thread-hide-subtree nil | |
602 "*If non-nil, hide all threads initially. | |
603 If threads are hidden, you have to run the command | |
604 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook' | |
605 to expose hidden threads.") | |
606 | |
607 (defvar gnus-thread-hide-killed t | |
608 "*If non-nil, hide killed threads automatically.") | |
609 | |
610 (defvar gnus-thread-ignore-subject nil | |
611 "*If non-nil, ignore subjects and do all threading based on the Reference header. | |
612 If nil, which is the default, articles that have different subjects | |
613 from their parents will start separate threads.") | |
614 | |
615 (defvar gnus-thread-indent-level 4 | |
616 "*Number that says how much each sub-thread should be indented.") | |
617 | |
618 (defvar gnus-ignored-newsgroups | |
619 (purecopy (mapconcat 'identity | |
620 '("^to\\." ; not "real" groups | |
621 "^[0-9. \t]+ " ; all digits in name | |
622 "[][\"#'()]" ; bogus characters | |
623 ) | |
624 "\\|")) | |
625 "*A regexp to match uninteresting newsgroups in the active file. | |
626 Any lines in the active file matching this regular expression are | |
627 removed from the newsgroup list before anything else is done to it, | |
628 thus making them effectively non-existent.") | |
629 | |
630 (defvar gnus-ignored-headers | |
631 "^Path:\\|^Posting-Version:\\|^Article-I.D.:\\|^Expires:\\|^Date-Received:\\|^References:\\|^Control:\\|^Xref:\\|^Lines:\\|^Posted:\\|^Relay-Version:\\|^Message-ID:\\|^Nf-ID:\\|^Nf-From:\\|^Approved:\\|^Sender:\\|^Received:\\|^Mail-from:" | |
632 "*All headers that match this regexp will be hidden. | |
633 If `gnus-visible-headers' is non-nil, this variable will be ignored.") | |
634 | |
635 (defvar gnus-visible-headers "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^Cc:" | |
636 "*All headers that do not match this regexp will be hidden. | |
637 If this variable is non-nil, `gnus-ignored-headers' will be ignored.") | |
638 | |
639 (defvar gnus-sorted-header-list | |
640 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:" | |
641 "^Cc:" "^Date:" "^Organization:") | |
642 "*This variable is a list of regular expressions. | |
643 If it is non-nil, headers that match the regular expressions will | |
644 be placed first in the article buffer in the sequence specified by | |
645 this list.") | |
646 | |
647 (defvar gnus-show-all-headers nil | |
648 "*If non-nil, don't hide any headers.") | |
649 | |
650 (defvar gnus-save-all-headers t | |
651 "*If non-nil, don't remove any headers before saving.") | |
652 | |
653 (defvar gnus-inhibit-startup-message nil | |
654 "*If non-nil, the startup message will not be displayed.") | |
655 | |
656 (defvar gnus-signature-separator "^-- *$" | |
657 "Regexp matching signature separator.") | |
658 | |
659 (defvar gnus-auto-extend-newsgroup t | |
660 "*If non-nil, extend newsgroup forward and backward when requested.") | |
661 | |
662 (defvar gnus-auto-select-first t | |
663 "*If non-nil, select the first unread article when entering a group. | |
664 If you want to prevent automatic selection of the first unread article | |
665 in some newsgroups, set the variable to nil in | |
666 `gnus-select-group-hook'.") | |
667 | |
668 (defvar gnus-auto-select-next t | |
669 "*If non-nil, offer to go to the next group from the end of the previous. | |
670 If the value is t and the next newsgroup is empty, Gnus will exit | |
671 summary mode and go back to group mode. If the value is neither nil | |
672 nor t, Gnus will select the following unread newsgroup. In | |
673 particular, if the value is the symbol `quietly', the next unread | |
674 newsgroup will be selected without any confirmations.") | |
675 | |
676 (defvar gnus-auto-select-same nil | |
677 "*If non-nil, select the next article with the same subject.") | |
678 | |
679 (defvar gnus-summary-check-current nil | |
680 "*If non-nil, consider the current article when moving. | |
681 The \"unread\" movement commands will stay on the same line if the | |
682 current article is unread.") | |
683 | |
684 (defvar gnus-auto-center-summary t | |
685 "*If non-nil, always center the current summary buffer.") | |
686 | |
687 (defvar gnus-break-pages t | |
688 "*If non-nil, do page breaking on articles. | |
689 The page delimiter is specified by the `gnus-page-delimiter' | |
690 variable.") | |
691 | |
692 (defvar gnus-page-delimiter "^\^L" | |
693 "*Regexp describing what to use as article page delimiters. | |
694 The default value is \"^\^L\", which is a form linefeed at the | |
695 beginning of a line.") | |
696 | |
697 (defvar gnus-use-full-window t | |
698 "*If non-nil, use the entire Emacs screen.") | |
699 | |
700 (defvar gnus-window-configuration nil | |
701 "Obsolete variable. See `gnus-buffer-configuration'.") | |
702 | |
703 (defvar gnus-buffer-configuration | |
704 '((group ([group 1.0 point] | |
705 (if gnus-carpal [group-carpal 4]))) | |
706 (summary ([summary 1.0 point] | |
707 (if gnus-carpal [summary-carpal 4]))) | |
708 (article ([summary 0.25 point] | |
709 (if gnus-carpal [summary-carpal 4]) | |
710 [article 1.0])) | |
711 (server ([server 1.0 point] | |
712 (if gnus-carpal [server-carpal 2]))) | |
713 (browse ([browse 1.0 point] | |
714 (if gnus-carpal [browse-carpal 2]))) | |
715 (group-mail ([mail 1.0 point])) | |
716 (summary-mail ([mail 1.0 point])) | |
717 (summary-reply ([article 0.5] | |
718 [mail 1.0 point])) | |
719 (info ([nil 1.0 point])) | |
720 (summary-faq ([summary 0.25] | |
721 [faq 1.0 point])) | |
722 (edit-group ([group 0.5] | |
723 [edit-group 1.0 point])) | |
724 (edit-server ([server 0.5] | |
725 [edit-server 1.0 point])) | |
726 (edit-score ([summary 0.25] | |
727 [edit-score 1.0 point])) | |
728 (post ([post 1.0 point])) | |
729 (reply ([article 0.5] | |
730 [mail 1.0 point])) | |
731 (mail-forward ([mail 1.0 point])) | |
732 (post-forward ([post 1.0 point])) | |
733 (reply-yank ([mail 1.0 point])) | |
734 (followup ([article 0.5] | |
735 [post 1.0 point])) | |
736 (followup-yank ([post 1.0 point]))) | |
737 "Window configuration for all possible Gnus buffers. | |
738 This variable is a list of lists. Each of these lists has a NAME and | |
739 a RULE. The NAMEs are commonsense names like `group', which names a | |
740 rule used when displaying the group buffer; `summary', which names a | |
741 rule for what happens when you enter a group and do not display an | |
742 article buffer; and so on. See the value of this variable for a | |
743 complete list of NAMEs. | |
744 | |
745 Each RULE is a list of vectors. The first element in this vector is | |
746 the name of the buffer to be displayed; the second element is the | |
747 percentage of the screen this buffer is to occupy (a number in the | |
748 0.0-0.99 range); the optional third element is `point', which should | |
749 be present to denote which buffer point is to go to after making this | |
750 buffer configuration.") | |
751 | |
752 (defvar gnus-window-to-buffer | |
753 '((group . gnus-group-buffer) | |
754 (summary . gnus-summary-buffer) | |
755 (article . gnus-article-buffer) | |
756 (server . gnus-server-buffer) | |
757 (browse . "*Gnus Browse Server*") | |
758 (edit-group . gnus-group-edit-buffer) | |
759 (edit-server . gnus-server-edit-buffer) | |
760 (group-carpal . gnus-carpal-group-buffer) | |
761 (summary-carpal . gnus-carpal-summary-buffer) | |
762 (server-carpal . gnus-carpal-server-buffer) | |
763 (browse-carpal . gnus-carpal-browse-buffer) | |
764 (edit-score . gnus-score-edit-buffer) | |
765 (mail . gnus-mail-buffer) | |
766 (post . gnus-post-news-buffer) | |
767 (faq . gnus-faq-buffer)) | |
768 "Mapping from short symbols to buffer names or buffer variables.") | |
769 | |
770 (defvar gnus-carpal nil | |
771 "*If non-nil, display clickable icons.") | |
772 | |
773 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies | |
774 "*Function called with a group name when new group is detected. | |
775 A few pre-made functions are supplied: `gnus-subscribe-randomly' | |
776 inserts new groups at the beginning of the list of groups; | |
777 `gnus-subscribe-alphabetically' inserts new groups in strict | |
778 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups | |
779 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks | |
780 for your decision.") | |
781 | |
782 ;; Suggested by a bug report by Hallvard B Furuseth. | |
783 ;; <h.b.furuseth@usit.uio.no>. | |
784 (defvar gnus-subscribe-options-newsgroup-method | |
785 (function gnus-subscribe-alphabetically) | |
786 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines. | |
787 If, for instance, you want to subscribe to all newsgroups in the | |
788 \"no\" and \"alt\" hierarchies, you'd put the following in your | |
789 .newsrc file: | |
790 | |
791 options -n no.all alt.all | |
792 | |
793 Gnus will the subscribe all new newsgroups in these hierarchies with | |
794 the subscription method in this variable.") | |
795 | |
796 (defvar gnus-subscribe-hierarchical-interactive nil | |
797 "*If non-nil, Gnus will offer to subscribe hierarchically. | |
798 When a new hierarchy appears, Gnus will ask the user: | |
799 | |
800 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys): | |
801 | |
802 If the user pressed `d', Gnus will descend the hierarchy, `y' will | |
803 subscribe to all newsgroups in the hierarchy and `s' will skip this | |
804 hierarchy in its entirety.") | |
805 | |
806 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet | |
807 "*Function used for sorting the group buffer. | |
808 This function will be called with group info entries as the arguments | |
809 for the groups to be sorted. Pre-made functions include | |
810 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-unread' and | |
811 `gnus-group-sort-by-level'") | |
812 | |
813 ;; Mark variables suggested by Thomas Michanek | |
814 ;; <Thomas.Michanek@telelogic.se>. | |
815 (defvar gnus-unread-mark ? | |
816 "*Mark used for unread articles.") | |
817 (defvar gnus-ticked-mark ?! | |
818 "*Mark used for ticked articles.") | |
819 (defvar gnus-dormant-mark ?? | |
820 "*Mark used for dormant articles.") | |
821 (defvar gnus-del-mark ?r | |
822 "*Mark used for del'd articles.") | |
823 (defvar gnus-read-mark ?R | |
824 "*Mark used for read articles.") | |
825 (defvar gnus-expirable-mark ?E | |
826 "*Mark used for expirable articles.") | |
827 (defvar gnus-killed-mark ?K | |
828 "*Mark used for killed articles.") | |
829 (defvar gnus-kill-file-mark ?X | |
830 "*Mark used for articles killed by kill files.") | |
831 (defvar gnus-low-score-mark ?Y | |
832 "*Mark used for articles with a low score.") | |
833 (defvar gnus-catchup-mark ?C | |
834 "*Mark used for articles that are caught up.") | |
835 (defvar gnus-replied-mark ?A | |
836 "*Mark used for articles that have been replied to.") | |
837 (defvar gnus-process-mark ?# | |
838 "*Process mark.") | |
839 (defvar gnus-ancient-mark ?O | |
840 "*Mark used for ancient articles.") | |
841 (defvar gnus-canceled-mark ?G | |
842 "*Mark used for canceled articles.") | |
843 (defvar gnus-score-over-mark ?+ | |
844 "*Score mark used for articles with high scores.") | |
845 (defvar gnus-score-below-mark ?- | |
846 "*Score mark used for articles with low scores.") | |
847 (defvar gnus-empty-thread-mark ? | |
848 "*There is no thread under the article.") | |
849 (defvar gnus-not-empty-thread-mark ?= | |
850 "*There is a thread under the article.") | |
851 (defvar gnus-dummy-mark ?Z | |
852 "*This is a dummy article.") | |
853 | |
854 (defvar gnus-view-pseudo-asynchronously nil | |
855 "*If non-nil, Gnus will view pseudo-articles asynchronously.") | |
856 | |
857 (defvar gnus-view-pseudos nil | |
858 "*If `automatic', pseudo-articles will be viewed automatically. | |
859 If `not-confirm', pseudos will be viewed automatically, and the user | |
860 will not be asked to confirm the command.") | |
861 | |
862 (defvar gnus-view-pseudos-separately t | |
863 "*If non-nil, one pseudo-article will be created for each file to be viewed. | |
864 If nil, all files that use the same viewing command will be given as a | |
865 list of parameters to that command.") | |
866 | |
867 (defvar gnus-group-line-format "%M%S%p%5y: %(%g%)\n" | |
868 "*Format of group lines. | |
869 It works along the same lines as a normal formatting string, | |
870 with some simple extensions. | |
871 | |
872 %M Only marked articles (character, \"*\" or \" \") | |
873 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \") | |
874 %L Level of subscribedness (integer) | |
875 %N Number of unread articles (integer) | |
876 %I Number of dormant articles (integer) | |
877 %i Number of ticked and dormant (integer) | |
878 %T Number of ticked articles (integer) | |
879 %R Number of read articles (integer) | |
880 %t Total number of articles (integer) | |
881 %y Number of unread, unticked articles (integer) | |
882 %G Group name (string) | |
883 %g Qualified group name (string) | |
884 %D Group description (string) | |
885 %s Select method (string) | |
886 %o Moderated group (char, \"m\") | |
887 %p Process mark (char) | |
888 %O Moderated group (string, \"(m)\" or \"\") | |
889 %n Select from where (string) | |
890 %z A string that look like `<%s:%n>' if a foreign select method is used | |
891 %u User defined specifier. The next character in the format string should | |
892 be a letter. Gnus will call the function gnus-user-format-function-X, | |
893 where X is the letter following %u. The function will be passed the | |
894 current header as argument. The function should return a string, which | |
895 will be inserted into the buffer just like information from any other | |
896 group specifier. | |
897 | |
898 Text between %( and %) will be highlighted with `gnus-mouse-face' when | |
899 the mouse point move inside the area. There can only be one such area. | |
900 | |
901 Note that this format specification is not always respected. For | |
902 reasons of efficiency, when listing killed groups, this specification | |
903 is ignored altogether. If the spec is changed considerably, your | |
904 output may end up looking strange when listing both alive and killed | |
905 groups. | |
906 | |
907 If you use %o or %O, reading the active file will be slower and quite | |
908 a bit of extra memory will be used. %D will also worsen performance. | |
909 Also note that if you change the format specification to include any | |
910 of these specs, you must probably re-start Gnus to see them go into | |
911 effect.") | |
912 | |
913 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n" | |
914 "*The format specification of the lines in the summary buffer. | |
915 | |
916 It works along the same lines as a normal formatting string, | |
917 with some simple extensions. | |
918 | |
919 %N Article number, left padded with spaces (string) | |
920 %S Subject (string) | |
921 %s Subject if it is at the root of a thread, and \"\" otherwise (string) | |
922 %n Name of the poster (string) | |
923 %a Extracted name of the poster (string) | |
924 %A Extracted address of the poster (string) | |
925 %F Contents of the From: header (string) | |
926 %x Contents of the Xref: header (string) | |
927 %D Date of the article (string) | |
928 %d Date of the article (string) in DD-MMM format | |
929 %M Message-id of the article (string) | |
930 %r References of the article (string) | |
931 %c Number of characters in the article (integer) | |
932 %L Number of lines in the article (integer) | |
933 %I Indentation based on thread level (a string of spaces) | |
934 %T A string with two possible values: 80 spaces if the article | |
935 is on thread level two or larger and 0 spaces on level one | |
936 %R \"A\" if this article has been replied to, \" \" otherwise (character) | |
937 %U Status of this article (character, \"R\", \"K\", \"-\" or \" \") | |
938 %[ Opening bracket (character, \"[\" or \"<\") | |
939 %] Closing bracket (character, \"]\" or \">\") | |
940 %> Spaces of length thread-level (string) | |
941 %< Spaces of length (- 20 thread-level) (string) | |
942 %i Article score (number) | |
943 %z Article zcore (character) | |
944 %t Number of articles under the current thread (number). | |
945 %e Whether the thread is empty or not (character). | |
946 %u User defined specifier. The next character in the format string should | |
947 be a letter. Gnus will call the function gnus-user-format-function-X, | |
948 where X is the letter following %u. The function will be passed the | |
949 current header as argument. The function should return a string, which | |
950 will be inserted into the summary just like information from any other | |
951 summary specifier. | |
952 | |
953 Text between %( and %) will be highlighted with `gnus-mouse-face' | |
954 when the mouse point is placed inside the area. There can only be one | |
955 such area. | |
956 | |
957 The %U (status), %R (replied) and %z (zcore) specs have to be handled | |
958 with care. For reasons of efficiency, Gnus will compute what column | |
959 these characters will end up in, and \"hard-code\" that. This means that | |
960 it is illegal to have these specs after a variable-length spec. Well, | |
961 you might not be arrested, but your summary buffer will look strange, | |
962 which is bad enough. | |
963 | |
964 The smart choice is to have these specs as for to the left as | |
965 possible. | |
966 | |
967 This restriction may disappear in later versions of Gnus.") | |
968 | |
969 (defvar gnus-summary-dummy-line-format "* : : %S\n" | |
970 "*The format specification for the dummy roots in the summary buffer. | |
971 It works along the same lines as a normal formatting string, | |
972 with some simple extensions. | |
973 | |
974 %S The subject") | |
975 | |
976 (defvar gnus-summary-mode-line-format "Gnus %G/%A %Z" | |
977 "*The format specification for the summary mode line.") | |
978 | |
979 (defvar gnus-article-mode-line-format "Gnus %G/%A %S" | |
980 "*The format specification for the article mode line.") | |
981 | |
982 (defvar gnus-group-mode-line-format "Gnus List of groups {%M:%S} " | |
983 "*The format specification for the group mode line.") | |
984 | |
985 (defvar gnus-valid-select-methods | |
986 '(("nntp" post address prompt-address) | |
987 ("nnspool" post) | |
988 ("nnvirtual" none virtual prompt-address) | |
989 ("nnmbox" mail respool) | |
990 ("nnml" mail respool) | |
991 ("nnmh" mail respool) | |
992 ("nndir" none prompt-address address) | |
993 ("nneething" none prompt-address) | |
994 ("nndigest" none) | |
995 ("nndoc" none prompt-address) | |
996 ("nnbabyl" mail respool) | |
997 ("nnkiboze" post virtual) | |
998 ;;("nnsoup" post) | |
999 ("nnfolder" mail respool)) | |
1000 "An alist of valid select methods. | |
1001 The first element of each list lists should be a string with the name | |
1002 of the select method. The other elements may be be the category of | |
1003 this method (ie. `post', `mail', `none' or whatever) or other | |
1004 properties that this method has (like being respoolable). | |
1005 If you implement a new select method, all you should have to change is | |
1006 this variable. I think.") | |
1007 | |
1008 (defvar gnus-updated-mode-lines '(group article summary) | |
1009 "*List of buffers that should update their mode lines. | |
1010 The list may contain the symbols `group', `article' and `summary'. If | |
1011 the corresponding symbol is present, Gnus will keep that mode line | |
1012 updated with information that may be pertinent. | |
1013 If this variable is nil, screen refresh may be quicker.") | |
1014 | |
1015 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>. | |
1016 (defvar gnus-mode-non-string-length 21 | |
1017 "*Max length of mode-line non-string contents. | |
1018 If this is nil, Gnus will take space as is needed, leaving the rest | |
1019 of the modeline intact.") | |
1020 | |
1021 ;see gnus-cus.el | |
1022 ;(defvar gnus-mouse-face 'highlight | |
1023 ; "*Face used for mouse highlighting in Gnus. | |
1024 ;No mouse highlights will be done if `gnus-visual' is nil.") | |
1025 | |
1026 (defvar gnus-summary-mark-below nil | |
1027 "*Mark all articles with a score below this variable as read. | |
1028 This variable is local to each summary buffer and usually set by the | |
1029 score file.") | |
1030 | |
1031 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number) | |
1032 "*List of functions used for sorting threads in the summary buffer. | |
1033 By default, threads are sorted by article number. | |
1034 | |
1035 Each function takes two threads and return non-nil if the first thread | |
1036 should be sorted before the other. If you use more than one function, | |
1037 the primary sort function should be the last. | |
1038 | |
1039 Ready-mady functions include `gnus-thread-sort-by-number', | |
1040 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject', | |
1041 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and | |
1042 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').") | |
1043 | |
1044 (defvar gnus-thread-score-function '+ | |
1045 "*Function used for calculating the total score of a thread. | |
1046 | |
1047 The function is called with the scores of the article and each | |
1048 subthread and should then return the score of the thread. | |
1049 | |
1050 Some functions you can use are `+', `max', or `min'.") | |
1051 | |
1052 (defvar gnus-options-subscribe nil | |
1053 "*All new groups matching this regexp will be subscribed unconditionally. | |
1054 Note that this variable deals only with new newsgroups. This variable | |
1055 does not affect old newsgroups.") | |
1056 | |
1057 (defvar gnus-options-not-subscribe nil | |
1058 "*All new groups matching this regexp will be ignored. | |
1059 Note that this variable deals only with new newsgroups. This variable | |
1060 does not affect old (already subscribed) newsgroups.") | |
1061 | |
1062 (defvar gnus-auto-expirable-newsgroups nil | |
1063 "*Groups in which to automatically mark read articles as expirable. | |
1064 If non-nil, this should be a regexp that should match all groups in | |
1065 which to perform auto-expiry. This only makes sense for mail groups.") | |
1066 | |
1067 (defvar gnus-hidden-properties '(invisible t intangible t) | |
1068 "Property list to use for hiding text.") | |
1069 | |
1070 (defvar gnus-modtime-botch nil | |
1071 "*Non-nil means .newsrc should be deleted prior to save. Its use is | |
1072 due to the bogus appearance that .newsrc was modified on disc.") | |
1073 | |
1074 ;; Hooks. | |
1075 | |
1076 (defvar gnus-group-mode-hook nil | |
1077 "*A hook for Gnus group mode.") | |
1078 | |
1079 (defvar gnus-summary-mode-hook nil | |
1080 "*A hook for Gnus summary mode. | |
1081 This hook is run before any variables are set in the summary buffer.") | |
1082 | |
1083 (defvar gnus-article-mode-hook nil | |
1084 "*A hook for Gnus article mode.") | |
1085 | |
1086 (defun gnus-summary-prepare-exit-hook nil | |
1087 "*A hook called when preparing to exit from the summary buffer. | |
1088 It calls `gnus-summary-expire-articles' by default.") | |
1089 (add-hook 'gnus-summary-prepare-exit-hook 'gnus-summary-expire-articles) | |
1090 | |
1091 (defun gnus-summary-exit-hook nil | |
1092 "*A hook called on exit from the summary buffer.") | |
1093 | |
1094 (defvar gnus-open-server-hook nil | |
1095 "*A hook called just before opening connection to the news server.") | |
1096 | |
1097 (defvar gnus-load-hook nil | |
1098 "*A hook run while Gnus is loaded.") | |
1099 | |
1100 (defvar gnus-startup-hook nil | |
1101 "*A hook called at startup. | |
1102 This hook is called after Gnus is connected to the NNTP server.") | |
1103 | |
1104 (defvar gnus-get-new-news-hook nil | |
1105 "*A hook run just before Gnus checks for new news.") | |
1106 | |
1107 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat | |
1108 "*A function that is called to generate the group buffer. | |
1109 The function is called with three arguments: The first is a number; | |
1110 all group with a level less or equal to that number should be listed, | |
1111 if the second is non-nil, empty groups should also be displayed. If | |
1112 the third is non-nil, it is a number. No groups with a level lower | |
1113 than this number should be displayed. | |
1114 | |
1115 The only current function implemented is `gnus-group-prepare-flat'.") | |
1116 | |
1117 (defvar gnus-group-prepare-hook nil | |
1118 "*A hook called after the group buffer has been generated. | |
1119 If you want to modify the group buffer, you can use this hook.") | |
1120 | |
1121 (defvar gnus-summary-prepare-hook nil | |
1122 "*A hook called after the summary buffer has been generated. | |
1123 If you want to modify the summary buffer, you can use this hook.") | |
1124 | |
1125 (defvar gnus-article-prepare-hook nil | |
1126 "*A hook called after an article has been prepared in the article buffer. | |
1127 If you want to run a special decoding program like nkf, use this hook.") | |
1128 | |
1129 ;(defvar gnus-article-display-hook nil | |
1130 ; "*A hook called after the article is displayed in the article buffer. | |
1131 ;The hook is designed to change the contents of the article | |
1132 ;buffer. Typical functions that this hook may contain are | |
1133 ;`gnus-article-hide-headers' (hide selected headers), | |
1134 ;`gnus-article-maybe-highlight' (perform fancy article highlighting), | |
1135 ;`gnus-article-hide-signature' (hide signature) and | |
1136 ;`gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).") | |
1137 ;(add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted) | |
1138 ;(add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike) | |
1139 ;(add-hook 'gnus-article-display-hook 'gnus-article-maybe-highlight) | |
1140 | |
1141 (defvar gnus-article-x-face-command | |
1142 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -" | |
1143 "String or function to be executed to display an X-Face header. | |
1144 If it is a string, the command will be executed in a sub-shell | |
1145 asynchronously. The compressed face will be piped to this command.") | |
1146 | |
1147 (defvar gnus-article-x-face-too-ugly nil | |
1148 "Regexp matching posters whose face shouldn't be shown automatically.") | |
1149 | |
1150 (defvar gnus-select-group-hook nil | |
1151 "*A hook called when a newsgroup is selected. | |
1152 | |
1153 If you'd like to simplify subjects like the | |
1154 `gnus-summary-next-same-subject' command does, you can use the | |
1155 following hook: | |
1156 | |
1157 (setq gnus-select-group-hook | |
1158 (list | |
1159 (lambda () | |
1160 (mapcar (lambda (header) | |
1161 (mail-header-set-subject | |
1162 header | |
1163 (gnus-simplify-subject | |
1164 (mail-header-subject header) 're-only))) | |
1165 gnus-newsgroup-headers))))") | |
1166 | |
1167 (defvar gnus-select-article-hook | |
1168 '(gnus-summary-show-thread) | |
1169 "*A hook called when an article is selected. | |
1170 The default hook shows conversation thread subtrees of the selected | |
1171 article automatically using `gnus-summary-show-thread'.") | |
1172 | |
1173 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file) | |
1174 "*A hook called to apply kill files to a group. | |
1175 This hook is intended to apply a kill file to the selected newsgroup. | |
1176 The function `gnus-apply-kill-file' is called by default. | |
1177 | |
1178 Since a general kill file is too heavy to use only for a few | |
1179 newsgroups, I recommend you to use a lighter hook function. For | |
1180 example, if you'd like to apply a kill file to articles which contains | |
1181 a string `rmgroup' in subject in newsgroup `control', you can use the | |
1182 following hook: | |
1183 | |
1184 (setq gnus-apply-kill-hook | |
1185 (list | |
1186 (lambda () | |
1187 (cond ((string-match \"control\" gnus-newsgroup-name) | |
1188 (gnus-kill \"Subject\" \"rmgroup\") | |
1189 (gnus-expunge \"X\"))))))") | |
1190 | |
1191 (defvar gnus-visual-mark-article-hook | |
1192 (list 'gnus-highlight-selected-summary) | |
1193 "*Hook run after selecting an article in the summary buffer. | |
1194 It is meant to be used for highlighting the article in some way. It | |
1195 is not run if `gnus-visual' is nil.") | |
1196 | |
13694
73433c3071a5
* gnus.el (gnus-parse-headers-hook): New hook.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
13579
diff
changeset
|
1197 (defun gnus-parse-headers-hook nil |
73433c3071a5
* gnus.el (gnus-parse-headers-hook): New hook.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
13579
diff
changeset
|
1198 "*A hook called before parsing the headers.") |
73433c3071a5
* gnus.el (gnus-parse-headers-hook): New hook.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
13579
diff
changeset
|
1199 |
13401 | 1200 (defvar gnus-exit-group-hook nil |
1201 "*A hook called when exiting (not quitting) summary mode.") | |
1202 | |
1203 (defvar gnus-suspend-gnus-hook nil | |
1204 "*A hook called when suspending (not exiting) Gnus.") | |
1205 | |
1206 (defvar gnus-exit-gnus-hook nil | |
1207 "*A hook called when exiting Gnus.") | |
1208 | |
1209 (defvar gnus-save-newsrc-hook nil | |
1210 "*A hook called when saving the newsrc file.") | |
1211 | |
1212 (defvar gnus-summary-update-hook | |
1213 (list 'gnus-summary-highlight-line) | |
1214 "*A hook called when a summary line is changed. | |
1215 The hook will not be called if `gnus-visual' is nil. | |
1216 | |
1217 The default function `gnus-summary-highlight-line' will | |
1218 highlight the line according to the `gnus-summary-highlight' | |
1219 variable.") | |
1220 | |
1221 (defvar gnus-mark-article-hook (list 'gnus-summary-mark-unread-as-read) | |
1222 "*A hook called when an article is selected for the first time. | |
1223 The hook is intended to mark an article as read (or unread) | |
1224 automatically when it is selected.") | |
1225 | |
1226 ;; Remove any hilit infestation. | |
1227 (add-hook 'gnus-startup-hook | |
1228 (lambda () | |
1229 (remove-hook 'gnus-summary-prepare-hook | |
1230 'hilit-rehighlight-buffer-quietly) | |
1231 (remove-hook 'gnus-summary-prepare-hook 'hilit-install-line-hooks) | |
1232 (setq gnus-mark-article-hook '(gnus-summary-mark-unread-as-read)) | |
1233 (remove-hook 'gnus-article-prepare-hook | |
1234 'hilit-rehighlight-buffer-quietly))) | |
1235 | |
1236 | |
1237 | |
1238 ;; Internal variables | |
1239 | |
1240 ;; Avoid highlighting in kill files. | |
1241 (defvar gnus-summary-inhibit-highlight nil) | |
1242 (defvar gnus-newsgroup-selected-overlay nil) | |
1243 | |
1244 (defvar gnus-article-mode-map nil) | |
1245 (defvar gnus-dribble-buffer nil) | |
1246 (defvar gnus-headers-retrieved-by nil) | |
1247 (defvar gnus-article-reply nil) | |
1248 (defvar gnus-override-method nil) | |
1249 (defvar gnus-article-check-size nil) | |
1250 | |
1251 (defvar gnus-current-score-file nil) | |
1252 (defvar gnus-internal-global-score-files nil) | |
1253 (defvar gnus-score-file-list nil) | |
1254 (defvar gnus-scores-exclude-files nil) | |
1255 | |
1256 (defvar gnus-current-move-group nil) | |
1257 | |
1258 (defvar gnus-newsgroup-dependencies nil) | |
1259 (defvar gnus-newsgroup-threads nil) | |
1260 (defvar gnus-newsgroup-async nil) | |
1261 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*") | |
1262 | |
1263 (defvar gnus-newsgroup-adaptive nil) | |
1264 | |
1265 (defvar gnus-summary-display-table nil) | |
1266 | |
1267 (defconst gnus-group-line-format-alist | |
1268 (list (list ?M 'marked ?c) | |
1269 (list ?S 'subscribed ?c) | |
1270 (list ?L 'level ?d) | |
1271 (list ?N 'number ?s) | |
1272 (list ?I 'number-of-dormant ?d) | |
1273 (list ?T 'number-of-ticked ?d) | |
1274 (list ?R 'number-of-read ?s) | |
1275 (list ?t 'number-total ?d) | |
1276 (list ?y 'number-of-unread-unticked ?s) | |
1277 (list ?i 'number-of-ticked-and-dormant ?d) | |
1278 (list ?g 'group ?s) | |
1279 (list ?G 'qualified-group ?s) | |
1280 (list ?D 'newsgroup-description ?s) | |
1281 (list ?o 'moderated ?c) | |
1282 (list ?O 'moderated-string ?s) | |
1283 (list ?p 'process-marked ?c) | |
1284 (list ?s 'news-server ?s) | |
1285 (list ?n 'news-method ?s) | |
1286 (list ?z 'news-method-string ?s) | |
1287 (list ?u 'user-defined ?s))) | |
1288 | |
1289 (defconst gnus-summary-line-format-alist | |
1290 (list (list ?N 'number ?d) | |
1291 (list ?S 'subject ?s) | |
1292 (list ?s 'subject-or-nil ?s) | |
1293 (list ?n 'name ?s) | |
1294 (list ?A '(car (cdr (funcall gnus-extract-address-components from))) | |
1295 ?s) | |
1296 (list ?a '(or (car (funcall gnus-extract-address-components from)) | |
1297 from) ?s) | |
1298 (list ?F 'from ?s) | |
1299 (list ?x (macroexpand '(mail-header-xref header)) ?s) | |
1300 (list ?D (macroexpand '(mail-header-date header)) ?s) | |
1301 (list ?d '(gnus-dd-mmm (mail-header-date header)) ?s) | |
1302 (list ?M (macroexpand '(mail-header-id header)) ?s) | |
1303 (list ?r (macroexpand '(mail-header-references header)) ?s) | |
1304 (list ?c '(or (mail-header-chars header) 0) ?d) | |
1305 (list ?L 'lines ?d) | |
1306 (list ?I 'indentation ?s) | |
1307 (list ?T '(if (= level 0) "" (make-string (frame-width) ? )) ?s) | |
1308 (list ?R 'replied ?c) | |
1309 (list ?\[ 'opening-bracket ?c) | |
1310 (list ?\] 'closing-bracket ?c) | |
1311 (list ?\> '(make-string level ? ) ?s) | |
1312 (list ?\< '(make-string (max 0 (- 20 level)) ? ) ?s) | |
1313 (list ?i 'score ?d) | |
1314 (list ?z 'score-char ?c) | |
1315 (list ?U 'unread ?c) | |
1316 (list ?t '(gnus-summary-number-of-articles-in-thread | |
1317 (and (boundp 'thread) (car thread))) | |
1318 ?d) | |
1319 (list ?e '(gnus-summary-number-of-articles-in-thread | |
1320 (and (boundp 'thread) (car thread)) t) | |
1321 ?c) | |
1322 (list ?u 'user-defined ?s)) | |
1323 "An alist of format specifications that can appear in summary lines, | |
1324 and what variables they correspond with, along with the type of the | |
1325 variable (string, integer, character, etc).") | |
1326 | |
1327 (defconst gnus-summary-dummy-line-format-alist | |
1328 (list (list ?S 'subject ?s) | |
1329 (list ?N 'number ?d) | |
1330 (list ?u 'user-defined ?s))) | |
1331 | |
1332 (defconst gnus-summary-mode-line-format-alist | |
1333 (list (list ?G 'group-name ?s) | |
1334 (list ?g '(gnus-short-group-name group-name) ?s) | |
1335 (list ?A 'article-number ?d) | |
1336 (list ?Z 'unread-and-unselected ?s) | |
1337 (list ?V 'gnus-version ?s) | |
1338 (list ?U 'unread ?d) | |
1339 (list ?S 'subject ?s) | |
1340 (list ?e 'unselected ?d) | |
1341 (list ?u 'user-defined ?s) | |
1342 (list ?s '(gnus-current-score-file-nondirectory) ?s))) | |
1343 | |
1344 (defconst gnus-group-mode-line-format-alist | |
1345 (list (list ?S 'news-server ?s) | |
1346 (list ?M 'news-method ?s) | |
1347 (list ?u 'user-defined ?s))) | |
1348 | |
1349 (defvar gnus-have-read-active-file nil) | |
1350 | |
1351 (defconst gnus-maintainer | |
1352 "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)" | |
1353 "The mail address of the Gnus maintainers.") | |
1354 | |
1355 (defconst gnus-version "Gnus v5.1" | |
1356 "Version number for this version of Gnus.") | |
1357 | |
1358 (defvar gnus-info-nodes | |
1359 '((gnus-group-mode "(gnus)The Group Buffer") | |
1360 (gnus-summary-mode "(gnus)The Summary Buffer") | |
1361 (gnus-article-mode "(gnus)The Article Buffer")) | |
1362 "Assoc list of major modes and related Info nodes.") | |
1363 | |
1364 (defvar gnus-group-buffer "*Group*") | |
1365 (defvar gnus-summary-buffer "*Summary*") | |
1366 (defvar gnus-article-buffer "*Article*") | |
1367 (defvar gnus-server-buffer "*Server*") | |
1368 | |
1369 (defvar gnus-work-buffer " *gnus work*") | |
1370 | |
1371 (defvar gnus-buffer-list nil | |
1372 "Gnus buffers that should be killed on exit.") | |
1373 | |
1374 (defvar gnus-server-alist nil | |
1375 "List of available servers.") | |
1376 | |
1377 (defvar gnus-variable-list | |
1378 '(gnus-newsrc-options gnus-newsrc-options-n | |
1379 gnus-newsrc-last-checked-date | |
1380 gnus-newsrc-alist gnus-server-alist | |
1381 gnus-killed-list gnus-zombie-list) | |
1382 "Gnus variables saved in the quick startup file.") | |
1383 | |
1384 (defvar gnus-overload-functions | |
1385 '((news-inews gnus-inews-news "rnewspost")) | |
1386 "Functions overloaded by gnus. | |
1387 It is a list of `(original overload &optional file)'.") | |
1388 | |
1389 (defvar gnus-newsrc-options nil | |
1390 "Options line in the .newsrc file.") | |
1391 | |
1392 (defvar gnus-newsrc-options-n nil | |
1393 "List of regexps representing groups to be subscribed/ignored unconditionally.") | |
1394 | |
1395 (defvar gnus-newsrc-last-checked-date nil | |
1396 "Date Gnus last asked server for new newsgroups.") | |
1397 | |
1398 (defvar gnus-newsrc-alist nil | |
1399 "Assoc list of read articles. | |
1400 gnus-newsrc-hashtb should be kept so that both hold the same information.") | |
1401 | |
1402 (defvar gnus-newsrc-hashtb nil | |
1403 "Hashtable of gnus-newsrc-alist.") | |
1404 | |
1405 (defvar gnus-killed-list nil | |
1406 "List of killed newsgroups.") | |
1407 | |
1408 (defvar gnus-killed-hashtb nil | |
1409 "Hash table equivalent of gnus-killed-list.") | |
1410 | |
1411 (defvar gnus-zombie-list nil | |
1412 "List of almost dead newsgroups.") | |
1413 | |
1414 (defvar gnus-description-hashtb nil | |
1415 "Descriptions of newsgroups.") | |
1416 | |
1417 (defvar gnus-list-of-killed-groups nil | |
1418 "List of newsgroups that have recently been killed by the user.") | |
1419 | |
1420 (defvar gnus-active-hashtb nil | |
1421 "Hashtable of active articles.") | |
1422 | |
1423 (defvar gnus-moderated-list nil | |
1424 "List of moderated newsgroups.") | |
1425 | |
1426 (defvar gnus-group-marked nil) | |
1427 | |
1428 (defvar gnus-current-startup-file nil | |
1429 "Startup file for the current host.") | |
1430 | |
1431 (defvar gnus-last-search-regexp nil | |
1432 "Default regexp for article search command.") | |
1433 | |
1434 (defvar gnus-last-shell-command nil | |
1435 "Default shell command on article.") | |
1436 | |
1437 (defvar gnus-current-select-method nil | |
1438 "The current method for selecting a newsgroup.") | |
1439 | |
1440 (defvar gnus-group-list-mode nil) | |
1441 | |
1442 (defvar gnus-article-internal-prepare-hook nil) | |
1443 | |
1444 (defvar gnus-newsgroup-name nil) | |
1445 (defvar gnus-newsgroup-begin nil) | |
1446 (defvar gnus-newsgroup-end nil) | |
1447 (defvar gnus-newsgroup-last-rmail nil) | |
1448 (defvar gnus-newsgroup-last-mail nil) | |
1449 (defvar gnus-newsgroup-last-folder nil) | |
1450 (defvar gnus-newsgroup-last-file nil) | |
1451 (defvar gnus-newsgroup-auto-expire nil) | |
1452 (defvar gnus-newsgroup-active nil) | |
1453 | |
1454 (defvar gnus-newsgroup-unreads nil | |
1455 "List of unread articles in the current newsgroup.") | |
1456 | |
1457 (defvar gnus-newsgroup-unselected nil | |
1458 "List of unselected unread articles in the current newsgroup.") | |
1459 | |
1460 (defvar gnus-newsgroup-reads nil | |
1461 "Alist of read articles and article marks in the current newsgroup.") | |
1462 | |
1463 (defvar gnus-newsgroup-marked nil | |
1464 "List of ticked articles in the current newsgroup (a subset of unread art).") | |
1465 | |
1466 (defvar gnus-newsgroup-killed nil | |
1467 "List of ranges of articles that have been through the scoring process.") | |
1468 | |
1469 (defvar gnus-newsgroup-kill-headers nil) | |
1470 | |
1471 (defvar gnus-newsgroup-replied nil | |
1472 "List of articles that have been replied to in the current newsgroup.") | |
1473 | |
1474 (defvar gnus-newsgroup-expirable nil | |
1475 "List of articles in the current newsgroup that can be expired.") | |
1476 | |
1477 (defvar gnus-newsgroup-processable nil | |
1478 "List of articles in the current newsgroup that can be processed.") | |
1479 | |
1480 (defvar gnus-newsgroup-bookmarks nil | |
1481 "List of articles in the current newsgroup that have bookmarks.") | |
1482 | |
1483 (defvar gnus-newsgroup-dormant nil | |
1484 "List of dormant articles in the current newsgroup.") | |
1485 | |
1486 (defvar gnus-newsgroup-scored nil | |
1487 "List of scored articles in the current newsgroup.") | |
1488 | |
1489 (defvar gnus-newsgroup-headers nil | |
1490 "List of article headers in the current newsgroup.") | |
1491 (defvar gnus-newsgroup-headers-hashtb-by-number nil) | |
1492 | |
1493 (defvar gnus-newsgroup-ancient nil | |
1494 "List of `gnus-fetch-old-headers' articles in the current newsgroup.") | |
1495 | |
1496 (defvar gnus-current-article nil) | |
1497 (defvar gnus-article-current nil) | |
1498 (defvar gnus-current-headers nil) | |
1499 (defvar gnus-have-all-headers nil) | |
1500 (defvar gnus-last-article nil) | |
1501 (defvar gnus-newsgroup-history nil) | |
1502 (defvar gnus-current-kill-article nil) | |
1503 | |
1504 ;; Save window configuration. | |
1505 (defvar gnus-prev-winconf nil) | |
1506 | |
1507 ;; Format specs | |
1508 (defvar gnus-summary-line-format-spec nil) | |
1509 (defvar gnus-summary-dummy-line-format-spec nil) | |
1510 (defvar gnus-group-line-format-spec nil) | |
1511 (defvar gnus-summary-mode-line-format-spec nil) | |
1512 (defvar gnus-article-mode-line-format-spec nil) | |
1513 (defvar gnus-group-mode-line-format-spec nil) | |
1514 (defvar gnus-summary-mark-positions nil) | |
1515 (defvar gnus-group-mark-positions nil) | |
1516 | |
1517 (defvar gnus-summary-expunge-below nil) | |
1518 (defvar gnus-reffed-article-number nil) | |
1519 | |
1520 ; Let the byte-compiler know that we know about this variable. | |
1521 (defvar rmail-default-rmail-file) | |
1522 | |
1523 (defvar gnus-cache-removeable-articles nil) | |
1524 | |
1525 (defconst gnus-summary-local-variables | |
1526 '(gnus-newsgroup-name | |
1527 gnus-newsgroup-begin gnus-newsgroup-end | |
1528 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail | |
1529 gnus-newsgroup-last-folder gnus-newsgroup-last-file | |
1530 gnus-newsgroup-auto-expire gnus-newsgroup-unreads | |
1531 gnus-newsgroup-unselected gnus-newsgroup-marked | |
1532 gnus-newsgroup-reads | |
1533 gnus-newsgroup-replied gnus-newsgroup-expirable | |
1534 gnus-newsgroup-processable gnus-newsgroup-killed | |
1535 gnus-newsgroup-bookmarks gnus-newsgroup-dormant | |
1536 gnus-newsgroup-headers gnus-newsgroup-headers-hashtb-by-number | |
1537 gnus-current-article gnus-current-headers gnus-have-all-headers | |
1538 gnus-last-article gnus-article-internal-prepare-hook | |
1539 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay | |
1540 gnus-newsgroup-scored gnus-newsgroup-kill-headers | |
1541 gnus-newsgroup-threads gnus-newsgroup-async | |
1542 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below | |
1543 gnus-summary-mark-below gnus-newsgroup-active gnus-scores-exclude-files | |
1544 gnus-newsgroup-history gnus-newsgroup-ancient | |
1545 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring) | |
1546 gnus-cache-removeable-articles) | |
1547 "Variables that are buffer-local to the summary buffers.") | |
1548 | |
1549 (defconst gnus-bug-message | |
1550 "Sending a bug report to the Gnus Towers. | |
1551 ======================================== | |
1552 | |
1553 The buffer below is a mail buffer. When you press `C-c C-c', it will | |
1554 be sent to the Gnus Bug Exterminators. | |
1555 | |
1556 At the bottom of the buffer you'll see lots of variable settings. | |
1557 Please do not delete those. They will tell the Bug People what your | |
1558 environment is, so that it will be easier to locate the bugs. | |
1559 | |
1560 If you have found a bug that makes Emacs go \"beep\", set | |
1561 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET') | |
1562 and include the backtrace in your bug report. | |
1563 | |
1564 Please describe the bug in annoying, painstaking detail. | |
1565 | |
1566 Thank you for your help in stamping out bugs. | |
1567 ") | |
1568 | |
1569 ;;; End of variables. | |
1570 | |
1571 ;; Define some autoload functions Gnus might use. | |
1572 (eval-and-compile | |
1573 | |
1574 ;; Various | |
1575 (autoload 'metamail-buffer "metamail") | |
1576 (autoload 'Info-goto-node "info") | |
1577 (autoload 'hexl-hex-string-to-integer "hexl") | |
1578 (autoload 'pp "pp") | |
1579 (autoload 'pp-to-string "pp") | |
1580 (autoload 'pp-eval-expression "pp") | |
1581 (autoload 'mail-extract-address-components "mail-extr") | |
1582 | |
1583 (autoload 'nnmail-split-fancy "nnmail") | |
1584 (autoload 'nnvirtual-catchup-group "nnvirtual") | |
1585 | |
1586 ;; timezone | |
1587 (autoload 'timezone-make-date-arpa-standard "timezone") | |
1588 (autoload 'timezone-fix-time "timezone") | |
1589 (autoload 'timezone-make-sortable-date "timezone") | |
1590 (autoload 'timezone-make-time-string "timezone") | |
1591 | |
1592 ;; rmail & friends | |
1593 (autoload 'mail-position-on-field "sendmail") | |
1594 (autoload 'mail-setup "sendmail") | |
1595 (autoload 'rmail-output "rmailout") | |
1596 (autoload 'news-mail-other-window "rnewspost") | |
1597 (autoload 'news-reply-yank-original "rnewspost") | |
1598 (autoload 'news-caesar-buffer-body "rnewspost") | |
1599 (autoload 'rmail-insert-rmail-file-header "rmail") | |
1600 (autoload 'rmail-count-new-messages "rmail") | |
1601 (autoload 'rmail-show-message "rmail") | |
1602 | |
1603 ;; gnus-soup | |
1604 ;;(autoload 'gnus-group-brew-soup "gnus-soup" nil t) | |
1605 ;;(autoload 'gnus-brew-soup "gnus-soup" nil t) | |
1606 ;;(autoload 'gnus-soup-add-article "gnus-soup" nil t) | |
1607 ;;(autoload 'gnus-soup-send-replies "gnus-soup" nil t) | |
1608 ;;(autoload 'gnus-soup-save-areas "gnus-soup" nil t) | |
1609 ;;(autoload 'gnus-soup-pack-packet "gnus-soup" nil t) | |
1610 ;;(autoload 'nnsoup-pack-replies "nnsoup" nil t) | |
1611 | |
1612 ;; gnus-mh | |
1613 (autoload 'gnus-mail-reply-using-mhe "gnus-mh") | |
1614 (autoload 'gnus-mail-forward-using-mhe "gnus-mh") | |
1615 (autoload 'gnus-mail-other-window-using-mhe "gnus-mh") | |
1616 (autoload 'gnus-summary-save-in-folder "gnus-mh" nil t) | |
1617 (autoload 'gnus-summary-save-article-folder "gnus-mh") | |
1618 (autoload 'gnus-Folder-save-name "gnus-mh") | |
1619 (autoload 'gnus-folder-save-name "gnus-mh") | |
1620 | |
1621 ;; gnus-vis misc | |
1622 (autoload 'gnus-group-make-menu-bar "gnus-vis") | |
1623 (autoload 'gnus-summary-make-menu-bar "gnus-vis") | |
1624 (autoload 'gnus-server-make-menu-bar "gnus-vis") | |
1625 (autoload 'gnus-article-make-menu-bar "gnus-vis") | |
1626 (autoload 'gnus-browse-make-menu-bar "gnus-vis") | |
1627 (autoload 'gnus-highlight-selected-summary "gnus-vis") | |
1628 (autoload 'gnus-summary-highlight-line "gnus-vis") | |
1629 (autoload 'gnus-carpal-setup-buffer "gnus-vis") | |
1630 | |
1631 ;; gnus-vis article | |
1632 (autoload 'gnus-article-push-button "gnus-vis" nil t) | |
1633 (autoload 'gnus-article-press-button "gnus-vis" nil t) | |
1634 (autoload 'gnus-article-highlight "gnus-vis" nil t) | |
1635 (autoload 'gnus-article-highlight-some "gnus-vis" nil t) | |
1636 (autoload 'gnus-article-hide "gnus-vis" nil t) | |
1637 (autoload 'gnus-article-hide-signature "gnus-vis" nil t) | |
1638 (autoload 'gnus-article-highlight-headers "gnus-vis" nil t) | |
1639 (autoload 'gnus-article-highlight-signature "gnus-vis" nil t) | |
1640 (autoload 'gnus-article-add-buttons "gnus-vis" nil t) | |
1641 (autoload 'gnus-article-next-button "gnus-vis" nil t) | |
1642 (autoload 'gnus-article-add-button "gnus-vis") | |
1643 | |
1644 ;; gnus-cite | |
1645 (autoload 'gnus-article-highlight-citation "gnus-cite" nil t) | |
1646 (autoload 'gnus-article-hide-citation-maybe "gnus-cite" nil t) | |
1647 (autoload 'gnus-article-hide-citation "gnus-cite" nil t) | |
1648 | |
1649 ;; gnus-kill | |
1650 (autoload 'gnus-kill "gnus-kill") | |
1651 (autoload 'gnus-apply-kill-file-internal "gnus-kill") | |
1652 (autoload 'gnus-kill-file-edit-file "gnus-kill") | |
1653 (autoload 'gnus-kill-file-raise-followups-to-author "gnus-kill") | |
1654 (autoload 'gnus-execute "gnus-kill") | |
1655 (autoload 'gnus-expunge "gnus-kill") | |
1656 | |
1657 ;; gnus-cache | |
1658 (autoload 'gnus-cache-possibly-enter-article "gnus-cache") | |
1659 (autoload 'gnus-cache-save-buffers "gnus-cache") | |
1660 (autoload 'gnus-cache-possibly-remove-articles "gnus-cache") | |
1661 (autoload 'gnus-cache-request-article "gnus-cache") | |
1662 (autoload 'gnus-cache-retrieve-headers "gnus-cache") | |
1663 (autoload 'gnus-cache-possibly-alter-active "gnus-cache") | |
1664 (autoload 'gnus-jog-cache "gnus-cache" nil t) | |
1665 (autoload 'gnus-cache-enter-remove-article "gnus-cache") | |
1666 | |
1667 ;; gnus-score | |
1668 (autoload 'gnus-summary-increase-score "gnus-score" nil t) | |
1669 (autoload 'gnus-summary-lower-score "gnus-score" nil t) | |
1670 (autoload 'gnus-summary-score-map "gnus-score" nil nil 'keymap) | |
1671 (autoload 'gnus-score-save "gnus-score") | |
1672 (autoload 'gnus-score-headers "gnus-score") | |
1673 (autoload 'gnus-current-score-file-nondirectory "gnus-score") | |
1674 (autoload 'gnus-score-adaptive "gnus-score") | |
1675 (autoload 'gnus-score-remove-lines-adaptive "gnus-score") | |
1676 (autoload 'gnus-score-find-trace "gnus-score") | |
1677 | |
1678 ;; gnus-edit | |
1679 (autoload 'gnus-score-customize "gnus-edit" nil t) | |
1680 | |
1681 ;; gnus-uu | |
1682 (autoload 'gnus-uu-extract-map "gnus-uu" nil nil 'keymap) | |
1683 (autoload 'gnus-uu-mark-map "gnus-uu" nil nil 'keymap) | |
1684 (autoload 'gnus-uu-digest-mail-forward "gnus-uu" nil t) | |
1685 (autoload 'gnus-uu-digest-post-forward "gnus-uu" nil t) | |
1686 (autoload 'gnus-uu-mark-series "gnus-uu" nil t) | |
1687 (autoload 'gnus-uu-mark-region "gnus-uu" nil t) | |
1688 (autoload 'gnus-uu-mark-by-regexp "gnus-uu" nil t) | |
1689 (autoload 'gnus-uu-mark-all "gnus-uu" nil t) | |
1690 (autoload 'gnus-uu-mark-sparse "gnus-uu" nil t) | |
1691 (autoload 'gnus-uu-mark-thread "gnus-uu" nil t) | |
1692 (autoload 'gnus-uu-decode-uu "gnus-uu" nil t) | |
1693 (autoload 'gnus-uu-decode-uu-and-save "gnus-uu" nil t) | |
1694 (autoload 'gnus-uu-decode-unshar "gnus-uu" nil t) | |
1695 (autoload 'gnus-uu-decode-unshar-and-save "gnus-uu" nil t) | |
1696 (autoload 'gnus-uu-decode-save "gnus-uu" nil t) | |
1697 (autoload 'gnus-uu-decode-binhex "gnus-uu" nil t) | |
1698 (autoload 'gnus-uu-decode-uu-view "gnus-uu" nil t) | |
1699 (autoload 'gnus-uu-decode-uu-and-save-view "gnus-uu" nil t) | |
1700 (autoload 'gnus-uu-decode-unshar-view "gnus-uu" nil t) | |
1701 (autoload 'gnus-uu-decode-unshar-and-save-view "gnus-uu" nil t) | |
1702 (autoload 'gnus-uu-decode-save-view "gnus-uu" nil t) | |
1703 (autoload 'gnus-uu-decode-binhex-view "gnus-uu" nil t) | |
1704 | |
1705 ;; gnus-msg | |
1706 (autoload 'gnus-summary-send-map "gnus-msg" nil nil 'keymap) | |
1707 (autoload 'gnus-group-post-news "gnus-msg" nil t) | |
1708 (autoload 'gnus-group-mail "gnus-msg" nil t) | |
1709 (autoload 'gnus-summary-post-news "gnus-msg" nil t) | |
1710 (autoload 'gnus-summary-followup "gnus-msg" nil t) | |
1711 (autoload 'gnus-summary-followup-with-original "gnus-msg" nil t) | |
1712 (autoload 'gnus-summary-followup-and-reply "gnus-msg" nil t) | |
1713 (autoload 'gnus-summary-followup-and-reply-with-original "gnus-msg" nil t) | |
1714 (autoload 'gnus-summary-cancel-article "gnus-msg" nil t) | |
1715 (autoload 'gnus-summary-supersede-article "gnus-msg" nil t) | |
1716 (autoload 'gnus-post-news "gnus-msg" nil t) | |
1717 (autoload 'gnus-inews-news "gnus-msg" nil t) | |
1718 (autoload 'gnus-cancel-news "gnus-msg" nil t) | |
1719 (autoload 'gnus-summary-reply "gnus-msg" nil t) | |
1720 (autoload 'gnus-summary-reply-with-original "gnus-msg" nil t) | |
1721 (autoload 'gnus-summary-mail-forward "gnus-msg" nil t) | |
1722 (autoload 'gnus-summary-mail-other-window "gnus-msg" nil t) | |
1723 (autoload 'gnus-mail-reply-using-mail "gnus-msg") | |
1724 (autoload 'gnus-mail-yank-original "gnus-msg") | |
1725 (autoload 'gnus-mail-send-and-exit "gnus-msg") | |
1726 (autoload 'gnus-mail-forward-using-mail "gnus-msg") | |
1727 (autoload 'gnus-mail-other-window-using-mail "gnus-msg") | |
1728 (autoload 'gnus-article-mail "gnus-msg") | |
1729 (autoload 'gnus-bug "gnus-msg" nil t) | |
1730 | |
1731 ;; gnus-vm | |
1732 (autoload 'gnus-summary-save-in-vm "gnus-vm" nil t) | |
1733 (autoload 'gnus-summary-save-article-vm "gnus-vm" nil t) | |
1734 (autoload 'gnus-mail-forward-using-vm "gnus-vm") | |
1735 (autoload 'gnus-mail-reply-using-vm "gnus-vm") | |
1736 (autoload 'gnus-mail-other-window-using-vm "gnus-vm" nil t) | |
1737 (autoload 'gnus-yank-article "gnus-vm" nil t) | |
1738 | |
1739 ) | |
1740 | |
1741 | |
1742 | |
1743 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>. | |
1744 ;; If you want the cursor to go somewhere else, set these two | |
1745 ;; functions in some startup hook to whatever you want. | |
1746 (defalias 'gnus-summary-position-cursor 'gnus-goto-colon) | |
1747 (defalias 'gnus-group-position-cursor 'gnus-goto-colon) | |
1748 | |
1749 ;;; Various macros and substs. | |
1750 | |
1751 (defmacro gnus-eval-in-buffer-window (buffer &rest forms) | |
1752 "Pop to BUFFER, evaluate FORMS, and then returns to original window." | |
1753 (` (let ((GnusStartBufferWindow (selected-window))) | |
1754 (unwind-protect | |
1755 (progn | |
1756 (pop-to-buffer (, buffer)) | |
1757 (,@ forms)) | |
1758 (select-window GnusStartBufferWindow))))) | |
1759 | |
1760 (defmacro gnus-gethash (string hashtable) | |
1761 "Get hash value of STRING in HASHTABLE." | |
1762 ;;(` (symbol-value (abbrev-symbol (, string) (, hashtable)))) | |
1763 ;;(` (abbrev-expansion (, string) (, hashtable))) | |
1764 (` (symbol-value (intern-soft (, string) (, hashtable))))) | |
1765 | |
1766 (defmacro gnus-sethash (string value hashtable) | |
1767 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE." | |
1768 ;; We cannot use define-abbrev since it only accepts string as value. | |
1769 ;; (set (intern string hashtable) value)) | |
1770 (` (set (intern (, string) (, hashtable)) (, value)))) | |
1771 | |
1772 (defsubst gnus-buffer-substring (beg end) | |
1773 (buffer-substring (match-beginning beg) (match-end end))) | |
1774 | |
1775 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp> | |
1776 ;; function `substring' might cut on a middle of multi-octet | |
1777 ;; character. | |
1778 (defun gnus-truncate-string (str width) | |
1779 (substring str 0 width)) | |
1780 | |
1781 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way | |
1782 ;; to limit the length of a string. This function is necessary since | |
1783 ;; `(substr "abc" 0 30)' pukes with "Args out of range". | |
1784 (defsubst gnus-limit-string (str width) | |
1785 (if (> (length str) width) | |
1786 (substring str 0 width) | |
1787 str)) | |
1788 | |
1789 (defsubst gnus-simplify-subject-re (subject) | |
1790 "Remove \"Re:\" from subject lines." | |
1791 (let ((case-fold-search t)) | |
1792 (if (string-match "^re: *" subject) | |
1793 (substring subject (match-end 0)) | |
1794 subject))) | |
1795 | |
1796 (defsubst gnus-goto-char (point) | |
1797 (and point (goto-char point))) | |
1798 | |
1799 (defmacro gnus-buffer-exists-p (buffer) | |
1800 (` (and (, buffer) | |
1801 (funcall (if (stringp (, buffer)) 'get-buffer 'buffer-name) | |
1802 (, buffer))))) | |
1803 | |
1804 (defmacro gnus-kill-buffer (buffer) | |
1805 (` (if (gnus-buffer-exists-p (, buffer)) | |
1806 (kill-buffer (, buffer))))) | |
1807 | |
1808 (defsubst gnus-point-at-bol () | |
1809 "Return point at the beginning of line." | |
1810 (let ((p (point))) | |
1811 (beginning-of-line) | |
1812 (prog1 | |
1813 (point) | |
1814 (goto-char p)))) | |
1815 | |
1816 (defsubst gnus-point-at-eol () | |
1817 "Return point at the beginning of line." | |
1818 (let ((p (point))) | |
1819 (end-of-line) | |
1820 (prog1 | |
1821 (point) | |
1822 (goto-char p)))) | |
1823 | |
1824 ;; Delete the current line (and the next N lines.); | |
1825 (defmacro gnus-delete-line (&optional n) | |
1826 (` (delete-region (progn (beginning-of-line) (point)) | |
1827 (progn (forward-line (, (or n 1))) (point))))) | |
1828 | |
1829 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>. | |
1830 (defvar gnus-init-inhibit nil) | |
1831 (defun gnus-read-init-file (&optional inhibit-next) | |
1832 (if gnus-init-inhibit | |
1833 (setq gnus-init-inhibit nil) | |
1834 (setq gnus-init-inhibit inhibit-next) | |
1835 (and gnus-init-file | |
1836 (or (and (file-exists-p gnus-init-file) | |
1837 ;; Don't try to load a directory. | |
1838 (not (file-directory-p gnus-init-file))) | |
1839 (file-exists-p (concat gnus-init-file ".el")) | |
1840 (file-exists-p (concat gnus-init-file ".elc"))) | |
1841 (load gnus-init-file nil t)))) | |
1842 | |
1843 ;;; Load the user startup file. | |
1844 ;; (eval '(gnus-read-init-file 'inhibit)) | |
1845 | |
1846 ;;; Load the compatability functions. | |
1847 | |
1848 (require 'gnus-cus) | |
1849 (require 'gnus-ems) | |
1850 | |
1851 | |
1852 ;;; | |
1853 ;;; Gnus Utility Functions | |
1854 ;;; | |
1855 | |
1856 (defun gnus-extract-address-components (from) | |
1857 (let (name address) | |
1858 ;; First find the address - the thing with the @ in it. This may | |
1859 ;; not be accurate in mail addresses, but does the trick most of | |
1860 ;; the time in news messages. | |
1861 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from) | |
1862 (setq address (substring from (match-beginning 0) (match-end 0)))) | |
1863 ;; Then we check whether the "name <address>" format is used. | |
1864 (and address | |
1865 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp> | |
1866 ;; Linear white space is not required. | |
1867 (string-match (concat "[ \t]*<" (regexp-quote address) ">") from) | |
1868 (and (setq name (substring from 0 (match-beginning 0))) | |
1869 ;; Strip any quotes from the name. | |
1870 (string-match "\".*\"" name) | |
1871 (setq name (substring name 1 (1- (match-end 0)))))) | |
1872 ;; If not, then "address (name)" is used. | |
1873 (or name | |
1874 (and (string-match "(.+)" from) | |
1875 (setq name (substring from (1+ (match-beginning 0)) | |
1876 (1- (match-end 0))))) | |
1877 (and (string-match "()" from) | |
1878 (setq name address)) | |
1879 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>. | |
1880 ;; XOVER might not support folded From headers. | |
1881 (and (string-match "(.*" from) | |
1882 (setq name (substring from (1+ (match-beginning 0)) | |
1883 (match-end 0))))) | |
1884 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>. | |
1885 (list (or name from) (or address from)))) | |
1886 | |
1887 (defun gnus-fetch-field (field) | |
1888 "Return the value of the header FIELD of current article." | |
1889 (save-excursion | |
1890 (save-restriction | |
1891 (let ((case-fold-search t)) | |
1892 (gnus-narrow-to-headers) | |
1893 (mail-fetch-field field))))) | |
1894 | |
1895 (defun gnus-goto-colon () | |
1896 (beginning-of-line) | |
1897 (search-forward ":" (gnus-point-at-eol) t)) | |
1898 | |
1899 (defun gnus-narrow-to-headers () | |
1900 (widen) | |
1901 (save-excursion | |
1902 (narrow-to-region | |
1903 (goto-char (point-min)) | |
1904 (if (search-forward "\n\n" nil t) | |
1905 (1- (point)) | |
1906 (point-max))))) | |
1907 | |
1908 (defvar gnus-old-specs nil) | |
1909 | |
1910 (defun gnus-update-format-specifications () | |
1911 (gnus-make-thread-indent-array) | |
1912 | |
1913 (let ((formats '(summary summary-dummy group | |
1914 summary-mode group-mode article-mode)) | |
1915 old-format new-format) | |
1916 (while formats | |
1917 (setq new-format (symbol-value | |
1918 (intern (format "gnus-%s-line-format" (car formats))))) | |
1919 (or (and (setq old-format (cdr (assq (car formats) gnus-old-specs))) | |
1920 (equal old-format new-format)) | |
1921 (set (intern (format "gnus-%s-line-format-spec" (car formats))) | |
1922 (gnus-parse-format | |
1923 new-format | |
1924 (symbol-value | |
1925 (intern (format "gnus-%s-line-format-alist" | |
1926 (if (eq (car formats) 'article-mode) | |
1927 'summary-mode (car formats)))))))) | |
1928 (setq gnus-old-specs (cons (cons (car formats) new-format) | |
1929 (delq (car formats) gnus-old-specs))) | |
1930 (setq formats (cdr formats)))) | |
1931 | |
1932 (gnus-update-group-mark-positions) | |
1933 (gnus-update-summary-mark-positions) | |
1934 | |
1935 (if (and (string-match "%D" gnus-group-line-format) | |
1936 (not gnus-description-hashtb) | |
1937 gnus-read-active-file) | |
1938 (gnus-read-all-descriptions-files))) | |
1939 | |
1940 (defun gnus-update-summary-mark-positions () | |
1941 (save-excursion | |
1942 (let ((gnus-replied-mark 129) | |
1943 (gnus-score-below-mark 130) | |
1944 (gnus-score-over-mark 130) | |
1945 (thread nil) | |
1946 pos) | |
1947 (gnus-set-work-buffer) | |
1948 (gnus-summary-insert-line | |
1949 nil [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1) | |
1950 (goto-char (point-min)) | |
1951 (setq pos (list (cons 'unread (and (search-forward "\200" nil t) | |
1952 (- (point) 2))))) | |
1953 (goto-char (point-min)) | |
1954 (setq pos (cons (cons 'replied (and (search-forward "\201" nil t) | |
1955 (- (point) 2))) pos)) | |
1956 (goto-char (point-min)) | |
1957 (setq pos (cons (cons 'score (and (search-forward "\202" nil t) | |
1958 (- (point) 2))) pos)) | |
1959 (setq gnus-summary-mark-positions pos)))) | |
1960 | |
1961 (defun gnus-update-group-mark-positions () | |
1962 (save-excursion | |
1963 (let ((gnus-process-mark 128) | |
1964 (gnus-group-marked '("dummy.group"))) | |
1965 (gnus-sethash "dummy.group" '(0 . 0) gnus-active-hashtb) | |
1966 (gnus-set-work-buffer) | |
1967 (gnus-group-insert-group-line nil "dummy.group" 0 nil 0 nil) | |
1968 (goto-char (point-min)) | |
1969 (setq gnus-group-mark-positions | |
1970 (list (cons 'process (and (search-forward "\200" nil t) | |
1971 (- (point) 2)))))))) | |
1972 | |
1973 (defun gnus-mouse-face-function (form) | |
1974 (` (let ((string (, form))) | |
1975 (put-text-property 0 (length string) 'mouse-face gnus-mouse-face string) | |
1976 string))) | |
1977 | |
1978 (defun gnus-max-width-function (el max-width) | |
1979 (or (numberp max-width) (signal 'wrong-type-argument '(numberp max-width))) | |
1980 (` (let* ((val (eval (, el))) | |
1981 (valstr (if (numberp val) | |
1982 (int-to-string val) val))) | |
1983 (if (> (length valstr) (, max-width)) | |
1984 (substring valstr 0 (, max-width)) | |
1985 valstr)))) | |
1986 | |
1987 (defun gnus-parse-format (format spec-alist) | |
1988 ;; This function parses the FORMAT string with the help of the | |
1989 ;; SPEC-ALIST and returns a list that can be eval'ed to return the | |
1990 ;; string. If the FORMAT string contains the specifiers %( and %) | |
1991 ;; the text between them will have the mouse-face text property. | |
1992 (if (string-match "\\`\\(.*\\)%(\\(.*\\)%)\\(.*\n?\\)\\'" format) | |
1993 (if (and gnus-visual gnus-mouse-face) | |
1994 (let ((pre (substring format (match-beginning 1) (match-end 1))) | |
1995 (button (substring format (match-beginning 2) (match-end 2))) | |
1996 (post (substring format (match-beginning 3) (match-end 3)))) | |
1997 (list 'concat | |
1998 (gnus-parse-simple-format pre spec-alist) | |
1999 (gnus-mouse-face-function | |
2000 (gnus-parse-simple-format button spec-alist)) | |
2001 (gnus-parse-simple-format post spec-alist))) | |
2002 (gnus-parse-simple-format | |
2003 (concat (substring format (match-beginning 1) (match-end 1)) | |
2004 (substring format (match-beginning 2) (match-end 2)) | |
2005 (substring format (match-beginning 3) (match-end 3))) | |
2006 spec-alist)) | |
2007 (gnus-parse-simple-format format spec-alist))) | |
2008 | |
2009 (defun gnus-parse-simple-format (format spec-alist) | |
2010 ;; This function parses the FORMAT string with the help of the | |
2011 ;; SPEC-ALIST and returns a list that can be eval'ed to return the | |
2012 ;; string. The list will consist of the symbol `format', a format | |
2013 ;; specification string, and a list of forms depending on the | |
2014 ;; SPEC-ALIST. | |
2015 (let ((max-width 0) | |
2016 spec flist fstring newspec elem beg) | |
2017 (save-excursion | |
2018 (gnus-set-work-buffer) | |
2019 (insert format) | |
2020 (goto-char (point-min)) | |
2021 (while (re-search-forward "%[-0-9]*\\(,[0-9]+\\)?\\([^0-9]\\)\\(.\\)?" nil t) | |
2022 (setq spec (string-to-char (buffer-substring (match-beginning 2) | |
2023 (match-end 2)))) | |
2024 ;; First check if there are any specs that look anything like | |
2025 ;; "%12,12A", ie. with a "max width specification". These have | |
2026 ;; to be treated specially. | |
2027 (if (setq beg (match-beginning 1)) | |
2028 (setq max-width | |
2029 (string-to-int | |
2030 (buffer-substring (1+ (match-beginning 1)) (match-end 1)))) | |
2031 (setq max-width 0) | |
2032 (setq beg (match-beginning 2))) | |
2033 ;; Find the specification from `spec-alist'. | |
2034 (if (not (setq elem (cdr (assq spec spec-alist)))) | |
2035 (setq elem '("*" ?s))) | |
2036 ;; Treat user defined format specifiers specially | |
2037 (and (eq (car elem) 'user-defined) | |
2038 (setq elem | |
2039 (list | |
2040 (list (intern (concat "gnus-user-format-function-" | |
2041 (buffer-substring | |
2042 (match-beginning 3) | |
2043 (match-end 3)))) | |
2044 'header) | |
2045 ?s)) | |
2046 (delete-region (match-beginning 3) (match-end 3))) | |
2047 (if (not (zerop max-width)) | |
2048 (let ((el (car elem))) | |
2049 (cond ((= (car (cdr elem)) ?c) | |
2050 (setq el (list 'char-to-string el))) | |
2051 ((= (car (cdr elem)) ?d) | |
2052 (numberp el) (setq el (list 'int-to-string el)))) | |
2053 (setq flist (cons (gnus-max-width-function el max-width) | |
2054 flist)) | |
2055 (setq newspec ?s)) | |
2056 (setq flist (cons (car elem) flist)) | |
2057 (setq newspec (car (cdr elem)))) | |
2058 ;; Remove the old specification (and possibly a ",12" string). | |
2059 (delete-region beg (match-end 2)) | |
2060 ;; Insert the new specification. | |
2061 (goto-char beg) | |
2062 (insert newspec)) | |
2063 (setq fstring (buffer-substring 1 (point-max)))) | |
2064 (cons 'format (cons fstring (nreverse flist))))) | |
2065 | |
2066 (defun gnus-set-work-buffer () | |
2067 (if (get-buffer gnus-work-buffer) | |
2068 (progn | |
2069 (set-buffer gnus-work-buffer) | |
2070 (erase-buffer)) | |
2071 (set-buffer (get-buffer-create gnus-work-buffer)) | |
2072 (kill-all-local-variables) | |
2073 (buffer-disable-undo (current-buffer)) | |
2074 (gnus-add-current-to-buffer-list))) | |
2075 | |
2076 ;; Article file names when saving. | |
2077 | |
2078 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file) | |
2079 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE. | |
2080 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num. | |
2081 Otherwise, it is like ~/News/news/group/num." | |
2082 (let ((default | |
2083 (expand-file-name | |
2084 (concat (if (gnus-use-long-file-name 'not-save) | |
2085 (gnus-capitalize-newsgroup newsgroup) | |
2086 (gnus-newsgroup-directory-form newsgroup)) | |
2087 "/" (int-to-string (mail-header-number headers))) | |
2088 (or gnus-article-save-directory "~/News")))) | |
2089 (if (and last-file | |
2090 (string-equal (file-name-directory default) | |
2091 (file-name-directory last-file)) | |
2092 (string-match "^[0-9]+$" (file-name-nondirectory last-file))) | |
2093 default | |
2094 (or last-file default)))) | |
2095 | |
2096 (defun gnus-numeric-save-name (newsgroup headers &optional last-file) | |
2097 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE. | |
2098 If variable `gnus-use-long-file-name' is non-nil, it is | |
2099 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num." | |
2100 (let ((default | |
2101 (expand-file-name | |
2102 (concat (if (gnus-use-long-file-name 'not-save) | |
2103 newsgroup | |
2104 (gnus-newsgroup-directory-form newsgroup)) | |
2105 "/" (int-to-string (mail-header-number headers))) | |
2106 (or gnus-article-save-directory "~/News")))) | |
2107 (if (and last-file | |
2108 (string-equal (file-name-directory default) | |
2109 (file-name-directory last-file)) | |
2110 (string-match "^[0-9]+$" (file-name-nondirectory last-file))) | |
2111 default | |
2112 (or last-file default)))) | |
2113 | |
2114 (defun gnus-Plain-save-name (newsgroup headers &optional last-file) | |
2115 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE. | |
2116 If variable `gnus-use-long-file-name' is non-nil, it is | |
2117 ~/News/News.group. Otherwise, it is like ~/News/news/group/news." | |
2118 (or last-file | |
2119 (expand-file-name | |
2120 (if (gnus-use-long-file-name 'not-save) | |
2121 (gnus-capitalize-newsgroup newsgroup) | |
2122 (concat (gnus-newsgroup-directory-form newsgroup) "/news")) | |
2123 (or gnus-article-save-directory "~/News")))) | |
2124 | |
2125 (defun gnus-plain-save-name (newsgroup headers &optional last-file) | |
2126 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE. | |
2127 If variable `gnus-use-long-file-name' is non-nil, it is | |
2128 ~/News/news.group. Otherwise, it is like ~/News/news/group/news." | |
2129 (or last-file | |
2130 (expand-file-name | |
2131 (if (gnus-use-long-file-name 'not-save) | |
2132 newsgroup | |
2133 (concat (gnus-newsgroup-directory-form newsgroup) "/news")) | |
2134 (or gnus-article-save-directory "~/News")))) | |
2135 | |
2136 ;; For subscribing new newsgroup | |
2137 | |
2138 (defun gnus-subscribe-hierarchical-interactive (groups) | |
2139 (let ((groups (sort groups 'string<)) | |
2140 prefixes prefix start ans group starts) | |
2141 (while groups | |
2142 (setq prefixes (list "^")) | |
2143 (while (and groups prefixes) | |
2144 (while (not (string-match (car prefixes) (car groups))) | |
2145 (setq prefixes (cdr prefixes))) | |
2146 (setq prefix (car prefixes)) | |
2147 (setq start (1- (length prefix))) | |
2148 (if (and (string-match "[^\\.]\\." (car groups) start) | |
2149 (cdr groups) | |
2150 (setq prefix | |
2151 (concat "^" (substring (car groups) 0 (match-end 0)))) | |
2152 (string-match prefix (car (cdr groups)))) | |
2153 (progn | |
2154 (setq prefixes (cons prefix prefixes)) | |
2155 (message "Descend hierarchy %s? ([y]nsq): " | |
2156 (substring prefix 1 (1- (length prefix)))) | |
2157 (setq ans (read-char)) | |
2158 (cond ((= ans ?n) | |
2159 (while (and groups | |
2160 (string-match prefix | |
2161 (setq group (car groups)))) | |
2162 (setq gnus-killed-list | |
2163 (cons group gnus-killed-list)) | |
2164 (gnus-sethash group group gnus-killed-hashtb) | |
2165 (setq groups (cdr groups))) | |
2166 (setq starts (cdr starts))) | |
2167 ((= ans ?s) | |
2168 (while (and groups | |
2169 (string-match prefix | |
2170 (setq group (car groups)))) | |
2171 (gnus-sethash group group gnus-killed-hashtb) | |
2172 (gnus-subscribe-alphabetically (car groups)) | |
2173 (setq groups (cdr groups))) | |
2174 (setq starts (cdr starts))) | |
2175 ((= ans ?q) | |
2176 (while groups | |
2177 (setq group (car groups)) | |
2178 (setq gnus-killed-list (cons group gnus-killed-list)) | |
2179 (gnus-sethash group group gnus-killed-hashtb) | |
2180 (setq groups (cdr groups)))) | |
2181 (t nil))) | |
2182 (message "Subscribe %s? ([n]yq)" (car groups)) | |
2183 (setq ans (read-char)) | |
2184 (setq group (car groups)) | |
2185 (cond ((= ans ?y) | |
2186 (gnus-subscribe-alphabetically (car groups)) | |
2187 (gnus-sethash group group gnus-killed-hashtb)) | |
2188 ((= ans ?q) | |
2189 (while groups | |
2190 (setq group (car groups)) | |
2191 (setq gnus-killed-list (cons group gnus-killed-list)) | |
2192 (gnus-sethash group group gnus-killed-hashtb) | |
2193 (setq groups (cdr groups)))) | |
2194 (t | |
2195 (setq gnus-killed-list (cons group gnus-killed-list)) | |
2196 (gnus-sethash group group gnus-killed-hashtb))) | |
2197 (setq groups (cdr groups))))))) | |
2198 | |
2199 (defun gnus-subscribe-randomly (newsgroup) | |
2200 "Subscribe new NEWSGROUP by making it the first newsgroup." | |
2201 (gnus-subscribe-newsgroup newsgroup)) | |
2202 | |
2203 (defun gnus-subscribe-alphabetically (newgroup) | |
2204 "Subscribe new NEWSGROUP and insert it in alphabetical order." | |
2205 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams) | |
2206 (let ((groups (cdr gnus-newsrc-alist)) | |
2207 before) | |
2208 (while (and (not before) groups) | |
2209 (if (string< newgroup (car (car groups))) | |
2210 (setq before (car (car groups))) | |
2211 (setq groups (cdr groups)))) | |
2212 (gnus-subscribe-newsgroup newgroup before))) | |
2213 | |
2214 (defun gnus-subscribe-hierarchically (newgroup) | |
2215 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order." | |
2216 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams) | |
2217 (save-excursion | |
2218 (set-buffer (find-file-noselect gnus-current-startup-file)) | |
2219 (let ((groupkey newgroup) | |
2220 before) | |
2221 (while (and (not before) groupkey) | |
2222 (goto-char (point-min)) | |
2223 (let ((groupkey-re | |
2224 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]"))) | |
2225 (while (and (re-search-forward groupkey-re nil t) | |
2226 (progn | |
2227 (setq before (buffer-substring | |
2228 (match-beginning 1) (match-end 1))) | |
2229 (string< before newgroup))))) | |
2230 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b) | |
2231 (setq groupkey | |
2232 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey) | |
2233 (substring groupkey (match-beginning 1) (match-end 1))))) | |
2234 (gnus-subscribe-newsgroup newgroup before)))) | |
2235 | |
2236 (defun gnus-subscribe-interactively (newsgroup) | |
2237 "Subscribe new NEWSGROUP interactively. | |
2238 It is inserted in hierarchical newsgroup order if subscribed. If not, | |
2239 it is killed." | |
2240 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " newsgroup)) | |
2241 (gnus-subscribe-hierarchically newsgroup) | |
2242 (setq gnus-killed-list (cons newsgroup gnus-killed-list)))) | |
2243 | |
2244 (defun gnus-subscribe-zombies (newsgroup) | |
2245 "Make new NEWSGROUP a zombie group." | |
2246 (setq gnus-zombie-list (cons newsgroup gnus-zombie-list))) | |
2247 | |
2248 (defun gnus-subscribe-newsgroup (newsgroup &optional next) | |
2249 "Subscribe new NEWSGROUP. | |
2250 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made | |
2251 the first newsgroup." | |
2252 ;; We subscribe the group by changing its level to `subscribed'. | |
2253 (gnus-group-change-level | |
2254 newsgroup gnus-level-default-subscribed | |
2255 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb)) | |
2256 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup)) | |
2257 | |
2258 ;; For directories | |
2259 | |
2260 (defun gnus-newsgroup-directory-form (newsgroup) | |
2261 "Make hierarchical directory name from NEWSGROUP name." | |
2262 (let ((newsgroup (gnus-newsgroup-saveable-name newsgroup)) | |
2263 (len (length newsgroup)) | |
2264 idx) | |
2265 ;; If this is a foreign group, we don't want to translate the | |
2266 ;; entire name. | |
2267 (if (setq idx (string-match ":" newsgroup)) | |
2268 (aset newsgroup idx ?/) | |
2269 (setq idx 0)) | |
2270 ;; Replace all occurrences of `.' with `/'. | |
2271 (while (< idx len) | |
2272 (if (= (aref newsgroup idx) ?.) | |
2273 (aset newsgroup idx ?/)) | |
2274 (setq idx (1+ idx))) | |
2275 newsgroup)) | |
2276 | |
2277 (defun gnus-newsgroup-saveable-name (group) | |
2278 ;; Replace any slashes in a group name (eg. an ange-ftp nndoc group) | |
2279 ;; with dots. | |
2280 (gnus-replace-chars-in-string group ?/ ?.)) | |
2281 | |
2282 (defun gnus-make-directory (dir) | |
2283 "Make DIRECTORY recursively." | |
2284 ;; Why don't we use `(make-directory dir 'parents)'? That's just one | |
2285 ;; of the many mysteries of the universe. | |
2286 (let* ((dir (expand-file-name dir default-directory)) | |
2287 dirs err) | |
2288 (if (string-match "/$" dir) | |
2289 (setq dir (substring dir 0 (match-beginning 0)))) | |
2290 ;; First go down the path until we find a directory that exists. | |
2291 (while (not (file-exists-p dir)) | |
2292 (setq dirs (cons dir dirs)) | |
2293 (string-match "/[^/]+$" dir) | |
2294 (setq dir (substring dir 0 (match-beginning 0)))) | |
2295 ;; Then create all the subdirs. | |
2296 (while (and dirs (not err)) | |
2297 (condition-case () | |
2298 (make-directory (car dirs)) | |
2299 (error (setq err t))) | |
2300 (setq dirs (cdr dirs))) | |
2301 ;; We return whether we were successful or not. | |
2302 (not dirs))) | |
2303 | |
2304 (defun gnus-capitalize-newsgroup (newsgroup) | |
2305 "Capitalize NEWSGROUP name." | |
2306 (and (not (zerop (length newsgroup))) | |
2307 (concat (char-to-string (upcase (aref newsgroup 0))) | |
2308 (substring newsgroup 1)))) | |
2309 | |
2310 ;; Var | |
2311 | |
2312 (defun gnus-simplify-subject (subject &optional re-only) | |
2313 "Remove `Re:' and words in parentheses. | |
2314 If optional argument RE-ONLY is non-nil, strip `Re:' only." | |
2315 (let ((case-fold-search t)) ;Ignore case. | |
2316 ;; Remove `Re:' and `Re^N:'. | |
2317 (if (string-match "^re:[ \t]*" subject) | |
2318 (setq subject (substring subject (match-end 0)))) | |
2319 ;; Remove words in parentheses from end. | |
2320 (or re-only | |
2321 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject) | |
2322 (setq subject (substring subject 0 (match-beginning 0))))) | |
2323 ;; Return subject string. | |
2324 subject)) | |
2325 | |
2326 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify | |
2327 ;; all whitespace. | |
2328 (defun gnus-simplify-subject-fuzzy (subject) | |
2329 (let ((case-fold-search t)) | |
2330 (save-excursion | |
2331 (gnus-set-work-buffer) | |
2332 (insert subject) | |
2333 (inline (gnus-simplify-buffer-fuzzy)) | |
2334 (buffer-string)))) | |
2335 | |
2336 (defun gnus-simplify-buffer-fuzzy () | |
2337 (goto-char (point-min)) | |
2338 ;; Fix by Stainless Steel Rat <ratinox@ccs.neu.edu>. | |
2339 (while (re-search-forward "^[ \t]*\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;][ \t]*" | |
2340 nil t) | |
2341 (replace-match "" t t)) | |
2342 (goto-char (point-min)) | |
2343 (while (re-search-forward "[ \t\n]*([^()]*)[ \t\n]*$" nil t) | |
2344 (replace-match "" t t)) | |
2345 (goto-char (point-min)) | |
2346 (while (re-search-forward "[ \t]+" nil t) | |
2347 (replace-match " " t t)) | |
2348 (goto-char (point-min)) | |
2349 (while (re-search-forward "[ \t]+$" nil t) | |
2350 (replace-match "" t t)) | |
2351 (goto-char (point-min)) | |
2352 (while (re-search-forward "^[ \t]+" nil t) | |
2353 (replace-match "" t t)) | |
2354 (if gnus-simplify-subject-fuzzy-regexp | |
2355 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t) | |
2356 (replace-match "" t t)))) | |
2357 | |
2358 ;; Add the current buffer to the list of buffers to be killed on exit. | |
2359 (defun gnus-add-current-to-buffer-list () | |
2360 (or (memq (current-buffer) gnus-buffer-list) | |
2361 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list)))) | |
2362 | |
2363 (defun gnus-string> (s1 s2) | |
2364 (not (or (string< s1 s2) | |
2365 (string= s1 s2)))) | |
2366 | |
2367 ;; Functions accessing headers. | |
2368 ;; Functions are more convenient than macros in some cases. | |
2369 | |
2370 (defun gnus-header-number (header) | |
2371 (mail-header-number header)) | |
2372 | |
2373 (defun gnus-header-subject (header) | |
2374 (mail-header-subject header)) | |
2375 | |
2376 (defun gnus-header-from (header) | |
2377 (mail-header-from header)) | |
2378 | |
2379 (defun gnus-header-xref (header) | |
2380 (mail-header-xref header)) | |
2381 | |
2382 (defun gnus-header-lines (header) | |
2383 (mail-header-lines header)) | |
2384 | |
2385 (defun gnus-header-date (header) | |
2386 (mail-header-date header)) | |
2387 | |
2388 (defun gnus-header-id (header) | |
2389 (mail-header-id header)) | |
2390 | |
2391 (defun gnus-header-message-id (header) | |
2392 (mail-header-id header)) | |
2393 | |
2394 (defun gnus-header-chars (header) | |
2395 (mail-header-chars header)) | |
2396 | |
2397 (defun gnus-header-references (header) | |
2398 (mail-header-references header)) | |
2399 | |
2400 ;;; General various misc type functions. | |
2401 | |
2402 (defun gnus-clear-system () | |
2403 "Clear all variables and buffers." | |
2404 ;; Clear Gnus variables. | |
2405 (let ((variables gnus-variable-list)) | |
2406 (while variables | |
2407 (set (car variables) nil) | |
2408 (setq variables (cdr variables)))) | |
2409 ;; Clear other internal variables. | |
2410 (setq gnus-list-of-killed-groups nil | |
2411 gnus-have-read-active-file nil | |
2412 gnus-newsrc-alist nil | |
2413 gnus-newsrc-hashtb nil | |
2414 gnus-killed-list nil | |
2415 gnus-zombie-list nil | |
2416 gnus-killed-hashtb nil | |
2417 gnus-active-hashtb nil | |
2418 gnus-moderated-list nil | |
2419 gnus-description-hashtb nil | |
2420 gnus-newsgroup-headers nil | |
2421 gnus-newsgroup-headers-hashtb-by-number nil | |
2422 gnus-newsgroup-name nil | |
2423 gnus-server-alist nil | |
2424 gnus-current-select-method nil) | |
2425 ;; Reset any score variables. | |
2426 (and (boundp 'gnus-score-cache) | |
2427 (set 'gnus-score-cache nil)) | |
2428 (and (boundp 'gnus-internal-global-score-files) | |
2429 (set 'gnus-internal-global-score-files nil)) | |
2430 ;; Kill the startup file. | |
2431 (and gnus-current-startup-file | |
2432 (get-file-buffer gnus-current-startup-file) | |
2433 (kill-buffer (get-file-buffer gnus-current-startup-file))) | |
2434 ;; Save any cache buffers. | |
2435 (and gnus-use-cache (gnus-cache-save-buffers)) | |
2436 ;; Clear the dribble buffer. | |
2437 (gnus-dribble-clear) | |
2438 ;; Kill global KILL file buffer. | |
2439 (if (get-file-buffer (gnus-newsgroup-kill-file nil)) | |
2440 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil)))) | |
2441 (gnus-kill-buffer nntp-server-buffer) | |
2442 ;; Kill Gnus buffers. | |
2443 (while gnus-buffer-list | |
2444 (gnus-kill-buffer (car gnus-buffer-list)) | |
2445 (setq gnus-buffer-list (cdr gnus-buffer-list)))) | |
2446 | |
2447 (defun gnus-windows-old-to-new (setting) | |
2448 ;; First we take care of the really, really old Gnus 3 actions. | |
2449 (if (symbolp setting) | |
2450 (setq setting | |
2451 (cond ((memq setting '(SelectArticle)) | |
2452 'article) | |
2453 ((memq setting '(SelectSubject ExpandSubject)) | |
2454 'summary) | |
2455 ((memq setting '(SelectNewsgroup ExitNewsgroup)) | |
2456 'group) | |
2457 (t setting)))) | |
2458 (if (or (listp setting) | |
2459 (not (and gnus-window-configuration | |
2460 (memq setting '(group summary article))))) | |
2461 setting | |
2462 (let* ((setting (if (eq setting 'group) | |
2463 (if (assq 'newsgroup gnus-window-configuration) | |
2464 'newsgroup | |
2465 'newsgroups) setting)) | |
2466 (elem (car (cdr (assq setting gnus-window-configuration)))) | |
2467 (total (apply '+ elem)) | |
2468 (types '(group summary article)) | |
2469 (pbuf (if (eq setting 'newsgroups) 'group 'summary)) | |
2470 (i 0) | |
2471 perc | |
2472 out) | |
2473 (while (< i 3) | |
2474 (or (not (numberp (nth i elem))) | |
2475 (zerop (nth i elem)) | |
2476 (progn | |
2477 (setq perc (/ (* 1.0 (nth 0 elem)) total)) | |
2478 (setq out (cons (if (eq pbuf (nth i types)) | |
2479 (vector (nth i types) perc 'point) | |
2480 (vector (nth i types) perc)) | |
2481 out)))) | |
2482 (setq i (1+ i))) | |
2483 (list (nreverse out))))) | |
2484 | |
2485 (defun gnus-add-configuration (conf) | |
2486 (setq gnus-buffer-configuration | |
2487 (cons conf (delq (assq (car conf) gnus-buffer-configuration) | |
2488 gnus-buffer-configuration)))) | |
2489 | |
2490 (defun gnus-configure-windows (setting &optional force) | |
2491 (setq setting (gnus-windows-old-to-new setting)) | |
2492 (let ((r (if (symbolp setting) | |
2493 (cdr (assq setting gnus-buffer-configuration)) | |
2494 setting)) | |
2495 (in-buf (current-buffer)) | |
2496 rule val w height hor ohor heights sub jump-buffer | |
2497 rel total to-buf all-visible) | |
2498 (or r (error "No such setting: %s" setting)) | |
2499 | |
2500 (if (and (not force) (setq all-visible (gnus-all-windows-visible-p r))) | |
2501 ;; All the windows mentioned are already visible, so we just | |
2502 ;; put point in the assigned buffer, and do not touch the | |
2503 ;; winconf. | |
2504 (select-window (get-buffer-window all-visible t)) | |
2505 | |
2506 | |
2507 ;; Either remove all windows or just remove all Gnus windows. | |
2508 (if gnus-use-full-window | |
2509 (delete-other-windows) | |
2510 (gnus-remove-some-windows) | |
2511 (switch-to-buffer nntp-server-buffer)) | |
2512 | |
2513 (while r | |
2514 (setq hor (car r) | |
2515 ohor nil) | |
2516 | |
2517 ;; We have to do the (possible) horizontal splitting before the | |
2518 ;; vertical. | |
2519 (if (and (listp (car hor)) | |
2520 (eq (car (car hor)) 'horizontal)) | |
2521 (progn | |
2522 (split-window | |
2523 nil | |
2524 (if (integerp (nth 1 (car hor))) | |
2525 (nth 1 (car hor)) | |
2526 (- (frame-width) (floor (* (frame-width) (nth 1 (car hor)))))) | |
2527 t) | |
2528 (setq hor (cdr hor)))) | |
2529 | |
2530 ;; Go through the rules and eval the elements that are to be | |
2531 ;; evaled. | |
2532 (while hor | |
2533 (if (setq val (if (vectorp (car hor)) (car hor) (eval (car hor)))) | |
2534 (progn | |
2535 ;; Expand short buffer name. | |
2536 (setq w (aref val 0)) | |
2537 (and (setq w (cdr (assq w gnus-window-to-buffer))) | |
2538 (progn | |
2539 (setq val (apply 'vector (mapcar 'identity val))) | |
2540 (aset val 0 w))) | |
2541 (setq ohor (cons val ohor)))) | |
2542 (setq hor (cdr hor))) | |
2543 (setq rule (cons (nreverse ohor) rule)) | |
2544 (setq r (cdr r))) | |
2545 (setq rule (nreverse rule)) | |
2546 | |
2547 ;; We tally the window sizes. | |
2548 (setq total (window-height)) | |
2549 (while rule | |
2550 (setq hor (car rule)) | |
2551 (if (and (listp (car hor)) (eq (car (car hor)) 'horizontal)) | |
2552 (setq hor (cdr hor))) | |
2553 (setq sub 0) | |
2554 (while hor | |
2555 (setq rel (aref (car hor) 1) | |
2556 heights (cons | |
2557 (cond ((and (floatp rel) (= 1.0 rel)) | |
2558 'x) | |
2559 ((integerp rel) | |
2560 rel) | |
2561 (t | |
2562 (max (floor (* total rel)) 4))) | |
2563 heights) | |
2564 sub (+ sub (if (numberp (car heights)) (car heights) 0)) | |
2565 hor (cdr hor))) | |
2566 (setq heights (nreverse heights) | |
2567 hor (car rule)) | |
2568 | |
2569 ;; We then go through these heighs and create windows for them. | |
2570 (while heights | |
2571 (setq height (car heights) | |
2572 heights (cdr heights)) | |
2573 (and (eq height 'x) | |
2574 (setq height (- total sub))) | |
2575 (and heights | |
2576 (split-window nil height)) | |
2577 (setq to-buf (aref (car hor) 0)) | |
2578 (switch-to-buffer | |
2579 (cond ((not to-buf) | |
2580 in-buf) | |
2581 ((symbolp to-buf) | |
2582 (symbol-value (aref (car hor) 0))) | |
2583 (t | |
2584 (aref (car hor) 0)))) | |
2585 (and (> (length (car hor)) 2) | |
2586 (eq (aref (car hor) 2) 'point) | |
2587 (setq jump-buffer (current-buffer))) | |
2588 (other-window 1) | |
2589 (setq hor (cdr hor))) | |
2590 | |
2591 (setq rule (cdr rule))) | |
2592 | |
2593 ;; Finally, we pop to the buffer that's supposed to have point. | |
2594 (or jump-buffer (error "Missing `point' in spec for %s" setting)) | |
2595 | |
2596 (select-window (get-buffer-window jump-buffer t)) | |
2597 (set-buffer jump-buffer)))) | |
2598 | |
2599 (defun gnus-all-windows-visible-p (rule) | |
2600 (let (invisible hor jump-buffer val buffer) | |
2601 ;; Go through the rules and eval the elements that are to be | |
2602 ;; evaled. | |
2603 (while (and rule (not invisible)) | |
2604 (setq hor (car rule) | |
2605 rule (cdr rule)) | |
2606 (while (and hor (not invisible)) | |
2607 (if (setq val (if (vectorp (car hor)) | |
2608 (car hor) | |
2609 (if (not (eq (car (car hor)) 'horizontal)) | |
2610 (eval (car hor))))) | |
2611 (progn | |
2612 ;; Expand short buffer name. | |
2613 (setq buffer (or (cdr (assq (aref val 0) gnus-window-to-buffer)) | |
2614 (aref val 0))) | |
2615 (setq buffer (if (symbolp buffer) (symbol-value buffer) | |
2616 buffer)) | |
2617 (and (> (length val) 2) (eq 'point (aref val 2)) | |
2618 (setq jump-buffer buffer)) | |
2619 (setq invisible (not (and buffer (get-buffer-window buffer)))))) | |
2620 (setq hor (cdr hor)))) | |
2621 (and (not invisible) jump-buffer))) | |
2622 | |
2623 (defun gnus-window-top-edge (&optional window) | |
2624 (nth 1 (window-edges window))) | |
2625 | |
2626 (defun gnus-remove-some-windows () | |
2627 (let ((buffers gnus-window-to-buffer) | |
2628 buf bufs lowest-buf lowest) | |
2629 (save-excursion | |
2630 ;; Remove windows on all known Gnus buffers. | |
2631 (while buffers | |
2632 (setq buf (cdr (car buffers))) | |
2633 (if (symbolp buf) | |
2634 (setq buf (and (boundp buf) (symbol-value buf)))) | |
2635 (and buf | |
2636 (get-buffer-window buf) | |
2637 (progn | |
2638 (setq bufs (cons buf bufs)) | |
2639 (pop-to-buffer buf) | |
2640 (if (or (not lowest) | |
2641 (< (gnus-window-top-edge) lowest)) | |
2642 (progn | |
2643 (setq lowest (gnus-window-top-edge)) | |
2644 (setq lowest-buf buf))))) | |
2645 (setq buffers (cdr buffers))) | |
2646 ;; Remove windows on *all* summary buffers. | |
2647 (let (wins) | |
2648 (walk-windows | |
2649 (lambda (win) | |
2650 (let ((buf (window-buffer win))) | |
2651 (if (string-match "^\\*Summary" (buffer-name buf)) | |
2652 (progn | |
2653 (setq bufs (cons buf bufs)) | |
2654 (pop-to-buffer buf) | |
2655 (if (or (not lowest) | |
2656 (< (gnus-window-top-edge) lowest)) | |
2657 (progn | |
2658 (setq lowest-buf buf) | |
2659 (setq lowest (gnus-window-top-edge)))))))))) | |
2660 (and lowest-buf | |
2661 (progn | |
2662 (pop-to-buffer lowest-buf) | |
2663 (switch-to-buffer nntp-server-buffer))) | |
2664 (while bufs | |
2665 (and (not (eq (car bufs) lowest-buf)) | |
2666 (delete-windows-on (car bufs))) | |
2667 (setq bufs (cdr bufs)))))) | |
2668 | |
2669 (defun gnus-version () | |
2670 "Version numbers of this version of Gnus." | |
2671 (interactive) | |
2672 (let ((methods gnus-valid-select-methods) | |
2673 (mess gnus-version) | |
2674 meth) | |
2675 ;; Go through all the legal select methods and add their version | |
2676 ;; numbers to the total version string. Only the backends that are | |
2677 ;; currently in use will have their message numbers taken into | |
2678 ;; consideration. | |
2679 (while methods | |
2680 (setq meth (intern (concat (car (car methods)) "-version"))) | |
2681 (and (boundp meth) | |
2682 (stringp (symbol-value meth)) | |
2683 (setq mess (concat mess "; " (symbol-value meth)))) | |
2684 (setq methods (cdr methods))) | |
2685 (gnus-message 2 mess))) | |
2686 | |
2687 (defun gnus-info-find-node () | |
2688 "Find Info documentation of Gnus." | |
2689 (interactive) | |
2690 ;; Enlarge info window if needed. | |
2691 (let ((mode major-mode)) | |
2692 (gnus-configure-windows 'info) | |
2693 (Info-goto-node (car (cdr (assq mode gnus-info-nodes)))))) | |
2694 | |
2695 (defun gnus-overload-functions (&optional overloads) | |
2696 "Overload functions specified by optional argument OVERLOADS. | |
2697 If nothing is specified, use the variable gnus-overload-functions." | |
2698 (let ((defs nil) | |
2699 (overloads (or overloads gnus-overload-functions))) | |
2700 (while overloads | |
2701 (setq defs (car overloads)) | |
2702 (setq overloads (cdr overloads)) | |
2703 ;; Load file before overloading function if necessary. Make | |
2704 ;; sure we cannot use `require' always. | |
2705 (and (not (fboundp (car defs))) | |
2706 (car (cdr (cdr defs))) | |
2707 (load (car (cdr (cdr defs))) nil 'nomessage)) | |
2708 (fset (car defs) (car (cdr defs)))))) | |
2709 | |
2710 (defun gnus-replace-chars-in-string (string &rest pairs) | |
2711 "Replace characters in STRING from FROM to TO." | |
2712 (let ((string (substring string 0)) ;Copy string. | |
2713 (len (length string)) | |
2714 (idx 0) | |
2715 sym to) | |
2716 (or (zerop (% (length pairs) 2)) | |
2717 (error "Odd number of translation pairs")) | |
2718 (setplist 'sym pairs) | |
2719 ;; Replace all occurrences of FROM with TO. | |
2720 (while (< idx len) | |
2721 (if (setq to (get 'sym (aref string idx))) | |
2722 (aset string idx to)) | |
2723 (setq idx (1+ idx))) | |
2724 string)) | |
2725 | |
2726 (defun gnus-days-between (date1 date2) | |
2727 ;; Return the number of days between date1 and date2. | |
2728 (- (gnus-day-number date1) (gnus-day-number date2))) | |
2729 | |
2730 (defun gnus-day-number (date) | |
2731 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) ) | |
2732 (timezone-parse-date date)))) | |
2733 (timezone-absolute-from-gregorian | |
2734 (nth 1 dat) (nth 2 dat) (car dat)))) | |
2735 | |
2736 ;; Returns a floating point number that says how many seconds have | |
2737 ;; lapsed between Jan 1 12:00:00 1970 and DATE. | |
2738 (defun gnus-seconds-since-epoch (date) | |
2739 (let* ((tdate (mapcar (lambda (ti) (and ti (string-to-int ti))) | |
2740 (timezone-parse-date date))) | |
2741 (ttime (mapcar (lambda (ti) (and ti (string-to-int ti))) | |
2742 (timezone-parse-time | |
2743 (aref (timezone-parse-date date) 3)))) | |
2744 (edate (mapcar (lambda (ti) (and ti (string-to-int ti))) | |
2745 (timezone-parse-date "Jan 1 12:00:00 1970"))) | |
2746 (tday (- (timezone-absolute-from-gregorian | |
2747 (nth 1 tdate) (nth 2 tdate) (nth 0 tdate)) | |
2748 (timezone-absolute-from-gregorian | |
2749 (nth 1 edate) (nth 2 edate) (nth 0 edate))))) | |
2750 (+ (nth 2 ttime) | |
2751 (* (nth 1 ttime) 60) | |
2752 (* 1.0 (nth 0 ttime) 60 60) | |
2753 (* 1.0 tday 60 60 24)))) | |
2754 | |
2755 (defun gnus-file-newer-than (file date) | |
2756 (let ((fdate (nth 5 (file-attributes file)))) | |
2757 (or (> (car fdate) (car date)) | |
2758 (and (= (car fdate) (car date)) | |
2759 (> (nth 1 fdate) (nth 1 date)))))) | |
2760 | |
2761 (defun gnus-group-read-only-p (&optional group) | |
2762 "Check whether GROUP supports editing or not. | |
2763 If GROUP is nil, `gnus-newsgroup-name' will be checked instead. Note | |
2764 that that variable is buffer-local to the summary buffers." | |
2765 (let ((group (or group gnus-newsgroup-name))) | |
2766 (not (gnus-check-backend-function 'request-replace-article group)))) | |
2767 | |
2768 ;; Two silly functions to ensure that all `y-or-n-p' questions clear | |
2769 ;; the echo area. | |
2770 (defun gnus-y-or-n-p (prompt) | |
2771 (prog1 | |
2772 (y-or-n-p prompt) | |
2773 (message ""))) | |
2774 | |
2775 (defun gnus-yes-or-no-p (prompt) | |
2776 (prog1 | |
2777 (yes-or-no-p prompt) | |
2778 (message ""))) | |
2779 | |
2780 ;; Check whether to use long file names. | |
2781 (defun gnus-use-long-file-name (symbol) | |
2782 ;; The variable has to be set... | |
2783 (and gnus-use-long-file-name | |
2784 ;; If it isn't a list, then we return t. | |
2785 (or (not (listp gnus-use-long-file-name)) | |
2786 ;; If it is a list, and the list contains `symbol', we | |
2787 ;; return nil. | |
2788 (not (memq symbol gnus-use-long-file-name))))) | |
2789 | |
2790 ;; I suspect there's a better way, but I haven't taken the time to do | |
2791 ;; it yet. -erik selberg@cs.washington.edu | |
2792 (defun gnus-dd-mmm (messy-date) | |
2793 "Return a string like DD-MMM from a big messy string" | |
2794 (let ((datevec (timezone-parse-date messy-date))) | |
2795 (format "%2s-%s" | |
2796 (or (aref datevec 2) "??") | |
2797 (capitalize | |
2798 (or (car | |
2799 (nth (1- (string-to-number (aref datevec 1))) | |
2800 timezone-months-assoc)) | |
2801 "???"))))) | |
2802 | |
2803 ;; Make a hash table (default and minimum size is 255). | |
2804 ;; Optional argument HASHSIZE specifies the table size. | |
2805 (defun gnus-make-hashtable (&optional hashsize) | |
2806 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0)) | |
2807 | |
2808 ;; Make a number that is suitable for hashing; bigger than MIN and one | |
2809 ;; less than 2^x. | |
2810 (defun gnus-create-hash-size (min) | |
2811 (let ((i 1)) | |
2812 (while (< i min) | |
2813 (setq i (* 2 i))) | |
2814 (1- i))) | |
2815 | |
2816 ;; Show message if message has a lower level than `gnus-verbose'. | |
2817 ;; Guide-line for numbers: | |
2818 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages | |
2819 ;; for things that take a long time, 7 - not very important messages | |
2820 ;; on stuff, 9 - messages inside loops. | |
2821 (defun gnus-message (level &rest args) | |
2822 (if (<= level gnus-verbose) | |
2823 (apply 'message args) | |
2824 ;; We have to do this format thingie here even if the result isn't | |
2825 ;; shown - the return value has to be the same as the return value | |
2826 ;; from `message'. | |
2827 (apply 'format args))) | |
2828 | |
2829 ;; Generate a unique new group name. | |
2830 (defun gnus-generate-new-group-name (leaf) | |
2831 (let ((name leaf) | |
2832 (num 0)) | |
2833 (while (gnus-gethash name gnus-newsrc-hashtb) | |
2834 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">"))) | |
2835 name)) | |
2836 | |
2837 (defun gnus-ephemeral-group-p (group) | |
2838 "Say whether GROUP is ephemeral or not." | |
2839 (assoc 'quit-config (gnus-find-method-for-group group))) | |
2840 | |
2841 (defun gnus-group-quit-config (group) | |
2842 "Return the quit-config of GROUP." | |
13579
9426437410bf
`gnus-group-quit-config' gave a list instead of the quit-config
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
13401
diff
changeset
|
2843 (nth 1 (assoc 'quit-config (gnus-find-method-for-group group)))) |
13401 | 2844 |
2845 ;;; List and range functions | |
2846 | |
2847 (defun gnus-last-element (list) | |
2848 "Return last element of LIST." | |
2849 (while (cdr list) | |
2850 (setq list (cdr list))) | |
2851 (car list)) | |
2852 | |
2853 (defun gnus-copy-sequence (list) | |
2854 "Do a complete, total copy of a list." | |
2855 (if (and (consp list) (not (consp (cdr list)))) | |
2856 (cons (car list) (cdr list)) | |
2857 (mapcar (lambda (elem) (if (consp elem) | |
2858 (if (consp (cdr elem)) | |
2859 (gnus-copy-sequence elem) | |
2860 (cons (car elem) (cdr elem))) | |
2861 elem)) | |
2862 list))) | |
2863 | |
2864 (defun gnus-set-difference (list1 list2) | |
2865 "Return a list of elements of LIST1 that do not appear in LIST2." | |
2866 (let ((list1 (copy-sequence list1))) | |
2867 (while list2 | |
2868 (setq list1 (delq (car list2) list1)) | |
2869 (setq list2 (cdr list2))) | |
2870 list1)) | |
2871 | |
2872 (defun gnus-sorted-complement (list1 list2) | |
2873 "Return a list of elements of LIST1 that do not appear in LIST2. | |
2874 Both lists have to be sorted over <." | |
2875 (let (out) | |
2876 (if (or (null list1) (null list2)) | |
2877 (or list1 list2) | |
2878 (while (and list1 list2) | |
2879 (cond ((= (car list1) (car list2)) | |
2880 (setq list1 (cdr list1) | |
2881 list2 (cdr list2))) | |
2882 ((< (car list1) (car list2)) | |
2883 (setq out (cons (car list1) out)) | |
2884 (setq list1 (cdr list1))) | |
2885 (t | |
2886 (setq out (cons (car list2) out)) | |
2887 (setq list2 (cdr list2))))) | |
2888 (nconc (nreverse out) (or list1 list2))))) | |
2889 | |
2890 (defun gnus-intersection (list1 list2) | |
2891 (let ((result nil)) | |
2892 (while list2 | |
2893 (if (memq (car list2) list1) | |
2894 (setq result (cons (car list2) result))) | |
2895 (setq list2 (cdr list2))) | |
2896 result)) | |
2897 | |
2898 (defun gnus-sorted-intersection (list1 list2) | |
2899 ;; LIST1 and LIST2 have to be sorted over <. | |
2900 (let (out) | |
2901 (while (and list1 list2) | |
2902 (cond ((= (car list1) (car list2)) | |
2903 (setq out (cons (car list1) out) | |
2904 list1 (cdr list1) | |
2905 list2 (cdr list2))) | |
2906 ((< (car list1) (car list2)) | |
2907 (setq list1 (cdr list1))) | |
2908 (t | |
2909 (setq list2 (cdr list2))))) | |
2910 (nreverse out))) | |
2911 | |
2912 (defun gnus-set-sorted-intersection (list1 list2) | |
2913 ;; LIST1 and LIST2 have to be sorted over <. | |
2914 ;; This function modifies LIST1. | |
2915 (let* ((top (cons nil list1)) | |
2916 (prev top)) | |
2917 (while (and list1 list2) | |
2918 (cond ((= (car list1) (car list2)) | |
2919 (setq prev list1 | |
2920 list1 (cdr list1) | |
2921 list2 (cdr list2))) | |
2922 ((< (car list1) (car list2)) | |
2923 (setcdr prev (cdr list1)) | |
2924 (setq list1 (cdr list1))) | |
2925 (t | |
2926 (setq list2 (cdr list2))))) | |
2927 (setcdr prev nil) | |
2928 (cdr top))) | |
2929 | |
2930 (defun gnus-compress-sequence (numbers &optional always-list) | |
2931 "Convert list of numbers to a list of ranges or a single range. | |
2932 If ALWAYS-LIST is non-nil, this function will always release a list of | |
2933 ranges." | |
2934 (let* ((first (car numbers)) | |
2935 (last (car numbers)) | |
2936 result) | |
2937 (if (null numbers) | |
2938 nil | |
2939 (if (not (listp (cdr numbers))) | |
2940 numbers | |
2941 (while numbers | |
2942 (cond ((= last (car numbers)) nil) ;Omit duplicated number | |
2943 ((= (1+ last) (car numbers)) ;Still in sequence | |
2944 (setq last (car numbers))) | |
2945 (t ;End of one sequence | |
2946 (setq result | |
2947 (cons (if (= first last) first | |
2948 (cons first last)) result)) | |
2949 (setq first (car numbers)) | |
2950 (setq last (car numbers)))) | |
2951 (setq numbers (cdr numbers))) | |
2952 (if (and (not always-list) (null result)) | |
2953 (if (= first last) (list first) (cons first last)) | |
2954 (nreverse (cons (if (= first last) first (cons first last)) | |
2955 result))))))) | |
2956 | |
2957 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range) | |
2958 (defun gnus-uncompress-range (ranges) | |
2959 "Expand a list of ranges into a list of numbers. | |
2960 RANGES is either a single range on the form `(num . num)' or a list of | |
2961 these ranges." | |
2962 (let (first last result) | |
2963 (cond | |
2964 ((null ranges) | |
2965 nil) | |
2966 ((not (listp (cdr ranges))) | |
2967 (setq first (car ranges)) | |
2968 (setq last (cdr ranges)) | |
2969 (while (<= first last) | |
2970 (setq result (cons first result)) | |
2971 (setq first (1+ first))) | |
2972 (nreverse result)) | |
2973 (t | |
2974 (while ranges | |
2975 (if (atom (car ranges)) | |
2976 (if (numberp (car ranges)) | |
2977 (setq result (cons (car ranges) result))) | |
2978 (setq first (car (car ranges))) | |
2979 (setq last (cdr (car ranges))) | |
2980 (while (<= first last) | |
2981 (setq result (cons first result)) | |
2982 (setq first (1+ first)))) | |
2983 (setq ranges (cdr ranges))) | |
2984 (nreverse result))))) | |
2985 | |
2986 (defun gnus-add-to-range (ranges list) | |
2987 "Return a list of ranges that has all articles from both RANGES and LIST. | |
2988 Note: LIST has to be sorted over `<'." | |
2989 (if (not ranges) | |
2990 (gnus-compress-sequence list t) | |
2991 (setq list (copy-sequence list)) | |
2992 (or (listp (cdr ranges)) | |
2993 (setq ranges (list ranges))) | |
2994 (let ((out ranges) | |
2995 ilist lowest highest temp) | |
2996 (while (and ranges list) | |
2997 (setq ilist list) | |
2998 (setq lowest (or (and (atom (car ranges)) (car ranges)) | |
2999 (car (car ranges)))) | |
3000 (while (and list (cdr list) (< (car (cdr list)) lowest)) | |
3001 (setq list (cdr list))) | |
3002 (if (< (car ilist) lowest) | |
3003 (progn | |
3004 (setq temp list) | |
3005 (setq list (cdr list)) | |
3006 (setcdr temp nil) | |
3007 (setq out (nconc (gnus-compress-sequence ilist t) out)))) | |
3008 (setq highest (or (and (atom (car ranges)) (car ranges)) | |
3009 (cdr (car ranges)))) | |
3010 (while (and list (<= (car list) highest)) | |
3011 (setq list (cdr list))) | |
3012 (setq ranges (cdr ranges))) | |
3013 (if list | |
3014 (setq out (nconc (gnus-compress-sequence list t) out))) | |
3015 (setq out (sort out (lambda (r1 r2) | |
3016 (< (or (and (atom r1) r1) (car r1)) | |
3017 (or (and (atom r2) r2) (car r2)))))) | |
3018 (setq ranges out) | |
3019 (while ranges | |
3020 (if (atom (car ranges)) | |
3021 (if (cdr ranges) | |
3022 (if (atom (car (cdr ranges))) | |
3023 (if (= (1+ (car ranges)) (car (cdr ranges))) | |
3024 (progn | |
3025 (setcar ranges (cons (car ranges) | |
3026 (car (cdr ranges)))) | |
3027 (setcdr ranges (cdr (cdr ranges))))) | |
3028 (if (= (1+ (car ranges)) (car (car (cdr ranges)))) | |
3029 (progn | |
3030 (setcar (car (cdr ranges)) (car ranges)) | |
3031 (setcar ranges (car (cdr ranges))) | |
3032 (setcdr ranges (cdr (cdr ranges))))))) | |
3033 (if (cdr ranges) | |
3034 (if (atom (car (cdr ranges))) | |
3035 (if (= (1+ (cdr (car ranges))) (car (cdr ranges))) | |
3036 (progn | |
3037 (setcdr (car ranges) (car (cdr ranges))) | |
3038 (setcdr ranges (cdr (cdr ranges))))) | |
3039 (if (= (1+ (cdr (car ranges))) (car (car (cdr ranges)))) | |
3040 (progn | |
3041 (setcdr (car ranges) (cdr (car (cdr ranges)))) | |
3042 (setcdr ranges (cdr (cdr ranges)))))))) | |
3043 (setq ranges (cdr ranges))) | |
3044 out))) | |
3045 | |
3046 (defun gnus-remove-from-range (ranges list) | |
3047 "Return a list of ranges that has all articles from LIST removed from RANGES. | |
3048 Note: LIST has to be sorted over `<'." | |
3049 ;; !!! This function shouldn't look like this, but I've got a headache. | |
3050 (gnus-compress-sequence | |
3051 (gnus-sorted-complement | |
3052 (gnus-uncompress-range ranges) list))) | |
3053 | |
3054 (defun gnus-member-of-range (number ranges) | |
3055 (if (not (listp (cdr ranges))) | |
3056 (and (>= number (car ranges)) | |
3057 (<= number (cdr ranges))) | |
3058 (let ((not-stop t)) | |
3059 (while (and ranges | |
3060 (if (numberp (car ranges)) | |
3061 (>= number (car ranges)) | |
3062 (>= number (car (car ranges)))) | |
3063 not-stop) | |
3064 (if (if (numberp (car ranges)) | |
3065 (= number (car ranges)) | |
3066 (and (>= number (car (car ranges))) | |
3067 (<= number (cdr (car ranges))))) | |
3068 (setq not-stop nil)) | |
3069 (setq ranges (cdr ranges))) | |
3070 (not not-stop)))) | |
3071 | |
3072 | |
3073 ;;; | |
3074 ;;; Gnus group mode | |
3075 ;;; | |
3076 | |
3077 (defvar gnus-group-mode-map nil) | |
3078 (defvar gnus-group-group-map nil) | |
3079 (defvar gnus-group-mark-map nil) | |
3080 (defvar gnus-group-list-map nil) | |
13694
73433c3071a5
* gnus.el (gnus-parse-headers-hook): New hook.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
13579
diff
changeset
|
3081 (defvar gnus-group-help-map nil) |
13401 | 3082 (defvar gnus-group-sub-map nil) |
3083 (put 'gnus-group-mode 'mode-class 'special) | |
3084 | |
3085 (if gnus-group-mode-map | |
3086 nil | |
3087 (setq gnus-group-mode-map (make-keymap)) | |
3088 (suppress-keymap gnus-group-mode-map) | |
3089 (define-key gnus-group-mode-map " " 'gnus-group-read-group) | |
3090 (define-key gnus-group-mode-map "=" 'gnus-group-select-group) | |
3091 (define-key gnus-group-mode-map "\r" 'gnus-group-select-group) | |
3092 (define-key gnus-group-mode-map "j" 'gnus-group-jump-to-group) | |
3093 (define-key gnus-group-mode-map "n" 'gnus-group-next-unread-group) | |
3094 (define-key gnus-group-mode-map "p" 'gnus-group-prev-unread-group) | |
3095 (define-key gnus-group-mode-map "\177" 'gnus-group-prev-unread-group) | |
3096 (define-key gnus-group-mode-map "N" 'gnus-group-next-group) | |
3097 (define-key gnus-group-mode-map "P" 'gnus-group-prev-group) | |
3098 (define-key gnus-group-mode-map | |
3099 "\M-n" 'gnus-group-next-unread-group-same-level) | |
3100 (define-key gnus-group-mode-map | |
3101 "\M-p" 'gnus-group-prev-unread-group-same-level) | |
3102 (define-key gnus-group-mode-map "," 'gnus-group-best-unread-group) | |
3103 (define-key gnus-group-mode-map "." 'gnus-group-first-unread-group) | |
3104 (define-key gnus-group-mode-map "u" 'gnus-group-unsubscribe-current-group) | |
3105 (define-key gnus-group-mode-map "U" 'gnus-group-unsubscribe-group) | |
3106 (define-key gnus-group-mode-map "c" 'gnus-group-catchup-current) | |
3107 (define-key gnus-group-mode-map "C" 'gnus-group-catchup-current-all) | |
3108 (define-key gnus-group-mode-map "l" 'gnus-group-list-groups) | |
3109 (define-key gnus-group-mode-map "L" 'gnus-group-list-all-groups) | |
3110 (define-key gnus-group-mode-map "m" 'gnus-group-mail) | |
3111 (define-key gnus-group-mode-map "g" 'gnus-group-get-new-news) | |
3112 (define-key gnus-group-mode-map "\M-g" 'gnus-group-get-new-news-this-group) | |
3113 (define-key gnus-group-mode-map "R" 'gnus-group-restart) | |
3114 (define-key gnus-group-mode-map "r" 'gnus-group-read-init-file) | |
3115 (define-key gnus-group-mode-map "B" 'gnus-group-browse-foreign-server) | |
3116 (define-key gnus-group-mode-map "b" 'gnus-group-check-bogus-groups) | |
3117 (define-key gnus-group-mode-map "F" 'gnus-find-new-newsgroups) | |
3118 (define-key gnus-group-mode-map "\C-c\C-d" 'gnus-group-describe-group) | |
3119 (define-key gnus-group-mode-map "\M-d" 'gnus-group-describe-all-groups) | |
3120 (define-key gnus-group-mode-map "\C-c\C-a" 'gnus-group-apropos) | |
3121 (define-key gnus-group-mode-map "\C-c\M-\C-a" 'gnus-group-description-apropos) | |
3122 (define-key gnus-group-mode-map "a" 'gnus-group-post-news) | |
3123 (define-key gnus-group-mode-map "\ek" 'gnus-group-edit-local-kill) | |
3124 (define-key gnus-group-mode-map "\eK" 'gnus-group-edit-global-kill) | |
3125 (define-key gnus-group-mode-map "\C-k" 'gnus-group-kill-group) | |
3126 (define-key gnus-group-mode-map "\C-y" 'gnus-group-yank-group) | |
3127 (define-key gnus-group-mode-map "\C-w" 'gnus-group-kill-region) | |
3128 (define-key gnus-group-mode-map "\C-x\C-t" 'gnus-group-transpose-groups) | |
3129 (define-key gnus-group-mode-map "\C-c\C-l" 'gnus-group-list-killed) | |
3130 (define-key gnus-group-mode-map "\C-c\C-x" 'gnus-group-expire-articles) | |
3131 (define-key gnus-group-mode-map "\C-c\M-\C-x" 'gnus-group-expire-all-groups) | |
3132 (define-key gnus-group-mode-map "V" 'gnus-version) | |
3133 (define-key gnus-group-mode-map "s" 'gnus-group-save-newsrc) | |
3134 (define-key gnus-group-mode-map "z" 'gnus-group-suspend) | |
3135 (define-key gnus-group-mode-map "Z" 'gnus-group-clear-dribble) | |
3136 (define-key gnus-group-mode-map "q" 'gnus-group-exit) | |
3137 (define-key gnus-group-mode-map "Q" 'gnus-group-quit) | |
3138 (define-key gnus-group-mode-map "?" 'gnus-group-describe-briefly) | |
3139 (define-key gnus-group-mode-map "\C-c\C-i" 'gnus-info-find-node) | |
3140 (define-key gnus-group-mode-map "\M-e" 'gnus-group-edit-group-method) | |
3141 (define-key gnus-group-mode-map "^" 'gnus-group-enter-server-mode) | |
3142 (define-key gnus-group-mode-map gnus-mouse-2 'gnus-mouse-pick-group) | |
3143 (define-key gnus-group-mode-map "<" 'beginning-of-buffer) | |
3144 (define-key gnus-group-mode-map ">" 'end-of-buffer) | |
3145 (define-key gnus-group-mode-map "\C-c\C-b" 'gnus-bug) | |
3146 (define-key gnus-group-mode-map "\C-c\C-s" 'gnus-group-sort-groups) | |
3147 | |
3148 (define-key gnus-group-mode-map "#" 'gnus-group-mark-group) | |
3149 (define-key gnus-group-mode-map "\M-#" 'gnus-group-unmark-group) | |
3150 (define-prefix-command 'gnus-group-mark-map) | |
3151 (define-key gnus-group-mode-map "M" 'gnus-group-mark-map) | |
3152 (define-key gnus-group-mark-map "m" 'gnus-group-mark-group) | |
3153 (define-key gnus-group-mark-map "u" 'gnus-group-unmark-group) | |
3154 (define-key gnus-group-mark-map "w" 'gnus-group-mark-region) | |
3155 | |
3156 (define-prefix-command 'gnus-group-group-map) | |
3157 (define-key gnus-group-mode-map "G" 'gnus-group-group-map) | |
3158 (define-key gnus-group-group-map "d" 'gnus-group-make-directory-group) | |
3159 (define-key gnus-group-group-map "h" 'gnus-group-make-help-group) | |
3160 (define-key gnus-group-group-map "a" 'gnus-group-make-archive-group) | |
3161 (define-key gnus-group-group-map "k" 'gnus-group-make-kiboze-group) | |
3162 (define-key gnus-group-group-map "m" 'gnus-group-make-group) | |
3163 (define-key gnus-group-group-map "E" 'gnus-group-edit-group) | |
3164 (define-key gnus-group-group-map "e" 'gnus-group-edit-group-method) | |
3165 (define-key gnus-group-group-map "p" 'gnus-group-edit-group-parameters) | |
3166 (define-key gnus-group-group-map "v" 'gnus-group-add-to-virtual) | |
3167 (define-key gnus-group-group-map "V" 'gnus-group-make-empty-virtual) | |
3168 (define-key gnus-group-group-map "D" 'gnus-group-enter-directory) | |
3169 (define-key gnus-group-group-map "f" 'gnus-group-make-doc-group) | |
3170 ;;(define-key gnus-group-group-map "sb" 'gnus-group-brew-soup) | |
3171 ;;(define-key gnus-group-group-map "sw" 'gnus-soup-save-areas) | |
3172 ;;(define-key gnus-group-group-map "ss" 'gnus-soup-send-replies) | |
3173 ;;(define-key gnus-group-group-map "sp" 'gnus-soup-pack-packet) | |
3174 ;;(define-key gnus-group-group-map "sr" 'nnsoup-pack-replies) | |
3175 | |
3176 (define-prefix-command 'gnus-group-list-map) | |
3177 (define-key gnus-group-mode-map "A" 'gnus-group-list-map) | |
3178 (define-key gnus-group-list-map "k" 'gnus-group-list-killed) | |
3179 (define-key gnus-group-list-map "z" 'gnus-group-list-zombies) | |
3180 (define-key gnus-group-list-map "s" 'gnus-group-list-groups) | |
3181 (define-key gnus-group-list-map "u" 'gnus-group-list-all-groups) | |
3182 (define-key gnus-group-list-map "a" 'gnus-group-apropos) | |
3183 (define-key gnus-group-list-map "d" 'gnus-group-description-apropos) | |
3184 (define-key gnus-group-list-map "m" 'gnus-group-list-matching) | |
3185 (define-key gnus-group-list-map "M" 'gnus-group-list-all-matching) | |
3186 | |
13694
73433c3071a5
* gnus.el (gnus-parse-headers-hook): New hook.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
13579
diff
changeset
|
3187 (define-prefix-command 'gnus-group-help-map) |
73433c3071a5
* gnus.el (gnus-parse-headers-hook): New hook.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
13579
diff
changeset
|
3188 (define-key gnus-group-mode-map "H" 'gnus-group-help-map) |
73433c3071a5
* gnus.el (gnus-parse-headers-hook): New hook.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
13579
diff
changeset
|
3189 (define-key gnus-group-help-map "f" 'gnus-group-fetch-faq) |
73433c3071a5
* gnus.el (gnus-parse-headers-hook): New hook.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
13579
diff
changeset
|
3190 |
13401 | 3191 (define-prefix-command 'gnus-group-sub-map) |
3192 (define-key gnus-group-mode-map "S" 'gnus-group-sub-map) | |
3193 (define-key gnus-group-sub-map "l" 'gnus-group-set-current-level) | |
3194 (define-key gnus-group-sub-map "t" 'gnus-group-unsubscribe-current-group) | |
3195 (define-key gnus-group-sub-map "s" 'gnus-group-unsubscribe-group) | |
3196 (define-key gnus-group-sub-map "k" 'gnus-group-kill-group) | |
3197 (define-key gnus-group-sub-map "y" 'gnus-group-yank-group) | |
3198 (define-key gnus-group-sub-map "w" 'gnus-group-kill-region) | |
3199 (define-key gnus-group-sub-map "z" 'gnus-group-kill-all-zombies)) | |
3200 | |
3201 (defun gnus-group-mode () | |
3202 "Major mode for reading news. | |
3203 | |
3204 All normal editing commands are switched off. | |
3205 \\<gnus-group-mode-map> | |
3206 The group buffer lists (some of) the groups available. For instance, | |
3207 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]' | |
3208 lists all zombie groups. | |
3209 | |
3210 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe | |
3211 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'. | |
3212 | |
3213 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]'). | |
3214 | |
3215 The following commands are available: | |
3216 | |
3217 \\{gnus-group-mode-map}" | |
3218 (interactive) | |
3219 (if gnus-visual (gnus-group-make-menu-bar)) | |
3220 (kill-all-local-variables) | |
3221 (setq mode-line-modified "-- ") | |
3222 (make-local-variable 'mode-line-format) | |
3223 (setq mode-line-format (copy-sequence mode-line-format)) | |
3224 (and (equal (nth 3 mode-line-format) " ") | |
3225 (setcar (nthcdr 3 mode-line-format) "")) | |
3226 (setq major-mode 'gnus-group-mode) | |
3227 (setq mode-name "Group") | |
3228 (gnus-group-set-mode-line) | |
3229 (setq mode-line-process nil) | |
3230 (use-local-map gnus-group-mode-map) | |
3231 (buffer-disable-undo (current-buffer)) | |
3232 (setq truncate-lines t) | |
3233 (setq buffer-read-only t) | |
3234 (run-hooks 'gnus-group-mode-hook)) | |
3235 | |
3236 (defun gnus-mouse-pick-group (e) | |
3237 (interactive "e") | |
3238 (mouse-set-point e) | |
3239 (gnus-group-read-group nil)) | |
3240 | |
3241 ;; Look at LEVEL and find out what the level is really supposed to be. | |
3242 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens | |
3243 ;; will depend on whether `gnus-group-use-permanent-levels' is used. | |
3244 (defun gnus-group-default-level (&optional level number-or-nil) | |
3245 (cond | |
3246 (gnus-group-use-permanent-levels | |
3247 (setq gnus-group-default-list-level | |
3248 (or level gnus-group-default-list-level)) | |
3249 (or gnus-group-default-list-level gnus-level-subscribed)) | |
3250 (number-or-nil | |
3251 level) | |
3252 (t | |
3253 (or level gnus-group-default-list-level gnus-level-subscribed)))) | |
3254 | |
3255 | |
3256 (defvar gnus-tmp-prev-perm nil) | |
3257 | |
3258 ;;;###autoload | |
3259 (defun gnus-no-server (&optional arg) | |
3260 "Read network news. | |
3261 If ARG is a positive number, Gnus will use that as the | |
3262 startup level. If ARG is nil, Gnus will be started at level 2. | |
3263 If ARG is non-nil and not a positive number, Gnus will | |
3264 prompt the user for the name of an NNTP server to use. | |
3265 As opposed to `gnus', this command will not connect to the local server." | |
3266 (interactive "P") | |
3267 (let ((perm | |
3268 (cons gnus-group-use-permanent-levels gnus-group-default-list-level))) | |
3269 (setq gnus-tmp-prev-perm nil) | |
3270 (setq gnus-group-use-permanent-levels t) | |
3271 (gnus (or arg (1- gnus-level-default-subscribed)) t) | |
3272 (setq gnus-tmp-prev-perm perm))) | |
3273 | |
3274 ;;;###autoload | |
3275 (defun gnus (&optional arg dont-connect) | |
3276 "Read network news. | |
3277 If ARG is non-nil and a positive number, Gnus will use that as the | |
3278 startup level. If ARG is non-nil and not a positive number, Gnus will | |
3279 prompt the user for the name of an NNTP server to use." | |
3280 (interactive "P") | |
3281 (if (get-buffer gnus-group-buffer) | |
3282 (progn | |
3283 (switch-to-buffer gnus-group-buffer) | |
3284 (gnus-group-get-new-news)) | |
3285 | |
3286 (gnus-clear-system) | |
3287 | |
3288 (nnheader-init-server-buffer) | |
3289 ;; We do this if `gnus-no-server' has been run. | |
3290 (if gnus-tmp-prev-perm | |
3291 (setq gnus-group-use-permanent-levels (car gnus-tmp-prev-perm) | |
3292 gnus-group-default-list-level (cdr gnus-tmp-prev-perm) | |
3293 gnus-tmp-prev-perm nil)) | |
3294 (gnus-read-init-file) | |
3295 | |
3296 (gnus-group-setup-buffer) | |
3297 (let ((buffer-read-only nil)) | |
3298 (erase-buffer) | |
3299 (if (not gnus-inhibit-startup-message) | |
3300 (progn | |
3301 (gnus-group-startup-message) | |
3302 (sit-for 0)))) | |
3303 | |
3304 (let ((level (and arg (numberp arg) (> arg 0) arg)) | |
3305 did-connect) | |
3306 (unwind-protect | |
3307 (progn | |
3308 (or dont-connect | |
3309 (setq did-connect | |
3310 (gnus-start-news-server (and arg (not level)))))) | |
3311 (if (and (not dont-connect) | |
3312 (not did-connect)) | |
3313 (gnus-group-quit) | |
3314 (run-hooks 'gnus-startup-hook) | |
3315 ;; NNTP server is successfully open. | |
3316 | |
3317 ;; Find the current startup file name. | |
3318 (setq gnus-current-startup-file | |
3319 (gnus-make-newsrc-file gnus-startup-file)) | |
3320 | |
3321 ;; Read the dribble file. | |
3322 (and gnus-use-dribble-file (gnus-dribble-read-file)) | |
3323 | |
3324 (gnus-summary-make-display-table) | |
3325 (gnus-setup-news nil level) | |
3326 (gnus-group-list-groups level) | |
3327 (gnus-configure-windows 'group)))))) | |
3328 | |
3329 (defun gnus-unload () | |
3330 "Unload all Gnus features." | |
3331 (interactive) | |
3332 (or (boundp 'load-history) | |
3333 (error "Sorry, `gnus-unload' is not implemented in this Emacs version.")) | |
3334 (let ((history load-history) | |
3335 feature) | |
3336 (while history | |
3337 (and (string-match "^gnus" (car (car history))) | |
3338 (setq feature (cdr (assq 'provide (car history)))) | |
3339 (unload-feature feature 'force)) | |
3340 (setq history (cdr history))))) | |
3341 | |
3342 (defun gnus-group-startup-message (&optional x y) | |
3343 "Insert startup message in current buffer." | |
3344 ;; Insert the message. | |
3345 (erase-buffer) | |
3346 (insert | |
3347 (format " | |
3348 _ ___ _ _ | |
3349 _ ___ __ ___ __ _ ___ | |
3350 __ _ ___ __ ___ | |
3351 _ ___ _ | |
3352 _ _ __ _ | |
3353 ___ __ _ | |
3354 __ _ | |
3355 _ _ _ | |
3356 _ _ _ | |
3357 _ _ _ | |
3358 __ ___ | |
3359 _ _ _ _ | |
3360 _ _ | |
3361 _ _ | |
3362 _ _ | |
3363 _ | |
3364 __ | |
3365 | |
3366 | |
3367 Gnus * A newsreader for Emacsen | |
3368 A Praxis release * larsi@ifi.uio.no | |
3369 " | |
3370 gnus-version)) | |
3371 ;; And then hack it. | |
3372 ;; 18 is the longest line. | |
3373 (indent-rigidly (point-min) (point-max) | |
3374 (/ (max (- (window-width) (or x 46)) 0) 2)) | |
3375 (goto-char (point-min)) | |
3376 (let* ((pheight (count-lines (point-min) (point-max))) | |
3377 (wheight (window-height)) | |
3378 (rest (- wheight pheight))) | |
3379 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n))) | |
3380 | |
3381 | |
3382 | |
3383 ;; Fontify some. | |
3384 (goto-char (point-min)) | |
3385 (search-forward "Praxis") | |
3386 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold) | |
3387 (goto-char (point-min))) | |
3388 | |
3389 (defun gnus-group-startup-message-old (&optional x y) | |
3390 "Insert startup message in current buffer." | |
3391 ;; Insert the message. | |
3392 (erase-buffer) | |
3393 (insert | |
3394 (format " | |
3395 %s | |
3396 A newsreader | |
3397 for GNU Emacs | |
3398 | |
3399 Based on GNUS | |
3400 written by | |
3401 Masanobu UMEDA | |
3402 | |
3403 A Praxis Release | |
3404 larsi@ifi.uio.no | |
3405 " | |
3406 gnus-version)) | |
3407 ;; And then hack it. | |
3408 ;; 18 is the longest line. | |
3409 (indent-rigidly (point-min) (point-max) | |
3410 (/ (max (- (window-width) (or x 28)) 0) 2)) | |
3411 (goto-char (point-min)) | |
3412 ;; +4 is fuzzy factor. | |
3413 (insert-char ?\n (/ (max (- (window-height) (or y 12)) 0) 2)) | |
3414 | |
3415 ;; Fontify some. | |
3416 (goto-char (point-min)) | |
3417 (search-forward "Praxis") | |
3418 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold) | |
3419 (goto-char (point-min))) | |
3420 | |
3421 (defun gnus-group-setup-buffer () | |
3422 (or (get-buffer gnus-group-buffer) | |
3423 (progn | |
3424 (switch-to-buffer gnus-group-buffer) | |
3425 (gnus-add-current-to-buffer-list) | |
3426 (gnus-group-mode) | |
3427 (and gnus-carpal (gnus-carpal-setup-buffer 'group))))) | |
3428 | |
3429 (defun gnus-group-list-groups (&optional level unread) | |
3430 "List newsgroups with level LEVEL or lower that have unread articles. | |
3431 Default is all subscribed groups. | |
3432 If argument UNREAD is non-nil, groups with no unread articles are also | |
3433 listed." | |
3434 (interactive (list (if current-prefix-arg | |
3435 (prefix-numeric-value current-prefix-arg) | |
3436 (or | |
3437 (gnus-group-default-level nil t) | |
3438 gnus-group-default-list-level | |
3439 gnus-level-subscribed)))) | |
3440 (or level | |
3441 (setq level (car gnus-group-list-mode) | |
3442 unread (cdr gnus-group-list-mode))) | |
3443 (setq level (gnus-group-default-level level)) | |
3444 (gnus-group-setup-buffer) ;May call from out of group buffer | |
3445 (let ((case-fold-search nil) | |
3446 (group (gnus-group-group-name))) | |
3447 (funcall gnus-group-prepare-function level unread nil) | |
3448 (if (zerop (buffer-size)) | |
3449 (gnus-message 5 gnus-no-groups-message) | |
3450 (goto-char (point-min)) | |
3451 (if (not group) | |
3452 ;; Go to the first group with unread articles. | |
3453 (gnus-group-search-forward nil nil nil t) | |
3454 ;; Find the right group to put point on. If the current group | |
3455 ;; has disapeared in the new listing, try to find the next | |
3456 ;; one. If no next one can be found, just leave point at the | |
3457 ;; first newsgroup in the buffer. | |
3458 (if (not (gnus-goto-char | |
3459 (text-property-any (point-min) (point-max) | |
3460 'gnus-group (intern group)))) | |
3461 (let ((newsrc (nthcdr 3 (gnus-gethash group gnus-newsrc-hashtb)))) | |
3462 (while (and newsrc | |
3463 (not (gnus-goto-char | |
3464 (text-property-any | |
3465 (point-min) (point-max) 'gnus-group | |
3466 (intern (car (car newsrc))))))) | |
3467 (setq newsrc (cdr newsrc))) | |
3468 (or newsrc (progn (goto-char (point-max)) | |
3469 (forward-line -1)))))) | |
3470 ;; Adjust cursor point. | |
3471 (gnus-group-position-cursor)))) | |
3472 | |
3473 (defun gnus-group-prepare-flat (level &optional all lowest regexp) | |
3474 "List all newsgroups with unread articles of level LEVEL or lower. | |
3475 If ALL is non-nil, list groups that have no unread articles. | |
3476 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher. | |
3477 If REGEXP, only list groups matching REGEXP." | |
3478 (set-buffer gnus-group-buffer) | |
3479 (let ((buffer-read-only nil) | |
3480 (newsrc (cdr gnus-newsrc-alist)) | |
3481 (lowest (or lowest 1)) | |
3482 info clevel unread group) | |
3483 (erase-buffer) | |
3484 (if (< lowest gnus-level-zombie) | |
3485 ;; List living groups. | |
3486 (while newsrc | |
3487 (setq info (car newsrc) | |
3488 group (car info) | |
3489 newsrc (cdr newsrc) | |
3490 unread (car (gnus-gethash group gnus-newsrc-hashtb))) | |
3491 (and unread ; This group might be bogus | |
3492 (or (not regexp) | |
3493 (string-match regexp group)) | |
3494 (<= (setq clevel (car (cdr info))) level) | |
3495 (>= clevel lowest) | |
3496 (or all ; We list all groups? | |
3497 (eq unread t) ; We list unactivated groups | |
3498 (> unread 0) ; We list groups with unread articles | |
3499 (cdr (assq 'tick (nth 3 info)))) ; And groups with tickeds | |
3500 (gnus-group-insert-group-line | |
3501 nil group (car (cdr info)) (nth 3 info) unread (nth 4 info))))) | |
3502 | |
3503 ;; List dead groups. | |
3504 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie) | |
3505 (gnus-group-prepare-flat-list-dead | |
3506 (setq gnus-zombie-list (sort gnus-zombie-list 'string<)) | |
3507 gnus-level-zombie ?Z | |
3508 regexp)) | |
3509 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed) | |
3510 (gnus-group-prepare-flat-list-dead | |
3511 (setq gnus-killed-list (sort gnus-killed-list 'string<)) | |
3512 gnus-level-killed ?K regexp)) | |
3513 | |
3514 (gnus-group-set-mode-line) | |
3515 (setq gnus-group-list-mode (cons level all)) | |
3516 (run-hooks 'gnus-group-prepare-hook))) | |
3517 | |
3518 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp) | |
3519 ;; List zombies and killed lists somehwat faster, which was | |
3520 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does | |
3521 ;; this by ignoring the group format specification altogether. | |
3522 (let (group beg) | |
3523 (while groups | |
3524 (setq group (car groups) | |
3525 groups (cdr groups)) | |
3526 (if (or (not regexp) | |
3527 (string-match regexp group)) | |
3528 (progn | |
3529 (setq beg (point)) | |
3530 (insert (format " %c *: %s\n" mark group)) | |
3531 (add-text-properties | |
3532 beg (1+ beg) | |
3533 (list 'gnus-group (intern group) | |
3534 'gnus-unread t | |
3535 'gnus-level level))))))) | |
3536 | |
3537 (defun gnus-group-real-name (group) | |
3538 "Find the real name of a foreign newsgroup." | |
3539 (if (string-match ":[^:]+$" group) | |
3540 (substring group (1+ (match-beginning 0))) | |
3541 group)) | |
3542 | |
3543 (defun gnus-group-prefixed-name (group method) | |
3544 "Return the whole name from GROUP and METHOD." | |
3545 (and (stringp method) (setq method (gnus-server-to-method method))) | |
3546 (concat (format "%s" (car method)) | |
3547 (if (and | |
3548 (assoc (format "%s" (car method)) (gnus-methods-using 'address)) | |
3549 (not (string= (nth 1 method) ""))) | |
3550 (concat "+" (nth 1 method))) | |
3551 ":" group)) | |
3552 | |
3553 (defun gnus-group-real-prefix (group) | |
3554 "Return the prefix of the current group name." | |
3555 (if (string-match "^[^:]+:" group) | |
3556 (substring group 0 (match-end 0)) | |
3557 "")) | |
3558 | |
3559 (defun gnus-group-method-name (group) | |
3560 "Return the method used for selecting GROUP." | |
3561 (let ((prefix (gnus-group-real-prefix group))) | |
3562 (if (equal prefix "") | |
3563 gnus-select-method | |
3564 (if (string-match "^[^\\+]+\\+" prefix) | |
3565 (list (intern (substring prefix 0 (1- (match-end 0)))) | |
3566 (substring prefix (match-end 0) (1- (length prefix)))) | |
3567 (list (intern (substring prefix 0 (1- (length prefix)))) ""))))) | |
3568 | |
3569 (defun gnus-group-foreign-p (group) | |
3570 "Return nil if GROUP is native, non-nil if it is foreign." | |
3571 (string-match ":" group)) | |
3572 | |
3573 (defun gnus-group-set-info (info &optional method-only-group part) | |
3574 (let* ((entry (gnus-gethash | |
3575 (or method-only-group (car info)) gnus-newsrc-hashtb)) | |
3576 (part-info info) | |
3577 (info (if method-only-group (nth 2 entry) info))) | |
3578 (if (not method-only-group) | |
3579 () | |
3580 (or entry | |
3581 (error "Trying to change non-existent group %s" method-only-group)) | |
3582 ;; We have recevied parts of the actual group info - either the | |
3583 ;; select method or the group parameters. We first check | |
3584 ;; whether we have to extend the info, and if so, do that. | |
3585 (let ((len (length info)) | |
3586 (total (if (eq part 'method) 5 6))) | |
3587 (and (< len total) | |
3588 (setcdr (nthcdr (1- len) info) | |
3589 (make-list (- total len) nil))) | |
3590 ;; Then we enter the new info. | |
3591 (setcar (nthcdr (1- total) info) part-info))) | |
3592 ;; We uncompress some lists of marked articles. | |
3593 (let (marked) | |
3594 (if (not (setq marked (nth 3 info))) | |
3595 () | |
3596 (while marked | |
3597 (or (eq 'score (car (car marked))) | |
3598 (eq 'bookmark (car (car marked))) | |
3599 (eq 'killed (car (car marked))) | |
3600 (setcdr (car marked) | |
3601 (gnus-uncompress-range (cdr (car marked))))) | |
3602 (setq marked (cdr marked))))) | |
3603 (if entry | |
3604 () | |
3605 ;; This is a new group, so we just create it. | |
3606 (save-excursion | |
3607 (set-buffer gnus-group-buffer) | |
3608 (if (nth 4 info) | |
3609 ;; It's a foreign group... | |
3610 (gnus-group-make-group | |
3611 (gnus-group-real-name (car info)) | |
3612 (prin1-to-string (car (nth 4 info))) | |
3613 (nth 1 (nth 4 info))) | |
3614 ;; It's a native group. | |
3615 (gnus-group-make-group (car info))) | |
3616 (gnus-message 6 "Note: New group created") | |
3617 (setq entry | |
3618 (gnus-gethash (gnus-group-prefixed-name | |
3619 (gnus-group-real-name (car info)) | |
3620 (or (nth 4 info) gnus-select-method)) | |
3621 gnus-newsrc-hashtb)))) | |
3622 ;; Whether it was a new group or not, we now have the entry, so we | |
3623 ;; can do the update. | |
3624 (if entry | |
3625 (progn | |
3626 (setcar (nthcdr 2 entry) info) | |
3627 (if (and (not (eq (car entry) t)) | |
3628 (gnus-gethash (car info) gnus-active-hashtb)) | |
3629 (let ((marked (nth 3 info))) | |
3630 (setcar entry | |
3631 (max 0 (- (length (gnus-list-of-unread-articles | |
3632 (car info))) | |
3633 (length (cdr (assq 'tick marked))) | |
3634 (length (cdr (assq 'dormant marked))))))))) | |
3635 (error "No such group: %s" (car info))))) | |
3636 | |
3637 (defun gnus-group-set-method-info (group select-method) | |
3638 (gnus-group-set-info select-method group 'method)) | |
3639 | |
3640 (defun gnus-group-set-params-info (group params) | |
3641 (gnus-group-set-info params group 'params)) | |
3642 | |
3643 (defun gnus-group-update-group-line () | |
3644 "This function updates the current line in the newsgroup buffer and | |
3645 moves the point to the colon." | |
3646 (let* ((buffer-read-only nil) | |
3647 (group (gnus-group-group-name)) | |
3648 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))) | |
3649 (if (and entry (not (gnus-ephemeral-group-p group))) | |
3650 (gnus-dribble-enter | |
3651 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry)) | |
3652 ")"))) | |
3653 (beginning-of-line) | |
3654 (delete-region (point) (progn (forward-line 1) (point))) | |
3655 (gnus-group-insert-group-line-info group) | |
3656 (forward-line -1) | |
3657 (gnus-group-position-cursor))) | |
3658 | |
3659 (defun gnus-group-insert-group-line-info (group) | |
3660 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)) | |
3661 active info) | |
3662 (if entry | |
3663 (progn | |
3664 (setq info (nth 2 entry)) | |
3665 (gnus-group-insert-group-line | |
3666 nil group (nth 1 info) (nth 3 info) (car entry) (nth 4 info))) | |
3667 (setq active (gnus-gethash group gnus-active-hashtb)) | |
3668 (gnus-group-insert-group-line | |
3669 nil group | |
3670 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed) | |
3671 nil (if active (- (1+ (cdr active)) (car active)) 0) nil)))) | |
3672 | |
3673 (defun gnus-group-insert-group-line (gformat group level marked number method) | |
3674 (let* ((gformat (or gformat gnus-group-line-format-spec)) | |
3675 (active (gnus-gethash group gnus-active-hashtb)) | |
3676 (number-total (if active (1+ (- (cdr active) (car active))) 0)) | |
3677 (number-of-dormant (length (cdr (assq 'dormant marked)))) | |
3678 (number-of-ticked (length (cdr (assq 'tick marked)))) | |
3679 (number-of-ticked-and-dormant | |
3680 (+ number-of-ticked number-of-dormant)) | |
3681 (number-of-unread-unticked | |
3682 (if (numberp number) (int-to-string (max 0 number)) | |
3683 "*")) | |
3684 (number-of-read | |
3685 (if (numberp number) | |
3686 (max 0 (- number-total number)) | |
3687 "*")) | |
3688 (subscribed (cond ((<= level gnus-level-subscribed) ? ) | |
3689 ((<= level gnus-level-unsubscribed) ?U) | |
3690 ((= level gnus-level-zombie) ?Z) | |
3691 (t ?K))) | |
3692 (qualified-group (gnus-group-real-name group)) | |
3693 (newsgroup-description | |
3694 (if gnus-description-hashtb | |
3695 (or (gnus-gethash group gnus-description-hashtb) "") | |
3696 "")) | |
3697 (moderated (if (member group gnus-moderated-list) ?m ? )) | |
3698 (moderated-string (if (eq moderated ?m) "(m)" "")) | |
3699 (method (gnus-server-get-method group method)) | |
3700 (news-server (or (car (cdr method)) "")) | |
3701 (news-method (or (car method) "")) | |
3702 (news-method-string | |
3703 (if method (format "(%s:%s)" (car method) (car (cdr method))) "")) | |
3704 (marked (if (and | |
3705 (numberp number) | |
3706 (zerop number) | |
3707 (> number-of-ticked 0)) | |
3708 ?* ? )) | |
3709 (number (if (eq number t) "*" (+ number number-of-dormant | |
3710 number-of-ticked))) | |
3711 (process-marked (if (member group gnus-group-marked) | |
3712 gnus-process-mark ? )) | |
3713 (buffer-read-only nil) | |
3714 header ; passed as parameter to user-funcs. | |
3715 b) | |
3716 (beginning-of-line) | |
3717 (setq b (point)) | |
3718 ;; Insert the text. | |
3719 (insert (eval gformat)) | |
3720 | |
3721 (add-text-properties | |
3722 b (1+ b) (list 'gnus-group (intern group) | |
3723 'gnus-unread (if (numberp number) | |
3724 (string-to-int number-of-unread-unticked) | |
3725 t) | |
3726 'gnus-marked marked | |
3727 'gnus-level level)))) | |
3728 | |
3729 (defun gnus-group-update-group (group &optional visible-only) | |
3730 "Update newsgroup info of GROUP. | |
3731 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't already." | |
3732 (save-excursion | |
3733 (set-buffer gnus-group-buffer) | |
3734 (let ((buffer-read-only nil) | |
3735 visible) | |
3736 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))) | |
3737 (if (and entry | |
3738 (not (gnus-ephemeral-group-p group))) | |
3739 (gnus-dribble-enter | |
3740 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry)) | |
3741 ")")))) | |
3742 ;; Buffer may be narrowed. | |
3743 (save-restriction | |
3744 (widen) | |
3745 ;; Search a line to modify. If the buffer is large, the search | |
3746 ;; takes long time. In most cases, current point is on the line | |
3747 ;; we are looking for. So, first of all, check current line. | |
3748 (if (or (progn | |
3749 (beginning-of-line) | |
3750 (eq (get-text-property (point) 'gnus-group) | |
3751 (intern group))) | |
3752 (progn | |
3753 (gnus-goto-char | |
3754 (text-property-any | |
3755 (point-min) (point-max) 'gnus-group (intern group))))) | |
3756 ;; GROUP is listed in current buffer. So, delete old line. | |
3757 (progn | |
3758 (setq visible t) | |
3759 (beginning-of-line) | |
3760 (delete-region (point) (progn (forward-line 1) (point)))) | |
3761 ;; No such line in the buffer, find out where it's supposed to | |
3762 ;; go, and insert it there (or at the end of the buffer). | |
3763 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>. | |
3764 (or visible-only | |
3765 (let ((entry | |
3766 (cdr (cdr (gnus-gethash group gnus-newsrc-hashtb))))) | |
3767 (while (and entry | |
3768 (car entry) | |
3769 (not | |
3770 (gnus-goto-char | |
3771 (text-property-any | |
3772 (point-min) (point-max) | |
3773 'gnus-group (intern (car (car entry))))))) | |
3774 (setq entry (cdr entry))) | |
3775 (or entry (goto-char (point-max))))))) | |
3776 (if (or visible (not visible-only)) | |
3777 (gnus-group-insert-group-line-info group)) | |
3778 (gnus-group-set-mode-line)))) | |
3779 | |
3780 (defun gnus-group-set-mode-line () | |
3781 (if (memq 'group gnus-updated-mode-lines) | |
3782 (let* ((gformat (or gnus-group-mode-line-format-spec | |
3783 (setq gnus-group-mode-line-format-spec | |
3784 (gnus-parse-format | |
3785 gnus-group-mode-line-format | |
3786 gnus-group-mode-line-format-alist)))) | |
3787 (news-server (car (cdr gnus-select-method))) | |
3788 (news-method (car gnus-select-method)) | |
3789 (max-len 60) | |
13699
e8358f30c41c
(gnus-group-set-mode-line): Allow user defined specs in the group
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
13694
diff
changeset
|
3790 header ;Dummy binding for user-defined specs. |
13401 | 3791 (mode-string (eval gformat))) |
3792 (setq mode-string (eval gformat)) | |
3793 (if (> (length mode-string) max-len) | |
3794 (setq mode-string (substring mode-string 0 (- max-len 4)))) | |
3795 (setq mode-line-buffer-identification mode-string) | |
3796 (set-buffer-modified-p t)))) | |
3797 | |
3798 (defun gnus-group-group-name () | |
3799 "Get the name of the newsgroup on the current line." | |
3800 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group))) | |
3801 (and group (symbol-name group)))) | |
3802 | |
3803 (defun gnus-group-group-level () | |
3804 "Get the level of the newsgroup on the current line." | |
3805 (get-text-property (gnus-point-at-bol) 'gnus-level)) | |
3806 | |
3807 (defun gnus-group-group-unread () | |
3808 "Get the number of unread articles of the newsgroup on the current line." | |
3809 (get-text-property (gnus-point-at-bol) 'gnus-unread)) | |
3810 | |
3811 (defun gnus-group-search-forward (&optional backward all level first-too) | |
3812 "Find the next newsgroup with unread articles. | |
3813 If BACKWARD is non-nil, find the previous newsgroup instead. | |
3814 If ALL is non-nil, just find any newsgroup. | |
3815 If LEVEL is non-nil, find group with level LEVEL, or higher if no such | |
3816 group exists. | |
3817 If FIRST-TOO, the current line is also eligible as a target." | |
3818 (let ((way (if backward -1 1)) | |
3819 (low gnus-level-killed) | |
3820 (beg (point)) | |
3821 pos found lev) | |
3822 (if (and backward (progn (beginning-of-line)) (bobp)) | |
3823 nil | |
3824 (or first-too (forward-line way)) | |
3825 (while (and | |
3826 (not (eobp)) | |
3827 (not (setq | |
3828 found | |
3829 (and (or all | |
3830 (and | |
3831 (let ((unread | |
3832 (get-text-property (point) 'gnus-unread))) | |
3833 (or (eq unread t) (and unread (> unread 0)))) | |
3834 (setq lev (get-text-property (point) | |
3835 'gnus-level)) | |
3836 (<= lev gnus-level-subscribed))) | |
3837 (or (not level) | |
3838 (and (setq lev (get-text-property (point) | |
3839 'gnus-level)) | |
3840 (or (= lev level) | |
3841 (and (< lev low) | |
3842 (< level lev) | |
3843 (progn | |
3844 (setq low lev) | |
3845 (setq pos (point)) | |
3846 nil)))))))) | |
3847 (zerop (forward-line way))))) | |
3848 (if found | |
3849 (progn (gnus-group-position-cursor) t) | |
3850 (goto-char (or pos beg)) | |
3851 (and pos t)))) | |
3852 | |
3853 ;;; Gnus group mode commands | |
3854 | |
3855 ;; Group marking. | |
3856 | |
3857 (defun gnus-group-mark-group (n &optional unmark no-advance) | |
3858 "Mark the current group." | |
3859 (interactive "p") | |
3860 (let ((buffer-read-only nil) | |
3861 group) | |
3862 (while | |
3863 (and (> n 0) | |
3864 (setq group (gnus-group-group-name)) | |
3865 (progn | |
3866 (beginning-of-line) | |
3867 (forward-char | |
3868 (or (cdr (assq 'process gnus-group-mark-positions)) 2)) | |
3869 (delete-char 1) | |
3870 (if unmark | |
3871 (progn | |
3872 (insert " ") | |
3873 (setq gnus-group-marked (delete group gnus-group-marked))) | |
3874 (insert "#") | |
3875 (setq gnus-group-marked | |
3876 (cons group (delete group gnus-group-marked)))) | |
3877 t) | |
3878 (or no-advance (zerop (gnus-group-next-group 1)))) | |
3879 (setq n (1- n))) | |
3880 (gnus-summary-position-cursor) | |
3881 n)) | |
3882 | |
3883 (defun gnus-group-unmark-group (n) | |
3884 "Remove the mark from the current group." | |
3885 (interactive "p") | |
3886 (gnus-group-mark-group n 'unmark)) | |
3887 | |
3888 (defun gnus-group-mark-region (unmark beg end) | |
3889 "Mark all groups between point and mark. | |
3890 If UNMARK, remove the mark instead." | |
3891 (interactive "P\nr") | |
3892 (let ((num (count-lines beg end))) | |
3893 (save-excursion | |
3894 (goto-char beg) | |
3895 (- num (gnus-group-mark-group num unmark))))) | |
3896 | |
3897 (defun gnus-group-remove-mark (group) | |
3898 (and (gnus-group-goto-group group) | |
3899 (save-excursion | |
3900 (gnus-group-mark-group 1 'unmark t)))) | |
3901 | |
3902 ;; Return a list of groups to work on. Take into consideration N (the | |
3903 ;; prefix) and the list of marked groups. | |
3904 (defun gnus-group-process-prefix (n) | |
3905 (cond (n | |
3906 (setq n (prefix-numeric-value n)) | |
3907 ;; There is a prefix, so we return a list of the N next | |
3908 ;; groups. | |
3909 (let ((way (if (< n 0) -1 1)) | |
3910 (n (abs n)) | |
3911 group groups) | |
3912 (save-excursion | |
3913 (while (and (> n 0) | |
3914 (setq group (gnus-group-group-name))) | |
3915 (setq groups (cons group groups)) | |
3916 (setq n (1- n)) | |
3917 (forward-line way))) | |
3918 (nreverse groups))) | |
3919 (gnus-group-marked | |
3920 ;; No prefix, but a list of marked articles. | |
3921 (reverse gnus-group-marked)) | |
3922 (t | |
3923 ;; Neither marked articles or a prefix, so we return the | |
3924 ;; current group. | |
3925 (let ((group (gnus-group-group-name))) | |
3926 (and group (list group)))))) | |
3927 | |
3928 ;; Selecting groups. | |
3929 | |
3930 (defun gnus-group-read-group (&optional all no-article group) | |
3931 "Read news in this newsgroup. | |
3932 If the prefix argument ALL is non-nil, already read articles become | |
3933 readable. If the optional argument NO-ARTICLE is non-nil, no article | |
3934 will be auto-selected upon group entry." | |
3935 (interactive "P") | |
3936 (let ((group (or group (gnus-group-group-name))) | |
3937 number active marked entry) | |
3938 (or group (error "No group on current line")) | |
3939 (setq marked | |
3940 (nth 3 (nth 2 (setq entry (gnus-gethash group gnus-newsrc-hashtb))))) | |
3941 ;; This group might be a dead group. In that case we have to get | |
3942 ;; the number of unread articles from `gnus-active-hashtb'. | |
3943 (if entry | |
3944 (setq number (car entry)) | |
3945 (if (setq active (gnus-gethash group gnus-active-hashtb)) | |
3946 (setq number (- (1+ (cdr active)) (car active))))) | |
3947 (gnus-summary-read-group | |
3948 group (or all (and (numberp number) | |
3949 (zerop (+ number (length (cdr (assq 'tick marked))) | |
3950 (length (cdr (assq 'dormant marked))))))) | |
3951 no-article))) | |
3952 | |
3953 (defun gnus-group-select-group (&optional all) | |
3954 "Select this newsgroup. | |
3955 No article is selected automatically. | |
3956 If argument ALL is non-nil, already read articles become readable." | |
3957 (interactive "P") | |
3958 (gnus-group-read-group all t)) | |
3959 | |
3960 (defun gnus-group-select-group-all () | |
3961 "Select the current group and display all articles in it." | |
3962 (interactive) | |
3963 (gnus-group-select-group 'all)) | |
3964 | |
3965 ;; Enter a group that is not in the group buffer. Non-nil is returned | |
3966 ;; if selection was successful. | |
3967 (defun gnus-group-read-ephemeral-group | |
3968 (group method &optional activate quit-config) | |
3969 (let ((group (if (gnus-group-foreign-p group) group | |
3970 (gnus-group-prefixed-name group method)))) | |
3971 (gnus-sethash | |
3972 group | |
3973 (list t nil (list group gnus-level-default-subscribed nil nil | |
3974 (append method | |
3975 (list | |
3976 (list 'quit-config | |
3977 (if quit-config quit-config | |
3978 (cons (current-buffer) 'summary))))))) | |
3979 gnus-newsrc-hashtb) | |
3980 (set-buffer gnus-group-buffer) | |
3981 (or (gnus-check-server method) | |
3982 (error "Unable to contact server: %s" (gnus-status-message method))) | |
3983 (if activate (or (gnus-request-group group) | |
3984 (error "Couldn't request group"))) | |
3985 (condition-case () | |
3986 (gnus-group-read-group t t group) | |
3987 (error nil) | |
3988 (quit nil)) | |
3989 (not (equal major-mode 'gnus-group-mode)))) | |
3990 | |
3991 (defun gnus-group-jump-to-group (group) | |
3992 "Jump to newsgroup GROUP." | |
3993 (interactive | |
3994 (list (completing-read | |
3995 "Group: " gnus-active-hashtb nil | |
3996 (memq gnus-select-method gnus-have-read-active-file)))) | |
3997 | |
3998 (if (equal group "") | |
3999 (error "Empty group name")) | |
4000 | |
4001 (let ((b (text-property-any | |
4002 (point-min) (point-max) 'gnus-group (intern group)))) | |
4003 (if b | |
4004 ;; Either go to the line in the group buffer... | |
4005 (goto-char b) | |
4006 ;; ... or insert the line. | |
4007 (or | |
4008 (gnus-gethash group gnus-active-hashtb) | |
4009 (gnus-activate-group group) | |
4010 (error "%s error: %s" group (gnus-status-message group))) | |
4011 | |
4012 (gnus-group-update-group group) | |
4013 (goto-char (text-property-any | |
4014 (point-min) (point-max) 'gnus-group (intern group))))) | |
4015 ;; Adjust cursor point. | |
4016 (gnus-group-position-cursor)) | |
4017 | |
4018 (defun gnus-group-goto-group (group) | |
4019 "Goto to newsgroup GROUP." | |
4020 (let ((b (text-property-any (point-min) (point-max) | |
4021 'gnus-group (intern group)))) | |
4022 (and b (goto-char b)))) | |
4023 | |
4024 (defun gnus-group-next-group (n) | |
4025 "Go to next N'th newsgroup. | |
4026 If N is negative, search backward instead. | |
4027 Returns the difference between N and the number of skips actually | |
4028 done." | |
4029 (interactive "p") | |
4030 (gnus-group-next-unread-group n t)) | |
4031 | |
4032 (defun gnus-group-next-unread-group (n &optional all level) | |
4033 "Go to next N'th unread newsgroup. | |
4034 If N is negative, search backward instead. | |
4035 If ALL is non-nil, choose any newsgroup, unread or not. | |
4036 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no | |
4037 such group can be found, the next group with a level higher than | |
4038 LEVEL. | |
4039 Returns the difference between N and the number of skips actually | |
4040 made." | |
4041 (interactive "p") | |
4042 (let ((backward (< n 0)) | |
4043 (n (abs n))) | |
4044 (while (and (> n 0) | |
4045 (gnus-group-search-forward | |
4046 backward (or (not gnus-group-goto-unread) all) level)) | |
4047 (setq n (1- n))) | |
4048 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread") | |
4049 (if level " on this level or higher" ""))) | |
4050 n)) | |
4051 | |
4052 (defun gnus-group-prev-group (n) | |
4053 "Go to previous N'th newsgroup. | |
4054 Returns the difference between N and the number of skips actually | |
4055 done." | |
4056 (interactive "p") | |
4057 (gnus-group-next-unread-group (- n) t)) | |
4058 | |
4059 (defun gnus-group-prev-unread-group (n) | |
4060 "Go to previous N'th unread newsgroup. | |
4061 Returns the difference between N and the number of skips actually | |
4062 done." | |
4063 (interactive "p") | |
4064 (gnus-group-next-unread-group (- n))) | |
4065 | |
4066 (defun gnus-group-next-unread-group-same-level (n) | |
4067 "Go to next N'th unread newsgroup on the same level. | |
4068 If N is negative, search backward instead. | |
4069 Returns the difference between N and the number of skips actually | |
4070 done." | |
4071 (interactive "p") | |
4072 (gnus-group-next-unread-group n t (gnus-group-group-level)) | |
4073 (gnus-group-position-cursor)) | |
4074 | |
4075 (defun gnus-group-prev-unread-group-same-level (n) | |
4076 "Go to next N'th unread newsgroup on the same level. | |
4077 Returns the difference between N and the number of skips actually | |
4078 done." | |
4079 (interactive "p") | |
4080 (gnus-group-next-unread-group (- n) t (gnus-group-group-level)) | |
4081 (gnus-group-position-cursor)) | |
4082 | |
4083 (defun gnus-group-best-unread-group (&optional exclude-group) | |
4084 "Go to the group with the highest level. | |
4085 If EXCLUDE-GROUP, do not go to that group." | |
4086 (interactive) | |
4087 (goto-char (point-min)) | |
4088 (let ((best 100000) | |
4089 unread best-point) | |
4090 (while (setq unread (get-text-property (point) 'gnus-unread)) | |
4091 (if (and (numberp unread) (> unread 0)) | |
4092 (progn | |
4093 (if (and (< (get-text-property (point) 'gnus-level) best) | |
4094 (or (not exclude-group) | |
4095 (not (equal exclude-group (gnus-group-group-name))))) | |
4096 (progn | |
4097 (setq best (get-text-property (point) 'gnus-level)) | |
4098 (setq best-point (point)))))) | |
4099 (forward-line 1)) | |
4100 (if best-point (goto-char best-point)) | |
4101 (gnus-summary-position-cursor) | |
4102 (and best-point (gnus-group-group-name)))) | |
4103 | |
4104 (defun gnus-group-first-unread-group () | |
4105 "Go to the first group with unread articles." | |
4106 (interactive) | |
4107 (prog1 | |
4108 (let ((opoint (point)) | |
4109 unread) | |
4110 (goto-char (point-min)) | |
4111 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active. | |
4112 (not (zerop unread)) ; Has unread articles. | |
4113 (zerop (gnus-group-next-unread-group 1))) ; Next unread group. | |
4114 (point) ; Success. | |
4115 (goto-char opoint) | |
4116 nil)) ; Not success. | |
4117 (gnus-group-position-cursor))) | |
4118 | |
4119 (defun gnus-group-enter-server-mode () | |
4120 "Jump to the server buffer." | |
4121 (interactive) | |
4122 (gnus-server-setup-buffer) | |
4123 (gnus-configure-windows 'server) | |
4124 (gnus-server-prepare)) | |
4125 | |
4126 (defun gnus-group-make-group (name &optional method address) | |
4127 "Add a new newsgroup. | |
4128 The user will be prompted for a NAME, for a select METHOD, and an | |
4129 ADDRESS." | |
4130 (interactive | |
4131 (cons | |
4132 (read-string "Group name: ") | |
4133 (let ((method | |
4134 (completing-read | |
4135 "Method: " (append gnus-valid-select-methods gnus-server-alist) | |
4136 nil t))) | |
4137 (if (assoc method gnus-valid-select-methods) | |
4138 (list method | |
4139 (if (memq 'prompt-address | |
4140 (assoc method gnus-valid-select-methods)) | |
4141 (read-string "Address: ") | |
4142 "")) | |
4143 (list method nil))))) | |
4144 | |
4145 (let* ((meth (and method (if address (list (intern method) address) method))) | |
4146 (nname (if method (gnus-group-prefixed-name name meth) name)) | |
4147 info) | |
4148 (and (gnus-gethash nname gnus-newsrc-hashtb) | |
4149 (error "Group %s already exists" nname)) | |
4150 (gnus-group-change-level | |
4151 (setq info (list t nname gnus-level-default-subscribed nil nil meth)) | |
4152 gnus-level-default-subscribed gnus-level-killed | |
4153 (and (gnus-group-group-name) | |
4154 (gnus-gethash (gnus-group-group-name) | |
4155 gnus-newsrc-hashtb)) | |
4156 t) | |
4157 (gnus-sethash nname (cons 1 0) gnus-active-hashtb) | |
4158 (or (gnus-ephemeral-group-p name) | |
4159 (gnus-dribble-enter | |
4160 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")"))) | |
4161 (gnus-group-insert-group-line-info nname) | |
4162 | |
4163 (if (assoc method gnus-valid-select-methods) | |
4164 (require (intern method))) | |
4165 (and (gnus-check-backend-function 'request-create-group nname) | |
4166 (gnus-request-create-group nname)))) | |
4167 | |
4168 (defun gnus-group-edit-group (group &optional part) | |
4169 "Edit the group on the current line." | |
4170 (interactive (list (gnus-group-group-name))) | |
4171 (let ((done-func '(lambda () | |
4172 "Exit editing mode and update the information." | |
4173 (interactive) | |
4174 (gnus-group-edit-group-done 'part 'group))) | |
4175 (part (or part 'info)) | |
4176 (winconf (current-window-configuration)) | |
4177 info) | |
4178 (or group (error "No group on current line")) | |
4179 (or (setq info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))) | |
4180 (error "Killed group; can't be edited")) | |
4181 (set-buffer (get-buffer-create gnus-group-edit-buffer)) | |
4182 (gnus-configure-windows 'edit-group) | |
4183 (gnus-add-current-to-buffer-list) | |
4184 (emacs-lisp-mode) | |
4185 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>. | |
4186 (use-local-map (copy-keymap emacs-lisp-mode-map)) | |
4187 (local-set-key "\C-c\C-c" done-func) | |
4188 (make-local-variable 'gnus-prev-winconf) | |
4189 (setq gnus-prev-winconf winconf) | |
4190 ;; We modify the func to let it know what part it is editing. | |
4191 (setcar (cdr (nth 4 done-func)) (list 'quote part)) | |
4192 (setcar (cdr (cdr (nth 4 done-func))) group) | |
4193 (erase-buffer) | |
4194 (insert | |
4195 (cond | |
4196 ((eq part 'method) | |
4197 ";; Type `C-c C-c' after editing the select method.\n\n") | |
4198 ((eq part 'params) | |
4199 ";; Type `C-c C-c' after editing the group parameters.\n\n") | |
4200 ((eq part 'info) | |
4201 ";; Type `C-c C-c' after editing the group info.\n\n"))) | |
4202 (let ((cinfo (gnus-copy-sequence info)) | |
4203 marked) | |
4204 (if (not (setq marked (nth 3 cinfo))) | |
4205 () | |
4206 (while marked | |
4207 (or (eq 'score (car (car marked))) | |
4208 (eq 'bookmark (car (car marked))) | |
4209 (eq 'killed (car (car marked))) | |
4210 (not (numberp (car (cdr (car marked))))) | |
4211 (setcdr (car marked) | |
4212 (gnus-compress-sequence (sort (cdr (car marked)) '<) t))) | |
4213 (setq marked (cdr marked)))) | |
4214 (insert | |
4215 (pp-to-string | |
4216 (cond ((eq part 'method) | |
4217 (or (nth 4 info) "native")) | |
4218 ((eq part 'params) | |
4219 (nth 5 info)) | |
4220 (t | |
4221 cinfo))) | |
4222 "\n")))) | |
4223 | |
4224 (defun gnus-group-edit-group-method (group) | |
4225 "Edit the select method of GROUP." | |
4226 (interactive (list (gnus-group-group-name))) | |
4227 (gnus-group-edit-group group 'method)) | |
4228 | |
4229 (defun gnus-group-edit-group-parameters (group) | |
4230 "Edit the group parameters of GROUP." | |
4231 (interactive (list (gnus-group-group-name))) | |
4232 (gnus-group-edit-group group 'params)) | |
4233 | |
4234 (defun gnus-group-edit-group-done (part group) | |
4235 "Get info from buffer, update variables and jump to the group buffer." | |
4236 (set-buffer (get-buffer-create gnus-group-edit-buffer)) | |
4237 (goto-char (point-min)) | |
4238 (let ((form (read (current-buffer))) | |
4239 (winconf gnus-prev-winconf)) | |
4240 (if (eq part 'info) | |
4241 (gnus-group-set-info form) | |
4242 (gnus-group-set-info form group part)) | |
4243 (kill-buffer (current-buffer)) | |
4244 (and winconf (set-window-configuration winconf)) | |
4245 (set-buffer gnus-group-buffer) | |
4246 (gnus-group-update-group (gnus-group-group-name)) | |
4247 (gnus-group-position-cursor))) | |
4248 | |
4249 (defun gnus-group-make-help-group () | |
4250 "Create the Gnus documentation group." | |
4251 (interactive) | |
4252 (let ((path (cons (concat installation-directory "etc/") load-path)) | |
4253 (name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help"))) | |
4254 file) | |
4255 (and (gnus-gethash name gnus-newsrc-hashtb) | |
4256 (error "Documentation group already exists")) | |
4257 (while (and path | |
4258 (not (file-exists-p | |
4259 (setq file (concat (file-name-as-directory (car path)) | |
4260 "gnus-tut.txt"))))) | |
4261 (setq path (cdr path))) | |
4262 (if (not path) | |
4263 (message "Couldn't find doc group") | |
4264 (gnus-group-make-group | |
4265 (gnus-group-real-name name) | |
4266 (list 'nndoc name | |
4267 (list 'nndoc-address file) | |
4268 (list 'nndoc-article-type 'mbox))))) | |
4269 (gnus-group-position-cursor)) | |
4270 | |
4271 (defun gnus-group-make-doc-group (file type) | |
4272 "Create a group that uses a single file as the source." | |
4273 (interactive | |
4274 (list (read-file-name "File name: ") | |
4275 (let ((err "") | |
4276 found char) | |
4277 (while (not found) | |
4278 (message "%sFile type (mbox, babyl, digest) [mbd]: " err) | |
4279 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox) | |
4280 ((= char ?b) 'babyl) | |
4281 ((= char ?d) 'digest) | |
4282 (t (setq err (format "%c unknown. " char)) | |
4283 nil)))) | |
4284 found))) | |
4285 (let* ((file (expand-file-name file)) | |
4286 (name (gnus-generate-new-group-name | |
4287 (gnus-group-prefixed-name | |
4288 (file-name-nondirectory file) '(nndoc ""))))) | |
4289 (gnus-group-make-group | |
4290 (gnus-group-real-name name) | |
4291 (list 'nndoc name | |
4292 (list 'nndoc-address file) | |
4293 (list 'nndoc-article-type type))))) | |
4294 | |
4295 (defun gnus-group-make-archive-group (&optional all) | |
4296 "Create the (ding) Gnus archive group of the most recent articles. | |
4297 Given a prefix, create a full group." | |
4298 (interactive "P") | |
4299 (let ((group (gnus-group-prefixed-name | |
4300 (if all "ding.archives" "ding.recent") '(nndir "")))) | |
4301 (and (gnus-gethash group gnus-newsrc-hashtb) | |
4302 (error "Archive group already exists")) | |
4303 (gnus-group-make-group | |
4304 (gnus-group-real-name group) | |
4305 "nndir" | |
4306 (if all gnus-group-archive-directory | |
4307 gnus-group-recent-archive-directory))) | |
4308 (gnus-group-position-cursor)) | |
4309 | |
4310 (defun gnus-group-make-directory-group (dir) | |
4311 "Create an nndir group. | |
4312 The user will be prompted for a directory. The contents of this | |
4313 directory will be used as a newsgroup. The directory should contain | |
4314 mail messages or news articles in files that have numeric names." | |
4315 (interactive | |
4316 (list (read-file-name "Create group from directory: "))) | |
4317 (or (file-exists-p dir) (error "No such directory")) | |
4318 (or (file-directory-p dir) (error "Not a directory")) | |
4319 (gnus-group-make-group dir "nndir" dir) | |
4320 (gnus-group-position-cursor)) | |
4321 | |
4322 (defun gnus-group-make-kiboze-group (group address scores) | |
4323 "Create an nnkiboze group. | |
4324 The user will be prompted for a name, a regexp to match groups, and | |
4325 score file entries for articles to include in the group." | |
4326 (interactive | |
4327 (list | |
4328 (read-string "nnkiboze group name: ") | |
4329 (read-string "Source groups (regexp): ") | |
4330 (let ((headers (mapcar (lambda (group) (list group)) | |
4331 '("subject" "from" "number" "date" "message-id" | |
4332 "references" "chars" "lines" "xref"))) | |
4333 scores header regexp regexps) | |
4334 (while (not (equal "" (setq header (completing-read | |
4335 "Match on header: " headers nil t)))) | |
4336 (setq regexps nil) | |
4337 (while (not (equal "" (setq regexp (read-string | |
4338 (format "Match on %s (string): " | |
4339 header))))) | |
4340 (setq regexps (cons (list regexp nil nil 'r) regexps))) | |
4341 (setq scores (cons (cons header regexps) scores))) | |
4342 scores))) | |
4343 (gnus-group-make-group group "nnkiboze" address) | |
4344 (save-excursion | |
4345 (gnus-set-work-buffer) | |
4346 (let (emacs-lisp-mode-hook) | |
4347 (pp scores (current-buffer))) | |
4348 (write-region (point-min) (point-max) | |
4349 (concat (or gnus-kill-files-directory "~/News") | |
4350 "nnkiboze:" group "." gnus-score-file-suffix))) | |
4351 (gnus-group-position-cursor)) | |
4352 | |
4353 (defun gnus-group-add-to-virtual (n vgroup) | |
4354 "Add the current group to a virtual group." | |
4355 (interactive | |
4356 (list current-prefix-arg | |
4357 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t | |
4358 "nnvirtual:"))) | |
4359 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual) | |
4360 (error "%s is not an nnvirtual group" vgroup)) | |
4361 (let* ((groups (gnus-group-process-prefix n)) | |
4362 (method (nth 4 (nth 2 (gnus-gethash vgroup gnus-newsrc-hashtb))))) | |
4363 (setcar (cdr method) | |
4364 (concat | |
4365 (nth 1 method) "\\|" | |
4366 (mapconcat | |
4367 (lambda (s) | |
4368 (gnus-group-remove-mark s) | |
4369 (concat "\\(^" (regexp-quote s) "$\\)")) | |
4370 groups "\\|")))) | |
4371 (gnus-group-position-cursor)) | |
4372 | |
4373 (defun gnus-group-make-empty-virtual (group) | |
4374 "Create a new, fresh, empty virtual group." | |
4375 (interactive "sCreate new, empty virtual group: ") | |
4376 (let* ((method (list 'nnvirtual "^$")) | |
4377 (pgroup (gnus-group-prefixed-name group method))) | |
4378 ;; Check whether it exists already. | |
4379 (and (gnus-gethash pgroup gnus-newsrc-hashtb) | |
4380 (error "Group %s already exists." pgroup)) | |
4381 ;; Subscribe the new group after the group on the current line. | |
4382 (gnus-subscribe-group pgroup (gnus-group-group-name) method) | |
4383 (gnus-group-update-group pgroup) | |
4384 (forward-line -1) | |
4385 (gnus-group-position-cursor))) | |
4386 | |
4387 (defun gnus-group-enter-directory (dir) | |
4388 "Enter an ephemeral nneething group." | |
4389 (interactive "DDirectory to read: ") | |
4390 (let* ((method (list 'nneething dir)) | |
4391 (leaf (gnus-group-prefixed-name | |
4392 (file-name-nondirectory (directory-file-name dir)) | |
4393 method)) | |
4394 (name (gnus-generate-new-group-name leaf))) | |
4395 (let ((nneething-read-only t)) | |
4396 (or (gnus-group-read-ephemeral-group | |
4397 name method t | |
4398 (cons (current-buffer) (if (eq major-mode 'gnus-summary-mode) | |
4399 'summary 'group))) | |
4400 (error "Couldn't enter %s" dir))))) | |
4401 | |
4402 ;; Group sorting commands | |
4403 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>. | |
4404 | |
4405 (defun gnus-group-sort-groups () | |
4406 "Sort the group buffer using `gnus-group-sort-function'." | |
4407 (interactive) | |
4408 (setq gnus-newsrc-alist | |
4409 (sort (cdr gnus-newsrc-alist) gnus-group-sort-function)) | |
4410 (gnus-make-hashtable-from-newsrc-alist) | |
4411 (gnus-group-list-groups)) | |
4412 | |
4413 (defun gnus-group-sort-by-alphabet (info1 info2) | |
4414 (string< (car info1) (car info2))) | |
4415 | |
4416 (defun gnus-group-sort-by-unread (info1 info2) | |
4417 (let ((n1 (car (gnus-gethash (car info1) gnus-newsrc-hashtb))) | |
4418 (n2 (car (gnus-gethash (car info2) gnus-newsrc-hashtb)))) | |
4419 (< (or (and (numberp n1) n1) 0) | |
4420 (or (and (numberp n2) n2) 0)))) | |
4421 | |
4422 (defun gnus-group-sort-by-level (info1 info2) | |
4423 (< (nth 1 info1) (nth 1 info2))) | |
4424 | |
4425 ;; Group catching up. | |
4426 | |
4427 (defun gnus-group-catchup-current (&optional n all) | |
4428 "Mark all articles not marked as unread in current newsgroup as read. | |
4429 If prefix argument N is numeric, the ARG next newsgroups will be | |
4430 caught up. If ALL is non-nil, marked articles will also be marked as | |
4431 read. Cross references (Xref: header) of articles are ignored. | |
4432 The difference between N and actual number of newsgroups that were | |
4433 caught up is returned." | |
4434 (interactive "P") | |
4435 (if (not (or (not gnus-interactive-catchup) ;Without confirmation? | |
4436 gnus-expert-user | |
4437 (gnus-y-or-n-p | |
4438 (if all | |
4439 "Do you really want to mark all articles as read? " | |
4440 "Mark all unread articles as read? ")))) | |
4441 n | |
4442 (let ((groups (gnus-group-process-prefix n)) | |
4443 (ret 0)) | |
4444 (while groups | |
4445 ;; Virtual groups have to be given special treatment. | |
4446 (let ((method (gnus-find-method-for-group (car groups)))) | |
4447 (if (eq 'nnvirtual (car method)) | |
4448 (nnvirtual-catchup-group | |
4449 (gnus-group-real-name (car groups)) (nth 1 method) all))) | |
4450 (gnus-group-remove-mark (car groups)) | |
4451 (if (prog1 | |
4452 (gnus-group-goto-group (car groups)) | |
4453 (gnus-group-catchup (car groups) all)) | |
4454 (gnus-group-update-group-line) | |
4455 (setq ret (1+ ret))) | |
4456 (setq groups (cdr groups))) | |
4457 (gnus-group-next-unread-group 1) | |
4458 ret))) | |
4459 | |
4460 (defun gnus-group-catchup-current-all (&optional n) | |
4461 "Mark all articles in current newsgroup as read. | |
4462 Cross references (Xref: header) of articles are ignored." | |
4463 (interactive "P") | |
4464 (gnus-group-catchup-current n 'all)) | |
4465 | |
4466 (defun gnus-group-catchup (group &optional all) | |
4467 "Mark all articles in GROUP as read. | |
4468 If ALL is non-nil, all articles are marked as read. | |
4469 The return value is the number of articles that were marked as read, | |
4470 or nil if no action could be taken." | |
4471 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb)) | |
4472 (num (car entry)) | |
4473 (marked (nth 3 (nth 2 entry)))) | |
4474 (if (not (numberp (car entry))) | |
4475 (gnus-message 1 "Can't catch up; non-active group") | |
4476 ;; Do the updating only if the newsgroup isn't killed. | |
4477 (if (not entry) | |
4478 () | |
4479 (gnus-update-read-articles | |
4480 group (and (not all) (append (cdr (assq 'tick marked)) | |
4481 (cdr (assq 'dormant marked)))) | |
4482 nil (and (not all) (cdr (assq 'tick marked)))) | |
4483 (and all | |
4484 (setq marked (nth 3 (nth 2 entry))) | |
4485 (setcar (nthcdr 3 (nth 2 entry)) | |
4486 (delq (assq 'dormant marked) | |
4487 (nth 3 (nth 2 entry))))))) | |
4488 num)) | |
4489 | |
4490 (defun gnus-group-expire-articles (&optional n) | |
4491 "Expire all expirable articles in the current newsgroup." | |
4492 (interactive "P") | |
4493 (let ((groups (gnus-group-process-prefix n)) | |
4494 group) | |
4495 (or groups (error "No groups to expire")) | |
4496 (while groups | |
4497 (setq group (car groups) | |
4498 groups (cdr groups)) | |
4499 (gnus-group-remove-mark group) | |
4500 (if (not (gnus-check-backend-function 'request-expire-articles group)) | |
4501 () | |
4502 (let* ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))) | |
4503 (expirable (if (memq 'total-expire (nth 5 info)) | |
4504 (cons nil (gnus-list-of-read-articles group)) | |
4505 (assq 'expire (nth 3 info))))) | |
4506 (and expirable | |
4507 (setcdr expirable | |
4508 (gnus-request-expire-articles | |
4509 (cdr expirable) group)))))))) | |
4510 | |
4511 (defun gnus-group-expire-all-groups () | |
4512 "Expire all expirable articles in all newsgroups." | |
4513 (interactive) | |
4514 (save-excursion | |
4515 (gnus-message 5 "Expiring...") | |
4516 (let ((gnus-group-marked (mapcar (lambda (info) (car info)) | |
4517 (cdr gnus-newsrc-alist)))) | |
4518 (gnus-group-expire-articles nil))) | |
4519 (gnus-group-position-cursor) | |
4520 (gnus-message 5 "Expiring...done")) | |
4521 | |
4522 (defun gnus-group-set-current-level (n level) | |
4523 "Set the level of the next N groups to LEVEL." | |
4524 (interactive "P\nnLevel: ") | |
4525 (or (and (>= level 1) (<= level gnus-level-killed)) | |
4526 (error "Illegal level: %d" level)) | |
4527 (let ((groups (gnus-group-process-prefix n)) | |
4528 group) | |
4529 (while groups | |
4530 (setq group (car groups) | |
4531 groups (cdr groups)) | |
4532 (gnus-group-remove-mark group) | |
4533 (gnus-message 6 "Changed level of %s from %d to %d" | |
4534 group (gnus-group-group-level) level) | |
4535 (gnus-group-change-level group level | |
4536 (gnus-group-group-level)) | |
4537 (gnus-group-update-group-line))) | |
4538 (gnus-group-position-cursor)) | |
4539 | |
4540 (defun gnus-group-unsubscribe-current-group (&optional n) | |
4541 "Toggle subscription of the current group. | |
4542 If given numerical prefix, toggle the N next groups." | |
4543 (interactive "P") | |
4544 (let ((groups (gnus-group-process-prefix n)) | |
4545 group) | |
4546 (while groups | |
4547 (setq group (car groups) | |
4548 groups (cdr groups)) | |
4549 (gnus-group-remove-mark group) | |
4550 (gnus-group-unsubscribe-group | |
4551 group (if (<= (gnus-group-group-level) gnus-level-subscribed) | |
4552 gnus-level-default-unsubscribed | |
4553 gnus-level-default-subscribed)) | |
4554 (gnus-group-update-group-line)) | |
4555 (gnus-group-next-group 1))) | |
4556 | |
4557 (defun gnus-group-unsubscribe-group (group &optional level) | |
4558 "Toggle subscribe from/to unsubscribe GROUP. | |
4559 New newsgroup is added to .newsrc automatically." | |
4560 (interactive | |
4561 (list (completing-read | |
4562 "Group: " gnus-active-hashtb nil | |
4563 (memq gnus-select-method gnus-have-read-active-file)))) | |
4564 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb))) | |
4565 (cond | |
4566 ((string-match "^[ \t]$" group) | |
4567 (error "Empty group name")) | |
4568 (newsrc | |
4569 ;; Toggle subscription flag. | |
4570 (gnus-group-change-level | |
4571 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc)) | |
4572 gnus-level-subscribed) | |
4573 (1+ gnus-level-subscribed) | |
4574 gnus-level-default-subscribed))) | |
4575 (gnus-group-update-group group)) | |
4576 ((and (stringp group) | |
4577 (or (not (memq gnus-select-method gnus-have-read-active-file)) | |
4578 (gnus-gethash group gnus-active-hashtb))) | |
4579 ;; Add new newsgroup. | |
4580 (gnus-group-change-level | |
4581 group | |
4582 (if level level gnus-level-default-subscribed) | |
4583 (or (and (member group gnus-zombie-list) | |
4584 gnus-level-zombie) | |
4585 gnus-level-killed) | |
4586 (and (gnus-group-group-name) | |
4587 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb))) | |
4588 (gnus-group-update-group group)) | |
4589 (t (error "No such newsgroup: %s" group))) | |
4590 (gnus-group-position-cursor))) | |
4591 | |
4592 (defun gnus-group-transpose-groups (n) | |
4593 "Move the current newsgroup up N places. | |
4594 If given a negative prefix, move down instead. The difference between | |
4595 N and the number of steps taken is returned." | |
4596 (interactive "p") | |
4597 (or (gnus-group-group-name) | |
4598 (error "No group on current line")) | |
4599 (gnus-group-kill-group 1) | |
4600 (prog1 | |
4601 (forward-line (- n)) | |
4602 (gnus-group-yank-group) | |
4603 (gnus-group-position-cursor))) | |
4604 | |
4605 (defun gnus-group-kill-all-zombies () | |
4606 "Kill all zombie newsgroups." | |
4607 (interactive) | |
4608 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list)) | |
4609 (setq gnus-zombie-list nil) | |
4610 (gnus-group-list-groups)) | |
4611 | |
4612 (defun gnus-group-kill-region (begin end) | |
4613 "Kill newsgroups in current region (excluding current point). | |
4614 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]." | |
4615 (interactive "r") | |
4616 (let ((lines | |
4617 ;; Count lines. | |
4618 (save-excursion | |
4619 (count-lines | |
4620 (progn | |
4621 (goto-char begin) | |
4622 (beginning-of-line) | |
4623 (point)) | |
4624 (progn | |
4625 (goto-char end) | |
4626 (beginning-of-line) | |
4627 (point)))))) | |
4628 (goto-char begin) | |
4629 (beginning-of-line) ;Important when LINES < 1 | |
4630 (gnus-group-kill-group lines))) | |
4631 | |
4632 (defun gnus-group-kill-group (&optional n) | |
4633 "The the next N groups. | |
4634 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]. | |
4635 However, only groups that were alive can be yanked; already killed | |
4636 groups or zombie groups can't be yanked. | |
4637 The return value is the name of the (last) group that was killed." | |
4638 (interactive "P") | |
4639 (let ((buffer-read-only nil) | |
4640 (groups (gnus-group-process-prefix n)) | |
4641 group entry level) | |
4642 (while groups | |
4643 (setq group (car groups) | |
4644 groups (cdr groups)) | |
4645 (gnus-group-remove-mark group) | |
4646 (setq level (gnus-group-group-level)) | |
4647 (gnus-delete-line) | |
4648 (if (setq entry (gnus-gethash group gnus-newsrc-hashtb)) | |
4649 (setq gnus-list-of-killed-groups | |
4650 (cons (cons (car entry) (nth 2 entry)) | |
4651 gnus-list-of-killed-groups))) | |
4652 (gnus-group-change-level | |
4653 (if entry entry group) gnus-level-killed (if entry nil level))) | |
4654 (gnus-group-position-cursor) | |
4655 group)) | |
4656 | |
4657 (defun gnus-group-yank-group (&optional arg) | |
4658 "Yank the last newsgroups killed with \\[gnus-group-kill-group], | |
4659 inserting it before the current newsgroup. The numeric ARG specifies | |
4660 how many newsgroups are to be yanked. The name of the (last) | |
4661 newsgroup yanked is returned." | |
4662 (interactive "p") | |
4663 (if (not arg) (setq arg 1)) | |
4664 (let (info group prev) | |
4665 (while (>= (setq arg (1- arg)) 0) | |
4666 (if (not (setq info (car gnus-list-of-killed-groups))) | |
4667 (error "No more newsgroups to yank")) | |
4668 (setq group (nth 2 info)) | |
4669 ;; Find which newsgroup to insert this one before - search | |
4670 ;; backward until something suitable is found. If there are no | |
4671 ;; other newsgroups in this buffer, just make this newsgroup the | |
4672 ;; first newsgroup. | |
4673 (setq prev (gnus-group-group-name)) | |
4674 (gnus-group-change-level | |
4675 info (nth 2 info) gnus-level-killed | |
4676 (and prev (gnus-gethash prev gnus-newsrc-hashtb)) | |
4677 t) | |
4678 (gnus-group-insert-group-line-info (nth 1 info)) | |
4679 (setq gnus-list-of-killed-groups | |
4680 (cdr gnus-list-of-killed-groups))) | |
4681 (forward-line -1) | |
4682 (gnus-group-position-cursor) | |
4683 group)) | |
4684 | |
4685 (defun gnus-group-list-all-groups (&optional arg) | |
4686 "List all newsgroups with level ARG or lower. | |
4687 Default is gnus-level-unsubscribed, which lists all subscribed and most | |
4688 unsubscribed groups." | |
4689 (interactive "P") | |
4690 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t)) | |
4691 | |
4692 (defun gnus-group-list-killed () | |
4693 "List all killed newsgroups in the group buffer." | |
4694 (interactive) | |
4695 (if (not gnus-killed-list) | |
4696 (gnus-message 6 "No killed groups") | |
4697 (let (gnus-group-list-mode) | |
4698 (funcall gnus-group-prepare-function | |
4699 gnus-level-killed t gnus-level-killed)) | |
4700 (goto-char (point-min))) | |
4701 (gnus-group-position-cursor)) | |
4702 | |
4703 (defun gnus-group-list-zombies () | |
4704 "List all zombie newsgroups in the group buffer." | |
4705 (interactive) | |
4706 (if (not gnus-zombie-list) | |
4707 (gnus-message 6 "No zombie groups") | |
4708 (let (gnus-group-list-mode) | |
4709 (funcall gnus-group-prepare-function | |
4710 gnus-level-zombie t gnus-level-zombie)) | |
4711 (goto-char (point-min))) | |
4712 (gnus-group-position-cursor)) | |
4713 | |
4714 (defun gnus-group-get-new-news (&optional arg) | |
4715 "Get newly arrived articles. | |
4716 If ARG is non-nil, it should be a number between one and nine to | |
4717 specify which levels you are interested in re-scanning." | |
4718 (interactive "P") | |
4719 (run-hooks 'gnus-get-new-news-hook) | |
4720 (setq arg (gnus-group-default-level arg t)) | |
4721 (if (and gnus-read-active-file (not arg)) | |
4722 (progn | |
4723 (gnus-read-active-file) | |
4724 (gnus-get-unread-articles (or arg (1+ gnus-level-subscribed)))) | |
4725 (let ((gnus-read-active-file (if arg nil gnus-read-active-file))) | |
4726 (gnus-get-unread-articles (or arg (1+ gnus-level-subscribed))))) | |
4727 (gnus-group-list-groups)) | |
4728 | |
4729 (defun gnus-group-get-new-news-this-group (&optional n) | |
4730 "Check for newly arrived news in the current group (and the N-1 next groups). | |
4731 The difference between N and the number of newsgroup checked is returned. | |
4732 If N is negative, this group and the N-1 previous groups will be checked." | |
4733 (interactive "P") | |
4734 (let* ((groups (gnus-group-process-prefix n)) | |
4735 (ret (if (numberp n) (- n (length groups)) 0)) | |
4736 group) | |
4737 (while groups | |
4738 (setq group (car groups) | |
4739 groups (cdr groups)) | |
4740 (gnus-group-remove-mark group) | |
4741 (or (gnus-get-new-news-in-group group) | |
4742 (progn | |
4743 (ding) | |
4744 (message "%s error: %s" group (gnus-status-message group)) | |
4745 (sit-for 2)))) | |
4746 (gnus-group-next-unread-group 1 t) | |
4747 (gnus-summary-position-cursor) | |
4748 ret)) | |
4749 | |
4750 (defun gnus-get-new-news-in-group (group) | |
4751 (and group | |
4752 (gnus-activate-group group) | |
4753 (progn | |
4754 (gnus-get-unread-articles-in-group | |
4755 (nth 2 (gnus-gethash group gnus-newsrc-hashtb)) | |
4756 (gnus-gethash group gnus-active-hashtb)) | |
4757 (gnus-group-update-group-line) | |
4758 t))) | |
4759 | |
4760 (defun gnus-group-fetch-faq (group) | |
4761 "Fetch the FAQ for the current group." | |
4762 (interactive (list (gnus-group-real-name (gnus-group-group-name)))) | |
4763 (or group (error "No group name given")) | |
4764 (let ((file (concat gnus-group-faq-directory (gnus-group-real-name group)))) | |
4765 (if (not (file-exists-p file)) | |
4766 (error "No such file: %s" file) | |
4767 (find-file file)))) | |
4768 | |
4769 (defun gnus-group-describe-group (force &optional group) | |
4770 "Display a description of the current newsgroup." | |
4771 (interactive (list current-prefix-arg (gnus-group-group-name))) | |
4772 (and force (setq gnus-description-hashtb nil)) | |
4773 (let ((method (gnus-find-method-for-group group)) | |
4774 desc) | |
4775 (or group (error "No group name given")) | |
4776 (and (or (and gnus-description-hashtb | |
4777 ;; We check whether this group's method has been | |
4778 ;; queried for a description file. | |
4779 (gnus-gethash | |
4780 (gnus-group-prefixed-name "" method) | |
4781 gnus-description-hashtb)) | |
4782 (setq desc (gnus-group-get-description group)) | |
4783 (gnus-read-descriptions-file method)) | |
4784 (message | |
4785 (or desc (gnus-gethash group gnus-description-hashtb) | |
4786 "No description available"))))) | |
4787 | |
4788 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>. | |
4789 (defun gnus-group-describe-all-groups (&optional force) | |
4790 "Pop up a buffer with descriptions of all newsgroups." | |
4791 (interactive "P") | |
4792 (and force (setq gnus-description-hashtb nil)) | |
4793 (if (not (or gnus-description-hashtb | |
4794 (gnus-read-all-descriptions-files))) | |
4795 (error "Couldn't request descriptions file")) | |
4796 (let ((buffer-read-only nil) | |
4797 b) | |
4798 (erase-buffer) | |
4799 (mapatoms | |
4800 (lambda (group) | |
4801 (setq b (point)) | |
4802 (insert (format " *: %-20s %s\n" (symbol-name group) | |
4803 (symbol-value group))) | |
4804 (add-text-properties | |
4805 b (1+ b) (list 'gnus-group group | |
4806 'gnus-unread t 'gnus-marked nil | |
4807 'gnus-level (1+ gnus-level-subscribed)))) | |
4808 gnus-description-hashtb) | |
4809 (goto-char (point-min)) | |
4810 (gnus-group-position-cursor))) | |
4811 | |
4812 ;; Suggested by by Daniel Quinlan <quinlan@best.com>. | |
4813 (defun gnus-group-apropos (regexp &optional search-description) | |
4814 "List all newsgroups that have names that match a regexp." | |
4815 (interactive "sGnus apropos (regexp): ") | |
4816 (let ((prev "") | |
4817 (obuf (current-buffer)) | |
4818 groups des) | |
4819 ;; Go through all newsgroups that are known to Gnus. | |
4820 (mapatoms | |
4821 (lambda (group) | |
4822 (and (symbol-name group) | |
4823 (string-match regexp (symbol-name group)) | |
4824 (setq groups (cons (symbol-name group) groups)))) | |
4825 gnus-active-hashtb) | |
4826 ;; Go through all descriptions that are known to Gnus. | |
4827 (if search-description | |
4828 (mapatoms | |
4829 (lambda (group) | |
4830 (and (string-match regexp (symbol-value group)) | |
4831 (gnus-gethash (symbol-name group) gnus-active-hashtb) | |
4832 (setq groups (cons (symbol-name group) groups)))) | |
4833 gnus-description-hashtb)) | |
4834 (if (not groups) | |
4835 (gnus-message 3 "No groups matched \"%s\"." regexp) | |
4836 ;; Print out all the groups. | |
4837 (save-excursion | |
4838 (pop-to-buffer "*Gnus Help*") | |
4839 (buffer-disable-undo (current-buffer)) | |
4840 (erase-buffer) | |
4841 (setq groups (sort groups 'string<)) | |
4842 (while groups | |
4843 ;; Groups may be entered twice into the list of groups. | |
4844 (if (not (string= (car groups) prev)) | |
4845 (progn | |
4846 (insert (setq prev (car groups)) "\n") | |
4847 (if (and gnus-description-hashtb | |
4848 (setq des (gnus-gethash (car groups) | |
4849 gnus-description-hashtb))) | |
4850 (insert " " des "\n")))) | |
4851 (setq groups (cdr groups))) | |
4852 (goto-char (point-min)))) | |
4853 (pop-to-buffer obuf))) | |
4854 | |
4855 (defun gnus-group-description-apropos (regexp) | |
4856 "List all newsgroups that have names or descriptions that match a regexp." | |
4857 (interactive "sGnus description apropos (regexp): ") | |
4858 (if (not (or gnus-description-hashtb | |
4859 (gnus-read-all-descriptions-files))) | |
4860 (error "Couldn't request descriptions file")) | |
4861 (gnus-group-apropos regexp t)) | |
4862 | |
4863 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>. | |
4864 (defun gnus-group-list-matching (level regexp &optional all lowest) | |
4865 "List all groups with unread articles that match REGEXP. | |
4866 If the prefix LEVEL is non-nil, it should be a number that says which | |
4867 level to cut off listing groups. | |
4868 If ALL, also list groups with no unread articles. | |
4869 If LOWEST, don't list groups with level lower than LOWEST." | |
4870 (interactive "P\nsList newsgroups matching: ") | |
4871 (gnus-group-prepare-flat (or level gnus-level-subscribed) | |
4872 all (or lowest 1) regexp) | |
4873 (goto-char (point-min)) | |
4874 (gnus-group-position-cursor)) | |
4875 | |
4876 (defun gnus-group-list-all-matching (level regexp &optional lowest) | |
4877 "List all groups that match REGEXP. | |
4878 If the prefix LEVEL is non-nil, it should be a number that says which | |
4879 level to cut off listing groups. | |
4880 If LOWEST, don't list groups with level lower than LOWEST." | |
4881 (interactive "P\nsList newsgroups matching: ") | |
4882 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest)) | |
4883 | |
4884 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. | |
4885 (defun gnus-group-save-newsrc () | |
4886 "Save the Gnus startup files." | |
4887 (interactive) | |
4888 (gnus-save-newsrc-file)) | |
4889 | |
4890 (defun gnus-group-restart (&optional arg) | |
4891 "Force Gnus to read the .newsrc file." | |
4892 (interactive "P") | |
4893 (gnus-save-newsrc-file) | |
4894 (gnus-setup-news 'force) | |
4895 (gnus-group-list-groups arg)) | |
4896 | |
4897 (defun gnus-group-read-init-file () | |
4898 "Read the Gnus elisp init file." | |
4899 (interactive) | |
4900 (gnus-read-init-file)) | |
4901 | |
4902 (defun gnus-group-check-bogus-groups (&optional silent) | |
4903 "Check bogus newsgroups. | |
4904 If given a prefix, don't ask for confirmation before removing a bogus | |
4905 group." | |
4906 (interactive "P") | |
4907 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user))) | |
4908 (gnus-group-list-groups)) | |
4909 | |
4910 (defun gnus-group-edit-global-kill (&optional article group) | |
4911 "Edit the global kill file. | |
4912 If GROUP, edit that local kill file instead." | |
4913 (interactive "P") | |
4914 (setq gnus-current-kill-article article) | |
4915 (gnus-kill-file-edit-file group) | |
4916 (gnus-message | |
4917 6 | |
4918 (substitute-command-keys | |
4919 "Editing a global kill file (Type \\[gnus-kill-file-exit] to exit)"))) | |
4920 | |
4921 (defun gnus-group-edit-local-kill (article group) | |
4922 "Edit a local kill file." | |
4923 (interactive (list nil (gnus-group-group-name))) | |
4924 (gnus-group-edit-global-kill article group)) | |
4925 | |
4926 (defun gnus-group-force-update () | |
4927 "Update `.newsrc' file." | |
4928 (interactive) | |
4929 (gnus-save-newsrc-file)) | |
4930 | |
4931 (defun gnus-group-suspend () | |
4932 "Suspend the current Gnus session. | |
4933 In fact, cleanup buffers except for group mode buffer. | |
4934 The hook gnus-suspend-gnus-hook is called before actually suspending." | |
4935 (interactive) | |
4936 (run-hooks 'gnus-suspend-gnus-hook) | |
4937 ;; Kill Gnus buffers except for group mode buffer. | |
4938 (let ((group-buf (get-buffer gnus-group-buffer))) | |
4939 ;; Do this on a separate list in case the user does a ^G before we finish | |
4940 (let ((gnus-buffer-list | |
4941 (delq group-buf (delq gnus-dribble-buffer | |
4942 (append gnus-buffer-list nil))))) | |
4943 (while gnus-buffer-list | |
4944 (gnus-kill-buffer (car gnus-buffer-list)) | |
4945 (setq gnus-buffer-list (cdr gnus-buffer-list)))) | |
4946 (if group-buf | |
4947 (progn | |
4948 (setq gnus-buffer-list (list group-buf)) | |
4949 (bury-buffer group-buf) | |
4950 (delete-windows-on group-buf t))))) | |
4951 | |
4952 (defun gnus-group-clear-dribble () | |
4953 "Clear all information from the dribble buffer." | |
4954 (interactive) | |
4955 (gnus-dribble-clear)) | |
4956 | |
4957 (defun gnus-group-exit () | |
4958 "Quit reading news after updating .newsrc.eld and .newsrc. | |
4959 The hook `gnus-exit-gnus-hook' is called before actually exiting." | |
4960 (interactive) | |
4961 (if (or noninteractive ;For gnus-batch-kill | |
4962 (not (gnus-server-opened gnus-select-method)) ;NNTP connection closed | |
4963 (not gnus-interactive-exit) ;Without confirmation | |
4964 gnus-expert-user | |
4965 (gnus-y-or-n-p "Are you sure you want to quit reading news? ")) | |
4966 (progn | |
4967 (run-hooks 'gnus-exit-gnus-hook) | |
4968 ;; Offer to save data from non-quitted summary buffers. | |
4969 (gnus-offer-save-summaries) | |
4970 ;; Save the newsrc file(s). | |
4971 (gnus-save-newsrc-file) | |
4972 ;; Kill-em-all. | |
4973 (gnus-close-backends) | |
4974 ;; Reset everything. | |
4975 (gnus-clear-system)))) | |
4976 | |
4977 (defun gnus-close-backends () | |
4978 ;; Send a close request to all backends that support such a request. | |
4979 (let ((methods gnus-valid-select-methods) | |
4980 func) | |
4981 (while methods | |
4982 (if (fboundp (setq func (intern (concat (car (car methods)) | |
4983 "-request-close")))) | |
4984 (funcall func)) | |
4985 (setq methods (cdr methods))))) | |
4986 | |
4987 (defun gnus-group-quit () | |
4988 "Quit reading news without updating .newsrc.eld or .newsrc. | |
4989 The hook `gnus-exit-gnus-hook' is called before actually exiting." | |
4990 (interactive) | |
4991 (if (or noninteractive ;For gnus-batch-kill | |
4992 (zerop (buffer-size)) | |
4993 (not (gnus-server-opened gnus-select-method)) | |
4994 gnus-expert-user | |
4995 (not gnus-current-startup-file) | |
4996 (gnus-yes-or-no-p | |
4997 (format "Quit reading news without saving %s? " | |
4998 (file-name-nondirectory gnus-current-startup-file)))) | |
4999 (progn | |
5000 (run-hooks 'gnus-exit-gnus-hook) | |
5001 (if gnus-use-full-window | |
5002 (delete-other-windows) | |
5003 (gnus-remove-some-windows)) | |
5004 (gnus-dribble-save) | |
5005 (gnus-close-backends) | |
5006 (gnus-clear-system)))) | |
5007 | |
5008 (defun gnus-offer-save-summaries () | |
5009 (save-excursion | |
5010 (let ((buflist (buffer-list)) | |
5011 buffers bufname) | |
5012 (while buflist | |
5013 (and (setq bufname (buffer-name (car buflist))) | |
5014 (string-match "Summary" bufname) | |
5015 (save-excursion | |
5016 (set-buffer bufname) | |
5017 ;; We check that this is, indeed, a summary buffer. | |
5018 (eq major-mode 'gnus-summary-mode)) | |
5019 (setq buffers (cons bufname buffers))) | |
5020 (setq buflist (cdr buflist))) | |
5021 (and buffers | |
5022 (map-y-or-n-p | |
5023 "Update summary buffer %s? " | |
5024 (lambda (buf) | |
5025 (set-buffer buf) | |
5026 (gnus-summary-exit)) | |
5027 buffers))))) | |
5028 | |
5029 (defun gnus-group-describe-briefly () | |
5030 "Give a one line description of the group mode commands." | |
5031 (interactive) | |
5032 (gnus-message 7 (substitute-command-keys "\\<gnus-group-mode-map>\\[gnus-group-read-group]:Select \\[gnus-group-next-unread-group]:Forward \\[gnus-group-prev-unread-group]:Backward \\[gnus-group-exit]:Exit \\[gnus-info-find-node]:Run Info \\[gnus-group-describe-briefly]:This help"))) | |
5033 | |
5034 (defun gnus-group-browse-foreign-server (method) | |
5035 "Browse a foreign news server. | |
5036 If called interactively, this function will ask for a select method | |
5037 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where). | |
5038 If not, METHOD should be a list where the first element is the method | |
5039 and the second element is the address." | |
5040 (interactive | |
5041 (list (let ((how (completing-read | |
5042 "Which backend: " | |
5043 (append gnus-valid-select-methods gnus-server-alist) | |
5044 nil t "nntp"))) | |
5045 ;; We either got a backend name or a virtual server name. | |
5046 ;; If the first, we also need an address. | |
5047 (if (assoc how gnus-valid-select-methods) | |
5048 (list (intern how) | |
5049 ;; Suggested by mapjph@bath.ac.uk. | |
5050 (completing-read | |
5051 "Address: " | |
5052 (mapcar (lambda (server) (list server)) | |
5053 gnus-secondary-servers))) | |
5054 ;; We got a server name, so we find the method. | |
5055 (gnus-server-to-method how))))) | |
5056 (gnus-browse-foreign-server method)) | |
5057 | |
5058 | |
5059 ;;; | |
5060 ;;; Browse Server Mode | |
5061 ;;; | |
5062 | |
5063 (defvar gnus-browse-mode-hook nil) | |
5064 (defvar gnus-browse-mode-map nil) | |
5065 (put 'gnus-browse-mode 'mode-class 'special) | |
5066 | |
5067 (if gnus-browse-mode-map | |
5068 nil | |
5069 (setq gnus-browse-mode-map (make-keymap)) | |
5070 (suppress-keymap gnus-browse-mode-map) | |
5071 (define-key gnus-browse-mode-map " " 'gnus-browse-read-group) | |
5072 (define-key gnus-browse-mode-map "=" 'gnus-browse-select-group) | |
5073 (define-key gnus-browse-mode-map "n" 'gnus-browse-next-group) | |
5074 (define-key gnus-browse-mode-map "p" 'gnus-browse-prev-group) | |
5075 (define-key gnus-browse-mode-map "\177" 'gnus-browse-prev-group) | |
5076 (define-key gnus-browse-mode-map "N" 'gnus-browse-next-group) | |
5077 (define-key gnus-browse-mode-map "P" 'gnus-browse-prev-group) | |
5078 (define-key gnus-browse-mode-map "\M-n" 'gnus-browse-next-group) | |
5079 (define-key gnus-browse-mode-map "\M-p" 'gnus-browse-prev-group) | |
5080 (define-key gnus-browse-mode-map "\r" 'gnus-browse-select-group) | |
5081 (define-key gnus-browse-mode-map "u" 'gnus-browse-unsubscribe-current-group) | |
5082 (define-key gnus-browse-mode-map "l" 'gnus-browse-exit) | |
5083 (define-key gnus-browse-mode-map "L" 'gnus-browse-exit) | |
5084 (define-key gnus-browse-mode-map "q" 'gnus-browse-exit) | |
5085 (define-key gnus-browse-mode-map "Q" 'gnus-browse-exit) | |
5086 (define-key gnus-browse-mode-map "\C-c\C-c" 'gnus-browse-exit) | |
5087 (define-key gnus-browse-mode-map "?" 'gnus-browse-describe-briefly) | |
5088 (define-key gnus-browse-mode-map "\C-c\C-i" 'gnus-info-find-node) | |
5089 ) | |
5090 | |
5091 (defvar gnus-browse-current-method nil) | |
5092 (defvar gnus-browse-return-buffer nil) | |
5093 | |
5094 (defvar gnus-browse-buffer "*Gnus Browse Server*") | |
5095 | |
5096 (defun gnus-browse-foreign-server (method &optional return-buffer) | |
5097 (setq gnus-browse-current-method method) | |
5098 (setq gnus-browse-return-buffer return-buffer) | |
5099 (let ((gnus-select-method method) | |
5100 groups group) | |
5101 (gnus-message 5 "Connecting to %s..." (nth 1 method)) | |
5102 (or (gnus-check-server method) | |
5103 (error "Unable to contact server: %s" (gnus-status-message method))) | |
5104 (or (gnus-request-list method) | |
5105 (error "Couldn't request list: %s" (gnus-status-message method))) | |
5106 (get-buffer-create gnus-browse-buffer) | |
5107 (gnus-add-current-to-buffer-list) | |
5108 (and gnus-carpal (gnus-carpal-setup-buffer 'browse)) | |
5109 (gnus-configure-windows 'browse) | |
5110 (buffer-disable-undo (current-buffer)) | |
5111 (let ((buffer-read-only nil)) | |
5112 (erase-buffer)) | |
5113 (gnus-browse-mode) | |
5114 (setq mode-line-buffer-identification | |
5115 (format | |
5116 "Gnus Browse Server {%s:%s}" (car method) (car (cdr method)))) | |
5117 (save-excursion | |
5118 (set-buffer nntp-server-buffer) | |
5119 (let ((cur (current-buffer))) | |
5120 (goto-char (point-min)) | |
5121 (or (string= gnus-ignored-newsgroups "") | |
5122 (delete-matching-lines gnus-ignored-newsgroups)) | |
5123 (while (re-search-forward | |
5124 "\\(^[^ \t]+\\)[ \t]+[0-9]+[ \t]+[0-9]+" nil t) | |
5125 (goto-char (match-end 1)) | |
5126 (setq groups (cons (cons (buffer-substring (match-beginning 1) | |
5127 (match-end 1)) | |
5128 (max 0 (- (1+ (read cur)) (read cur)))) | |
5129 groups))))) | |
5130 (setq groups (sort groups | |
5131 (lambda (l1 l2) | |
5132 (string< (car l1) (car l2))))) | |
5133 (let ((buffer-read-only nil)) | |
5134 (while groups | |
5135 (setq group (car groups)) | |
5136 (insert | |
5137 (format "K%7d: %s\n" (cdr group) (car group))) | |
5138 (setq groups (cdr groups)))) | |
5139 (switch-to-buffer (current-buffer)) | |
5140 (goto-char (point-min)) | |
5141 (gnus-group-position-cursor))) | |
5142 | |
5143 (defun gnus-browse-mode () | |
5144 "Major mode for browsing a foreign server. | |
5145 | |
5146 All normal editing commands are switched off. | |
5147 | |
5148 \\<gnus-browse-mode-map> | |
5149 The only things you can do in this buffer is | |
5150 | |
5151 1) `\\[gnus-browse-unsubscribe-current-group]' to subscribe to a group. | |
5152 The group will be inserted into the group buffer upon exit from this | |
5153 buffer. | |
5154 | |
5155 2) `\\[gnus-browse-read-group]' to read a group ephemerally. | |
5156 | |
5157 3) `\\[gnus-browse-exit]' to return to the group buffer." | |
5158 (interactive) | |
5159 (kill-all-local-variables) | |
5160 (if gnus-visual (gnus-browse-make-menu-bar)) | |
5161 (setq mode-line-modified "-- ") | |
5162 (make-local-variable 'mode-line-format) | |
5163 (setq mode-line-format (copy-sequence mode-line-format)) | |
5164 (and (equal (nth 3 mode-line-format) " ") | |
5165 (setcar (nthcdr 3 mode-line-format) "")) | |
5166 (setq major-mode 'gnus-browse-mode) | |
5167 (setq mode-name "Browse Server") | |
5168 (setq mode-line-process nil) | |
5169 (use-local-map gnus-browse-mode-map) | |
5170 (buffer-disable-undo (current-buffer)) | |
5171 (setq truncate-lines t) | |
5172 (setq buffer-read-only t) | |
5173 (run-hooks 'gnus-browse-mode-hook)) | |
5174 | |
5175 (defun gnus-browse-read-group (&optional no-article) | |
5176 "Enter the group at the current line." | |
5177 (interactive) | |
5178 (let ((group (gnus-browse-group-name))) | |
5179 (or (gnus-group-read-ephemeral-group | |
5180 group gnus-browse-current-method nil | |
5181 (cons (current-buffer) 'browse)) | |
5182 (error "Couldn't enter %s" group)))) | |
5183 | |
5184 (defun gnus-browse-select-group () | |
5185 "Select the current group." | |
5186 (interactive) | |
5187 (gnus-browse-read-group 'no)) | |
5188 | |
5189 (defun gnus-browse-next-group (n) | |
5190 "Go to the next group." | |
5191 (interactive "p") | |
5192 (prog1 | |
5193 (forward-line n) | |
5194 (gnus-group-position-cursor))) | |
5195 | |
5196 (defun gnus-browse-prev-group (n) | |
5197 "Go to the next group." | |
5198 (interactive "p") | |
5199 (gnus-browse-next-group (- n))) | |
5200 | |
5201 (defun gnus-browse-unsubscribe-current-group (arg) | |
5202 "(Un)subscribe to the next ARG groups." | |
5203 (interactive "p") | |
5204 (and (eobp) | |
5205 (error "No group at current line.")) | |
5206 (let ((ward (if (< arg 0) -1 1)) | |
5207 (arg (abs arg))) | |
5208 (while (and (> arg 0) | |
5209 (not (eobp)) | |
5210 (gnus-browse-unsubscribe-group) | |
5211 (zerop (gnus-browse-next-group ward))) | |
5212 (setq arg (1- arg))) | |
5213 (gnus-group-position-cursor) | |
5214 (if (/= 0 arg) (gnus-message 7 "No more newsgroups")) | |
5215 arg)) | |
5216 | |
5217 (defun gnus-browse-group-name () | |
5218 (save-excursion | |
5219 (beginning-of-line) | |
5220 (if (not (re-search-forward ": \\(.*\\)$" (gnus-point-at-eol) t)) | |
5221 () | |
5222 (gnus-group-prefixed-name | |
5223 (buffer-substring (match-beginning 1) (match-end 1)) | |
5224 gnus-browse-current-method)))) | |
5225 | |
5226 (defun gnus-browse-unsubscribe-group () | |
5227 "Toggle subscription of the current group in the browse buffer." | |
5228 (let ((sub nil) | |
5229 (buffer-read-only nil) | |
5230 group) | |
5231 (save-excursion | |
5232 (beginning-of-line) | |
5233 ;; If this group it killed, then we want to subscribe it. | |
5234 (if (= (following-char) ?K) (setq sub t)) | |
5235 (setq group (gnus-browse-group-name)) | |
5236 (delete-char 1) | |
5237 (if sub | |
5238 (progn | |
5239 (gnus-group-change-level | |
5240 (list t group gnus-level-default-subscribed | |
5241 nil nil gnus-browse-current-method) | |
5242 gnus-level-default-subscribed gnus-level-killed | |
5243 (and (car (nth 1 gnus-newsrc-alist)) | |
5244 (gnus-gethash (car (nth 1 gnus-newsrc-alist)) | |
5245 gnus-newsrc-hashtb)) | |
5246 t) | |
5247 (insert ? )) | |
5248 (gnus-group-change-level | |
5249 group gnus-level-killed gnus-level-default-subscribed) | |
5250 (insert ?K))) | |
5251 t)) | |
5252 | |
5253 (defun gnus-browse-exit () | |
5254 "Quit browsing and return to the group buffer." | |
5255 (interactive) | |
5256 (if (eq major-mode 'gnus-browse-mode) | |
5257 (kill-buffer (current-buffer))) | |
5258 (if gnus-browse-return-buffer | |
5259 (gnus-configure-windows 'server 'force) | |
5260 (gnus-configure-windows 'group 'force) | |
5261 (gnus-group-list-groups nil))) | |
5262 | |
5263 (defun gnus-browse-describe-briefly () | |
5264 "Give a one line description of the group mode commands." | |
5265 (interactive) | |
5266 (gnus-message 6 | |
5267 (substitute-command-keys "\\<gnus-browse-mode-map>\\[gnus-group-next-group]:Forward \\[gnus-group-prev-group]:Backward \\[gnus-browse-exit]:Exit \\[gnus-info-find-node]:Run Info \\[gnus-browse-describe-briefly]:This help"))) | |
5268 | |
5269 | |
5270 ;;; | |
5271 ;;; Gnus summary mode | |
5272 ;;; | |
5273 | |
5274 (defvar gnus-summary-mode-map nil) | |
5275 (defvar gnus-summary-mark-map nil) | |
5276 (defvar gnus-summary-mscore-map nil) | |
5277 (defvar gnus-summary-article-map nil) | |
5278 (defvar gnus-summary-thread-map nil) | |
5279 (defvar gnus-summary-goto-map nil) | |
5280 (defvar gnus-summary-exit-map nil) | |
5281 (defvar gnus-summary-interest-map nil) | |
5282 (defvar gnus-summary-sort-map nil) | |
5283 (defvar gnus-summary-backend-map nil) | |
5284 (defvar gnus-summary-save-map nil) | |
5285 (defvar gnus-summary-wash-map nil) | |
5286 (defvar gnus-summary-wash-hide-map nil) | |
5287 (defvar gnus-summary-wash-highlight-map nil) | |
5288 (defvar gnus-summary-wash-time-map nil) | |
5289 (defvar gnus-summary-help-map nil) | |
5290 | |
5291 (put 'gnus-summary-mode 'mode-class 'special) | |
5292 | |
5293 (if gnus-summary-mode-map | |
5294 nil | |
5295 (setq gnus-summary-mode-map (make-keymap)) | |
5296 (suppress-keymap gnus-summary-mode-map) | |
5297 | |
5298 ;; Non-orthogonal keys | |
5299 | |
5300 (define-key gnus-summary-mode-map " " 'gnus-summary-next-page) | |
5301 (define-key gnus-summary-mode-map "\177" 'gnus-summary-prev-page) | |
5302 (define-key gnus-summary-mode-map "\r" 'gnus-summary-scroll-up) | |
5303 (define-key gnus-summary-mode-map "n" 'gnus-summary-next-unread-article) | |
5304 (define-key gnus-summary-mode-map "p" 'gnus-summary-prev-unread-article) | |
5305 (define-key gnus-summary-mode-map "N" 'gnus-summary-next-article) | |
5306 (define-key gnus-summary-mode-map "P" 'gnus-summary-prev-article) | |
5307 (define-key gnus-summary-mode-map "\M-\C-n" 'gnus-summary-next-same-subject) | |
5308 (define-key gnus-summary-mode-map "\M-\C-p" 'gnus-summary-prev-same-subject) | |
5309 (define-key gnus-summary-mode-map "\M-n" 'gnus-summary-next-unread-subject) | |
5310 (define-key gnus-summary-mode-map "\M-p" 'gnus-summary-prev-unread-subject) | |
5311 (define-key gnus-summary-mode-map "." 'gnus-summary-first-unread-article) | |
5312 (define-key gnus-summary-mode-map "," 'gnus-summary-best-unread-article) | |
5313 (define-key gnus-summary-mode-map | |
5314 "\M-s" 'gnus-summary-search-article-forward) | |
5315 (define-key gnus-summary-mode-map | |
5316 "\M-r" 'gnus-summary-search-article-backward) | |
5317 (define-key gnus-summary-mode-map "<" 'gnus-summary-beginning-of-article) | |
5318 (define-key gnus-summary-mode-map ">" 'gnus-summary-end-of-article) | |
5319 (define-key gnus-summary-mode-map "j" 'gnus-summary-goto-subject) | |
5320 (define-key gnus-summary-mode-map "^" 'gnus-summary-refer-parent-article) | |
5321 (define-key gnus-summary-mode-map "\M-^" 'gnus-summary-refer-article) | |
5322 (define-key gnus-summary-mode-map "u" 'gnus-summary-tick-article-forward) | |
5323 (define-key gnus-summary-mode-map "!" 'gnus-summary-tick-article-forward) | |
5324 (define-key gnus-summary-mode-map "U" 'gnus-summary-tick-article-backward) | |
5325 (define-key gnus-summary-mode-map "d" 'gnus-summary-mark-as-read-forward) | |
5326 (define-key gnus-summary-mode-map "D" 'gnus-summary-mark-as-read-backward) | |
5327 (define-key gnus-summary-mode-map "E" 'gnus-summary-mark-as-expirable) | |
5328 (define-key gnus-summary-mode-map "\M-u" 'gnus-summary-clear-mark-forward) | |
5329 (define-key gnus-summary-mode-map "\M-U" 'gnus-summary-clear-mark-backward) | |
5330 (define-key gnus-summary-mode-map | |
5331 "k" 'gnus-summary-kill-same-subject-and-select) | |
5332 (define-key gnus-summary-mode-map "\C-k" 'gnus-summary-kill-same-subject) | |
5333 (define-key gnus-summary-mode-map "\M-\C-k" 'gnus-summary-kill-thread) | |
5334 (define-key gnus-summary-mode-map "\M-\C-l" 'gnus-summary-lower-thread) | |
5335 (define-key gnus-summary-mode-map "e" 'gnus-summary-edit-article) | |
5336 (define-key gnus-summary-mode-map "#" 'gnus-summary-mark-as-processable) | |
5337 (define-key gnus-summary-mode-map "\M-#" 'gnus-summary-unmark-as-processable) | |
5338 (define-key gnus-summary-mode-map "\M-\C-t" 'gnus-summary-toggle-threads) | |
5339 (define-key gnus-summary-mode-map "\M-\C-s" 'gnus-summary-show-thread) | |
5340 (define-key gnus-summary-mode-map "\M-\C-h" 'gnus-summary-hide-thread) | |
5341 (define-key gnus-summary-mode-map "\M-\C-f" 'gnus-summary-next-thread) | |
5342 (define-key gnus-summary-mode-map "\M-\C-b" 'gnus-summary-prev-thread) | |
5343 (define-key gnus-summary-mode-map "\M-\C-u" 'gnus-summary-up-thread) | |
5344 (define-key gnus-summary-mode-map "\M-\C-d" 'gnus-summary-down-thread) | |
5345 (define-key gnus-summary-mode-map "&" 'gnus-summary-execute-command) | |
5346 (define-key gnus-summary-mode-map "c" 'gnus-summary-catchup-and-exit) | |
5347 (define-key gnus-summary-mode-map "\C-w" 'gnus-summary-mark-region-as-read) | |
5348 (define-key gnus-summary-mode-map "\C-t" 'gnus-summary-toggle-truncation) | |
5349 (define-key gnus-summary-mode-map "?" 'gnus-summary-mark-as-dormant) | |
5350 (define-key gnus-summary-mode-map | |
5351 "\C-c\M-\C-s" 'gnus-summary-show-all-expunged) | |
5352 (define-key gnus-summary-mode-map | |
5353 "\C-c\C-s\C-n" 'gnus-summary-sort-by-number) | |
5354 (define-key gnus-summary-mode-map | |
5355 "\C-c\C-s\C-a" 'gnus-summary-sort-by-author) | |
5356 (define-key gnus-summary-mode-map | |
5357 "\C-c\C-s\C-s" 'gnus-summary-sort-by-subject) | |
5358 (define-key gnus-summary-mode-map "\C-c\C-s\C-d" 'gnus-summary-sort-by-date) | |
5359 (define-key gnus-summary-mode-map "\C-c\C-s\C-i" 'gnus-summary-sort-by-score) | |
5360 (define-key gnus-summary-mode-map "=" 'gnus-summary-expand-window) | |
5361 (define-key gnus-summary-mode-map | |
5362 "\C-x\C-s" 'gnus-summary-reselect-current-group) | |
5363 (define-key gnus-summary-mode-map "\M-g" 'gnus-summary-rescan-group) | |
5364 (define-key gnus-summary-mode-map "w" 'gnus-summary-stop-page-breaking) | |
5365 (define-key gnus-summary-mode-map "\C-c\C-r" 'gnus-summary-caesar-message) | |
5366 (define-key gnus-summary-mode-map "\M-t" 'gnus-summary-toggle-mime) | |
5367 (define-key gnus-summary-mode-map "f" 'gnus-summary-followup) | |
5368 (define-key gnus-summary-mode-map "F" 'gnus-summary-followup-with-original) | |
5369 (define-key gnus-summary-mode-map "C" 'gnus-summary-cancel-article) | |
5370 (define-key gnus-summary-mode-map "r" 'gnus-summary-reply) | |
5371 (define-key gnus-summary-mode-map "R" 'gnus-summary-reply-with-original) | |
5372 (define-key gnus-summary-mode-map "\C-c\C-f" 'gnus-summary-mail-forward) | |
5373 (define-key gnus-summary-mode-map "o" 'gnus-summary-save-article) | |
5374 (define-key gnus-summary-mode-map "\C-o" 'gnus-summary-save-article-mail) | |
5375 (define-key gnus-summary-mode-map "|" 'gnus-summary-pipe-output) | |
5376 (define-key gnus-summary-mode-map "\M-k" 'gnus-summary-edit-local-kill) | |
5377 (define-key gnus-summary-mode-map "\M-K" 'gnus-summary-edit-global-kill) | |
5378 (define-key gnus-summary-mode-map "V" 'gnus-version) | |
5379 (define-key gnus-summary-mode-map "\C-c\C-d" 'gnus-summary-describe-group) | |
5380 (define-key gnus-summary-mode-map "q" 'gnus-summary-exit) | |
5381 (define-key gnus-summary-mode-map "Q" 'gnus-summary-exit-no-update) | |
5382 (define-key gnus-summary-mode-map "\C-c\C-i" 'gnus-info-find-node) | |
5383 (define-key gnus-summary-mode-map gnus-mouse-2 'gnus-mouse-pick-article) | |
5384 (define-key gnus-summary-mode-map "m" 'gnus-summary-mail-other-window) | |
5385 (define-key gnus-summary-mode-map "a" 'gnus-summary-post-news) | |
5386 (define-key gnus-summary-mode-map | |
5387 "x" 'gnus-summary-remove-lines-marked-as-read) | |
5388 ; (define-key gnus-summary-mode-map "X" 'gnus-summary-remove-lines-marked-with) | |
5389 (define-key gnus-summary-mode-map "s" 'gnus-summary-isearch-article) | |
5390 (define-key gnus-summary-mode-map "t" 'gnus-summary-toggle-header) | |
5391 (define-key gnus-summary-mode-map "g" 'gnus-summary-show-article) | |
5392 ; (define-key gnus-summary-mode-map "?" 'gnus-summary-describe-briefly) | |
5393 (define-key gnus-summary-mode-map "l" 'gnus-summary-goto-last-article) | |
5394 (define-key gnus-summary-mode-map "\C-c\C-v\C-v" 'gnus-uu-decode-uu-view) | |
5395 (define-key gnus-summary-mode-map "\C-d" 'gnus-summary-enter-digest-group) | |
5396 (define-key gnus-summary-mode-map "v" 'gnus-summary-verbose-headers) | |
5397 (define-key gnus-summary-mode-map "\C-c\C-b" 'gnus-bug) | |
5398 | |
5399 | |
5400 ;; Sort of orthogonal keymap | |
5401 (define-prefix-command 'gnus-summary-mark-map) | |
5402 (define-key gnus-summary-mode-map "M" 'gnus-summary-mark-map) | |
5403 (define-key gnus-summary-mark-map "t" 'gnus-summary-tick-article-forward) | |
5404 (define-key gnus-summary-mark-map "!" 'gnus-summary-tick-article-forward) | |
5405 (define-key gnus-summary-mark-map "d" 'gnus-summary-mark-as-read-forward) | |
5406 (define-key gnus-summary-mark-map "r" 'gnus-summary-mark-as-read-forward) | |
5407 (define-key gnus-summary-mark-map "c" 'gnus-summary-clear-mark-forward) | |
5408 (define-key gnus-summary-mark-map " " 'gnus-summary-clear-mark-forward) | |
5409 (define-key gnus-summary-mark-map "e" 'gnus-summary-mark-as-expirable) | |
5410 (define-key gnus-summary-mark-map "x" 'gnus-summary-mark-as-expirable) | |
5411 (define-key gnus-summary-mark-map "?" 'gnus-summary-mark-as-dormant) | |
5412 (define-key gnus-summary-mark-map "b" 'gnus-summary-set-bookmark) | |
5413 (define-key gnus-summary-mark-map "B" 'gnus-summary-remove-bookmark) | |
5414 (define-key gnus-summary-mark-map "#" 'gnus-summary-mark-as-processable) | |
5415 (define-key gnus-summary-mark-map "\M-#" 'gnus-summary-unmark-as-processable) | |
5416 (define-key gnus-summary-mark-map | |
5417 "\M-r" 'gnus-summary-remove-lines-marked-as-read) | |
5418 (define-key gnus-summary-mark-map | |
5419 "\M-\C-r" 'gnus-summary-remove-lines-marked-with) | |
5420 (define-key gnus-summary-mark-map "D" 'gnus-summary-show-all-dormant) | |
5421 (define-key gnus-summary-mark-map "\M-D" 'gnus-summary-hide-all-dormant) | |
5422 (define-key gnus-summary-mark-map "S" 'gnus-summary-show-all-expunged) | |
5423 (define-key gnus-summary-mark-map "C" 'gnus-summary-catchup) | |
5424 (define-key gnus-summary-mark-map "H" 'gnus-summary-catchup-to-here) | |
5425 (define-key gnus-summary-mark-map "\C-c" 'gnus-summary-catchup-all) | |
5426 (define-key gnus-summary-mark-map | |
5427 "k" 'gnus-summary-kill-same-subject-and-select) | |
5428 (define-key gnus-summary-mark-map "K" 'gnus-summary-kill-same-subject) | |
5429 | |
5430 (define-prefix-command 'gnus-summary-mscore-map) | |
5431 (define-key gnus-summary-mark-map "V" 'gnus-summary-mscore-map) | |
5432 (define-key gnus-summary-mscore-map "c" 'gnus-summary-clear-above) | |
5433 (define-key gnus-summary-mscore-map "u" 'gnus-summary-tick-above) | |
5434 (define-key gnus-summary-mscore-map "m" 'gnus-summary-mark-above) | |
5435 (define-key gnus-summary-mscore-map "k" 'gnus-summary-kill-below) | |
5436 | |
5437 (define-key gnus-summary-mark-map "P" 'gnus-uu-mark-map) | |
5438 | |
5439 (define-key gnus-summary-mode-map "S" 'gnus-summary-send-map) | |
5440 | |
5441 (define-prefix-command 'gnus-summary-goto-map) | |
5442 (define-key gnus-summary-mode-map "G" 'gnus-summary-goto-map) | |
5443 (define-key gnus-summary-goto-map "n" 'gnus-summary-next-unread-article) | |
5444 (define-key gnus-summary-goto-map "p" 'gnus-summary-prev-unread-article) | |
5445 (define-key gnus-summary-goto-map "N" 'gnus-summary-next-article) | |
5446 (define-key gnus-summary-goto-map "P" 'gnus-summary-prev-article) | |
5447 (define-key gnus-summary-goto-map "\C-n" 'gnus-summary-next-same-subject) | |
5448 (define-key gnus-summary-goto-map "\C-p" 'gnus-summary-prev-same-subject) | |
5449 (define-key gnus-summary-goto-map "\M-n" 'gnus-summary-next-unread-subject) | |
5450 (define-key gnus-summary-goto-map "\M-p" 'gnus-summary-prev-unread-subject) | |
5451 (define-key gnus-summary-goto-map "f" 'gnus-summary-first-unread-article) | |
5452 (define-key gnus-summary-goto-map "b" 'gnus-summary-best-unread-article) | |
5453 (define-key gnus-summary-goto-map "g" 'gnus-summary-goto-subject) | |
5454 (define-key gnus-summary-goto-map "l" 'gnus-summary-goto-last-article) | |
5455 (define-key gnus-summary-goto-map "p" 'gnus-summary-pop-article) | |
5456 | |
5457 | |
5458 (define-prefix-command 'gnus-summary-thread-map) | |
5459 (define-key gnus-summary-mode-map "T" 'gnus-summary-thread-map) | |
5460 (define-key gnus-summary-thread-map "k" 'gnus-summary-kill-thread) | |
5461 (define-key gnus-summary-thread-map "l" 'gnus-summary-lower-thread) | |
5462 (define-key gnus-summary-thread-map "i" 'gnus-summary-raise-thread) | |
5463 (define-key gnus-summary-thread-map "T" 'gnus-summary-toggle-threads) | |
5464 (define-key gnus-summary-thread-map "s" 'gnus-summary-show-thread) | |
5465 (define-key gnus-summary-thread-map "S" 'gnus-summary-show-all-threads) | |
5466 (define-key gnus-summary-thread-map "h" 'gnus-summary-hide-thread) | |
5467 (define-key gnus-summary-thread-map "H" 'gnus-summary-hide-all-threads) | |
5468 (define-key gnus-summary-thread-map "n" 'gnus-summary-next-thread) | |
5469 (define-key gnus-summary-thread-map "p" 'gnus-summary-prev-thread) | |
5470 (define-key gnus-summary-thread-map "u" 'gnus-summary-up-thread) | |
5471 (define-key gnus-summary-thread-map "d" 'gnus-summary-down-thread) | |
5472 (define-key gnus-summary-thread-map "#" 'gnus-uu-mark-thread) | |
5473 | |
5474 | |
5475 (define-prefix-command 'gnus-summary-exit-map) | |
5476 (define-key gnus-summary-mode-map "Z" 'gnus-summary-exit-map) | |
5477 (define-key gnus-summary-exit-map "c" 'gnus-summary-catchup-and-exit) | |
5478 (define-key gnus-summary-exit-map "C" 'gnus-summary-catchup-all-and-exit) | |
5479 (define-key gnus-summary-exit-map "E" 'gnus-summary-exit-no-update) | |
5480 (define-key gnus-summary-exit-map "Q" 'gnus-summary-exit) | |
5481 (define-key gnus-summary-exit-map "Z" 'gnus-summary-exit) | |
5482 (define-key gnus-summary-exit-map | |
5483 "n" 'gnus-summary-catchup-and-goto-next-group) | |
5484 (define-key gnus-summary-exit-map "R" 'gnus-summary-reselect-current-group) | |
5485 (define-key gnus-summary-exit-map "G" 'gnus-summary-rescan-group) | |
5486 (define-key gnus-summary-exit-map "N" 'gnus-summary-next-group) | |
5487 (define-key gnus-summary-exit-map "P" 'gnus-summary-prev-group) | |
5488 | |
5489 | |
5490 (define-prefix-command 'gnus-summary-article-map) | |
5491 (define-key gnus-summary-mode-map "A" 'gnus-summary-article-map) | |
5492 (define-key gnus-summary-article-map " " 'gnus-summary-next-page) | |
5493 (define-key gnus-summary-article-map "n" 'gnus-summary-next-page) | |
5494 (define-key gnus-summary-article-map "\177" 'gnus-summary-prev-page) | |
5495 (define-key gnus-summary-article-map "p" 'gnus-summary-prev-page) | |
5496 (define-key gnus-summary-article-map "\r" 'gnus-summary-scroll-up) | |
5497 (define-key gnus-summary-article-map "<" 'gnus-summary-beginning-of-article) | |
5498 (define-key gnus-summary-article-map ">" 'gnus-summary-end-of-article) | |
5499 (define-key gnus-summary-article-map "b" 'gnus-summary-beginning-of-article) | |
5500 (define-key gnus-summary-article-map "e" 'gnus-summary-end-of-article) | |
5501 (define-key gnus-summary-article-map "^" 'gnus-summary-refer-parent-article) | |
5502 (define-key gnus-summary-article-map "r" 'gnus-summary-refer-parent-article) | |
5503 (define-key gnus-summary-article-map "g" 'gnus-summary-show-article) | |
5504 (define-key gnus-summary-article-map "s" 'gnus-summary-isearch-article) | |
5505 | |
5506 | |
5507 | |
5508 (define-prefix-command 'gnus-summary-wash-map) | |
5509 (define-key gnus-summary-mode-map "W" 'gnus-summary-wash-map) | |
5510 | |
5511 (define-prefix-command 'gnus-summary-wash-hide-map) | |
5512 (define-key gnus-summary-wash-map "W" 'gnus-summary-wash-hide-map) | |
5513 (define-key gnus-summary-wash-hide-map "a" 'gnus-article-hide) | |
5514 (define-key gnus-summary-wash-hide-map "h" 'gnus-article-hide-headers) | |
5515 (define-key gnus-summary-wash-hide-map "s" 'gnus-article-hide-signature) | |
5516 (define-key gnus-summary-wash-hide-map "c" 'gnus-article-hide-citation) | |
5517 (define-key gnus-summary-wash-hide-map | |
5518 "\C-c" 'gnus-article-hide-citation-maybe) | |
5519 | |
5520 (define-prefix-command 'gnus-summary-wash-highlight-map) | |
5521 (define-key gnus-summary-wash-map "H" 'gnus-summary-wash-highlight-map) | |
5522 (define-key gnus-summary-wash-highlight-map "a" 'gnus-article-highlight) | |
5523 (define-key gnus-summary-wash-highlight-map | |
5524 "h" 'gnus-article-highlight-headers) | |
5525 (define-key gnus-summary-wash-highlight-map | |
5526 "c" 'gnus-article-highlight-citation) | |
5527 (define-key gnus-summary-wash-highlight-map | |
5528 "s" 'gnus-article-highlight-signature) | |
5529 | |
5530 (define-prefix-command 'gnus-summary-wash-time-map) | |
5531 (define-key gnus-summary-wash-map "T" 'gnus-summary-wash-time-map) | |
5532 (define-key gnus-summary-wash-time-map "z" 'gnus-article-date-ut) | |
5533 (define-key gnus-summary-wash-time-map "u" 'gnus-article-date-ut) | |
5534 (define-key gnus-summary-wash-time-map "l" 'gnus-article-date-local) | |
5535 (define-key gnus-summary-wash-time-map "e" 'gnus-article-date-lapsed) | |
5536 | |
5537 (define-key gnus-summary-wash-map "b" 'gnus-article-add-buttons) | |
5538 (define-key gnus-summary-wash-map "o" 'gnus-article-treat-overstrike) | |
5539 (define-key gnus-summary-wash-map "w" 'gnus-article-word-wrap) | |
5540 (define-key gnus-summary-wash-map "c" 'gnus-article-remove-cr) | |
5541 (define-key gnus-summary-wash-map "q" 'gnus-article-de-quoted-unreadable) | |
5542 (define-key gnus-summary-wash-map "f" 'gnus-article-display-x-face) | |
5543 (define-key gnus-summary-wash-map "l" 'gnus-summary-stop-page-breaking) | |
5544 (define-key gnus-summary-wash-map "r" 'gnus-summary-caesar-message) | |
5545 (define-key gnus-summary-wash-map "t" 'gnus-summary-toggle-header) | |
5546 (define-key gnus-summary-wash-map "m" 'gnus-summary-toggle-mime) | |
5547 | |
5548 | |
5549 (define-prefix-command 'gnus-summary-help-map) | |
5550 (define-key gnus-summary-mode-map "H" 'gnus-summary-help-map) | |
5551 (define-key gnus-summary-help-map "v" 'gnus-version) | |
5552 (define-key gnus-summary-help-map "f" 'gnus-summary-fetch-faq) | |
5553 (define-key gnus-summary-help-map "d" 'gnus-summary-describe-group) | |
5554 (define-key gnus-summary-help-map "h" 'gnus-summary-describe-briefly) | |
5555 (define-key gnus-summary-help-map "i" 'gnus-info-find-node) | |
5556 | |
5557 | |
5558 (define-prefix-command 'gnus-summary-backend-map) | |
5559 (define-key gnus-summary-mode-map "B" 'gnus-summary-backend-map) | |
5560 (define-key gnus-summary-backend-map "e" 'gnus-summary-expire-articles) | |
5561 (define-key gnus-summary-backend-map "\M-\C-e" | |
5562 'gnus-summary-expire-articles-now) | |
5563 (define-key gnus-summary-backend-map "\177" 'gnus-summary-delete-article) | |
5564 (define-key gnus-summary-backend-map "m" 'gnus-summary-move-article) | |
5565 (define-key gnus-summary-backend-map "r" 'gnus-summary-respool-article) | |
5566 (define-key gnus-summary-backend-map "w" 'gnus-summary-edit-article) | |
5567 (define-key gnus-summary-backend-map "c" 'gnus-summary-copy-article) | |
5568 (define-key gnus-summary-backend-map "q" 'gnus-summary-fancy-query) | |
5569 (define-key gnus-summary-backend-map "i" 'gnus-summary-import-article) | |
5570 | |
5571 | |
5572 (define-prefix-command 'gnus-summary-save-map) | |
5573 (define-key gnus-summary-mode-map "O" 'gnus-summary-save-map) | |
5574 (define-key gnus-summary-save-map "o" 'gnus-summary-save-article) | |
5575 (define-key gnus-summary-save-map "m" 'gnus-summary-save-article-mail) | |
5576 (define-key gnus-summary-save-map "r" 'gnus-summary-save-article-rmail) | |
5577 (define-key gnus-summary-save-map "f" 'gnus-summary-save-article-file) | |
5578 (define-key gnus-summary-save-map "h" 'gnus-summary-save-article-folder) | |
5579 (define-key gnus-summary-save-map "v" 'gnus-summary-save-article-vm) | |
5580 (define-key gnus-summary-save-map "p" 'gnus-summary-pipe-output) | |
5581 ; (define-key gnus-summary-save-map "s" 'gnus-soup-add-article) | |
5582 | |
5583 (define-key gnus-summary-mode-map "X" 'gnus-uu-extract-map) | |
5584 | |
5585 (define-key gnus-summary-mode-map "\M-&" 'gnus-summary-universal-argument) | |
5586 ; (define-key gnus-summary-various-map "\C-s" 'gnus-summary-search-article-forward) | |
5587 ; (define-key gnus-summary-various-map "\C-r" 'gnus-summary-search-article-backward) | |
5588 ; (define-key gnus-summary-various-map "r" 'gnus-summary-refer-article) | |
5589 ; (define-key gnus-summary-various-map "&" 'gnus-summary-execute-command) | |
5590 ; (define-key gnus-summary-various-map "T" 'gnus-summary-toggle-truncation) | |
5591 ; (define-key gnus-summary-various-map "e" 'gnus-summary-expand-window) | |
5592 (define-key gnus-summary-article-map "D" 'gnus-summary-enter-digest-group) | |
5593 ; (define-key gnus-summary-various-map "k" 'gnus-summary-edit-local-kill) | |
5594 ; (define-key gnus-summary-various-map "K" 'gnus-summary-edit-global-kill) | |
5595 | |
5596 (define-key gnus-summary-mode-map "V" 'gnus-summary-score-map) | |
5597 | |
5598 ; (define-prefix-command 'gnus-summary-sort-map) | |
5599 ; (define-key gnus-summary-various-map "s" 'gnus-summary-sort-map) | |
5600 ; (define-key gnus-summary-sort-map "n" 'gnus-summary-sort-by-number) | |
5601 ; (define-key gnus-summary-sort-map "a" 'gnus-summary-sort-by-author) | |
5602 ; (define-key gnus-summary-sort-map "s" 'gnus-summary-sort-by-subject) | |
5603 ; (define-key gnus-summary-sort-map "d" 'gnus-summary-sort-by-date) | |
5604 ; (define-key gnus-summary-sort-map "i" 'gnus-summary-sort-by-score) | |
5605 | |
5606 (define-key gnus-summary-mode-map "I" 'gnus-summary-increase-score) | |
5607 (define-key gnus-summary-mode-map "L" 'gnus-summary-lower-score) | |
5608 ) | |
5609 | |
5610 | |
5611 | |
5612 | |
5613 (defun gnus-summary-mode (&optional group) | |
5614 "Major mode for reading articles. | |
5615 | |
5616 All normal editing commands are switched off. | |
5617 \\<gnus-summary-mode-map> | |
5618 Each line in this buffer represents one article. To read an | |
5619 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards | |
5620 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]', | |
5621 respectively. | |
5622 | |
5623 You can also post articles and send mail from this buffer. To | |
5624 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author | |
5625 of an article, type `\\[gnus-summary-reply]'. | |
5626 | |
5627 There are approx. one gazillion commands you can execute in this | |
5628 buffer; read the info pages for more information (`\\[gnus-info-find-node]'). | |
5629 | |
5630 The following commands are available: | |
5631 | |
5632 \\{gnus-summary-mode-map}" | |
5633 (interactive) | |
5634 (if gnus-visual (gnus-summary-make-menu-bar)) | |
5635 (kill-all-local-variables) | |
5636 (let ((locals gnus-summary-local-variables)) | |
5637 (while locals | |
5638 (if (consp (car locals)) | |
5639 (progn | |
5640 (make-local-variable (car (car locals))) | |
5641 (set (car (car locals)) (eval (cdr (car locals))))) | |
5642 (make-local-variable (car locals)) | |
5643 (set (car locals) nil)) | |
5644 (setq locals (cdr locals)))) | |
5645 (gnus-make-thread-indent-array) | |
5646 (setq mode-line-modified "-- ") | |
5647 (make-local-variable 'mode-line-format) | |
5648 (setq mode-line-format (copy-sequence mode-line-format)) | |
5649 (and (equal (nth 3 mode-line-format) " ") | |
5650 (setcar (nthcdr 3 mode-line-format) "")) | |
5651 (setq major-mode 'gnus-summary-mode) | |
5652 (setq mode-name "Summary") | |
5653 (make-local-variable 'minor-mode-alist) | |
5654 (use-local-map gnus-summary-mode-map) | |
5655 (buffer-disable-undo (current-buffer)) | |
5656 (setq buffer-read-only t) ;Disable modification | |
5657 (setq truncate-lines t) | |
5658 (setq selective-display t) | |
5659 (setq selective-display-ellipses t) ;Display `...' | |
5660 (setq buffer-display-table gnus-summary-display-table) | |
5661 (setq gnus-newsgroup-name group) | |
5662 (run-hooks 'gnus-summary-mode-hook)) | |
5663 | |
5664 (defun gnus-summary-make-display-table () | |
5665 ;; Change the display table. Odd characters have a tendency to mess | |
5666 ;; up nicely formatted displays - we make all possible glyphs | |
5667 ;; display only a single character. | |
5668 | |
5669 ;; We start from the standard display table, if any. | |
5670 (setq gnus-summary-display-table | |
5671 (or (copy-sequence standard-display-table) | |
5672 (make-display-table))) | |
5673 ;; Nix out all the control chars... | |
5674 (let ((i 32)) | |
5675 (while (>= (setq i (1- i)) 0) | |
5676 (aset gnus-summary-display-table i [??]))) | |
5677 ;; ... but not newline and cr, of course. (cr is necessary for the | |
5678 ;; selective display). | |
5679 (aset gnus-summary-display-table ?\n nil) | |
5680 (aset gnus-summary-display-table ?\r nil) | |
5681 ;; We nix out any glyphs over 126 that are not set already. | |
5682 (let ((i 256)) | |
5683 (while (>= (setq i (1- i)) 127) | |
5684 ;; Only modify if the entry is nil. | |
5685 (or (aref gnus-summary-display-table i) | |
5686 (aset gnus-summary-display-table i [??]))))) | |
5687 | |
5688 (defun gnus-summary-clear-local-variables () | |
5689 (let ((locals gnus-summary-local-variables)) | |
5690 (while locals | |
5691 (if (consp (car locals)) | |
5692 (and (vectorp (car (car locals))) | |
5693 (set (car (car locals)) nil)) | |
5694 (and (vectorp (car locals)) | |
5695 (set (car locals) nil))) | |
5696 (setq locals (cdr locals))))) | |
5697 | |
5698 ;; Some summary mode macros. | |
5699 | |
5700 ;; Return a header specified by a NUMBER. | |
5701 (defun gnus-get-header-by-number (number) | |
5702 (save-excursion | |
5703 (set-buffer gnus-summary-buffer) | |
5704 (or gnus-newsgroup-headers-hashtb-by-number | |
5705 (gnus-make-headers-hashtable-by-number)) | |
5706 (gnus-gethash (int-to-string number) | |
5707 gnus-newsgroup-headers-hashtb-by-number))) | |
5708 | |
5709 ;; Fast version of the function above. | |
5710 (defmacro gnus-get-header-by-num (number) | |
5711 (` (gnus-gethash (int-to-string (, number)) | |
5712 gnus-newsgroup-headers-hashtb-by-number))) | |
5713 | |
5714 (defmacro gnus-summary-search-forward (&optional unread subject backward) | |
5715 "Search for article forward. | |
5716 If UNREAD is non-nil, only unread articles are selected. | |
5717 If SUBJECT is non-nil, the article which has the same subject will be | |
5718 searched for. | |
5719 If BACKWARD is non-nil, the search will be performed backwards instead." | |
5720 (` (gnus-summary-search-subject (, backward) (, unread) (, subject)))) | |
5721 | |
5722 (defmacro gnus-summary-search-backward (&optional unread subject) | |
5723 "Search for article backward. | |
5724 If 1st optional argument UNREAD is non-nil, only unread article is selected. | |
5725 If 2nd optional argument SUBJECT is non-nil, the article which has | |
5726 the same subject will be searched for." | |
5727 (` (gnus-summary-search-forward (, unread) (, subject) t))) | |
5728 | |
5729 (defmacro gnus-summary-article-number (&optional number-or-nil) | |
5730 "The article number of the article on the current line. | |
5731 If there isn's an article number here, then we return the current | |
5732 article number." | |
5733 (if number-or-nil | |
5734 '(get-text-property (gnus-point-at-bol) 'gnus-number) | |
5735 '(or (get-text-property (gnus-point-at-bol) 'gnus-number) | |
5736 gnus-current-article))) | |
5737 | |
5738 (defmacro gnus-summary-thread-level () | |
5739 "The thread level of the article on the current line." | |
5740 '(or (get-text-property (gnus-point-at-bol) 'gnus-level) | |
5741 0)) | |
5742 | |
5743 (defmacro gnus-summary-article-mark () | |
5744 "The mark on the current line." | |
5745 '(get-text-property (gnus-point-at-bol) 'gnus-mark)) | |
5746 | |
5747 (defun gnus-summary-subject-string () | |
5748 "Return current subject string or nil if nothing." | |
5749 (let ((article (gnus-summary-article-number)) | |
5750 header) | |
5751 (and article | |
5752 (setq header (gnus-get-header-by-num article)) | |
5753 (vectorp header) | |
5754 (mail-header-subject header)))) | |
5755 | |
5756 ;; Various summary mode internalish functions. | |
5757 | |
5758 (defun gnus-mouse-pick-article (e) | |
5759 (interactive "e") | |
5760 (mouse-set-point e) | |
5761 (gnus-summary-next-page nil t)) | |
5762 | |
5763 (defun gnus-summary-setup-buffer (group) | |
5764 "Initialize summary buffer." | |
5765 (let ((buffer (concat "*Summary " group "*"))) | |
5766 (if (get-buffer buffer) | |
5767 (progn | |
5768 (set-buffer buffer) | |
5769 (not gnus-newsgroup-begin)) | |
5770 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu> | |
5771 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer))) | |
5772 (gnus-add-current-to-buffer-list) | |
5773 (gnus-summary-mode group) | |
5774 (and gnus-carpal (gnus-carpal-setup-buffer 'summary)) | |
5775 (setq gnus-newsgroup-name group) | |
5776 t))) | |
5777 | |
5778 (defun gnus-set-global-variables () | |
5779 ;; Set the global equivalents of the summary buffer-local variables | |
5780 ;; to the latest values they had. These reflect the summary buffer | |
5781 ;; that was in action when the last article was fetched. | |
5782 (if (eq major-mode 'gnus-summary-mode) | |
5783 (progn | |
5784 (setq gnus-summary-buffer (current-buffer)) | |
5785 (let ((name gnus-newsgroup-name) | |
5786 (marked gnus-newsgroup-marked) | |
5787 (unread gnus-newsgroup-unreads) | |
5788 (headers gnus-current-headers) | |
5789 (score-file gnus-current-score-file)) | |
5790 (save-excursion | |
5791 (set-buffer gnus-group-buffer) | |
5792 (setq gnus-newsgroup-name name) | |
5793 (setq gnus-newsgroup-marked marked) | |
5794 (setq gnus-newsgroup-unreads unread) | |
5795 (setq gnus-current-headers headers) | |
5796 (setq gnus-current-score-file score-file)))))) | |
5797 | |
5798 (defun gnus-summary-insert-dummy-line (sformat subject number) | |
5799 (if (not sformat) | |
5800 (setq sformat gnus-summary-dummy-line-format-spec)) | |
5801 (let (b) | |
5802 (beginning-of-line) | |
5803 (setq b (point)) | |
5804 (insert (eval sformat)) | |
5805 (add-text-properties | |
5806 b (1+ b) | |
5807 (list 'gnus-number number | |
5808 'gnus-mark gnus-dummy-mark | |
5809 'gnus-level 0)))) | |
5810 | |
5811 (defvar gnus-thread-indent-array nil) | |
5812 (defvar gnus-thread-indent-array-level gnus-thread-indent-level) | |
5813 (defun gnus-make-thread-indent-array () | |
5814 (let ((n 200)) | |
5815 (if (and gnus-thread-indent-array | |
5816 (= gnus-thread-indent-level gnus-thread-indent-array-level)) | |
5817 nil | |
5818 (setq gnus-thread-indent-array (make-vector 201 "") | |
5819 gnus-thread-indent-array-level gnus-thread-indent-level) | |
5820 (while (>= n 0) | |
5821 (aset gnus-thread-indent-array n | |
5822 (make-string (* n gnus-thread-indent-level) ? )) | |
5823 (setq n (1- n)))))) | |
5824 | |
5825 (defun gnus-summary-insert-line | |
5826 (sformat header level current unread replied expirable subject-or-nil | |
5827 &optional dummy score process) | |
5828 (or sformat (setq sformat gnus-summary-line-format-spec)) | |
5829 (let* ((indentation (aref gnus-thread-indent-array level)) | |
5830 (lines (mail-header-lines header)) | |
5831 (score (or score gnus-summary-default-score 0)) | |
5832 (score-char | |
5833 (if (or (null gnus-summary-default-score) | |
5834 (<= (abs (- score gnus-summary-default-score)) | |
5835 gnus-summary-zcore-fuzz)) ? | |
5836 (if (< score gnus-summary-default-score) | |
5837 gnus-score-below-mark gnus-score-over-mark))) | |
5838 (replied (cond (process gnus-process-mark) | |
5839 (replied gnus-replied-mark) | |
5840 (t gnus-unread-mark))) | |
5841 (from (mail-header-from header)) | |
5842 (name (cond | |
5843 ((string-match "(.+)" from) | |
5844 (substring from (1+ (match-beginning 0)) (1- (match-end 0)))) | |
5845 ((string-match "<[^>]+> *$" from) | |
5846 (let ((beg (match-beginning 0))) | |
5847 (or (and (string-match "^\"[^\"]*\"" from) | |
5848 (substring from (1+ (match-beginning 0)) | |
5849 (1- (match-end 0)))) | |
5850 (substring from 0 beg)))) | |
5851 (t from))) | |
5852 (subject (mail-header-subject header)) | |
5853 (number (mail-header-number header)) | |
5854 (opening-bracket (if dummy ?\< ?\[)) | |
5855 (closing-bracket (if dummy ?\> ?\])) | |
5856 (buffer-read-only nil) | |
5857 (b (progn (beginning-of-line) (point)))) | |
5858 (or (numberp lines) (setq lines 0)) | |
5859 (insert (eval sformat)) | |
5860 (add-text-properties | |
5861 b (1+ b) (list 'gnus-number number | |
5862 'gnus-mark (or unread gnus-unread-mark) | |
5863 'gnus-level level)))) | |
5864 | |
5865 (defun gnus-summary-update-line (&optional dont-update) | |
5866 ;; Update summary line after change. | |
5867 (or (not gnus-summary-default-score) | |
5868 gnus-summary-inhibit-highlight | |
5869 (let ((gnus-summary-inhibit-highlight t) | |
5870 (article (gnus-summary-article-number))) | |
5871 (progn | |
5872 (or dont-update | |
5873 (if (and gnus-summary-mark-below | |
5874 (< (gnus-summary-article-score) | |
5875 gnus-summary-mark-below)) | |
5876 (and (not (memq article gnus-newsgroup-marked)) | |
5877 (not (memq article gnus-newsgroup-dormant)) | |
5878 (memq article gnus-newsgroup-unreads) | |
5879 (gnus-summary-mark-article-as-read gnus-low-score-mark)) | |
5880 (and (eq (gnus-summary-article-mark) gnus-low-score-mark) | |
5881 (gnus-summary-mark-article-as-unread gnus-unread-mark)))) | |
5882 (and gnus-visual | |
5883 (run-hooks 'gnus-summary-update-hook)))))) | |
5884 | |
5885 (defun gnus-summary-update-lines (&optional beg end) | |
5886 ;; Mark article as read (or not) by taking into account scores. | |
5887 (let ((beg (or beg (point-min))) | |
5888 (end (or end (point-max)))) | |
5889 (if (or (not gnus-summary-default-score) | |
5890 gnus-summary-inhibit-highlight) | |
5891 () | |
5892 (let ((gnus-summary-inhibit-highlight t) | |
5893 article) | |
5894 (save-excursion | |
5895 (set-buffer gnus-summary-buffer) | |
5896 (goto-char beg) | |
5897 (beginning-of-line) | |
5898 (while (and (not (eobp)) (< (point) end)) | |
5899 (if (and gnus-summary-mark-below | |
5900 (< (or (cdr (assq | |
5901 (setq article (get-text-property | |
5902 (point) 'gnus-number)) | |
5903 gnus-newsgroup-scored)) | |
5904 gnus-summary-default-score 0) | |
5905 gnus-summary-mark-below)) | |
5906 ;; We want to possibly mark it as read... | |
5907 (and (not (memq article gnus-newsgroup-marked)) | |
5908 (not (memq article gnus-newsgroup-dormant)) | |
5909 (memq article gnus-newsgroup-unreads) | |
5910 (gnus-summary-mark-article-as-read gnus-low-score-mark)) | |
5911 ;; We want to possibly mark it as unread. | |
5912 (and (eq (get-text-property (point) 'gnus-mark) | |
5913 gnus-low-score-mark) | |
5914 (gnus-summary-mark-article-as-unread gnus-unread-mark))) | |
5915 ;; Do the visual highlights at the same time. | |
5916 (and gnus-visual (run-hooks 'gnus-summary-update-hook)) | |
5917 (forward-line 1))))))) | |
5918 | |
5919 (defvar gnus-tmp-gathered nil) | |
5920 | |
5921 (defun gnus-summary-number-of-articles-in-thread (thread &optional char) | |
5922 ;; Sum up all elements (and sub-elements) in a list. | |
5923 (let* ((number | |
5924 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>. | |
5925 (if (and (consp thread) (cdr thread)) | |
5926 (apply | |
5927 '+ 1 (mapcar | |
5928 'gnus-summary-number-of-articles-in-thread | |
5929 (cdr thread))) | |
5930 1))) | |
5931 (if char | |
5932 (if (> number 1) gnus-not-empty-thread-mark | |
5933 gnus-empty-thread-mark) | |
5934 number))) | |
5935 | |
5936 (defun gnus-summary-read-group | |
5937 (group &optional show-all no-article kill-buffer) | |
5938 "Start reading news in newsgroup GROUP. | |
5939 If SHOW-ALL is non-nil, already read articles are also listed. | |
5940 If NO-ARTICLE is non-nil, no article is selected initially." | |
5941 (gnus-message 5 "Retrieving newsgroup: %s..." group) | |
5942 (let* ((new-group (gnus-summary-setup-buffer group)) | |
5943 (quit-config (gnus-group-quit-config group)) | |
5944 (did-select (and new-group (gnus-select-newsgroup group show-all)))) | |
5945 (cond | |
5946 ((not new-group) | |
5947 (gnus-set-global-variables) | |
5948 (gnus-kill-buffer kill-buffer) | |
5949 (gnus-configure-windows 'summary 'force) | |
5950 (gnus-set-mode-line 'summary) | |
5951 (gnus-summary-position-cursor) | |
5952 (message "") | |
5953 t) | |
5954 ((null did-select) | |
5955 (and (eq major-mode 'gnus-summary-mode) | |
5956 (not (equal (current-buffer) kill-buffer)) | |
5957 (progn | |
5958 (kill-buffer (current-buffer)) | |
5959 (if (not quit-config) | |
5960 (progn | |
5961 (set-buffer gnus-group-buffer) | |
5962 (gnus-group-jump-to-group group) | |
5963 (gnus-group-next-unread-group 1)) | |
5964 (if (not (buffer-name (car quit-config))) | |
5965 (gnus-configure-windows 'group 'force) | |
5966 (set-buffer (car quit-config)) | |
5967 (and (eq major-mode 'gnus-summary-mode) | |
5968 (gnus-set-global-variables)) | |
5969 (gnus-configure-windows (cdr quit-config)))))) | |
5970 (message "Can't select group") | |
5971 nil) | |
5972 ((eq did-select 'quit) | |
5973 (and (eq major-mode 'gnus-summary-mode) | |
5974 (not (equal (current-buffer) kill-buffer)) | |
5975 (kill-buffer (current-buffer))) | |
5976 (gnus-kill-buffer kill-buffer) | |
5977 (if (not quit-config) | |
5978 (progn | |
5979 (set-buffer gnus-group-buffer) | |
5980 (gnus-group-jump-to-group group) | |
5981 (gnus-group-next-unread-group 1) | |
5982 (gnus-configure-windows 'group 'force)) | |
5983 (if (not (buffer-name (car quit-config))) | |
5984 (gnus-configure-windows 'group 'force) | |
5985 (set-buffer (car quit-config)) | |
5986 (and (eq major-mode 'gnus-summary-mode) | |
5987 (gnus-set-global-variables)) | |
5988 (gnus-configure-windows (cdr quit-config)))) | |
5989 (signal 'quit nil)) | |
5990 (t | |
5991 (gnus-set-global-variables) | |
5992 ;; Save the active value in effect when the group was entered. | |
5993 (setq gnus-newsgroup-active | |
5994 (gnus-copy-sequence | |
5995 (gnus-gethash gnus-newsgroup-name gnus-active-hashtb))) | |
5996 ;; You can change the subjects in this hook. | |
5997 (run-hooks 'gnus-select-group-hook) | |
5998 ;; Do score processing. | |
5999 (and gnus-use-scoring (gnus-possibly-score-headers)) | |
6000 (gnus-update-format-specifications) | |
6001 ;; Generate the summary buffer. | |
6002 (gnus-summary-prepare) | |
6003 (if (zerop (buffer-size)) | |
6004 (cond (gnus-newsgroup-dormant | |
6005 (gnus-summary-show-all-dormant)) | |
6006 ((and gnus-newsgroup-scored show-all) | |
6007 (gnus-summary-show-all-expunged)))) | |
6008 ;; Function `gnus-apply-kill-file' must be called in this hook. | |
6009 (run-hooks 'gnus-apply-kill-hook) | |
6010 (if (zerop (buffer-size)) | |
6011 (progn | |
6012 ;; This newsgroup is empty. | |
6013 (gnus-summary-catchup-and-exit nil t) ;Without confirmations. | |
6014 (gnus-message 6 "No unread news") | |
6015 (gnus-kill-buffer kill-buffer) | |
6016 nil) | |
6017 ;;(save-excursion | |
6018 ;; (if kill-buffer | |
6019 ;; (let ((gnus-summary-buffer kill-buffer)) | |
6020 ;; (gnus-configure-windows 'group)))) | |
6021 ;; Hide conversation thread subtrees. We cannot do this in | |
6022 ;; gnus-summary-prepare-hook since kill processing may not | |
6023 ;; work with hidden articles. | |
6024 (and gnus-show-threads | |
6025 gnus-thread-hide-subtree | |
6026 (gnus-summary-hide-all-threads)) | |
6027 ;; Show first unread article if requested. | |
6028 (goto-char (point-min)) | |
6029 (if (and (not no-article) | |
6030 gnus-auto-select-first | |
6031 (gnus-summary-first-unread-article)) | |
6032 () | |
6033 (gnus-configure-windows 'summary 'force)) | |
6034 (gnus-set-mode-line 'summary) | |
6035 (gnus-summary-position-cursor) | |
6036 ;; If in async mode, we send some info to the backend. | |
6037 (and gnus-newsgroup-async | |
6038 (setq gnus-newsgroup-threads (nreverse gnus-newsgroup-threads)) | |
6039 (gnus-request-asynchronous | |
6040 gnus-newsgroup-name | |
6041 (if (and gnus-asynchronous-article-function | |
6042 (fboundp gnus-asynchronous-article-function)) | |
6043 (funcall gnus-asynchronous-article-function | |
6044 gnus-newsgroup-threads) | |
6045 gnus-newsgroup-threads))) | |
6046 (gnus-kill-buffer kill-buffer) | |
6047 (if (not (get-buffer-window gnus-group-buffer)) | |
6048 () | |
6049 ;; gotta use windows, because recenter does wierd stuff if | |
6050 ;; the current buffer ain't the displayed window. | |
6051 (let ((owin (selected-window))) | |
6052 (select-window (get-buffer-window gnus-group-buffer)) | |
6053 (and (gnus-group-goto-group group) | |
6054 (recenter)) | |
6055 (select-window owin)))) | |
6056 t)))) | |
6057 | |
6058 (defun gnus-summary-prepare () | |
6059 ;; Generate the summary buffer. | |
6060 (let ((buffer-read-only nil)) | |
6061 (erase-buffer) | |
6062 (gnus-summary-prepare-threads | |
6063 (if gnus-show-threads | |
6064 (gnus-gather-threads | |
6065 (gnus-sort-threads | |
6066 (if (and gnus-summary-expunge-below | |
6067 (not gnus-fetch-old-headers)) | |
6068 (gnus-make-threads-and-expunge) | |
6069 (gnus-make-threads)))) | |
6070 gnus-newsgroup-headers) | |
6071 'cull) | |
6072 (gnus-summary-update-lines) | |
6073 ;; Create the header hashtb. | |
6074 (gnus-make-headers-hashtable-by-number) | |
6075 ;; Call hooks for modifying summary buffer. | |
6076 ;; Suggested by sven@tde.LTH.Se (Sven Mattisson). | |
6077 (goto-char (point-min)) | |
6078 (run-hooks 'gnus-summary-prepare-hook))) | |
6079 | |
6080 (defun gnus-gather-threads (threads) | |
6081 "Gather threads that have lost their roots." | |
6082 (if (not gnus-summary-make-false-root) | |
6083 threads | |
6084 (let ((hashtb (gnus-make-hashtable 1023)) | |
6085 (prev threads) | |
6086 (result threads) | |
6087 subject hthread whole-subject) | |
6088 (while threads | |
6089 (setq whole-subject | |
6090 (setq subject (mail-header-subject (car (car threads))))) | |
6091 (if gnus-summary-gather-subject-limit | |
6092 (or (and (numberp gnus-summary-gather-subject-limit) | |
6093 (> (length subject) gnus-summary-gather-subject-limit) | |
6094 (setq subject | |
6095 (substring subject 0 | |
6096 gnus-summary-gather-subject-limit))) | |
6097 (and (eq 'fuzzy gnus-summary-gather-subject-limit) | |
6098 (setq subject (gnus-simplify-subject-fuzzy subject)))) | |
6099 (setq subject (gnus-simplify-subject-re subject))) | |
6100 (if (setq hthread | |
6101 (gnus-gethash subject hashtb)) | |
6102 (progn | |
6103 (or (stringp (car (car hthread))) | |
6104 (setcar hthread (list whole-subject (car hthread)))) | |
6105 (setcdr (car hthread) (nconc (cdr (car hthread)) | |
6106 (list (car threads)))) | |
6107 (setcdr prev (cdr threads)) | |
6108 (setq threads prev)) | |
6109 (gnus-sethash subject threads hashtb)) | |
6110 (setq prev threads) | |
6111 (setq threads (cdr threads))) | |
6112 result))) | |
6113 | |
6114 (defun gnus-make-threads () | |
6115 ;; This function takes the dependencies already made by | |
6116 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go | |
6117 ;; through the dependecies in the hash table and finds all the | |
6118 ;; roots. Roots do not refer back to any valid articles. | |
6119 (gnus-message 6 "Threading...") | |
6120 (let (roots new-roots) | |
6121 (and gnus-fetch-old-headers | |
6122 (eq gnus-headers-retrieved-by 'nov) | |
6123 (gnus-build-old-threads)) | |
6124 (mapatoms | |
6125 (lambda (refs) | |
6126 (if (not (car (symbol-value refs))) | |
6127 (setq roots (append (cdr (symbol-value refs)) roots)) | |
6128 ;; Ok, these refer back to valid articles, but if | |
6129 ;; `gnus-thread-ignore-subject' is nil, we have to check that | |
6130 ;; the root has the same subject as its children. The children | |
6131 ;; that do not are made into roots and removed from the list | |
6132 ;; of children. | |
6133 (or gnus-thread-ignore-subject | |
6134 (let* ((prev (symbol-value refs)) | |
6135 (subject (gnus-simplify-subject-re | |
6136 (mail-header-subject (car prev)))) | |
6137 (headers (cdr prev))) | |
6138 (while headers | |
6139 (if (not (string= subject | |
6140 (gnus-simplify-subject-re | |
6141 (mail-header-subject (car headers))))) | |
6142 (progn | |
6143 (setq new-roots (cons (car headers) new-roots)) | |
6144 (setcdr prev (cdr headers))) | |
6145 (setq prev headers)) | |
6146 (setq headers (cdr headers))))))) | |
6147 gnus-newsgroup-dependencies) | |
6148 | |
6149 ;; We enter the new roots into the dependencies structure to | |
6150 ;; ensure that any possible later thread-regeneration will be | |
6151 ;; possible. | |
6152 (let ((r new-roots)) | |
6153 (while r | |
6154 (gnus-sethash (concat (mail-header-id (car r)) ".boo") | |
6155 (list nil (car r)) gnus-newsgroup-dependencies) | |
6156 (setq r (cdr r)))) | |
6157 | |
6158 (setq roots (nconc new-roots roots)) | |
6159 | |
6160 (prog1 | |
6161 (mapcar 'gnus-trim-thread | |
6162 (apply 'append | |
6163 (mapcar 'gnus-cut-thread | |
6164 (mapcar 'gnus-make-sub-thread roots)))) | |
6165 (gnus-message 6 "Threading...done")))) | |
6166 | |
6167 | |
6168 (defun gnus-make-threads-and-expunge () | |
6169 ;; This function takes the dependencies already made by | |
6170 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go | |
6171 ;; through the dependecies in the hash table and finds all the | |
6172 ;; roots. Roots do not refer back to any valid articles. | |
6173 (gnus-message 6 "Threading...") | |
6174 (let ((default (or gnus-summary-default-score 0)) | |
6175 (below gnus-summary-expunge-below) | |
6176 roots article new-roots) | |
6177 (and gnus-fetch-old-headers | |
6178 (eq gnus-headers-retrieved-by 'nov) | |
6179 (gnus-build-old-threads)) | |
6180 (mapatoms | |
6181 (lambda (refs) | |
6182 (if (not (car (symbol-value refs))) | |
6183 ;; These articles do not refer back to any other articles - | |
6184 ;; they are roots. | |
6185 (let ((headers (cdr (symbol-value refs)))) | |
6186 ;; We weed out the low-scored articles. | |
6187 (while headers | |
6188 (if (not (< (or (cdr (assq (mail-header-number (car headers)) | |
6189 gnus-newsgroup-scored)) default) | |
6190 below)) | |
6191 ;; It is over. | |
6192 (setq roots (cons (car headers) roots)) | |
6193 ;; It is below, so we mark it as read. | |
6194 (setq gnus-newsgroup-unreads | |
6195 (delq (mail-header-number (car headers)) | |
6196 gnus-newsgroup-unreads)) | |
6197 (setq gnus-newsgroup-reads | |
6198 (cons (cons (mail-header-number (car headers)) | |
6199 gnus-low-score-mark) | |
6200 gnus-newsgroup-reads))) | |
6201 (setq headers (cdr headers)))) | |
6202 ;; Ok, these refer back to valid articles, but if | |
6203 ;; `gnus-thread-ignore-subject' is nil, we have to check that | |
6204 ;; the root has the same subject as its children. The children | |
6205 ;; that do not are made into roots and removed from the list | |
6206 ;; of children. | |
6207 (or gnus-thread-ignore-subject | |
6208 (let* ((prev (symbol-value refs)) | |
6209 (subject (gnus-simplify-subject-re | |
6210 (mail-header-subject (car prev)))) | |
6211 (headers (cdr prev))) | |
6212 (while headers | |
6213 (if (not (string= subject | |
6214 (gnus-simplify-subject-re | |
6215 (mail-header-subject (car headers))))) | |
6216 (progn | |
6217 (if (not (< (or (cdr (assq (mail-header-number | |
6218 (car headers)) | |
6219 gnus-newsgroup-scored)) | |
6220 default) below)) | |
6221 (setq new-roots (cons (car headers) new-roots)) | |
6222 (setq gnus-newsgroup-unreads | |
6223 (delq (mail-header-number (car headers)) | |
6224 gnus-newsgroup-unreads)) | |
6225 (setq gnus-newsgroup-reads | |
6226 (cons (cons (mail-header-number (car headers)) | |
6227 gnus-low-score-mark) | |
6228 gnus-newsgroup-reads))) | |
6229 (setcdr prev (cdr headers))) | |
6230 (setq prev headers)) | |
6231 (setq headers (cdr headers))))) | |
6232 ;; If this article is expunged, some of the children might be | |
6233 ;; roots. | |
6234 (if (< (or (cdr (assq (mail-header-number (car (symbol-value refs))) | |
6235 gnus-newsgroup-scored)) default) | |
6236 below) | |
6237 (let* ((prev (symbol-value refs)) | |
6238 (headers (cdr prev))) | |
6239 (while headers | |
6240 (setq article (mail-header-number (car headers))) | |
6241 (if (not (< (or (cdr (assq article gnus-newsgroup-scored)) | |
6242 default) below)) | |
6243 (progn (setq new-roots (cons (car headers) new-roots)) | |
6244 (setq prev headers)) | |
6245 (setq gnus-newsgroup-unreads | |
6246 (delq article gnus-newsgroup-unreads)) | |
6247 (setq gnus-newsgroup-reads | |
6248 (cons (cons article gnus-low-score-mark) | |
6249 gnus-newsgroup-reads)) | |
6250 (setcdr prev (cdr headers))) | |
6251 (setq headers (cdr headers)))) | |
6252 ;; It was not expunged, but we look at expunged children. | |
6253 (let* ((prev (symbol-value refs)) | |
6254 (headers (cdr prev)) | |
6255 article) | |
6256 (while headers | |
6257 (setq article (mail-header-number (car headers))) | |
6258 (if (not (< (or (cdr (assq article gnus-newsgroup-scored)) | |
6259 default) below)) | |
6260 (setq prev headers) | |
6261 (setq gnus-newsgroup-unreads | |
6262 (delq article gnus-newsgroup-unreads)) | |
6263 (setq gnus-newsgroup-reads | |
6264 (cons (cons article gnus-low-score-mark) | |
6265 gnus-newsgroup-reads)) | |
6266 (setcdr prev (cdr headers))) | |
6267 (setq headers (cdr headers))))))) | |
6268 gnus-newsgroup-dependencies) | |
6269 | |
6270 ;; We enter the new roots into the dependencies structure to | |
6271 ;; ensure that any possible later thread-regeneration will be | |
6272 ;; possible. | |
6273 (let ((r new-roots)) | |
6274 (while r | |
6275 (gnus-sethash (concat (mail-header-id (car r)) ".boo") | |
6276 (list nil (car r)) gnus-newsgroup-dependencies) | |
6277 (setq r (cdr r)))) | |
6278 | |
6279 (setq roots (nconc new-roots roots)) | |
6280 | |
6281 (prog1 | |
6282 (mapcar 'gnus-trim-thread | |
6283 (apply 'append | |
6284 (mapcar 'gnus-cut-thread | |
6285 (mapcar 'gnus-make-sub-thread roots)))) | |
6286 (gnus-message 6 "Threading...done")))) | |
6287 | |
6288 | |
6289 (defun gnus-cut-thread (thread) | |
6290 ;; Remove leaf dormant or ancient articles from THREAD. | |
6291 (let ((head (car thread)) | |
6292 (tail (apply 'append (mapcar 'gnus-cut-thread (cdr thread))))) | |
6293 (if (and (null tail) | |
6294 (let ((number (mail-header-number head))) | |
6295 (or (memq number gnus-newsgroup-ancient) | |
6296 (memq number gnus-newsgroup-dormant) | |
6297 (and gnus-summary-expunge-below | |
6298 (eq gnus-fetch-old-headers 'some) | |
6299 (< (or (cdr (assq number gnus-newsgroup-scored)) | |
6300 gnus-summary-default-score 0) | |
6301 gnus-summary-expunge-below) | |
6302 (progn | |
6303 (setq gnus-newsgroup-unreads | |
6304 (delq number gnus-newsgroup-unreads)) | |
6305 (setq gnus-newsgroup-reads | |
6306 (cons (cons number gnus-low-score-mark) | |
6307 gnus-newsgroup-reads)) | |
6308 t))))) | |
6309 nil | |
6310 (list (cons head tail))))) | |
6311 | |
6312 (defun gnus-trim-thread (thread) | |
6313 ;; Remove root ancient articles with only one child from THREAD. | |
6314 (if (and (eq gnus-fetch-old-headers 'some) | |
6315 (memq (mail-header-number (car thread)) gnus-newsgroup-ancient) | |
6316 (= (length thread) 2)) | |
6317 (gnus-trim-thread (nth 1 thread)) | |
6318 thread)) | |
6319 | |
6320 (defun gnus-make-sub-thread (root) | |
6321 ;; This function makes a sub-tree for a node in the tree. | |
6322 (let ((children (reverse (cdr (gnus-gethash (downcase (mail-header-id root)) | |
6323 gnus-newsgroup-dependencies))))) | |
6324 (cons root (mapcar 'gnus-make-sub-thread children)))) | |
6325 | |
6326 (defun gnus-build-old-threads () | |
6327 ;; Look at all the articles that refer back to old articles, and | |
6328 ;; fetch the headers for the articles that aren't there. This will | |
6329 ;; build complete threads - if the roots haven't been expired by the | |
6330 ;; server, that is. | |
6331 (let (id heads) | |
6332 (mapatoms | |
6333 (lambda (refs) | |
6334 (if (not (car (symbol-value refs))) | |
6335 (progn | |
6336 (setq heads (cdr (symbol-value refs))) | |
6337 (while heads | |
6338 (if (not (memq (mail-header-number (car heads)) | |
6339 gnus-newsgroup-dormant)) | |
6340 (progn | |
6341 (setq id (symbol-name refs)) | |
6342 (while (and (setq id (gnus-build-get-header id)) | |
6343 (not (car (gnus-gethash | |
6344 id gnus-newsgroup-dependencies))))) | |
6345 (setq heads nil)) | |
6346 (setq heads (cdr heads))))))) | |
6347 gnus-newsgroup-dependencies))) | |
6348 | |
6349 (defun gnus-build-get-header (id) | |
6350 ;; Look through the buffer of NOV lines and find the header to | |
6351 ;; ID. Enter this line into the dependencies hash table, and return | |
6352 ;; the id of the parent article (if any). | |
6353 (let ((deps gnus-newsgroup-dependencies) | |
6354 found header) | |
6355 (prog1 | |
6356 (save-excursion | |
6357 (set-buffer nntp-server-buffer) | |
6358 (goto-char (point-min)) | |
6359 (while (and (not found) (search-forward id nil t)) | |
6360 (beginning-of-line) | |
6361 (setq found (looking-at | |
6362 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s" | |
6363 (regexp-quote id)))) | |
6364 (or found (beginning-of-line 2))) | |
6365 (if found | |
6366 (let (ref) | |
6367 (beginning-of-line) | |
6368 (and | |
6369 (setq header (gnus-nov-parse-line | |
6370 (read (current-buffer)) deps)) | |
6371 (setq ref (mail-header-references header)) | |
6372 (string-match "\\(<[^>]+>\\) *$" ref) | |
6373 (substring ref (match-beginning 1) (match-end 1)))))) | |
6374 (and header | |
6375 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers) | |
6376 gnus-newsgroup-ancient (cons (mail-header-number header) | |
6377 gnus-newsgroup-ancient)))))) | |
6378 | |
6379 ;; Re-build the thread containing ID. | |
6380 (defun gnus-rebuild-thread (id) | |
6381 (let ((dep gnus-newsgroup-dependencies) | |
6382 (buffer-read-only nil) | |
6383 parent headers refs thread art) | |
6384 (while (and id (setq headers | |
6385 (car (setq art (gnus-gethash (downcase id) dep))))) | |
6386 (setq parent art) | |
6387 (setq id (and (setq refs (mail-header-references headers)) | |
6388 (string-match "\\(<[^>]+>\\) *$" refs) | |
6389 (substring refs (match-beginning 1) (match-end 1))))) | |
6390 (setq thread (gnus-make-sub-thread (car parent))) | |
6391 (gnus-rebuild-remove-articles thread) | |
6392 (let ((beg (point))) | |
6393 (gnus-summary-prepare-threads (list thread)) | |
6394 (gnus-summary-update-lines beg (point))))) | |
6395 | |
6396 ;; Delete all lines in the summary buffer that correspond to articles | |
6397 ;; in this thread. | |
6398 (defun gnus-rebuild-remove-articles (thread) | |
6399 (and (gnus-summary-goto-subject (mail-header-number (car thread))) | |
6400 (gnus-delete-line)) | |
6401 (mapcar (lambda (th) (gnus-rebuild-remove-articles th)) (cdr thread))) | |
6402 | |
6403 (defun gnus-sort-threads (threads) | |
6404 ;; Sort threads as specified in `gnus-thread-sort-functions'. | |
6405 (let ((fun gnus-thread-sort-functions)) | |
6406 (while fun | |
6407 (gnus-message 6 "Sorting with %S..." fun) | |
6408 (setq threads (sort threads (car fun)) | |
6409 fun (cdr fun)))) | |
6410 (if gnus-thread-sort-functions | |
6411 (gnus-message 6 "Sorting...done")) | |
6412 threads) | |
6413 | |
6414 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>. | |
6415 (defmacro gnus-thread-header (thread) | |
6416 ;; Return header of first article in THREAD. | |
6417 ;; Note that THREAD must never, evr be anything else than a variable - | |
6418 ;; using some other form will lead to serious barfage. | |
6419 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread))) | |
6420 ;; (8% speedup to gnus-summary-prepare, just for fun :-) | |
6421 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ; | |
6422 (vector thread) 2)) | |
6423 | |
6424 (defun gnus-thread-sort-by-number (h1 h2) | |
6425 "Sort threads by root article number." | |
6426 (< (mail-header-number (gnus-thread-header h1)) | |
6427 (mail-header-number (gnus-thread-header h2)))) | |
6428 | |
6429 (defun gnus-thread-sort-by-author (h1 h2) | |
6430 "Sort threads by root author." | |
6431 (string-lessp | |
6432 (let ((extract (funcall | |
6433 gnus-extract-address-components | |
6434 (mail-header-from (gnus-thread-header h1))))) | |
6435 (or (car extract) (cdr extract))) | |
6436 (let ((extract (funcall | |
6437 gnus-extract-address-components | |
6438 (mail-header-from (gnus-thread-header h2))))) | |
6439 (or (car extract) (cdr extract))))) | |
6440 | |
6441 (defun gnus-thread-sort-by-subject (h1 h2) | |
6442 "Sort threads by root subject." | |
6443 (string-lessp | |
6444 (downcase (gnus-simplify-subject-re | |
6445 (mail-header-subject (gnus-thread-header h1)))) | |
6446 (downcase (gnus-simplify-subject-re | |
6447 (mail-header-subject (gnus-thread-header h2)))))) | |
6448 | |
6449 (defun gnus-thread-sort-by-date (h1 h2) | |
6450 "Sort threads by root article date." | |
6451 (string-lessp | |
6452 (gnus-sortable-date (mail-header-date (gnus-thread-header h1))) | |
6453 (gnus-sortable-date (mail-header-date (gnus-thread-header h2))))) | |
6454 | |
6455 (defun gnus-thread-sort-by-score (h1 h2) | |
6456 "Sort threads by root article score. | |
6457 Unscored articles will be counted as having a score of zero." | |
6458 (> (or (cdr (assq (mail-header-number (gnus-thread-header h1)) | |
6459 gnus-newsgroup-scored)) | |
6460 gnus-summary-default-score 0) | |
6461 (or (cdr (assq (mail-header-number (gnus-thread-header h2)) | |
6462 gnus-newsgroup-scored)) | |
6463 gnus-summary-default-score 0))) | |
6464 | |
6465 (defun gnus-thread-sort-by-total-score (h1 h2) | |
6466 "Sort threads by the sum of all scores in the thread. | |
6467 Unscored articles will be counted as having a score of zero." | |
6468 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2))) | |
6469 | |
6470 (defun gnus-thread-total-score (thread) | |
6471 ;; This function find the total score of THREAD. | |
6472 (if (consp thread) | |
6473 (if (stringp (car thread)) | |
6474 (apply gnus-thread-score-function 0 | |
6475 (mapcar 'gnus-thread-total-score-1 (cdr thread))) | |
6476 (gnus-thread-total-score-1 thread)) | |
6477 (gnus-thread-total-score-1 (list thread)))) | |
6478 | |
6479 (defun gnus-thread-total-score-1 (root) | |
6480 ;; This function find the total score of the thread below ROOT. | |
6481 (setq root (car root)) | |
6482 (apply gnus-thread-score-function | |
6483 (or (cdr (assq (mail-header-number root) gnus-newsgroup-scored)) | |
6484 gnus-summary-default-score 0) | |
6485 (mapcar 'gnus-thread-total-score | |
6486 (cdr (gnus-gethash (downcase (mail-header-id root)) | |
6487 gnus-newsgroup-dependencies))))) | |
6488 | |
6489 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>. | |
6490 (defvar gnus-tmp-prev-subject "") | |
6491 | |
6492 (defun gnus-summary-prepare-threads (threads &optional cull) | |
6493 "Prepare summary buffer from THREADS and indentation LEVEL. | |
6494 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])' | |
6495 or a straight list of headers." | |
6496 (message "Generating summary...") | |
6497 (let ((level 0) | |
6498 thread header number subject stack state gnus-tmp-gathered) | |
6499 (if (vectorp (car threads)) | |
6500 ;; If this is a straight (sic) list of headers, then a | |
6501 ;; threaded summary display isn't required, so we just create | |
6502 ;; an unthreaded one. | |
6503 (gnus-summary-prepare-unthreaded threads cull) | |
6504 | |
6505 ;; Do the threaded display. | |
6506 | |
6507 (while (or threads stack) | |
6508 | |
6509 (if threads | |
6510 ;; If there are some threads, we do them before the | |
6511 ;; threads on the stack. | |
6512 (setq thread threads | |
6513 header (car (car thread))) | |
6514 ;; There were no current threads, so we pop something off | |
6515 ;; the stack. | |
6516 (setq state (car stack) | |
6517 level (car state) | |
6518 thread (cdr state) | |
6519 stack (cdr stack) | |
6520 header (car (car thread)))) | |
6521 | |
6522 (if (stringp header) | |
6523 (progn | |
6524 ;; The header is a dummy root. | |
6525 (cond | |
6526 ((eq gnus-summary-make-false-root 'adopt) | |
6527 ;; We let the first article adopt the rest. | |
6528 (let ((th (car (cdr (car thread))))) | |
6529 (while (cdr th) | |
6530 (setq th (cdr th))) | |
6531 (setcdr th (cdr (cdr (car thread)))) | |
6532 (setq gnus-tmp-gathered | |
6533 (nconc (mapcar | |
6534 (lambda (h) (mail-header-number (car h))) | |
6535 (cdr (cdr (car thread)))) | |
6536 gnus-tmp-gathered)) | |
6537 (setcdr (cdr (car thread)) nil)) | |
6538 (setq level -1)) | |
6539 ((eq gnus-summary-make-false-root 'empty) | |
6540 ;; We print adopted articles with empty subject fields. | |
6541 (setq gnus-tmp-gathered | |
6542 (nconc (mapcar | |
6543 (lambda (h) (mail-header-number (car h))) | |
6544 (cdr (cdr (car thread)))) | |
6545 gnus-tmp-gathered)) | |
6546 (setq level -1)) | |
6547 ((eq gnus-summary-make-false-root 'dummy) | |
6548 ;; We output a dummy root. | |
6549 (gnus-summary-insert-dummy-line | |
6550 nil header (mail-header-number | |
6551 (car (car (cdr (car thread))))))) | |
6552 (t | |
6553 ;; We do not make a root for the gathered | |
6554 ;; sub-threads at all. | |
6555 (setq level -1)))) | |
6556 | |
6557 (setq number (mail-header-number header) | |
6558 subject (mail-header-subject header)) | |
6559 | |
6560 ;; Do the async thing. | |
6561 (and gnus-newsgroup-async | |
6562 (setq gnus-newsgroup-threads | |
6563 (cons (cons number (mail-header-lines header)) | |
6564 gnus-newsgroup-threads))) | |
6565 | |
6566 ;; We may have to root out some bad articles... | |
6567 (and cull | |
6568 (= level 0) | |
6569 (cond ((and (memq (setq number (mail-header-number header)) | |
6570 gnus-newsgroup-dormant) | |
6571 (null thread)) | |
6572 (setq header nil)) | |
6573 ((and gnus-summary-expunge-below | |
6574 (< (or (cdr (assq number gnus-newsgroup-scored)) | |
6575 gnus-summary-default-score 0) | |
6576 gnus-summary-expunge-below)) | |
6577 (setq header nil) | |
6578 (setq gnus-newsgroup-unreads | |
6579 (delq number gnus-newsgroup-unreads)) | |
6580 (setq gnus-newsgroup-reads | |
6581 (cons (cons number gnus-low-score-mark) | |
6582 gnus-newsgroup-reads))))) | |
6583 | |
6584 (and | |
6585 header | |
6586 (progn | |
6587 (inline | |
6588 (gnus-summary-insert-line | |
6589 nil header level nil | |
6590 (cond | |
6591 ((memq number gnus-newsgroup-marked) gnus-ticked-mark) | |
6592 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark) | |
6593 ((memq number gnus-newsgroup-unreads) gnus-unread-mark) | |
6594 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark) | |
6595 (t (or (cdr (assq number gnus-newsgroup-reads)) | |
6596 gnus-ancient-mark))) | |
6597 (memq number gnus-newsgroup-replied) | |
6598 (memq number gnus-newsgroup-expirable) | |
6599 (cond | |
6600 ((and gnus-thread-ignore-subject | |
6601 (not (string= | |
6602 (gnus-simplify-subject-re gnus-tmp-prev-subject) | |
6603 (gnus-simplify-subject-re subject)))) | |
6604 subject) | |
6605 ((zerop level) | |
6606 (if (and (eq gnus-summary-make-false-root 'empty) | |
6607 (memq number gnus-tmp-gathered)) | |
6608 gnus-summary-same-subject | |
6609 subject)) | |
6610 (t gnus-summary-same-subject)) | |
6611 (and (eq gnus-summary-make-false-root 'adopt) | |
6612 (memq number gnus-tmp-gathered)) | |
6613 (cdr (assq number gnus-newsgroup-scored)) | |
6614 (memq number gnus-newsgroup-processable)) | |
6615 | |
6616 (setq gnus-tmp-prev-subject subject))))) | |
6617 | |
6618 (if (nth 1 thread) | |
6619 (setq stack (cons (cons (max 0 level) (nthcdr 1 thread)) stack))) | |
6620 (setq level (1+ level)) | |
6621 (setq threads (cdr (car thread)))))) | |
6622 (message "Generating summary...done")) | |
6623 | |
6624 | |
6625 | |
6626 (defun gnus-summary-prepare-unthreaded (headers &optional cull) | |
6627 (let (header number) | |
6628 | |
6629 ;; Do the async thing, if that is required. | |
6630 (if gnus-newsgroup-async | |
6631 (setq gnus-newsgroup-threads | |
6632 (mapcar (lambda (h) | |
6633 (cons (mail-header-number h) (mail-header-lines h))) | |
6634 headers))) | |
6635 | |
6636 (while headers | |
6637 (setq header (car headers) | |
6638 headers (cdr headers) | |
6639 number (mail-header-number header)) | |
6640 | |
6641 ;; We may have to root out some bad articles... | |
6642 (cond | |
6643 ((and cull | |
6644 (memq (setq number (mail-header-number header)) | |
6645 gnus-newsgroup-dormant))) | |
6646 ((and cull gnus-summary-expunge-below | |
6647 (< (or (cdr (assq number gnus-newsgroup-scored)) | |
6648 gnus-summary-default-score 0) | |
6649 gnus-summary-expunge-below)) | |
6650 (setq gnus-newsgroup-unreads | |
6651 (delq number gnus-newsgroup-unreads)) | |
6652 (setq gnus-newsgroup-reads | |
6653 (cons (cons number gnus-low-score-mark) | |
6654 gnus-newsgroup-reads))) | |
6655 (t | |
6656 (gnus-summary-insert-line | |
6657 nil header 0 nil | |
6658 (cond ((memq number gnus-newsgroup-marked) gnus-ticked-mark) | |
6659 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark) | |
6660 ((memq number gnus-newsgroup-unreads) gnus-unread-mark) | |
6661 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark) | |
6662 (t (or (cdr (assq number gnus-newsgroup-reads)) | |
6663 gnus-ancient-mark))) | |
6664 (memq number gnus-newsgroup-replied) | |
6665 (memq number gnus-newsgroup-expirable) | |
6666 (mail-header-subject header) nil | |
6667 (cdr (assq number gnus-newsgroup-scored)) | |
6668 (memq number gnus-newsgroup-processable))))))) | |
6669 | |
6670 (defun gnus-select-newsgroup (group &optional read-all) | |
6671 "Select newsgroup GROUP. | |
6672 If READ-ALL is non-nil, all articles in the group are selected." | |
6673 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb)) | |
6674 (info (nth 2 entry)) | |
6675 articles) | |
6676 | |
6677 (or (gnus-check-server | |
6678 (setq gnus-current-select-method (gnus-find-method-for-group group))) | |
6679 (error "Couldn't open server")) | |
6680 | |
6681 (or (and entry (not (eq (car entry) t))) ; Either it's active... | |
6682 (gnus-activate-group group) ; Or we can activate it... | |
6683 (progn ; Or we bug out. | |
6684 (kill-buffer (current-buffer)) | |
6685 (error "Couldn't request group %s: %s" | |
6686 group (gnus-status-message group)))) | |
6687 | |
6688 (setq gnus-newsgroup-name group) | |
6689 (setq gnus-newsgroup-unselected nil) | |
6690 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group)) | |
6691 | |
6692 (and gnus-asynchronous | |
6693 (gnus-check-backend-function | |
6694 'request-asynchronous gnus-newsgroup-name) | |
6695 (setq gnus-newsgroup-async | |
6696 (gnus-request-asynchronous gnus-newsgroup-name))) | |
6697 | |
6698 (setq articles (gnus-articles-to-read group read-all)) | |
6699 | |
6700 (cond | |
6701 ((null articles) | |
6702 (gnus-message 3 "Couldn't select newsgroup") | |
6703 'quit) | |
6704 ((eq articles 0) nil) | |
6705 (t | |
6706 ;; Init the dependencies hash table. | |
6707 (setq gnus-newsgroup-dependencies | |
6708 (gnus-make-hashtable (length articles))) | |
6709 ;; Retrieve the headers and read them in. | |
6710 (gnus-message 5 "Fetching headers...") | |
6711 (setq gnus-newsgroup-headers | |
6712 (if (eq 'nov (setq gnus-headers-retrieved-by | |
6713 ;; This is a naughty hack. To get the | |
6714 ;; retrieval of old headers to work, we | |
6715 ;; set `nntp-nov-gap' to nil (locally), | |
6716 ;; and then just retrieve the headers. | |
6717 ;; Mucho magic. | |
6718 (if gnus-fetch-old-headers | |
6719 (let (nntp-nov-gap) | |
6720 (gnus-retrieve-headers | |
6721 (if (not (eq 1 (car articles))) | |
6722 (cons 1 articles) | |
6723 articles) | |
6724 gnus-newsgroup-name)) | |
6725 (gnus-retrieve-headers | |
6726 articles gnus-newsgroup-name)))) | |
6727 (progn | |
6728 (gnus-get-newsgroup-headers-xover articles)) | |
6729 ;; If we were to fetch old headers, but the backend didn't | |
6730 ;; support XOVER, then it is possible we fetched one article | |
6731 ;; that we shouldn't have. If that's the case, we remove it. | |
6732 (if (or (not gnus-fetch-old-headers) | |
6733 (eq 1 (car articles))) | |
6734 () | |
6735 (save-excursion | |
6736 (set-buffer nntp-server-buffer) | |
6737 (goto-char (point-min)) | |
6738 (and | |
6739 (looking-at "[0-9]+[ \t]+1[ \t]") ; This is not a NOV line. | |
6740 (delete-region ; So we delete this head. | |
6741 (point) | |
6742 (search-forward "\n.\n" nil t))))) | |
6743 (gnus-get-newsgroup-headers))) | |
6744 (gnus-message 5 "Fetching headers...done") | |
6745 ;; Remove canceled articles from the list of unread articles. | |
6746 (setq gnus-newsgroup-unreads | |
6747 (gnus-set-sorted-intersection | |
6748 gnus-newsgroup-unreads | |
6749 (mapcar (lambda (headers) (mail-header-number headers)) | |
6750 gnus-newsgroup-headers))) | |
6751 ;; Adjust and set lists of article marks. | |
6752 (and info | |
6753 (let (marked) | |
6754 (gnus-adjust-marked-articles info) | |
6755 (setq gnus-newsgroup-marked | |
6756 (copy-sequence | |
6757 (cdr (assq 'tick (setq marked (nth 3 info)))))) | |
6758 (setq gnus-newsgroup-replied | |
6759 (copy-sequence (cdr (assq 'reply marked)))) | |
6760 (setq gnus-newsgroup-expirable | |
6761 (copy-sequence (cdr (assq 'expire marked)))) | |
6762 (setq gnus-newsgroup-killed | |
6763 (copy-sequence (cdr (assq 'killed marked)))) | |
6764 (setq gnus-newsgroup-bookmarks | |
6765 (copy-sequence (cdr (assq 'bookmark marked)))) | |
6766 (setq gnus-newsgroup-dormant | |
6767 (copy-sequence (cdr (assq 'dormant marked)))) | |
6768 (setq gnus-newsgroup-scored | |
6769 (copy-sequence (cdr (assq 'score marked)))) | |
6770 (setq gnus-newsgroup-processable nil))) | |
6771 ;; Check whether auto-expire is to be done in this group. | |
6772 (setq gnus-newsgroup-auto-expire | |
6773 (or (and (stringp gnus-auto-expirable-newsgroups) | |
6774 (string-match gnus-auto-expirable-newsgroups group)) | |
6775 (memq 'auto-expire (nth 5 info)))) | |
6776 ;; First and last article in this newsgroup. | |
6777 (and gnus-newsgroup-headers | |
6778 (setq gnus-newsgroup-begin | |
6779 (mail-header-number (car gnus-newsgroup-headers))) | |
6780 (setq gnus-newsgroup-end | |
6781 (mail-header-number | |
6782 (gnus-last-element gnus-newsgroup-headers)))) | |
6783 (setq gnus-reffed-article-number -1) | |
6784 ;; GROUP is successfully selected. | |
6785 (or gnus-newsgroup-headers t))))) | |
6786 | |
6787 (defun gnus-articles-to-read (group read-all) | |
6788 ;; Find out what articles the user wants to read. | |
6789 (let* ((articles | |
6790 ;; Select all articles if `read-all' is non-nil, or if all the | |
6791 ;; unread articles are dormant articles. | |
6792 (if (or read-all | |
6793 (= (length gnus-newsgroup-unreads) | |
6794 (length gnus-newsgroup-dormant))) | |
6795 (gnus-uncompress-range | |
6796 (gnus-gethash group gnus-active-hashtb)) | |
6797 gnus-newsgroup-unreads)) | |
6798 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles)) | |
6799 (scored (length scored-list)) | |
6800 (number (length articles)) | |
6801 (marked (+ (length gnus-newsgroup-marked) | |
6802 (length gnus-newsgroup-dormant))) | |
6803 (select | |
6804 (cond | |
6805 ((numberp read-all) | |
6806 read-all) | |
6807 (t | |
6808 (condition-case () | |
6809 (cond ((and (or (<= scored marked) | |
6810 (= scored number)) | |
6811 (numberp gnus-large-newsgroup) | |
6812 (> number gnus-large-newsgroup)) | |
6813 (let ((input | |
6814 (read-string | |
6815 (format | |
6816 "How many articles from %s (default %d): " | |
6817 gnus-newsgroup-name number)))) | |
6818 (if (string-match "^[ \t]*$" input) | |
6819 number input))) | |
6820 ((and (> scored marked) (< scored number)) | |
6821 (let ((input | |
6822 (read-string | |
6823 (format | |
6824 "%s %s (%d scored, %d total): " | |
6825 "How many articles from" | |
6826 group scored number)))) | |
6827 (if (string-match "^[ \t]*$" input) | |
6828 number input))) | |
6829 (t number)) | |
6830 (quit nil)))))) | |
6831 (setq select (if (stringp select) (string-to-number select) select)) | |
6832 (if (or (null select) (zerop select)) | |
6833 select | |
6834 (if (and (not (zerop scored)) (<= (abs select) scored)) | |
6835 (progn | |
6836 (setq articles (sort scored-list '<)) | |
6837 (setq number (length articles))) | |
6838 (setq articles (copy-sequence articles))) | |
6839 | |
6840 (if (< (abs select) number) | |
6841 (if (< select 0) | |
6842 ;; Select the N oldest articles. | |
6843 (setcdr (nthcdr (1- (abs select)) articles) nil) | |
6844 ;; Select the N most recent articles. | |
6845 (setq articles (nthcdr (- number select) articles)))) | |
6846 (setq gnus-newsgroup-unselected | |
6847 (gnus-sorted-intersection | |
6848 gnus-newsgroup-unreads | |
6849 (gnus-sorted-complement gnus-newsgroup-unreads articles))) | |
6850 articles))) | |
6851 | |
6852 (defun gnus-killed-articles (killed articles) | |
6853 (let (out) | |
6854 (while articles | |
6855 (if (inline (gnus-member-of-range (car articles) killed)) | |
6856 (setq out (cons (car articles) out))) | |
6857 (setq articles (cdr articles))) | |
6858 out)) | |
6859 | |
6860 (defun gnus-adjust-marked-articles (info &optional active) | |
6861 "Remove all marked articles that are no longer legal." | |
6862 (let ((marked-lists (nth 3 info)) | |
6863 (active (or active (gnus-gethash (car info) gnus-active-hashtb))) | |
6864 m prev) | |
6865 ;; There are many types of marked articles. | |
6866 (while marked-lists | |
6867 (setq m (cdr (setq prev (car marked-lists)))) | |
6868 (cond ((or (eq 'tick (car prev)) (eq 'dormant (car prev))) | |
6869 ;; Make sure that all ticked articles are a subset of the | |
6870 ;; unread/unselected articles. | |
6871 (while m | |
6872 (if (or (memq (car m) gnus-newsgroup-unreads) | |
6873 (memq (car m) gnus-newsgroup-unselected)) | |
6874 (setq prev m) | |
6875 (setcdr prev (cdr m))) | |
6876 (setq m (cdr m)))) | |
6877 ((eq 'score (car prev)) | |
6878 ;; Scored articles should be a subset of | |
6879 ;; unread/unselected articles. | |
6880 (while m | |
6881 (if (or (memq (car (car m)) gnus-newsgroup-unreads) | |
6882 (memq (car (car m)) gnus-newsgroup-unreads)) | |
6883 (setq prev m) | |
6884 (setcdr prev (cdr m))) | |
6885 (setq m (cdr m)))) | |
6886 ((eq 'bookmark (car prev)) | |
6887 ;; Bookmarks should be a subset of active articles. | |
6888 (while m | |
6889 (if (< (car (car m)) (car active)) | |
6890 (setcdr prev (cdr m)) | |
6891 (setq prev m)) | |
6892 (setq m (cdr m)))) | |
6893 ((eq 'killed (car prev)) | |
6894 ;; Articles that have been through the kill process are | |
6895 ;; to be a subset of active articles. | |
6896 (while (and m (< (or (and (numberp (car m)) (car m)) | |
6897 (cdr (car m))) | |
6898 (car active))) | |
6899 (setcdr prev (cdr m)) | |
6900 (setq m (cdr m))) | |
6901 (if (and m (< (or (and (numberp (car m)) (car m)) | |
6902 (car (car m))) | |
6903 (car active))) | |
6904 (setcar (if (numberp (car m)) m (car m)) (car active)))) | |
6905 ((or (eq 'reply (car prev)) (eq 'expire (car prev))) | |
6906 ;; The replied and expirable articles have to be articles | |
6907 ;; that are active. | |
6908 (while m | |
6909 (if (< (car m) (car active)) | |
6910 (setcdr prev (cdr m)) | |
6911 (setq prev m)) | |
6912 (setq m (cdr m))))) | |
6913 (setq marked-lists (cdr marked-lists))) | |
6914 ;; Remove all lists that are empty. | |
6915 (setq marked-lists (nth 3 info)) | |
6916 (if marked-lists | |
6917 (progn | |
6918 (while (= 1 (length (car marked-lists))) | |
6919 (setq marked-lists (cdr marked-lists))) | |
6920 (setq m (cdr (setq prev marked-lists))) | |
6921 (while m | |
6922 (if (= 1 (length (car m))) | |
6923 (setcdr prev (cdr m)) | |
6924 (setq prev m)) | |
6925 (setq m (cdr m))) | |
6926 (setcar (nthcdr 3 info) marked-lists))) | |
6927 ;; Finally, if there are no marked lists at all left, and if there | |
6928 ;; are no elements after the lists in the info list, we just chop | |
6929 ;; the info list off before the marked lists. | |
6930 (and (null marked-lists) | |
6931 (not (nthcdr 4 info)) | |
6932 (setcdr (nthcdr 2 info) nil))) | |
6933 info) | |
6934 | |
6935 (defun gnus-set-marked-articles | |
6936 (info ticked replied expirable killed dormant bookmark score) | |
6937 "Enter the various lists of marked articles into the newsgroup info list." | |
6938 (let (newmarked) | |
6939 (and ticked (setq newmarked (cons (cons 'tick ticked) nil))) | |
6940 (and replied (setq newmarked (cons (cons 'reply replied) newmarked))) | |
6941 (and expirable (setq newmarked (cons (cons 'expire expirable) | |
6942 newmarked))) | |
6943 (and killed (setq newmarked (cons (cons 'killed killed) newmarked))) | |
6944 (and dormant (setq newmarked (cons (cons 'dormant dormant) newmarked))) | |
6945 (and bookmark (setq newmarked (cons (cons 'bookmark bookmark) | |
6946 newmarked))) | |
6947 (and score (setq newmarked (cons (cons 'score score) newmarked))) | |
6948 (if (nthcdr 3 info) | |
6949 (progn | |
6950 (setcar (nthcdr 3 info) newmarked) | |
6951 (and (not newmarked) | |
6952 (not (nthcdr 4 info)) | |
6953 (setcdr (nthcdr 2 info) nil))) | |
6954 (if newmarked | |
6955 (setcdr (nthcdr 2 info) (list newmarked)))))) | |
6956 | |
6957 (defun gnus-add-marked-articles (group type articles &optional info force) | |
6958 ;; Add ARTICLES of TYPE to the info of GROUP. | |
6959 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't | |
6960 ;; add, but replace marked articles of TYPE with ARTICLES. | |
6961 (let ((info (or info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))) | |
6962 marked m) | |
6963 (or (not info) | |
6964 (and (not (setq marked (nthcdr 3 info))) | |
6965 (setcdr (nthcdr 2 info) (list (list (cons type articles))))) | |
6966 (and (not (setq m (assq type (car marked)))) | |
6967 (setcar marked (cons (cons type articles) (car marked)))) | |
6968 (if force | |
6969 (setcdr m articles) | |
6970 (nconc m articles))))) | |
6971 | |
6972 (defun gnus-set-mode-line (where) | |
6973 "This function sets the mode line of the article or summary buffers. | |
6974 If WHERE is `summary', the summary mode line format will be used." | |
6975 (if (memq where gnus-updated-mode-lines) | |
6976 (let (mode-string) | |
6977 (save-excursion | |
6978 (set-buffer gnus-summary-buffer) | |
6979 (let* ((mformat (if (eq where 'article) | |
6980 gnus-article-mode-line-format-spec | |
6981 gnus-summary-mode-line-format-spec)) | |
6982 (group-name gnus-newsgroup-name) | |
6983 (article-number (or gnus-current-article 0)) | |
6984 (unread (- (length gnus-newsgroup-unreads) | |
6985 (length gnus-newsgroup-dormant))) | |
6986 (unread-and-unticked | |
6987 (- unread (length gnus-newsgroup-marked))) | |
6988 (unselected (length gnus-newsgroup-unselected)) | |
6989 (unread-and-unselected | |
6990 (cond ((and (zerop unread-and-unticked) | |
6991 (zerop unselected)) "") | |
6992 ((zerop unselected) | |
6993 (format "{%d more}" unread-and-unticked)) | |
6994 (t (format "{%d(+%d) more}" | |
6995 unread-and-unticked unselected)))) | |
6996 (subject | |
6997 (if gnus-current-headers | |
6998 (mail-header-subject gnus-current-headers) "")) | |
6999 (max-len (and gnus-mode-non-string-length | |
7000 (- (frame-width) gnus-mode-non-string-length))) | |
7001 header);; passed as argument to any user-format-funcs | |
7002 (setq mode-string (eval mformat)) | |
7003 (or (numberp max-len) | |
7004 (setq max-len (length mode-string))) | |
7005 (if (< max-len 4) (setq max-len 4)) | |
7006 (if (> (length mode-string) max-len) | |
7007 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp> | |
7008 ;; function `substring' might cut on a middle | |
7009 ;; of multi-octet character. | |
7010 (setq mode-string | |
7011 (concat (gnus-truncate-string mode-string (- max-len 3)) | |
7012 "..."))) | |
7013 (setq mode-string (format (format "%%-%ds" max-len) | |
7014 mode-string)))) | |
7015 (setq mode-line-buffer-identification mode-string) | |
7016 (set-buffer-modified-p t)))) | |
7017 | |
7018 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads) | |
7019 "Go through the HEADERS list and add all Xrefs to a hash table. | |
7020 The resulting hash table is returned, or nil if no Xrefs were found." | |
7021 (let* ((from-method (gnus-find-method-for-group from-newsgroup)) | |
7022 (prefix (if (and | |
7023 (gnus-group-foreign-p from-newsgroup) | |
7024 (not (memq 'virtual | |
7025 (assoc (symbol-name (car from-method)) | |
7026 gnus-valid-select-methods)))) | |
7027 (gnus-group-real-prefix from-newsgroup))) | |
7028 (xref-hashtb (make-vector 63 0)) | |
7029 start group entry number xrefs header) | |
7030 (while headers | |
7031 (setq header (car headers)) | |
7032 (if (and (setq xrefs (mail-header-xref header)) | |
7033 (not (memq (mail-header-number header) unreads))) | |
7034 (progn | |
7035 (setq start 0) | |
7036 (while (string-match "\\([^ ]+\\):\\([0-9]+\\)" xrefs start) | |
7037 (setq start (match-end 0)) | |
7038 (setq group (concat prefix (substring xrefs (match-beginning 1) | |
7039 (match-end 1)))) | |
7040 (setq number | |
7041 (string-to-int (substring xrefs (match-beginning 2) | |
7042 (match-end 2)))) | |
7043 (if (setq entry (gnus-gethash group xref-hashtb)) | |
7044 (setcdr entry (cons number (cdr entry))) | |
7045 (gnus-sethash group (cons number nil) xref-hashtb))))) | |
7046 (setq headers (cdr headers))) | |
7047 (if start xref-hashtb nil))) | |
7048 | |
7049 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads expirable) | |
7050 "Look through all the headers and mark the Xrefs as read." | |
7051 (let ((virtual (memq 'virtual | |
7052 (assoc (symbol-name (car (gnus-find-method-for-group | |
7053 from-newsgroup))) | |
7054 gnus-valid-select-methods))) | |
7055 name entry info xref-hashtb idlist method | |
7056 nth4) | |
7057 (save-excursion | |
7058 (set-buffer gnus-group-buffer) | |
7059 (if (setq xref-hashtb | |
7060 (gnus-create-xref-hashtb from-newsgroup headers unreads)) | |
7061 (mapatoms | |
7062 (lambda (group) | |
7063 (if (string= from-newsgroup (setq name (symbol-name group))) | |
7064 () | |
7065 (setq idlist (symbol-value group)) | |
7066 ;; Dead groups are not updated. | |
7067 (if (and (prog1 | |
7068 (setq entry (gnus-gethash name gnus-newsrc-hashtb) | |
7069 info (nth 2 entry)) | |
7070 (if (stringp (setq nth4 (nth 4 info))) | |
7071 (setq nth4 (gnus-server-to-method nth4)))) | |
7072 ;; Only do the xrefs if the group has the same | |
7073 ;; select method as the group we have just read. | |
7074 (or (gnus-methods-equal-p | |
7075 nth4 (gnus-find-method-for-group from-newsgroup)) | |
7076 virtual | |
7077 (equal nth4 | |
7078 (setq method (gnus-find-method-for-group | |
7079 from-newsgroup))) | |
7080 (and (equal (car nth4) (car method)) | |
7081 (equal (nth 1 nth4) (nth 1 method)))) | |
7082 gnus-use-cross-reference | |
7083 (or (not (eq gnus-use-cross-reference t)) | |
7084 virtual | |
7085 ;; Only do cross-references on subscribed | |
7086 ;; groups, if that is what is wanted. | |
7087 (<= (nth 1 info) gnus-level-subscribed))) | |
7088 (gnus-group-make-articles-read name idlist expirable)))) | |
7089 xref-hashtb))))) | |
7090 | |
7091 (defun gnus-group-make-articles-read (group articles expirable) | |
7092 (let* ((num 0) | |
7093 (entry (gnus-gethash group gnus-newsrc-hashtb)) | |
7094 (info (nth 2 entry)) | |
7095 (active (gnus-gethash group gnus-active-hashtb)) | |
7096 exps expirable range) | |
7097 ;; First peel off all illegal article numbers. | |
7098 (if active | |
7099 (let ((ids articles) | |
7100 (ticked (cdr (assq 'tick (nth 3 info)))) | |
7101 (dormant (cdr (assq 'dormant (nth 3 info)))) | |
7102 id first) | |
7103 (setq exps nil) | |
7104 (while ids | |
7105 (setq id (car ids)) | |
7106 (if (and first (> id (cdr active))) | |
7107 (progn | |
7108 ;; We'll end up in this situation in one particular | |
7109 ;; obscure situation. If you re-scan a group and get | |
7110 ;; a new article that is cross-posted to a different | |
7111 ;; group that has not been re-scanned, you might get | |
7112 ;; crossposted article that has a higher number than | |
7113 ;; Gnus believes possible. So we re-activate this | |
7114 ;; group as well. This might mean doing the | |
7115 ;; crossposting thingie will *increase* the number | |
7116 ;; of articles in some groups. Tsk, tsk. | |
7117 (setq active (or (gnus-activate-group group) active)))) | |
7118 (if (or (> id (cdr active)) | |
7119 (< id (car active)) | |
7120 (memq id ticked) | |
7121 (memq id dormant)) | |
7122 (setq articles (delq id articles))) | |
7123 (and (memq id expirable) | |
7124 (setq exps (cons id exps))) | |
7125 (setq ids (cdr ids))))) | |
7126 ;; Update expirable articles. | |
7127 (gnus-add-marked-articles nil 'expirable exps info) | |
7128 (and active | |
7129 (null (nth 2 info)) | |
7130 (> (car active) 1) | |
7131 (setcar (nthcdr 2 info) (cons 1 (1- (car active))))) | |
7132 (setcar (nthcdr 2 info) | |
7133 (setq range | |
7134 (gnus-add-to-range | |
7135 (nth 2 info) | |
7136 (setq articles (sort articles '<))))) | |
7137 ;; Then we have to re-compute how many unread | |
7138 ;; articles there are in this group. | |
7139 (if active | |
7140 (progn | |
7141 (cond | |
7142 ((not range) | |
7143 (setq num (- (1+ (cdr active)) (car active)))) | |
7144 ((not (listp (cdr range))) | |
7145 (setq num (- (cdr active) (- (1+ (cdr range)) | |
7146 (car range))))) | |
7147 (t | |
7148 (while range | |
7149 (if (numberp (car range)) | |
7150 (setq num (1+ num)) | |
7151 (setq num (+ num (- (1+ (cdr (car range))) | |
7152 (car (car range)))))) | |
7153 (setq range (cdr range))) | |
7154 (setq num (- (cdr active) num)))) | |
7155 ;; Update the number of unread articles. | |
7156 (setcar | |
7157 entry | |
7158 (max 0 (- num | |
7159 (length (cdr (assq 'tick (nth 3 info)))) | |
7160 (length | |
7161 (cdr (assq 'dormant (nth 3 info))))))) | |
7162 ;; Update the group buffer. | |
7163 (gnus-group-update-group group t))))) | |
7164 | |
7165 (defun gnus-methods-equal-p (m1 m2) | |
7166 (let ((m1 (or m1 gnus-select-method)) | |
7167 (m2 (or m2 gnus-select-method))) | |
7168 (or (equal m1 m2) | |
7169 (and (eq (car m1) (car m2)) | |
7170 (or (not (memq 'address (assoc (symbol-name (car m1)) | |
7171 gnus-valid-select-methods))) | |
7172 (equal (nth 1 m1) (nth 1 m2))))))) | |
7173 | |
7174 (defsubst gnus-header-value () | |
7175 (buffer-substring (match-end 0) (gnus-point-at-eol))) | |
7176 | |
7177 (defvar gnus-newsgroup-none-id 0) | |
7178 | |
7179 (defun gnus-get-newsgroup-headers () | |
7180 (setq gnus-article-internal-prepare-hook nil) | |
7181 (let ((cur nntp-server-buffer) | |
7182 (dependencies gnus-newsgroup-dependencies) | |
7183 headers id dep end ref) | |
7184 (save-excursion | |
7185 (set-buffer nntp-server-buffer) | |
13694
73433c3071a5
* gnus.el (gnus-parse-headers-hook): New hook.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
13579
diff
changeset
|
7186 ;; Allow the user to mangle the headers before parsing them. |
73433c3071a5
* gnus.el (gnus-parse-headers-hook): New hook.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
13579
diff
changeset
|
7187 (run-hooks 'gnus-parse-headers-hook) |
13401 | 7188 (goto-char (point-min)) |
7189 ;; Search to the beginning of the next header. Error messages | |
7190 ;; do not begin with 2 or 3. | |
7191 (while (re-search-forward "^[23][0-9]+ " nil t) | |
7192 (let ((header (make-vector 9 nil)) | |
7193 (case-fold-search t) | |
7194 (p (point)) | |
7195 in-reply-to) | |
7196 (setq id nil | |
7197 ref nil) | |
7198 (mail-header-set-number header (read cur)) | |
7199 ;; This implementation of this function, with nine | |
7200 ;; search-forwards instead of the one re-search-forward and | |
7201 ;; a case (which basically was the old function) is actually | |
7202 ;; about twice as fast, even though it looks messier. You | |
7203 ;; can't have everything, I guess. Speed and elegance | |
7204 ;; doesn't always come hand in hand. | |
7205 (save-restriction | |
7206 (narrow-to-region (point) (or (save-excursion | |
7207 (search-forward "\n.\n" nil t)) | |
7208 (point))) | |
7209 (if (search-forward "\nfrom: " nil t) | |
7210 (mail-header-set-from header (gnus-header-value)) | |
7211 (mail-header-set-from header "(nobody)")) | |
7212 (goto-char p) | |
7213 (if (search-forward "\nsubject: " nil t) | |
7214 (mail-header-set-subject header (gnus-header-value)) | |
7215 (mail-header-set-subject header "(none)")) | |
7216 (goto-char p) | |
7217 (and (search-forward "\nxref: " nil t) | |
7218 (mail-header-set-xref header (gnus-header-value))) | |
7219 (goto-char p) | |
7220 (or (numberp (and (search-forward "\nlines: " nil t) | |
7221 (mail-header-set-lines header (read cur)))) | |
7222 (mail-header-set-lines header 0)) | |
7223 (goto-char p) | |
7224 (and (search-forward "\ndate: " nil t) | |
7225 (mail-header-set-date header (gnus-header-value))) | |
7226 (goto-char p) | |
7227 (if (search-forward "\nmessage-id: " nil t) | |
7228 (mail-header-set-id header (setq id (gnus-header-value))) | |
7229 ;; If there was no message-id, we just fake one to make | |
7230 ;; subsequent routines simpler. | |
7231 (mail-header-set-id | |
7232 header | |
7233 (setq id (concat "none+" | |
7234 (int-to-string | |
7235 (setq gnus-newsgroup-none-id | |
7236 (1+ gnus-newsgroup-none-id))))))) | |
7237 (goto-char p) | |
7238 (if (search-forward "\nreferences: " nil t) | |
7239 (progn | |
7240 (mail-header-set-references header (gnus-header-value)) | |
7241 (setq end (match-end 0)) | |
7242 (save-excursion | |
7243 (setq ref | |
7244 (downcase | |
7245 (buffer-substring | |
7246 (progn | |
7247 (end-of-line) | |
7248 (search-backward ">" end t) | |
7249 (1+ (point))) | |
7250 (progn | |
7251 (search-backward "<" end t) | |
7252 (point))))))) | |
7253 ;; Get the references from the in-reply-to header if there | |
7254 ;; ware no references and the in-reply-to header looks | |
7255 ;; promising. | |
7256 (if (and (search-forward "\nin-reply-to: " nil t) | |
7257 (setq in-reply-to (gnus-header-value)) | |
7258 (string-match "<[^>]+>" in-reply-to)) | |
7259 (progn | |
7260 (mail-header-set-references | |
7261 header | |
7262 (setq ref (substring in-reply-to (match-beginning 0) | |
7263 (match-end 0)))) | |
7264 (setq ref (downcase ref))) | |
7265 (setq ref "none"))) | |
7266 ;; We do some threading while we read the headers. The | |
7267 ;; message-id and the last reference are both entered into | |
7268 ;; the same hash table. Some tippy-toeing around has to be | |
7269 ;; done in case an article has arrived before the article | |
7270 ;; which it refers to. | |
7271 (if (boundp (setq dep (intern (downcase id) dependencies))) | |
7272 (if (car (symbol-value dep)) | |
7273 ;; An article with this Message-ID has already | |
7274 ;; been seen, so we ignore this one, except we add | |
7275 ;; any additional Xrefs (in case the two articles | |
7276 ;; came from different servers. | |
7277 (progn | |
7278 (mail-header-set-xref | |
7279 (car (symbol-value dep)) | |
7280 (concat (or (mail-header-xref | |
7281 (car (symbol-value dep))) "") | |
7282 (or (mail-header-xref header) ""))) | |
7283 (setq header nil)) | |
7284 (setcar (symbol-value dep) header)) | |
7285 (set dep (list header))) | |
7286 (if header | |
7287 (progn | |
7288 (if (boundp (setq dep (intern ref dependencies))) | |
7289 (setcdr (symbol-value dep) | |
7290 (cons header (cdr (symbol-value dep)))) | |
7291 (set dep (list nil header))) | |
7292 (setq headers (cons header headers)))) | |
7293 (goto-char (point-max)))))) | |
7294 (nreverse headers))) | |
7295 | |
7296 ;; The following macros and functions were written by Felix Lee | |
7297 ;; <flee@cse.psu.edu>. | |
7298 | |
7299 (defmacro gnus-nov-read-integer () | |
7300 '(prog1 | |
7301 (if (= (following-char) ?\t) | |
7302 0 | |
7303 (let ((num (condition-case nil (read buffer) (error nil)))) | |
7304 (if (numberp num) num 0))) | |
7305 (or (eobp) (forward-char 1)))) | |
7306 | |
7307 (defmacro gnus-nov-skip-field () | |
7308 '(search-forward "\t" eol 'move)) | |
7309 | |
7310 (defmacro gnus-nov-field () | |
7311 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol))) | |
7312 | |
7313 ;; Goes through the xover lines and returns a list of vectors | |
7314 (defun gnus-get-newsgroup-headers-xover (sequence) | |
7315 "Parse the news overview data in the server buffer, and return a | |
7316 list of headers that match SEQUENCE (see `nntp-retrieve-headers')." | |
7317 ;; Get the Xref when the users reads the articles since most/some | |
7318 ;; NNTP servers do not include Xrefs when using XOVER. | |
7319 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs)) | |
7320 (let ((cur nntp-server-buffer) | |
7321 (dependencies gnus-newsgroup-dependencies) | |
7322 number headers header) | |
7323 (save-excursion | |
7324 (set-buffer nntp-server-buffer) | |
13694
73433c3071a5
* gnus.el (gnus-parse-headers-hook): New hook.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
13579
diff
changeset
|
7325 ;; Allow the user to mangle the headers before parsing them. |
73433c3071a5
* gnus.el (gnus-parse-headers-hook): New hook.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
13579
diff
changeset
|
7326 (run-hooks 'gnus-parse-headers-hook) |
13401 | 7327 (goto-char (point-min)) |
7328 (while (and sequence (not (eobp))) | |
7329 (setq number (read cur)) | |
7330 (while (and sequence (< (car sequence) number)) | |
7331 (setq sequence (cdr sequence))) | |
7332 (and sequence | |
7333 (eq number (car sequence)) | |
7334 (progn | |
7335 (setq sequence (cdr sequence)) | |
7336 (if (setq header | |
7337 (inline (gnus-nov-parse-line number dependencies))) | |
7338 (setq headers (cons header headers))))) | |
7339 (forward-line 1)) | |
7340 (setq headers (nreverse headers))) | |
7341 headers)) | |
7342 | |
7343 ;; This function has to be called with point after the article number | |
7344 ;; on the beginning of the line. | |
7345 (defun gnus-nov-parse-line (number dependencies) | |
7346 (let ((none 0) | |
7347 (eol (gnus-point-at-eol)) | |
7348 (buffer (current-buffer)) | |
7349 header ref id dep) | |
7350 | |
7351 ;; overview: [num subject from date id refs chars lines misc] | |
7352 (narrow-to-region (point) eol) | |
7353 (or (eobp) (forward-char)) | |
7354 | |
7355 (condition-case nil | |
7356 (setq header | |
7357 (vector | |
7358 number ; number | |
7359 (gnus-nov-field) ; subject | |
7360 (gnus-nov-field) ; from | |
7361 (gnus-nov-field) ; date | |
7362 (setq id (or (gnus-nov-field) | |
7363 (concat "none+" | |
7364 (int-to-string | |
7365 (setq none (1+ none)))))) ; id | |
7366 (progn | |
7367 (save-excursion | |
7368 (let ((beg (point))) | |
7369 (search-forward "\t" eol) | |
7370 (if (search-backward ">" beg t) | |
7371 (setq ref | |
7372 (downcase | |
7373 (buffer-substring | |
7374 (1+ (point)) | |
7375 (progn | |
7376 (search-backward "<" beg t) | |
7377 (point))))) | |
7378 (setq ref nil)))) | |
7379 (gnus-nov-field)) ; refs | |
7380 (gnus-nov-read-integer) ; chars | |
7381 (gnus-nov-read-integer) ; lines | |
7382 (if (= (following-char) ?\n) | |
7383 nil | |
7384 (gnus-nov-field)) ; misc | |
7385 )) | |
7386 (error (progn | |
7387 (ding) | |
7388 (message "Strange nov line.") | |
7389 (setq header nil) | |
7390 (goto-char eol)))) | |
7391 | |
7392 (widen) | |
7393 | |
7394 ;; We build the thread tree. | |
7395 (and header | |
7396 (if (boundp (setq dep (intern (downcase id) dependencies))) | |
7397 (if (car (symbol-value dep)) | |
7398 ;; An article with this Message-ID has already been seen, | |
7399 ;; so we ignore this one, except we add any additional | |
7400 ;; Xrefs (in case the two articles came from different | |
7401 ;; servers. | |
7402 (progn | |
7403 (mail-header-set-xref | |
7404 (car (symbol-value dep)) | |
7405 (concat (or (mail-header-xref (car (symbol-value dep))) "") | |
7406 (or (mail-header-xref header) ""))) | |
7407 (setq header nil)) | |
7408 (setcar (symbol-value dep) header)) | |
7409 (set dep (list header)))) | |
7410 (if header | |
7411 (progn | |
7412 (if (boundp (setq dep (intern (or ref "none") | |
7413 dependencies))) | |
7414 (setcdr (symbol-value dep) | |
7415 (cons header (cdr (symbol-value dep)))) | |
7416 (set dep (list nil header))))) | |
7417 header)) | |
7418 | |
7419 (defun gnus-article-get-xrefs () | |
7420 "Fill in the Xref value in `gnus-current-headers', if necessary. | |
7421 This is meant to be called in `gnus-article-internal-prepare-hook'." | |
7422 (let ((headers (save-excursion (set-buffer gnus-summary-buffer) | |
7423 gnus-current-headers))) | |
7424 (or (not gnus-use-cross-reference) | |
7425 (not headers) | |
7426 (and (mail-header-xref headers) | |
7427 (not (string= (mail-header-xref headers) ""))) | |
7428 (let ((case-fold-search t) | |
7429 xref) | |
7430 (save-restriction | |
7431 (gnus-narrow-to-headers) | |
7432 (goto-char (point-min)) | |
7433 (if (or (and (eq (downcase (following-char)) ?x) | |
7434 (looking-at "Xref:")) | |
7435 (search-forward "\nXref:" nil t)) | |
7436 (progn | |
7437 (goto-char (1+ (match-end 0))) | |
7438 (setq xref (buffer-substring (point) | |
7439 (progn (end-of-line) (point)))) | |
7440 (mail-header-set-xref headers xref)))))))) | |
7441 | |
7442 (defalias 'gnus-find-header-by-number 'gnus-get-header-by-number) | |
7443 (make-obsolete 'gnus-find-header-by-number 'gnus-get-header-by-number) | |
7444 | |
7445 (defun gnus-make-headers-hashtable-by-number () | |
7446 "Make hashtable for the variable gnus-newsgroup-headers by number." | |
7447 (save-excursion | |
7448 (set-buffer gnus-summary-buffer) | |
7449 (let ((headers gnus-newsgroup-headers) | |
7450 header) | |
7451 (setq gnus-newsgroup-headers-hashtb-by-number | |
7452 (gnus-make-hashtable (length headers))) | |
7453 (while headers | |
7454 (setq header (car headers)) | |
7455 (gnus-sethash (int-to-string (mail-header-number header)) | |
7456 header gnus-newsgroup-headers-hashtb-by-number) | |
7457 (setq headers (cdr headers)))))) | |
7458 | |
7459 (defun gnus-more-header-backward () | |
7460 "Find new header backward." | |
7461 (let ((first (car (gnus-gethash gnus-newsgroup-name gnus-active-hashtb))) | |
7462 (artnum gnus-newsgroup-begin) | |
7463 (header nil)) | |
7464 (while (and (not header) | |
7465 (> artnum first)) | |
7466 (setq artnum (1- artnum)) | |
7467 (setq header (gnus-read-header artnum))) | |
7468 header)) | |
7469 | |
7470 (defun gnus-more-header-forward (&optional backward) | |
7471 "Find new header forward. | |
7472 If BACKWARD, find new header backward instead." | |
7473 (if backward | |
7474 (gnus-more-header-backward) | |
7475 (let ((last (cdr (gnus-gethash gnus-newsgroup-name gnus-active-hashtb))) | |
7476 (artnum gnus-newsgroup-end) | |
7477 (header nil)) | |
7478 (while (and (not header) | |
7479 (< artnum last)) | |
7480 (setq artnum (1+ artnum)) | |
7481 (setq header (gnus-read-header artnum))) | |
7482 header))) | |
7483 | |
7484 (defun gnus-extend-newsgroup (header &optional backward) | |
7485 "Extend newsgroup selection with HEADER. | |
7486 Optional argument BACKWARD means extend toward backward." | |
7487 (if header | |
7488 (let ((artnum (mail-header-number header))) | |
7489 (setq gnus-newsgroup-headers | |
7490 (if backward | |
7491 (cons header gnus-newsgroup-headers) | |
7492 (nconc gnus-newsgroup-headers (list header)))) | |
7493 (setq gnus-newsgroup-unselected | |
7494 (delq artnum gnus-newsgroup-unselected)) | |
7495 (setq gnus-newsgroup-begin (min gnus-newsgroup-begin artnum)) | |
7496 (setq gnus-newsgroup-end (max gnus-newsgroup-end artnum))))) | |
7497 | |
7498 (defun gnus-summary-work-articles (n) | |
7499 "Return a list of articles to be worked upon. The prefix argument, | |
7500 the list of process marked articles, and the current article will be | |
7501 taken into consideration." | |
7502 (let (articles) | |
7503 (if (and n (numberp n)) | |
7504 (let ((backward (< n 0)) | |
7505 (n (abs n))) | |
7506 (save-excursion | |
7507 (while (and (> n 0) | |
7508 (setq articles (cons (gnus-summary-article-number) | |
7509 articles)) | |
7510 (gnus-summary-search-forward nil nil backward)) | |
7511 (setq n (1- n)))) | |
7512 (sort articles (function <))) | |
7513 (or (reverse gnus-newsgroup-processable) | |
7514 (list (gnus-summary-article-number)))))) | |
7515 | |
7516 (defun gnus-summary-search-group (&optional backward use-level) | |
7517 "Search for next unread newsgroup. | |
7518 If optional argument BACKWARD is non-nil, search backward instead." | |
7519 (save-excursion | |
7520 (set-buffer gnus-group-buffer) | |
7521 (if (gnus-group-search-forward | |
7522 backward nil (if use-level (gnus-group-group-level) nil)) | |
7523 (gnus-group-group-name)))) | |
7524 | |
7525 (defun gnus-summary-best-group (&optional exclude-group) | |
7526 "Find the name of the best unread group. | |
7527 If EXCLUDE-GROUP, do not go to this group." | |
7528 (save-excursion | |
7529 (set-buffer gnus-group-buffer) | |
7530 (save-excursion | |
7531 (gnus-group-best-unread-group exclude-group)))) | |
7532 | |
7533 (defun gnus-subject-equal (s1 s2) | |
7534 (cond | |
7535 ((null gnus-summary-gather-subject-limit) | |
7536 (equal (gnus-simplify-subject-re s1) | |
7537 (gnus-simplify-subject-re s2))) | |
7538 ((eq gnus-summary-gather-subject-limit 'fuzzy) | |
7539 (equal (gnus-simplify-subject-fuzzy s1) | |
7540 (gnus-simplify-subject-fuzzy s2))) | |
7541 ((numberp gnus-summary-gather-subject-limit) | |
7542 (equal (gnus-limit-string s1 gnus-summary-gather-subject-limit) | |
7543 (gnus-limit-string s2 gnus-summary-gather-subject-limit))) | |
7544 (t | |
7545 (equal s1 s2)))) | |
7546 | |
7547 (defun gnus-summary-search-subject (&optional backward unread subject) | |
7548 "Search for article forward. | |
7549 If BACKWARD is non-nil, search backward. | |
7550 If UNREAD is non-nil, only unread articles are selected. | |
7551 If SUBJECT is non-nil, the article which has the same subject will be | |
7552 searched for." | |
7553 (let ((func (if backward 'previous-single-property-change | |
7554 'next-single-property-change)) | |
7555 (beg (point)) | |
7556 (did t) | |
7557 pos psubject) | |
7558 (beginning-of-line) | |
7559 (and gnus-summary-check-current unread | |
7560 (eq (get-text-property (point) 'gnus-mark) gnus-unread-mark) | |
7561 (setq did nil)) | |
7562 (if (not did) | |
7563 () | |
7564 (forward-char (if backward (if (bobp) 0 -1) (if (eobp) 0 1))) | |
7565 (while | |
7566 (and | |
7567 (setq pos (funcall func (point) 'gnus-number)) | |
7568 (goto-char (if backward (1- pos) pos)) | |
7569 (setq did | |
7570 (not (and | |
7571 (or (not unread) | |
7572 (eq (get-text-property (point) 'gnus-mark) | |
7573 gnus-unread-mark)) | |
7574 (or (not subject) | |
7575 (and (setq psubject | |
7576 (inline (gnus-summary-subject-string))) | |
7577 (inline | |
7578 (gnus-subject-equal subject psubject))))))) | |
7579 (if backward (if (bobp) nil (forward-char -1) t) | |
7580 (if (eobp) nil (forward-char 1) t))))) | |
7581 (if did | |
7582 (progn (goto-char beg) nil) | |
7583 (prog1 | |
7584 (get-text-property (point) 'gnus-number) | |
7585 (gnus-summary-show-thread) | |
7586 (gnus-summary-position-cursor))))) | |
7587 | |
7588 (defun gnus-summary-pseudo-article () | |
7589 "The thread level of the article on the current line." | |
7590 (get-text-property (gnus-point-at-bol) 'gnus-pseudo)) | |
7591 | |
7592 (defalias 'gnus-summary-score 'gnus-summary-article-score) | |
7593 (make-obsolete 'gnus-summary-score 'gnus-summary-article-score) | |
7594 (defun gnus-summary-article-score () | |
7595 "Return current article score." | |
7596 (or (cdr (assq (gnus-summary-article-number) gnus-newsgroup-scored)) | |
7597 gnus-summary-default-score 0)) | |
7598 | |
7599 (defun gnus-summary-recenter () | |
7600 "Center point in the summary window. | |
7601 If `gnus-auto-center-summary' is nil, or the article buffer isn't | |
7602 displayed, no centering will be performed." | |
7603 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle). | |
7604 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu. | |
7605 (let* ((top (cond ((< (window-height) 4) 0) | |
7606 ((< (window-height) 7) 1) | |
7607 (t 2))) | |
7608 (height (1- (window-height))) | |
7609 (bottom (save-excursion (goto-char (point-max)) | |
7610 (forward-line (- height)) | |
7611 (point))) | |
7612 (window (get-buffer-window (current-buffer)))) | |
7613 (and | |
7614 ;; The user has to want it, | |
7615 gnus-auto-center-summary | |
7616 ;; the article buffer must be displayed, | |
7617 (get-buffer-window gnus-article-buffer) | |
7618 ;; Set the window start to either `bottom', which is the biggest | |
7619 ;; possible valid number, or the second line from the top, | |
7620 ;; whichever is the least. | |
7621 (set-window-start | |
7622 window (min bottom (save-excursion (forward-line (- top)) (point))))))) | |
7623 | |
7624 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>. | |
7625 (defun gnus-short-group-name (group &optional levels) | |
7626 "Collapse GROUP name LEVELS." | |
7627 (let* ((name "") (foreign "") (depth -1) (skip 1) | |
7628 (levels (or levels | |
7629 (progn | |
7630 (while (string-match "\\." group skip) | |
7631 (setq skip (match-end 0) | |
7632 depth (+ depth 1))) | |
7633 depth)))) | |
7634 (if (string-match ":" group) | |
7635 (setq foreign (substring group 0 (match-end 0)) | |
7636 group (substring group (match-end 0)))) | |
7637 (while group | |
7638 (if (and (string-match "\\." group) (> levels 0)) | |
7639 (setq name (concat name (substring group 0 1)) | |
7640 group (substring group (match-end 0)) | |
7641 levels (- levels 1) | |
7642 name (concat name ".")) | |
7643 (setq name (concat foreign name group) | |
7644 group nil))) | |
7645 name)) | |
7646 | |
7647 (defun gnus-summary-jump-to-group (newsgroup) | |
7648 "Move point to NEWSGROUP in group mode buffer." | |
7649 ;; Keep update point of group mode buffer if visible. | |
7650 (if (eq (current-buffer) (get-buffer gnus-group-buffer)) | |
7651 (save-window-excursion | |
7652 ;; Take care of tree window mode. | |
7653 (if (get-buffer-window gnus-group-buffer) | |
7654 (pop-to-buffer gnus-group-buffer)) | |
7655 (gnus-group-jump-to-group newsgroup)) | |
7656 (save-excursion | |
7657 ;; Take care of tree window mode. | |
7658 (if (get-buffer-window gnus-group-buffer) | |
7659 (pop-to-buffer gnus-group-buffer) | |
7660 (set-buffer gnus-group-buffer)) | |
7661 (gnus-group-jump-to-group newsgroup)))) | |
7662 | |
7663 ;; This function returns a list of article numbers based on the | |
7664 ;; difference between the ranges of read articles in this group and | |
7665 ;; the range of active articles. | |
7666 (defun gnus-list-of-unread-articles (group) | |
7667 (let* ((read (nth 2 (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))) | |
7668 (active (gnus-gethash group gnus-active-hashtb)) | |
7669 (last (cdr active)) | |
7670 first nlast unread) | |
7671 ;; If none are read, then all are unread. | |
7672 (if (not read) | |
7673 (setq first (car active)) | |
7674 ;; If the range of read articles is a single range, then the | |
7675 ;; first unread article is the article after the last read | |
7676 ;; article. Sounds logical, doesn't it? | |
7677 (if (not (listp (cdr read))) | |
7678 (setq first (1+ (cdr read))) | |
7679 ;; `read' is a list of ranges. | |
7680 (if (/= (setq nlast (or (and (numberp (car read)) (car read)) | |
7681 (car (car read)))) 1) | |
7682 (setq first 1)) | |
7683 (while read | |
7684 (if first | |
7685 (while (< first nlast) | |
7686 (setq unread (cons first unread)) | |
7687 (setq first (1+ first)))) | |
7688 (setq first (1+ (if (atom (car read)) (car read) (cdr (car read))))) | |
7689 (setq nlast (if (atom (car (cdr read))) | |
7690 (car (cdr read)) | |
7691 (car (car (cdr read))))) | |
7692 (setq read (cdr read))))) | |
7693 ;; And add the last unread articles. | |
7694 (while (<= first last) | |
7695 (setq unread (cons first unread)) | |
7696 (setq first (1+ first))) | |
7697 ;; Return the list of unread articles. | |
7698 (nreverse unread))) | |
7699 | |
7700 (defun gnus-list-of-read-articles (group) | |
7701 (let ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))) | |
7702 (active (gnus-gethash group gnus-active-hashtb))) | |
7703 (and info active | |
7704 (gnus-sorted-complement | |
7705 (gnus-uncompress-range active) | |
7706 (gnus-list-of-unread-articles group))))) | |
7707 | |
7708 ;; Various summary commands | |
7709 | |
7710 (defun gnus-summary-universal-argument () | |
7711 "Perform any operation on all articles marked with the process mark." | |
7712 (interactive) | |
7713 (gnus-set-global-variables) | |
7714 (let ((articles (reverse gnus-newsgroup-processable)) | |
7715 func) | |
7716 (or articles (error "No articles marked")) | |
7717 (or (setq func (key-binding (read-key-sequence "C-c C-u"))) | |
7718 (error "Undefined key")) | |
7719 (while articles | |
7720 (gnus-summary-goto-subject (car articles)) | |
7721 (command-execute func) | |
7722 (gnus-summary-remove-process-mark (car articles)) | |
7723 (setq articles (cdr articles))))) | |
7724 | |
7725 (defun gnus-summary-toggle-truncation (&optional arg) | |
7726 "Toggle truncation of summary lines. | |
7727 With arg, turn line truncation on iff arg is positive." | |
7728 (interactive "P") | |
7729 (setq truncate-lines | |
7730 (if (null arg) (not truncate-lines) | |
7731 (> (prefix-numeric-value arg) 0))) | |
7732 (redraw-display)) | |
7733 | |
7734 (defun gnus-summary-reselect-current-group (&optional all) | |
7735 "Once exit and then reselect the current newsgroup. | |
7736 The prefix argument ALL means to select all articles." | |
7737 (interactive "P") | |
7738 (gnus-set-global-variables) | |
7739 (let ((current-subject (gnus-summary-article-number)) | |
7740 (group gnus-newsgroup-name)) | |
7741 (setq gnus-newsgroup-begin nil) | |
7742 (gnus-summary-exit t) | |
7743 ;; We have to adjust the point of group mode buffer because the | |
7744 ;; current point was moved to the next unread newsgroup by | |
7745 ;; exiting. | |
7746 (gnus-summary-jump-to-group group) | |
7747 (gnus-group-read-group all t) | |
7748 (gnus-summary-goto-subject current-subject))) | |
7749 | |
7750 (defun gnus-summary-rescan-group (&optional all) | |
7751 "Exit the newsgroup, ask for new articles, and select the newsgroup." | |
7752 (interactive "P") | |
7753 (gnus-set-global-variables) | |
7754 ;; Fix by Ilja Weis <kult@uni-paderborn.de>. | |
7755 (let ((group gnus-newsgroup-name)) | |
7756 (gnus-summary-exit) | |
7757 (gnus-summary-jump-to-group group) | |
7758 (save-excursion | |
7759 (set-buffer gnus-group-buffer) | |
7760 (gnus-group-get-new-news-this-group 1)) | |
7761 (gnus-summary-jump-to-group group) | |
7762 (gnus-group-read-group all))) | |
7763 | |
7764 (defun gnus-summary-update-info () | |
7765 (let* ((group gnus-newsgroup-name)) | |
7766 (if gnus-newsgroup-kill-headers | |
7767 (setq gnus-newsgroup-killed | |
7768 (gnus-compress-sequence | |
7769 (nconc | |
7770 (gnus-set-sorted-intersection | |
7771 (gnus-uncompress-range gnus-newsgroup-killed) | |
7772 (setq gnus-newsgroup-unselected | |
7773 (sort gnus-newsgroup-unselected '<))) | |
7774 (setq gnus-newsgroup-unreads | |
7775 (sort gnus-newsgroup-unreads '<))) t))) | |
7776 (or (listp (cdr gnus-newsgroup-killed)) | |
7777 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed))) | |
7778 (let ((headers gnus-newsgroup-headers)) | |
7779 (gnus-close-group group) | |
7780 (run-hooks 'gnus-exit-group-hook) | |
7781 (gnus-update-read-articles | |
7782 group gnus-newsgroup-unreads gnus-newsgroup-unselected | |
7783 gnus-newsgroup-marked | |
7784 t gnus-newsgroup-replied gnus-newsgroup-expirable | |
7785 gnus-newsgroup-killed gnus-newsgroup-dormant | |
7786 gnus-newsgroup-bookmarks | |
7787 (and gnus-save-score gnus-newsgroup-scored)) | |
7788 (and gnus-use-cross-reference | |
7789 (gnus-mark-xrefs-as-read | |
7790 group headers gnus-newsgroup-unreads gnus-newsgroup-expirable)) | |
7791 ;; Do adaptive scoring, and possibly save score files. | |
7792 (and gnus-newsgroup-adaptive | |
7793 (gnus-score-adaptive)) | |
7794 (and gnus-use-scoring | |
7795 (fboundp 'gnus-score-save) | |
7796 (funcall 'gnus-score-save)) | |
7797 ;; Do not switch windows but change the buffer to work. | |
7798 (set-buffer gnus-group-buffer) | |
7799 (or (gnus-ephemeral-group-p gnus-newsgroup-name) | |
7800 (gnus-group-update-group group))))) | |
7801 | |
7802 (defun gnus-summary-exit (&optional temporary) | |
7803 "Exit reading current newsgroup, and then return to group selection mode. | |
7804 gnus-exit-group-hook is called with no arguments if that value is non-nil." | |
7805 (interactive) | |
7806 (gnus-set-global-variables) | |
7807 (gnus-kill-save-kill-buffer) | |
7808 (let* ((group gnus-newsgroup-name) | |
7809 (quit-config (gnus-group-quit-config gnus-newsgroup-name)) | |
7810 (mode major-mode) | |
7811 (buf (current-buffer))) | |
7812 (run-hooks 'gnus-summary-prepare-exit-hook) | |
7813 ;; Make all changes in this group permanent. | |
7814 (gnus-summary-update-info) | |
7815 (set-buffer buf) | |
7816 (and gnus-use-cache (gnus-cache-possibly-remove-articles)) | |
7817 ;; Make sure where I was, and go to next newsgroup. | |
7818 (set-buffer gnus-group-buffer) | |
7819 (or quit-config | |
7820 (progn | |
7821 (gnus-group-jump-to-group group) | |
7822 (gnus-group-next-unread-group 1))) | |
7823 (if temporary | |
7824 nil ;Nothing to do. | |
7825 ;; We set all buffer-local variables to nil. It is unclear why | |
7826 ;; this is needed, but if we don't, buffer-local variables are | |
7827 ;; not garbage-collected, it seems. This would the lead to en | |
7828 ;; ever-growing Emacs. | |
7829 (set-buffer buf) | |
7830 (gnus-summary-clear-local-variables) | |
7831 ;; We clear the global counterparts of the buffer-local | |
7832 ;; variables as well, just to be on the safe side. | |
7833 (gnus-configure-windows 'group 'force) | |
7834 (gnus-summary-clear-local-variables) | |
7835 ;; Return to group mode buffer. | |
7836 (if (eq mode 'gnus-summary-mode) | |
7837 (gnus-kill-buffer buf)) | |
7838 (if (get-buffer gnus-article-buffer) | |
7839 (bury-buffer gnus-article-buffer)) | |
7840 (setq gnus-current-select-method gnus-select-method) | |
7841 (pop-to-buffer gnus-group-buffer) | |
7842 (if (not quit-config) | |
7843 (progn | |
7844 (gnus-group-jump-to-group group) | |
7845 (gnus-group-next-unread-group 1)) | |
7846 (if (not (buffer-name (car quit-config))) | |
7847 (gnus-configure-windows 'group 'force) | |
7848 (set-buffer (car quit-config)) | |
7849 (and (eq major-mode 'gnus-summary-mode) | |
7850 (gnus-set-global-variables)) | |
7851 (gnus-configure-windows (cdr quit-config)))) | |
7852 (run-hooks 'gnus-summary-exit-hook)))) | |
7853 | |
7854 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update) | |
7855 (defun gnus-summary-exit-no-update (&optional no-questions) | |
7856 "Quit reading current newsgroup without updating read article info." | |
7857 (interactive) | |
7858 (gnus-set-global-variables) | |
7859 (let* ((group gnus-newsgroup-name) | |
7860 (quit-config (gnus-group-quit-config group))) | |
7861 (if (or no-questions | |
7862 gnus-expert-user | |
7863 (gnus-y-or-n-p "Do you really wanna quit reading this group? ")) | |
7864 (progn | |
7865 (gnus-close-group group) | |
7866 (gnus-summary-clear-local-variables) | |
7867 (set-buffer gnus-group-buffer) | |
7868 (gnus-summary-clear-local-variables) | |
7869 ;; Return to group selection mode. | |
7870 (gnus-configure-windows 'group 'force) | |
7871 (if (get-buffer gnus-summary-buffer) | |
7872 (kill-buffer gnus-summary-buffer)) | |
7873 (if (get-buffer gnus-article-buffer) | |
7874 (bury-buffer gnus-article-buffer)) | |
7875 (if (equal (gnus-group-group-name) group) | |
7876 (gnus-group-next-unread-group 1)) | |
7877 (if quit-config | |
7878 (progn | |
7879 (if (not (buffer-name (car quit-config))) | |
7880 (gnus-configure-windows 'group 'force) | |
7881 (set-buffer (car quit-config)) | |
7882 (and (eq major-mode 'gnus-summary-mode) | |
7883 (gnus-set-global-variables)) | |
7884 (gnus-configure-windows (cdr quit-config))))))))) | |
7885 | |
7886 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>. | |
7887 (defun gnus-summary-fetch-faq (group) | |
7888 "Fetch the FAQ for the current group." | |
7889 (interactive (list gnus-newsgroup-name)) | |
7890 (let (gnus-faq-buffer) | |
7891 (and (setq gnus-faq-buffer (gnus-group-fetch-faq group)) | |
7892 (gnus-configure-windows 'summary-faq)))) | |
7893 | |
7894 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>. | |
7895 (defun gnus-summary-describe-group (&optional force) | |
7896 "Describe the current newsgroup." | |
7897 (interactive "P") | |
7898 (gnus-group-describe-group force gnus-newsgroup-name)) | |
7899 | |
7900 (defun gnus-summary-describe-briefly () | |
7901 "Describe summary mode commands briefly." | |
7902 (interactive) | |
7903 (gnus-message 6 | |
7904 (substitute-command-keys "\\<gnus-summary-mode-map>\\[gnus-summary-next-page]:Select \\[gnus-summary-next-unread-article]:Forward \\[gnus-summary-prev-unread-article]:Backward \\[gnus-summary-exit]:Exit \\[gnus-info-find-node]:Run Info \\[gnus-summary-describe-briefly]:This help"))) | |
7905 | |
7906 ;; Walking around group mode buffer from summary mode. | |
7907 | |
7908 (defun gnus-summary-next-group (&optional no-article target-group backward) | |
7909 "Exit current newsgroup and then select next unread newsgroup. | |
7910 If prefix argument NO-ARTICLE is non-nil, no article is selected | |
7911 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to | |
7912 previous group instead." | |
7913 (interactive "P") | |
7914 (gnus-set-global-variables) | |
7915 (let ((current-group gnus-newsgroup-name) | |
7916 (current-buffer (current-buffer)) | |
7917 entered) | |
7918 ;; First we semi-exit this group to update Xrefs and all variables. | |
7919 ;; We can't do a real exit, because the window conf must remain | |
7920 ;; the same in case the user is prompted for info, and we don't | |
7921 ;; want the window conf to change before that... | |
7922 (gnus-summary-exit t) | |
7923 (while (not entered) | |
7924 ;; Then we find what group we are supposed to enter. | |
7925 (set-buffer gnus-group-buffer) | |
7926 (gnus-group-jump-to-group current-group) | |
7927 (setq target-group | |
7928 (or target-group | |
7929 (if (eq gnus-keep-same-level 'best) | |
7930 (gnus-summary-best-group gnus-newsgroup-name) | |
7931 (gnus-summary-search-group backward gnus-keep-same-level)))) | |
7932 (if (not target-group) | |
7933 ;; There are no further groups, so we return to the group | |
7934 ;; buffer. | |
7935 (progn | |
7936 (gnus-message 5 "Returning to the group buffer") | |
7937 (setq entered t) | |
7938 (set-buffer current-buffer) | |
7939 (gnus-summary-exit)) | |
7940 ;; We try to enter the target group. | |
7941 (gnus-group-jump-to-group target-group) | |
7942 (let ((unreads (gnus-group-group-unread))) | |
7943 (if (and (or (eq t unreads) | |
7944 (and unreads (not (zerop unreads)))) | |
7945 (gnus-summary-read-group | |
7946 target-group nil no-article current-buffer)) | |
7947 (setq entered t) | |
7948 (setq current-group target-group | |
7949 target-group nil))))))) | |
7950 | |
7951 (defun gnus-summary-next-group-old (&optional no-article group backward) | |
7952 "Exit current newsgroup and then select next unread newsgroup. | |
7953 If prefix argument NO-ARTICLE is non-nil, no article is selected initially. | |
7954 If BACKWARD, go to previous group instead." | |
7955 (interactive "P") | |
7956 (gnus-set-global-variables) | |
7957 (let ((ingroup gnus-newsgroup-name) | |
7958 (sumbuf (current-buffer)) | |
7959 num) | |
7960 (set-buffer gnus-group-buffer) | |
7961 (if (and group | |
7962 (or (and (numberp (setq num (car (gnus-gethash | |
7963 group gnus-newsrc-hashtb)))) | |
7964 (< num 1)) | |
7965 (null num))) | |
7966 (progn | |
7967 (gnus-group-jump-to-group group) | |
7968 (setq group nil)) | |
7969 (gnus-group-jump-to-group ingroup)) | |
7970 (gnus-summary-search-group backward) | |
7971 (let ((group (or group (gnus-summary-search-group backward)))) | |
7972 (set-buffer sumbuf) | |
7973 (gnus-summary-exit t) ;Update all information. | |
7974 (if (null group) | |
7975 (gnus-summary-exit-no-update t) | |
7976 (gnus-group-jump-to-group ingroup) | |
7977 (setq group (gnus-summary-search-group backward)) | |
7978 (gnus-message 5 "Selecting %s..." group) | |
7979 (set-buffer gnus-group-buffer) | |
7980 ;; We are now in group mode buffer. | |
7981 ;; Make sure group mode buffer point is on GROUP. | |
7982 (gnus-group-jump-to-group group) | |
7983 (if (not (eq gnus-auto-select-next 'quietly)) | |
7984 (progn | |
7985 (gnus-summary-read-group group nil no-article sumbuf) | |
7986 (and (string= gnus-newsgroup-name ingroup) | |
7987 (bufferp sumbuf) (buffer-name sumbuf) | |
7988 (progn | |
7989 (set-buffer (setq gnus-summary-buffer sumbuf)) | |
7990 (gnus-summary-exit-no-update t)))) | |
7991 (let ((prevgroup group)) | |
7992 (gnus-group-jump-to-group ingroup) | |
7993 (setq group (gnus-summary-search-group backward)) | |
7994 (gnus-summary-read-group group nil no-article sumbuf) | |
7995 (while (and (string= gnus-newsgroup-name ingroup) | |
7996 (bufferp sumbuf) | |
7997 (buffer-name sumbuf) | |
7998 (not (string= prevgroup (gnus-group-group-name)))) | |
7999 (set-buffer gnus-group-buffer) | |
8000 (gnus-summary-read-group | |
8001 (setq prevgroup (gnus-group-group-name)) | |
8002 nil no-article sumbuf)) | |
8003 (and (string= prevgroup (gnus-group-group-name)) | |
8004 ;; We have reached the final group in the group | |
8005 ;; buffer. | |
8006 (progn | |
8007 (if (buffer-name sumbuf) | |
8008 (progn | |
8009 (set-buffer sumbuf) | |
8010 (gnus-summary-exit))))))))))) | |
8011 | |
8012 (defun gnus-summary-prev-group (&optional no-article) | |
8013 "Exit current newsgroup and then select previous unread newsgroup. | |
8014 If prefix argument NO-ARTICLE is non-nil, no article is selected initially." | |
8015 (interactive "P") | |
8016 (gnus-summary-next-group no-article nil t)) | |
8017 | |
8018 ;; Walking around summary lines. | |
8019 | |
8020 (defun gnus-summary-first-subject (&optional unread) | |
8021 "Go to the first unread subject. | |
8022 If UNREAD is non-nil, go to the first unread article. | |
8023 Returns nil if there are no unread articles." | |
8024 (interactive "P") | |
8025 (prog1 | |
8026 (cond ((not unread) | |
8027 (goto-char (point-min))) | |
8028 ((gnus-goto-char | |
8029 (text-property-any | |
8030 (point-min) (point-max) 'gnus-mark gnus-unread-mark)) | |
8031 t) | |
8032 (t | |
8033 ;; There are no unread articles. | |
8034 (gnus-message 3 "No more unread articles") | |
8035 nil)) | |
8036 (gnus-summary-position-cursor))) | |
8037 | |
8038 (defun gnus-summary-next-subject (n &optional unread dont-display) | |
8039 "Go to next N'th summary line. | |
8040 If N is negative, go to the previous N'th subject line. | |
8041 If UNREAD is non-nil, only unread articles are selected. | |
8042 The difference between N and the actual number of steps taken is | |
8043 returned." | |
8044 (interactive "p") | |
8045 (let ((backward (< n 0)) | |
8046 (n (abs n))) | |
8047 (while (and (> n 0) | |
8048 (gnus-summary-search-forward unread nil backward)) | |
8049 (setq n (1- n))) | |
8050 (if (/= 0 n) (gnus-message 7 "No more%s articles" | |
8051 (if unread " unread" ""))) | |
8052 (or dont-display | |
8053 (progn | |
8054 (gnus-summary-recenter) | |
8055 (gnus-summary-position-cursor))) | |
8056 n)) | |
8057 | |
8058 (defun gnus-summary-next-unread-subject (n) | |
8059 "Go to next N'th unread summary line." | |
8060 (interactive "p") | |
8061 (gnus-summary-next-subject n t)) | |
8062 | |
8063 (defun gnus-summary-prev-subject (n &optional unread) | |
8064 "Go to previous N'th summary line. | |
8065 If optional argument UNREAD is non-nil, only unread article is selected." | |
8066 (interactive "p") | |
8067 (gnus-summary-next-subject (- n) unread)) | |
8068 | |
8069 (defun gnus-summary-prev-unread-subject (n) | |
8070 "Go to previous N'th unread summary line." | |
8071 (interactive "p") | |
8072 (gnus-summary-next-subject (- n) t)) | |
8073 | |
8074 (defun gnus-summary-goto-subject (article) | |
8075 "Go the subject line of ARTICLE." | |
8076 (interactive | |
8077 (list | |
8078 (string-to-int | |
8079 (completing-read "Article number: " | |
8080 (mapcar | |
8081 (lambda (headers) | |
8082 (list | |
8083 (int-to-string (mail-header-number headers)))) | |
8084 gnus-newsgroup-headers) | |
8085 nil 'require-match)))) | |
8086 (or article (error "No article number")) | |
8087 (let ((b (point))) | |
8088 (if (not (gnus-goto-char (text-property-any (point-min) (point-max) | |
8089 'gnus-number article))) | |
8090 () | |
8091 (gnus-summary-show-thread) | |
8092 ;; Skip dummy articles. | |
8093 (if (eq (gnus-summary-article-mark) gnus-dummy-mark) | |
8094 (forward-line 1)) | |
8095 (prog1 | |
8096 (if (not (eobp)) | |
8097 article | |
8098 (goto-char b) | |
8099 nil) | |
8100 (gnus-summary-position-cursor))))) | |
8101 | |
8102 ;; Walking around summary lines with displaying articles. | |
8103 | |
8104 (defun gnus-summary-expand-window (&optional arg) | |
8105 "Make the summary buffer take up the entire Emacs frame. | |
8106 Given a prefix, will force an `article' buffer configuration." | |
8107 (interactive "P") | |
8108 (gnus-set-global-variables) | |
8109 (if arg | |
8110 (gnus-configure-windows 'article 'force) | |
8111 (gnus-configure-windows 'summary 'force))) | |
8112 | |
8113 (defun gnus-summary-display-article (article &optional all-header) | |
8114 "Display ARTICLE in article buffer." | |
8115 (gnus-set-global-variables) | |
8116 (if (null article) | |
8117 nil | |
8118 (prog1 | |
8119 (gnus-article-prepare article all-header) | |
8120 (gnus-summary-show-thread) | |
8121 (if (eq (gnus-summary-article-mark) gnus-dummy-mark) | |
8122 (progn | |
8123 (forward-line 1) | |
8124 (gnus-summary-position-cursor))) | |
8125 (run-hooks 'gnus-select-article-hook) | |
8126 (gnus-summary-recenter) | |
8127 (gnus-summary-goto-subject article) | |
8128 ;; Successfully display article. | |
8129 (gnus-summary-update-line) | |
8130 (gnus-article-set-window-start | |
8131 (cdr (assq article gnus-newsgroup-bookmarks))) | |
8132 t))) | |
8133 | |
8134 (defun gnus-summary-select-article (&optional all-headers force pseudo article) | |
8135 "Select the current article. | |
8136 If ALL-HEADERS is non-nil, show all header fields. If FORCE is | |
8137 non-nil, the article will be re-fetched even if it already present in | |
8138 the article buffer. If PSEUDO is non-nil, pseudo-articles will also | |
8139 be displayed." | |
8140 (and (not pseudo) (gnus-summary-pseudo-article) | |
8141 (error "This is a pseudo-article.")) | |
8142 (let ((article (or article (gnus-summary-article-number))) | |
8143 (all-headers (not (not all-headers))) ;Must be T or NIL. | |
8144 did) | |
8145 (prog1 | |
8146 (save-excursion | |
8147 (set-buffer gnus-summary-buffer) | |
8148 (if (or (null gnus-current-article) | |
8149 (null gnus-article-current) | |
8150 (null (get-buffer gnus-article-buffer)) | |
8151 (not (eq article (cdr gnus-article-current))) | |
8152 (not (equal (car gnus-article-current) gnus-newsgroup-name)) | |
8153 force) | |
8154 ;; The requested article is different from the current article. | |
8155 (progn | |
8156 (gnus-summary-display-article article all-headers) | |
8157 (setq did article)) | |
8158 (if (or all-headers gnus-show-all-headers) | |
8159 (gnus-article-show-all-headers)) | |
8160 nil)) | |
8161 (if did | |
8162 (gnus-article-set-window-start | |
8163 (cdr (assq article gnus-newsgroup-bookmarks))))))) | |
8164 | |
8165 (defun gnus-summary-set-current-mark (&optional current-mark) | |
8166 "Obsolete function." | |
8167 nil) | |
8168 | |
8169 (defun gnus-summary-next-article (&optional unread subject backward) | |
8170 "Select the next article. | |
8171 If UNREAD, only unread articles are selected. | |
8172 If SUBJECT, only articles with SUBJECT are selected. | |
8173 If BACKWARD, the previous article is selected instead of the next." | |
8174 (interactive "P") | |
8175 (gnus-set-global-variables) | |
8176 (let (header) | |
8177 (cond | |
8178 ;; Is there such an article? | |
8179 ((and (gnus-summary-search-forward unread subject backward) | |
8180 (or (gnus-summary-display-article (gnus-summary-article-number)) | |
8181 (eq (gnus-summary-article-mark) gnus-canceled-mark))) | |
8182 (gnus-summary-position-cursor)) | |
8183 ;; If not, we try the first unread, if that is wanted. | |
8184 ((and subject | |
8185 gnus-auto-select-same | |
8186 (or (gnus-summary-first-unread-article) | |
8187 (eq (gnus-summary-article-mark) gnus-canceled-mark))) | |
8188 (gnus-summary-position-cursor) | |
8189 (gnus-message 6 "Wrapped")) | |
8190 ;; Try to get next/previous article not displayed in this group. | |
8191 ((and gnus-auto-extend-newsgroup | |
8192 (not unread) (not subject) | |
8193 (setq header (gnus-more-header-forward backward))) | |
8194 (gnus-extend-newsgroup header backward) | |
8195 (let ((buffer-read-only nil)) | |
8196 (goto-char (if backward (point-min) (point-max))) | |
8197 (gnus-summary-prepare-threads (list header))) | |
8198 (gnus-summary-goto-article (if backward gnus-newsgroup-begin | |
8199 gnus-newsgroup-end))) | |
8200 ;; Go to next/previous group. | |
8201 (t | |
8202 (or (gnus-ephemeral-group-p gnus-newsgroup-name) | |
8203 (gnus-summary-jump-to-group gnus-newsgroup-name)) | |
8204 (let ((cmd last-command-char) | |
8205 (group | |
8206 (if (eq gnus-keep-same-level 'best) | |
8207 (gnus-summary-best-group gnus-newsgroup-name) | |
8208 (gnus-summary-search-group backward gnus-keep-same-level)))) | |
8209 ;; For some reason, the group window gets selected. We change | |
8210 ;; it back. | |
8211 (select-window (get-buffer-window (current-buffer))) | |
8212 ;; Keep just the event type of CMD. | |
8213 ;(and (listp cmd) (setq cmd (car cmd))) | |
8214 ;; Select next unread newsgroup automagically. | |
8215 (cond | |
8216 ((not gnus-auto-select-next) | |
8217 (gnus-message 7 "No more%s articles" (if unread " unread" ""))) | |
8218 ((eq gnus-auto-select-next 'quietly) | |
8219 ;; Select quietly. | |
8220 (if (gnus-ephemeral-group-p gnus-newsgroup-name) | |
8221 (gnus-summary-exit) | |
8222 (gnus-message 7 "No more%s articles (%s)..." | |
8223 (if unread " unread" "") | |
8224 (if group (concat "selecting " group) | |
8225 "exiting")) | |
8226 (gnus-summary-next-group nil group backward))) | |
8227 (t | |
8228 (let ((keystrokes '(?\C-n ?\C-p)) | |
8229 key) | |
8230 (while (or (null key) (memq key keystrokes)) | |
8231 (gnus-message | |
8232 7 "No more%s articles%s" (if unread " unread" "") | |
8233 (if (and group | |
8234 (not (gnus-ephemeral-group-p gnus-newsgroup-name))) | |
8235 (format " (Type %s for %s [%s])" | |
8236 (single-key-description cmd) group | |
8237 (car (gnus-gethash group gnus-newsrc-hashtb))) | |
8238 (format " (Type %s to exit %s)" | |
8239 (single-key-description cmd) | |
8240 gnus-newsgroup-name))) | |
8241 ;; Confirm auto selection. | |
8242 (let* ((event (read-char))) | |
8243 (setq key (if (listp event) (car event) event)) | |
8244 (if (memq key keystrokes) | |
8245 (let ((obuf (current-buffer))) | |
8246 (switch-to-buffer gnus-group-buffer) | |
8247 (and group | |
8248 (gnus-group-jump-to-group group)) | |
8249 (condition-case () | |
8250 (execute-kbd-macro (char-to-string key)) | |
8251 (error (ding) nil)) | |
8252 (setq group (gnus-group-group-name)) | |
8253 (switch-to-buffer obuf))))) | |
8254 (if (equal key cmd) | |
8255 (if (or (not group) | |
8256 (gnus-ephemeral-group-p gnus-newsgroup-name)) | |
8257 (gnus-summary-exit) | |
8258 (gnus-summary-next-group nil group backward)) | |
8259 (execute-kbd-macro (char-to-string key))))))))))) | |
8260 | |
8261 (defun gnus-summary-next-unread-article () | |
8262 "Select unread article after current one." | |
8263 (interactive) | |
8264 (gnus-summary-next-article t (and gnus-auto-select-same | |
8265 (gnus-summary-subject-string)))) | |
8266 | |
8267 (defun gnus-summary-prev-article (&optional unread subject) | |
8268 "Select the article after the current one. | |
8269 If UNREAD is non-nil, only unread articles are selected." | |
8270 (interactive "P") | |
8271 (gnus-summary-next-article unread subject t)) | |
8272 | |
8273 (defun gnus-summary-prev-unread-article () | |
8274 "Select unred article before current one." | |
8275 (interactive) | |
8276 (gnus-summary-prev-article t (and gnus-auto-select-same | |
8277 (gnus-summary-subject-string)))) | |
8278 | |
8279 (defun gnus-summary-next-page (&optional lines circular) | |
8280 "Show next page of selected article. | |
8281 If end of article, select next article. | |
8282 Argument LINES specifies lines to be scrolled up. | |
8283 If CIRCULAR is non-nil, go to the start of the article instead of | |
8284 instead of selecting the next article when reaching the end of the | |
8285 current article." | |
8286 (interactive "P") | |
8287 (setq gnus-summary-buffer (current-buffer)) | |
8288 (gnus-set-global-variables) | |
8289 (let ((article (gnus-summary-article-number)) | |
8290 (endp nil)) | |
8291 (gnus-configure-windows 'article) | |
8292 (if (or (null gnus-current-article) | |
8293 (null gnus-article-current) | |
8294 (/= article (cdr gnus-article-current)) | |
8295 (not (equal (car gnus-article-current) gnus-newsgroup-name))) | |
8296 ;; Selected subject is different from current article's. | |
8297 (gnus-summary-display-article article) | |
8298 (gnus-eval-in-buffer-window | |
8299 gnus-article-buffer | |
8300 (setq endp (gnus-article-next-page lines))) | |
8301 (if endp | |
8302 (cond (circular | |
8303 (gnus-summary-beginning-of-article)) | |
8304 (lines | |
8305 (gnus-message 3 "End of message")) | |
8306 ((null lines) | |
8307 (gnus-summary-next-unread-article))))) | |
8308 (gnus-summary-recenter) | |
8309 (gnus-summary-position-cursor))) | |
8310 | |
8311 (defun gnus-summary-prev-page (&optional lines) | |
8312 "Show previous page of selected article. | |
8313 Argument LINES specifies lines to be scrolled down." | |
8314 (interactive "P") | |
8315 (gnus-set-global-variables) | |
8316 (let ((article (gnus-summary-article-number))) | |
8317 (gnus-configure-windows 'article) | |
8318 (if (or (null gnus-current-article) | |
8319 (null gnus-article-current) | |
8320 (/= article (cdr gnus-article-current)) | |
8321 (not (equal (car gnus-article-current) gnus-newsgroup-name))) | |
8322 ;; Selected subject is different from current article's. | |
8323 (gnus-summary-display-article article) | |
8324 (gnus-summary-recenter) | |
8325 (gnus-eval-in-buffer-window gnus-article-buffer | |
8326 (gnus-article-prev-page lines)))) | |
8327 (gnus-summary-position-cursor)) | |
8328 | |
8329 (defun gnus-summary-scroll-up (lines) | |
8330 "Scroll up (or down) one line current article. | |
8331 Argument LINES specifies lines to be scrolled up (or down if negative)." | |
8332 (interactive "p") | |
8333 (gnus-set-global-variables) | |
8334 (gnus-configure-windows 'article) | |
8335 (or (gnus-summary-select-article nil nil 'pseudo) | |
8336 (gnus-eval-in-buffer-window | |
8337 gnus-article-buffer | |
8338 (cond ((> lines 0) | |
8339 (if (gnus-article-next-page lines) | |
8340 (gnus-message 3 "End of message"))) | |
8341 ((< lines 0) | |
8342 (gnus-article-prev-page (- lines)))))) | |
8343 (gnus-summary-recenter) | |
8344 (gnus-summary-position-cursor)) | |
8345 | |
8346 (defun gnus-summary-next-same-subject () | |
8347 "Select next article which has the same subject as current one." | |
8348 (interactive) | |
8349 (gnus-set-global-variables) | |
8350 (gnus-summary-next-article nil (gnus-summary-subject-string))) | |
8351 | |
8352 (defun gnus-summary-prev-same-subject () | |
8353 "Select previous article which has the same subject as current one." | |
8354 (interactive) | |
8355 (gnus-set-global-variables) | |
8356 (gnus-summary-prev-article nil (gnus-summary-subject-string))) | |
8357 | |
8358 (defun gnus-summary-next-unread-same-subject () | |
8359 "Select next unread article which has the same subject as current one." | |
8360 (interactive) | |
8361 (gnus-set-global-variables) | |
8362 (gnus-summary-next-article t (gnus-summary-subject-string))) | |
8363 | |
8364 (defun gnus-summary-prev-unread-same-subject () | |
8365 "Select previous unread article which has the same subject as current one." | |
8366 (interactive) | |
8367 (gnus-set-global-variables) | |
8368 (gnus-summary-prev-article t (gnus-summary-subject-string))) | |
8369 | |
8370 (defun gnus-summary-first-unread-article () | |
8371 "Select the first unread article. | |
8372 Return nil if there are no unread articles." | |
8373 (interactive) | |
8374 (gnus-set-global-variables) | |
8375 (prog1 | |
8376 (if (gnus-summary-first-subject t) | |
8377 (progn | |
8378 (gnus-summary-show-thread) | |
8379 (gnus-summary-first-subject t) | |
8380 (gnus-summary-display-article (gnus-summary-article-number)))) | |
8381 (gnus-summary-position-cursor))) | |
8382 | |
8383 (defun gnus-summary-best-unread-article () | |
8384 "Select the unread article with the highest score." | |
8385 (interactive) | |
8386 (gnus-set-global-variables) | |
8387 (let ((best -1000000) | |
8388 article score) | |
8389 (save-excursion | |
8390 (or (gnus-summary-first-subject t) | |
8391 (error "No unread articles")) | |
8392 (while | |
8393 (and | |
8394 (progn | |
8395 (and (> (setq score (gnus-summary-article-score)) best) | |
8396 (setq best score | |
8397 article (gnus-summary-article-number))) | |
8398 t) | |
8399 (gnus-summary-search-subject nil t)))) | |
8400 (if (not article) | |
8401 (error "No unread articles") | |
8402 (gnus-summary-goto-article article)) | |
8403 (gnus-summary-position-cursor))) | |
8404 | |
8405 (defun gnus-summary-goto-article (article &optional all-headers) | |
8406 "Fetch ARTICLE and display it if it exists. | |
8407 If ALL-HEADERS is non-nil, no header lines are hidden." | |
8408 (interactive | |
8409 (list | |
8410 (string-to-int | |
8411 (completing-read | |
8412 "Article number: " | |
8413 (mapcar (lambda (headers) | |
8414 (list (int-to-string (mail-header-number headers)))) | |
8415 gnus-newsgroup-headers) | |
8416 nil 'require-match)))) | |
8417 (prog1 | |
8418 (and (gnus-summary-goto-subject article) | |
8419 (gnus-summary-display-article article all-headers)) | |
8420 (gnus-summary-position-cursor))) | |
8421 | |
8422 (defun gnus-summary-goto-last-article () | |
8423 "Go to the previously read article." | |
8424 (interactive) | |
8425 (prog1 | |
8426 (and gnus-last-article | |
8427 (gnus-summary-goto-article gnus-last-article)) | |
8428 (gnus-summary-position-cursor))) | |
8429 | |
8430 (defun gnus-summary-pop-article (number) | |
8431 "Pop one article off the history and go to the previous. | |
8432 NUMBER articles will be popped off." | |
8433 (interactive "p") | |
8434 (let (to) | |
8435 (setq gnus-newsgroup-history | |
8436 (cdr (setq to (nthcdr number gnus-newsgroup-history)))) | |
8437 (if to | |
8438 (gnus-summary-goto-article (car to)) | |
8439 (error "Article history empty"))) | |
8440 (gnus-summary-position-cursor)) | |
8441 | |
8442 ;; Summary article oriented commands | |
8443 | |
8444 (defun gnus-summary-refer-parent-article (n) | |
8445 "Refer parent article N times. | |
8446 The difference between N and the number of articles fetched is returned." | |
8447 (interactive "p") | |
8448 (gnus-set-global-variables) | |
8449 (while | |
8450 (and | |
8451 (> n 0) | |
8452 (let ((ref (mail-header-references (gnus-get-header-by-num | |
8453 (gnus-summary-article-number))))) | |
8454 (if (and ref (not (equal ref "")) | |
8455 (string-match "<[^<>]*>[ \t]*$" ref)) | |
8456 (gnus-summary-refer-article | |
8457 (substring ref (match-beginning 0) (match-end 0))) | |
8458 (gnus-message 1 "No references in article %d" | |
8459 (gnus-summary-article-number)) | |
8460 nil))) | |
8461 (setq n (1- n))) | |
8462 (gnus-summary-position-cursor) | |
8463 n) | |
8464 | |
8465 (defun gnus-summary-refer-article (message-id) | |
8466 "Refer article specified by MESSAGE-ID. | |
8467 NOTE: This command only works with newsgroups that use real or simulated NNTP." | |
8468 (interactive "sMessage-ID: ") | |
8469 (if (or (not (stringp message-id)) | |
8470 (zerop (length message-id))) | |
8471 () | |
8472 ;; Construct the correct Message-ID if necessary. | |
8473 ;; Suggested by tale@pawl.rpi.edu. | |
8474 (or (string-match "^<" message-id) | |
8475 (setq message-id (concat "<" message-id))) | |
8476 (or (string-match ">$" message-id) | |
8477 (setq message-id (concat message-id ">"))) | |
8478 (let ((header (car (gnus-gethash (downcase message-id) | |
8479 gnus-newsgroup-dependencies)))) | |
8480 (if header | |
8481 (or (gnus-summary-goto-article (mail-header-number header)) | |
8482 ;; The header has been read, but the article had been | |
8483 ;; expunged, so we insert it again. | |
8484 (progn | |
8485 (gnus-summary-insert-line | |
8486 nil header 0 nil gnus-read-mark nil nil | |
8487 (mail-header-subject header)) | |
8488 (forward-line -1) | |
8489 (mail-header-number header))) | |
8490 (let ((gnus-override-method gnus-refer-article-method) | |
8491 (gnus-ancient-mark gnus-read-mark) | |
8492 (tmp-point (window-start | |
8493 (get-buffer-window gnus-article-buffer))) | |
8494 number tmp-buf) | |
8495 (and gnus-refer-article-method | |
8496 (gnus-check-server gnus-refer-article-method)) | |
8497 ;; Save the old article buffer. | |
8498 (save-excursion | |
8499 (set-buffer (gnus-article-setup-buffer)) | |
8500 (gnus-kill-buffer " *temp Article*") | |
8501 (setq tmp-buf (rename-buffer " *temp Article*"))) | |
8502 (prog1 | |
8503 (if (gnus-article-prepare | |
8504 message-id nil (gnus-read-header message-id)) | |
8505 (progn | |
8506 (setq number (mail-header-number gnus-current-headers)) | |
8507 (gnus-rebuild-thread message-id) | |
8508 (gnus-summary-goto-subject number) | |
8509 (if (null gnus-use-full-window) | |
8510 (progn | |
8511 (delete-windows-on tmp-buf) | |
8512 (gnus-configure-windows 'article 'force))) | |
8513 (gnus-summary-recenter) | |
8514 (gnus-article-set-window-start | |
8515 (cdr (assq number gnus-newsgroup-bookmarks))) | |
8516 (and gnus-visual | |
8517 (run-hooks 'gnus-visual-mark-article-hook)) | |
8518 message-id) | |
8519 ;; We restore the old article buffer. | |
8520 (save-excursion | |
8521 (kill-buffer gnus-article-buffer) | |
8522 (set-buffer tmp-buf) | |
8523 (rename-buffer gnus-article-buffer) | |
8524 (let ((buffer-read-only nil)) | |
8525 (and tmp-point | |
8526 (set-window-start (get-buffer-window (current-buffer)) | |
8527 tmp-point))))))))))) | |
8528 | |
8529 (defun gnus-summary-enter-digest-group () | |
8530 "Enter a digest group based on the current article." | |
8531 (interactive) | |
8532 (gnus-set-global-variables) | |
8533 (gnus-summary-select-article) | |
8534 ;; We do not want a narrowed article. | |
8535 (gnus-summary-stop-page-breaking) | |
8536 (let ((name (format "%s-%d" | |
8537 (gnus-group-prefixed-name | |
8538 gnus-newsgroup-name (list 'nndoc "")) | |
8539 gnus-current-article)) | |
8540 (ogroup gnus-newsgroup-name) | |
8541 (buf (current-buffer))) | |
8542 (if (gnus-group-read-ephemeral-group | |
8543 name (list 'nndoc name | |
8544 (list 'nndoc-address (get-buffer gnus-article-buffer)) | |
8545 '(nndoc-article-type digest)) | |
8546 t) | |
8547 (setcdr (nthcdr 4 (nth 2 (gnus-gethash name gnus-newsrc-hashtb))) | |
8548 (list (list (cons 'to-group ogroup)))) | |
8549 (switch-to-buffer buf) | |
8550 (gnus-set-global-variables) | |
8551 (gnus-configure-windows 'summary) | |
8552 (gnus-message 3 "Article not a digest?")))) | |
8553 | |
8554 (defun gnus-summary-isearch-article () | |
8555 "Do incremental search forward on current article." | |
8556 (interactive) | |
8557 (gnus-set-global-variables) | |
8558 (gnus-summary-select-article) | |
8559 (gnus-eval-in-buffer-window | |
8560 gnus-article-buffer (isearch-forward))) | |
8561 | |
8562 (defun gnus-summary-search-article-forward (regexp &optional backward) | |
8563 "Search for an article containing REGEXP forward. | |
8564 If BACKWARD, search backward instead." | |
8565 (interactive | |
8566 (list (read-string | |
8567 (format "Search article %s (regexp%s): " | |
8568 (if current-prefix-arg "backward" "forward") | |
8569 (if gnus-last-search-regexp | |
8570 (concat ", default " gnus-last-search-regexp) | |
8571 ""))) | |
8572 current-prefix-arg)) | |
8573 (gnus-set-global-variables) | |
8574 (if (string-equal regexp "") | |
8575 (setq regexp (or gnus-last-search-regexp "")) | |
8576 (setq gnus-last-search-regexp regexp)) | |
8577 (if (gnus-summary-search-article regexp backward) | |
8578 (gnus-article-set-window-start | |
8579 (cdr (assq (gnus-summary-article-number) gnus-newsgroup-bookmarks))) | |
8580 (error "Search failed: \"%s\"" regexp))) | |
8581 | |
8582 (defun gnus-summary-search-article-backward (regexp) | |
8583 "Search for an article containing REGEXP backward." | |
8584 (interactive | |
8585 (list (read-string | |
8586 (format "Search article backward (regexp%s): " | |
8587 (if gnus-last-search-regexp | |
8588 (concat ", default " gnus-last-search-regexp) | |
8589 ""))))) | |
8590 (gnus-summary-search-article-forward regexp 'backward)) | |
8591 | |
8592 (defun gnus-summary-search-article (regexp &optional backward) | |
8593 "Search for an article containing REGEXP. | |
8594 Optional argument BACKWARD means do search for backward. | |
8595 gnus-select-article-hook is not called during the search." | |
8596 (let ((gnus-select-article-hook nil) ;Disable hook. | |
8597 (gnus-mark-article-hook nil) ;Inhibit marking as read. | |
8598 (re-search | |
8599 (if backward | |
8600 (function re-search-backward) (function re-search-forward))) | |
8601 (found nil) | |
8602 (last nil)) | |
8603 ;; Hidden thread subtrees must be searched for ,too. | |
8604 (gnus-summary-show-all-threads) | |
8605 (if (eobp) (forward-line -1)) | |
8606 ;; First of all, search current article. | |
8607 ;; We don't want to read article again from NNTP server nor reset | |
8608 ;; current point. | |
8609 (gnus-summary-select-article) | |
8610 (gnus-message 9 "Searching article: %d..." gnus-current-article) | |
8611 (setq last gnus-current-article) | |
8612 (gnus-eval-in-buffer-window | |
8613 gnus-article-buffer | |
8614 (save-restriction | |
8615 (widen) | |
8616 ;; Begin search from current point. | |
8617 (setq found (funcall re-search regexp nil t)))) | |
8618 ;; Then search next articles. | |
8619 (while (and (not found) | |
8620 (gnus-summary-display-article | |
8621 (gnus-summary-search-subject backward nil nil))) | |
8622 (gnus-message 9 "Searching article: %d..." gnus-current-article) | |
8623 (gnus-eval-in-buffer-window | |
8624 gnus-article-buffer | |
8625 (save-restriction | |
8626 (widen) | |
8627 (goto-char (if backward (point-max) (point-min))) | |
8628 (setq found (funcall re-search regexp nil t))))) | |
8629 (message "") | |
8630 ;; Adjust article pointer. | |
8631 (or (eq last gnus-current-article) | |
8632 (setq gnus-last-article last)) | |
8633 ;; Return T if found such article. | |
8634 found)) | |
8635 | |
8636 (defun gnus-summary-execute-command (header regexp command &optional backward) | |
8637 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND. | |
8638 If HEADER is an empty string (or nil), the match is done on the entire | |
8639 article. If BACKWARD (the prefix) is non-nil, search backward instead." | |
8640 (interactive | |
8641 (list (let ((completion-ignore-case t)) | |
8642 (completing-read | |
8643 "Header name: " | |
8644 (mapcar (lambda (string) (list string)) | |
8645 '("Number" "Subject" "From" "Lines" "Date" | |
8646 "Message-ID" "Xref" "References")) | |
8647 nil 'require-match)) | |
8648 (read-string "Regexp: ") | |
8649 (read-key-sequence "Command: ") | |
8650 current-prefix-arg)) | |
8651 (gnus-set-global-variables) | |
8652 ;; Hidden thread subtrees must be searched as well. | |
8653 (gnus-summary-show-all-threads) | |
8654 ;; We don't want to change current point nor window configuration. | |
8655 (save-excursion | |
8656 (save-window-excursion | |
8657 (gnus-message 6 "Executing %s..." (key-description command)) | |
8658 ;; We'd like to execute COMMAND interactively so as to give arguments. | |
8659 (gnus-execute header regexp | |
8660 (` (lambda () | |
8661 (call-interactively '(, (key-binding command))))) | |
8662 backward) | |
8663 (gnus-message 6 "Executing %s...done" (key-description command))))) | |
8664 | |
8665 (defun gnus-summary-beginning-of-article () | |
8666 "Scroll the article back to the beginning." | |
8667 (interactive) | |
8668 (gnus-set-global-variables) | |
8669 (gnus-summary-select-article) | |
8670 (gnus-configure-windows 'article) | |
8671 (gnus-eval-in-buffer-window | |
8672 gnus-article-buffer | |
8673 (widen) | |
8674 (goto-char (point-min)) | |
8675 (and gnus-break-pages (gnus-narrow-to-page)))) | |
8676 | |
8677 (defun gnus-summary-end-of-article () | |
8678 "Scroll to the end of the article." | |
8679 (interactive) | |
8680 (gnus-set-global-variables) | |
8681 (gnus-summary-select-article) | |
8682 (gnus-configure-windows 'article) | |
8683 (gnus-eval-in-buffer-window | |
8684 gnus-article-buffer | |
8685 (widen) | |
8686 (goto-char (point-max)) | |
8687 (recenter -3) | |
8688 (and gnus-break-pages (gnus-narrow-to-page)))) | |
8689 | |
8690 (defun gnus-summary-show-article () | |
8691 "Force re-fetching of the current article." | |
8692 (interactive) | |
8693 (gnus-set-global-variables) | |
8694 (gnus-summary-select-article nil 'force) | |
8695 (gnus-configure-windows 'article) | |
8696 (gnus-summary-position-cursor)) | |
8697 | |
8698 (defun gnus-summary-verbose-headers (&optional arg) | |
8699 "Toggle permanent full header display. | |
8700 If ARG is a positive number, turn header display on. | |
8701 If ARG is a negative number, turn header display off." | |
8702 (interactive "P") | |
8703 (gnus-set-global-variables) | |
8704 (gnus-summary-toggle-header arg) | |
8705 (setq gnus-show-all-headers | |
8706 (cond ((or (not (numberp arg)) | |
8707 (zerop arg)) | |
8708 (not gnus-show-all-headers)) | |
8709 ((natnump arg) | |
8710 t)))) | |
8711 | |
8712 (defun gnus-summary-toggle-header (&optional arg) | |
8713 "Show the headers if they are hidden, or hide them if they are shown. | |
8714 If ARG is a positive number, show the entire header. | |
8715 If ARG is a negative number, hide the unwanted header lines." | |
8716 (interactive "P") | |
8717 (gnus-set-global-variables) | |
8718 (save-excursion | |
8719 (set-buffer gnus-article-buffer) | |
8720 (let ((buffer-read-only nil)) | |
8721 (if (numberp arg) | |
8722 (if (> arg 0) (remove-text-properties (point-min) (point-max) | |
8723 gnus-hidden-properties) | |
8724 (if (< arg 0) (run-hooks 'gnus-article-display-hook))) | |
8725 (if (text-property-any (point-min) (point-max) 'invisible t) | |
8726 (remove-text-properties | |
8727 (point-min) (point-max) gnus-hidden-properties) | |
8728 ;; We hide the headers. This song and dance act below is | |
8729 ;; done because `gnus-have-all-headers' is buffer-local to | |
8730 ;; the summary buffer, and we only want to temporarily | |
8731 ;; change it in that buffer. Ugh. | |
8732 (let ((have gnus-have-all-headers)) | |
8733 (save-excursion | |
8734 (set-buffer gnus-summary-buffer) | |
8735 (setq gnus-have-all-headers nil) | |
8736 (save-excursion | |
8737 (set-buffer gnus-article-buffer) | |
8738 (run-hooks 'gnus-article-display-hook)) | |
8739 (setq gnus-have-all-headers have))))) | |
8740 (set-window-point (get-buffer-window (current-buffer)) (point-min))))) | |
8741 | |
8742 (defun gnus-summary-show-all-headers () | |
8743 "Make all header lines visible." | |
8744 (interactive) | |
8745 (gnus-set-global-variables) | |
8746 (gnus-article-show-all-headers)) | |
8747 | |
8748 (defun gnus-summary-toggle-mime (&optional arg) | |
8749 "Toggle MIME processing. | |
8750 If ARG is a positive number, turn MIME processing on." | |
8751 (interactive "P") | |
8752 (gnus-set-global-variables) | |
8753 (setq gnus-show-mime | |
8754 (if (null arg) (not gnus-show-mime) | |
8755 (> (prefix-numeric-value arg) 0))) | |
8756 (gnus-summary-select-article t 'force)) | |
8757 | |
8758 (defun gnus-summary-caesar-message (&optional arg) | |
8759 "Caesar rotate the current article by 13. | |
8760 The numerical prefix specifies how manu places to rotate each letter | |
8761 forward." | |
8762 (interactive "P") | |
8763 (gnus-set-global-variables) | |
8764 (gnus-summary-select-article) | |
8765 (let ((mail-header-separator "")) | |
8766 (gnus-eval-in-buffer-window | |
8767 gnus-article-buffer | |
8768 (save-restriction | |
8769 (widen) | |
8770 (let ((start (window-start))) | |
8771 (news-caesar-buffer-body arg) | |
8772 (set-window-start (get-buffer-window (current-buffer)) start)))))) | |
8773 | |
8774 (defun gnus-summary-stop-page-breaking () | |
8775 "Stop page breaking in the current article." | |
8776 (interactive) | |
8777 (gnus-set-global-variables) | |
8778 (gnus-summary-select-article) | |
8779 (gnus-eval-in-buffer-window gnus-article-buffer (widen))) | |
8780 | |
8781 ;; Suggested by Brian Edmonds <bedmonds@prodigy.bc.ca>. | |
8782 | |
8783 (defun gnus-summary-move-article (&optional n to-newsgroup select-method) | |
8784 "Move the current article to a different newsgroup. | |
8785 If N is a positive number, move the N next articles. | |
8786 If N is a negative number, move the N previous articles. | |
8787 If N is nil and any articles have been marked with the process mark, | |
8788 move those articles instead. | |
8789 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to. | |
8790 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but | |
8791 re-spool using this method. | |
8792 For this function to work, both the current newsgroup and the | |
8793 newsgroup that you want to move to have to support the `request-move' | |
8794 and `request-accept' functions. (Ie. mail newsgroups at present.)" | |
8795 (interactive "P") | |
8796 (gnus-set-global-variables) | |
8797 (or (gnus-check-backend-function 'request-move-article gnus-newsgroup-name) | |
8798 (error "The current newsgroup does not support article moving")) | |
8799 (let ((articles (gnus-summary-work-articles n)) | |
8800 (prefix (gnus-group-real-prefix gnus-newsgroup-name)) | |
8801 art-group to-method sel-met) | |
8802 (if (and (not to-newsgroup) (not select-method)) | |
8803 (setq to-newsgroup | |
8804 (completing-read | |
8805 (format "Where do you want to move %s? %s" | |
8806 (if (> (length articles) 1) | |
8807 (format "these %d articles" (length articles)) | |
8808 "this article") | |
8809 (if gnus-current-move-group | |
8810 (format "(%s default) " gnus-current-move-group) | |
8811 "")) | |
8812 gnus-active-hashtb nil nil prefix))) | |
8813 (if to-newsgroup | |
8814 (progn | |
8815 (if (or (string= to-newsgroup "") (string= to-newsgroup prefix)) | |
8816 (setq to-newsgroup (or gnus-current-move-group ""))) | |
8817 (or (gnus-gethash to-newsgroup gnus-active-hashtb) | |
8818 (gnus-activate-group to-newsgroup) | |
8819 (error "No such group: %s" to-newsgroup)) | |
8820 (setq gnus-current-move-group to-newsgroup))) | |
8821 (setq to-method (if select-method (list select-method "") | |
8822 (gnus-find-method-for-group to-newsgroup))) | |
8823 (or (gnus-check-backend-function 'request-accept-article (car to-method)) | |
8824 (error "%s does not support article copying" (car to-method))) | |
8825 (or (gnus-check-server to-method) | |
8826 (error "Can't open server %s" (car to-method))) | |
8827 (gnus-message 6 "Moving to %s: %s..." | |
8828 (or select-method to-newsgroup) articles) | |
8829 (while articles | |
8830 (if (setq art-group | |
8831 (gnus-request-move-article | |
8832 (car articles) ; Article to move | |
8833 gnus-newsgroup-name ; From newsgrouo | |
8834 (nth 1 (gnus-find-method-for-group | |
8835 gnus-newsgroup-name)) ; Server | |
8836 (list 'gnus-request-accept-article | |
8837 (if select-method | |
8838 (list 'quote select-method) | |
8839 to-newsgroup) | |
8840 (not (cdr articles))) ; Accept form | |
8841 (not (cdr articles)))) ; Only save nov last time | |
8842 (let* ((buffer-read-only nil) | |
8843 (entry | |
8844 (or | |
8845 (gnus-gethash (car art-group) gnus-newsrc-hashtb) | |
8846 (gnus-gethash | |
8847 (gnus-group-prefixed-name | |
8848 (car art-group) | |
8849 (if select-method (list select-method "") | |
8850 (gnus-find-method-for-group to-newsgroup))) | |
8851 gnus-newsrc-hashtb))) | |
8852 (info (nth 2 entry)) | |
8853 (article (car articles))) | |
8854 (gnus-summary-goto-subject article) | |
8855 (beginning-of-line) | |
8856 (delete-region (point) (progn (forward-line 1) (point))) | |
8857 ;; Update the group that has been moved to. | |
8858 (if (not info) | |
8859 () ; This group does not exist yet. | |
8860 (if (not (memq article gnus-newsgroup-unreads)) | |
8861 (setcar (cdr (cdr info)) | |
8862 (gnus-add-to-range (nth 2 info) | |
8863 (list (cdr art-group))))) | |
8864 ;; Copy any marks over to the new group. | |
8865 (let ((marks '((tick . gnus-newsgroup-marked) | |
8866 (dormant . gnus-newsgroup-dormant) | |
8867 (expire . gnus-newsgroup-expirable) | |
8868 (bookmark . gnus-newsgroup-bookmarks) | |
8869 (reply . gnus-newsgroup-replied))) | |
8870 (to-article (cdr art-group))) | |
8871 (while marks | |
8872 (if (memq article (symbol-value (cdr (car marks)))) | |
8873 (gnus-add-marked-articles | |
8874 (car info) (car (car marks)) (list to-article) info)) | |
8875 (setq marks (cdr marks))))) | |
8876 ;; Update marks. | |
8877 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)) | |
8878 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads)) | |
8879 (setq gnus-newsgroup-dormant | |
8880 (delq article gnus-newsgroup-dormant)) | |
8881 (setq gnus-newsgroup-reads | |
8882 (cons (cons article gnus-canceled-mark) | |
8883 gnus-newsgroup-reads))) | |
8884 (gnus-message 1 "Couldn't move article %s" (car articles))) | |
8885 (gnus-summary-remove-process-mark (car articles)) | |
8886 (setq articles (cdr articles))) | |
8887 (gnus-set-mode-line 'summary))) | |
8888 | |
8889 (defun gnus-summary-respool-article (&optional n respool-method) | |
8890 "Respool the current article. | |
8891 The article will be squeezed through the mail spooling process again, | |
8892 which means that it will be put in some mail newsgroup or other | |
8893 depending on `nnmail-split-methods'. | |
8894 If N is a positive number, respool the N next articles. | |
8895 If N is a negative number, respool the N previous articles. | |
8896 If N is nil and any articles have been marked with the process mark, | |
8897 respool those articles instead. | |
8898 | |
8899 Respooling can be done both from mail groups and \"real\" newsgroups. | |
8900 In the former case, the articles in question will be moved from the | |
8901 current group into whatever groups they are destined to. In the | |
8902 latter case, they will be copied into the relevant groups." | |
8903 (interactive "P") | |
8904 (gnus-set-global-variables) | |
8905 (let ((respool-methods (gnus-methods-using 'respool)) | |
8906 (methname | |
8907 (symbol-name (car (gnus-find-method-for-group gnus-newsgroup-name))))) | |
8908 (or respool-method | |
8909 (setq respool-method | |
8910 (completing-read | |
8911 "What method do you want to use when respooling? " | |
8912 respool-methods nil t methname))) | |
8913 (or (string= respool-method "") | |
8914 (if (assoc (symbol-name | |
8915 (car (gnus-find-method-for-group gnus-newsgroup-name))) | |
8916 respool-methods) | |
8917 (gnus-summary-move-article n nil (intern respool-method)) | |
8918 (gnus-summary-copy-article n nil (intern respool-method)))))) | |
8919 | |
8920 ;; Suggested by gregj@unidata.com (Gregory J. Grubbs). | |
8921 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method) | |
8922 "Move the current article to a different newsgroup. | |
8923 If N is a positive number, move the N next articles. | |
8924 If N is a negative number, move the N previous articles. | |
8925 If N is nil and any articles have been marked with the process mark, | |
8926 move those articles instead. | |
8927 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to. | |
8928 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but | |
8929 re-spool using this method. | |
8930 For this function to work, the newsgroup that you want to move to have | |
8931 to support the `request-move' and `request-accept' | |
8932 functions. (Ie. mail newsgroups at present.)" | |
8933 (interactive "P") | |
8934 (gnus-set-global-variables) | |
8935 (let ((articles (gnus-summary-work-articles n)) | |
8936 (copy-buf (get-buffer-create "*copy work*")) | |
8937 (prefix (gnus-group-real-prefix gnus-newsgroup-name)) | |
8938 art-group to-method) | |
8939 (buffer-disable-undo copy-buf) | |
8940 (if (and (not to-newsgroup) (not select-method)) | |
8941 (setq to-newsgroup | |
8942 (completing-read | |
8943 (format "Where do you want to copy %s? %s" | |
8944 (if (> (length articles) 1) | |
8945 (format "these %d articles" (length articles)) | |
8946 "this article") | |
8947 (if gnus-current-move-group | |
8948 (format "(%s default) " gnus-current-move-group) | |
8949 "")) | |
8950 gnus-active-hashtb nil nil prefix))) | |
8951 (if to-newsgroup | |
8952 (progn | |
8953 (if (or (string= to-newsgroup "") (string= to-newsgroup prefix)) | |
8954 (setq to-newsgroup (or gnus-current-move-group ""))) | |
8955 (or (gnus-gethash to-newsgroup gnus-active-hashtb) | |
8956 (gnus-activate-group to-newsgroup) | |
8957 (error "No such group: %s" to-newsgroup)) | |
8958 (setq gnus-current-move-group to-newsgroup))) | |
8959 (setq to-method (if select-method (list select-method "") | |
8960 (gnus-find-method-for-group to-newsgroup))) | |
8961 (or (gnus-check-backend-function 'request-accept-article (car to-method)) | |
8962 (error "%s does not support article copying" (car to-method))) | |
8963 (or (gnus-check-server to-method) | |
8964 (error "Can't open server %s" (car to-method))) | |
8965 (while articles | |
8966 (gnus-message 6 "Copying to %s: %s..." | |
8967 (or select-method to-newsgroup) articles) | |
8968 (if (setq art-group | |
8969 (save-excursion | |
8970 (set-buffer copy-buf) | |
8971 (gnus-request-article-this-buffer | |
8972 (car articles) gnus-newsgroup-name) | |
8973 (gnus-request-accept-article | |
13694
73433c3071a5
* gnus.el (gnus-parse-headers-hook): New hook.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
13579
diff
changeset
|
8974 (if select-method (list 'quote select-method) to-newsgroup) |
13401 | 8975 (not (cdr articles))))) |
8976 (let* ((entry | |
8977 (or | |
8978 (gnus-gethash (car art-group) gnus-newsrc-hashtb) | |
8979 (gnus-gethash | |
8980 (gnus-group-prefixed-name | |
8981 (car art-group) | |
8982 (if select-method (list select-method "") | |
8983 (gnus-find-method-for-group to-newsgroup))) | |
8984 gnus-newsrc-hashtb))) | |
8985 (info (nth 2 entry)) | |
8986 (article (car articles))) | |
8987 ;; We copy the info over to the new group. | |
8988 (if (not info) | |
8989 () ; This group does not exist (yet). | |
8990 (if (not (memq article gnus-newsgroup-unreads)) | |
8991 (setcar (cdr (cdr info)) | |
8992 (gnus-add-to-range (nth 2 info) | |
8993 (list (cdr art-group))))) | |
8994 ;; Copy any marks over to the new group. | |
8995 (let ((marks '((tick . gnus-newsgroup-marked) | |
8996 (dormant . gnus-newsgroup-dormant) | |
8997 (expire . gnus-newsgroup-expirable) | |
8998 (bookmark . gnus-newsgroup-bookmarks) | |
8999 (reply . gnus-newsgroup-replied))) | |
9000 (to-article (cdr art-group))) | |
9001 (while marks | |
9002 (if (memq article (symbol-value (cdr (car marks)))) | |
9003 (gnus-add-marked-articles | |
9004 (car info) (car (car marks)) (list to-article) info)) | |
9005 (setq marks (cdr marks)))))) | |
9006 (gnus-message 1 "Couldn't copy article %s" (car articles))) | |
9007 (gnus-summary-remove-process-mark (car articles)) | |
9008 (setq articles (cdr articles))) | |
9009 (kill-buffer copy-buf))) | |
9010 | |
9011 (defun gnus-summary-import-article (file) | |
9012 "Import a random file into a mail newsgroup." | |
9013 (interactive "fImport file: ") | |
9014 (let ((group gnus-newsgroup-name) | |
9015 atts) | |
9016 (or (gnus-check-backend-function 'request-accept-article group) | |
9017 (error "%s does not support article importing" group)) | |
9018 (or (file-readable-p file) | |
9019 (not (file-regular-p file)) | |
9020 (error "Can't read %s" file)) | |
9021 (save-excursion | |
9022 (set-buffer (get-buffer-create " *import file*")) | |
9023 (buffer-disable-undo (current-buffer)) | |
9024 (erase-buffer) | |
9025 (insert-file-contents file) | |
9026 (goto-char (point-min)) | |
9027 (if (nnheader-article-p) | |
9028 () | |
9029 (setq atts (file-attributes file)) | |
9030 (insert "From: " (read-string "From: ") "\n" | |
9031 "Subject: " (read-string "Subject: ") "\n" | |
9032 "Date: " (current-time-string (nth 5 atts)) "\n" | |
9033 "Chars: " (int-to-string (nth 7 atts)) "\n\n")) | |
9034 (gnus-request-accept-article group t) | |
9035 (kill-buffer (current-buffer))))) | |
9036 | |
9037 (defun gnus-summary-expire-articles () | |
9038 "Expire all articles that are marked as expirable in the current group." | |
9039 (interactive) | |
9040 (if (not (gnus-check-backend-function | |
9041 'request-expire-articles gnus-newsgroup-name)) | |
9042 () | |
9043 (let* ((info (nth 2 (gnus-gethash gnus-newsgroup-name | |
9044 gnus-newsrc-hashtb))) | |
9045 (total (memq 'total-expire (nth 5 info))) | |
9046 (expirable (if total | |
9047 (gnus-list-of-read-articles gnus-newsgroup-name) | |
9048 (setq gnus-newsgroup-expirable | |
9049 (sort gnus-newsgroup-expirable '<)))) | |
9050 es) | |
9051 (if (not expirable) | |
9052 () | |
9053 (gnus-message 6 "Expiring articles...") | |
9054 ;; The list of articles that weren't expired is returned. | |
9055 (setq es (gnus-request-expire-articles expirable gnus-newsgroup-name)) | |
9056 (or total (setq gnus-newsgroup-expirable es)) | |
9057 ;; We go through the old list of expirable, and mark all | |
9058 ;; really expired articles as non-existant. | |
9059 (or (eq es expirable) ;If nothing was expired, we don't mark. | |
9060 (let ((gnus-use-cache nil)) | |
9061 (while expirable | |
9062 (or (memq (car expirable) es) | |
9063 (gnus-summary-mark-article | |
9064 (car expirable) gnus-canceled-mark)) | |
9065 (setq expirable (cdr expirable))))) | |
9066 (gnus-message 6 "Expiring articles...done"))))) | |
9067 | |
9068 (defun gnus-summary-expire-articles-now () | |
9069 "Expunge all expirable articles in the current group. | |
9070 This means that *all* articles that are marked as expirable will be | |
9071 deleted forever, right now." | |
9072 (interactive) | |
9073 (or gnus-expert-user | |
9074 (gnus-y-or-n-p | |
9075 "Are you really, really, really sure you want to expunge? ") | |
9076 (error "Phew!")) | |
9077 (let ((nnmail-expiry-wait -1) | |
9078 (nnmail-expiry-wait-function nil)) | |
9079 (gnus-summary-expire-articles))) | |
9080 | |
9081 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. | |
9082 (defun gnus-summary-delete-article (&optional n) | |
9083 "Delete the N next (mail) articles. | |
9084 This command actually deletes articles. This is not a marking | |
9085 command. The article will disappear forever from you life, never to | |
9086 return. | |
9087 If N is negative, delete backwards. | |
9088 If N is nil and articles have been marked with the process mark, | |
9089 delete these instead." | |
9090 (interactive "P") | |
9091 (or (gnus-check-backend-function 'request-expire-articles | |
9092 gnus-newsgroup-name) | |
9093 (error "The current newsgroup does not support article deletion.")) | |
9094 ;; Compute the list of articles to delete. | |
9095 (let ((articles (gnus-summary-work-articles n)) | |
9096 not-deleted) | |
9097 (if (and gnus-novice-user | |
9098 (not (gnus-y-or-n-p | |
9099 (format "Do you really want to delete %s forever? " | |
9100 (if (> (length articles) 1) "these articles" | |
9101 "this article"))))) | |
9102 () | |
9103 ;; Delete the articles. | |
9104 (setq not-deleted (gnus-request-expire-articles | |
9105 articles gnus-newsgroup-name 'force)) | |
9106 (while articles | |
9107 (gnus-summary-remove-process-mark (car articles)) | |
9108 ;; The backend might not have been able to delete the article | |
9109 ;; after all. | |
9110 (or (memq (car articles) not-deleted) | |
9111 (gnus-summary-mark-article (car articles) gnus-canceled-mark)) | |
9112 (setq articles (cdr articles)))) | |
9113 (gnus-summary-position-cursor) | |
9114 (gnus-set-mode-line 'summary) | |
9115 not-deleted)) | |
9116 | |
9117 (defun gnus-summary-edit-article (&optional force) | |
9118 "Enter into a buffer and edit the current article. | |
9119 This will have permanent effect only in mail groups. | |
9120 If FORCE is non-nil, allow editing of articles even in read-only | |
9121 groups." | |
9122 (interactive "P") | |
9123 (or force | |
9124 (not (gnus-group-read-only-p)) | |
9125 (error "The current newsgroup does not support article editing.")) | |
9126 (gnus-summary-select-article t) | |
9127 (gnus-configure-windows 'article) | |
9128 (select-window (get-buffer-window gnus-article-buffer)) | |
9129 (gnus-message 6 "C-c C-c to end edits") | |
9130 (setq buffer-read-only nil) | |
9131 (text-mode) | |
9132 (use-local-map (copy-keymap (current-local-map))) | |
9133 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done) | |
9134 (buffer-enable-undo) | |
9135 (widen) | |
9136 (goto-char (point-min)) | |
9137 (search-forward "\n\n" nil t)) | |
9138 | |
9139 (defun gnus-summary-edit-article-done () | |
9140 "Make edits to the current article permanent." | |
9141 (interactive) | |
9142 (if (gnus-group-read-only-p) | |
9143 (progn | |
9144 (gnus-summary-edit-article-postpone) | |
9145 (message "The current newsgroup does not support article editing.") | |
9146 (ding)) | |
9147 (let ((buf (buffer-substring-no-properties (point-min) (point-max)))) | |
9148 (erase-buffer) | |
9149 (insert buf) | |
9150 (if (not (gnus-request-replace-article | |
9151 (cdr gnus-article-current) (car gnus-article-current) | |
9152 (current-buffer))) | |
9153 (error "Couldn't replace article.") | |
9154 (gnus-article-mode) | |
9155 (use-local-map gnus-article-mode-map) | |
9156 (setq buffer-read-only t) | |
9157 (buffer-disable-undo (current-buffer)) | |
9158 (gnus-configure-windows 'summary)) | |
9159 (and gnus-visual (run-hooks 'gnus-visual-mark-article-hook))))) | |
9160 | |
9161 (defun gnus-summary-edit-article-postpone () | |
9162 "Postpone changes to the current article." | |
9163 (interactive) | |
9164 (gnus-article-mode) | |
9165 (use-local-map gnus-article-mode-map) | |
9166 (setq buffer-read-only t) | |
9167 (buffer-disable-undo (current-buffer)) | |
9168 (gnus-configure-windows 'summary) | |
9169 (and gnus-visual (run-hooks 'gnus-visual-mark-article-hook))) | |
9170 | |
9171 (defun gnus-summary-fancy-query () | |
9172 "Query where the fancy respool algorithm would put this article." | |
9173 (interactive) | |
9174 (gnus-summary-select-article) | |
9175 (save-excursion | |
9176 (set-buffer gnus-article-buffer) | |
9177 (save-restriction | |
9178 (goto-char (point-min)) | |
9179 (search-forward "\n\n") | |
9180 (narrow-to-region (point-min) (point)) | |
9181 (pp-eval-expression (list 'quote (nnmail-split-fancy)))))) | |
9182 | |
9183 ;; Summary score commands. | |
9184 | |
9185 ;; Suggested by boubaker@cenatls.cena.dgac.fr. | |
9186 | |
9187 (defun gnus-summary-raise-score (n) | |
9188 "Raise the score of the current article by N." | |
9189 (interactive "p") | |
9190 (gnus-summary-set-score (+ (gnus-summary-article-score) n))) | |
9191 | |
9192 (defun gnus-summary-set-score (n) | |
9193 "Set the score of the current article to N." | |
9194 (interactive "p") | |
9195 ;; Skip dummy header line. | |
9196 (save-excursion | |
9197 (gnus-summary-show-thread) | |
9198 (if (eq (gnus-summary-article-mark) gnus-dummy-mark) | |
9199 (forward-line 1)) | |
9200 (let ((buffer-read-only nil)) | |
9201 ;; Set score. | |
9202 (gnus-summary-update-mark | |
9203 (if (= n (or gnus-summary-default-score 0)) ? | |
9204 (if (< n (or gnus-summary-default-score 0)) | |
9205 gnus-score-below-mark gnus-score-over-mark)) 'score)) | |
9206 (let* ((article (gnus-summary-article-number)) | |
9207 (score (assq article gnus-newsgroup-scored))) | |
9208 (if score (setcdr score n) | |
9209 (setq gnus-newsgroup-scored | |
9210 (cons (cons article n) gnus-newsgroup-scored)))) | |
9211 (gnus-summary-update-line))) | |
9212 | |
9213 (defun gnus-summary-current-score () | |
9214 "Return the score of the current article." | |
9215 (interactive) | |
9216 (message "%s" (gnus-summary-article-score))) | |
9217 | |
9218 ;; Summary marking commands. | |
9219 | |
9220 (defun gnus-summary-raise-same-subject-and-select (score) | |
9221 "Raise articles which has the same subject with SCORE and select the next." | |
9222 (interactive "p") | |
9223 (let ((subject (gnus-summary-subject-string))) | |
9224 (gnus-summary-raise-score score) | |
9225 (while (gnus-summary-search-subject nil nil subject) | |
9226 (gnus-summary-raise-score score)) | |
9227 (gnus-summary-next-article t))) | |
9228 | |
9229 (defun gnus-summary-raise-same-subject (score) | |
9230 "Raise articles which has the same subject with SCORE." | |
9231 (interactive "p") | |
9232 (let ((subject (gnus-summary-subject-string))) | |
9233 (gnus-summary-raise-score score) | |
9234 (while (gnus-summary-search-subject nil nil subject) | |
9235 (gnus-summary-raise-score score)) | |
9236 (gnus-summary-next-subject 1 t))) | |
9237 | |
9238 (defun gnus-score-default (level) | |
9239 (if level (prefix-numeric-value level) | |
9240 gnus-score-interactive-default-score)) | |
9241 | |
9242 (defun gnus-summary-raise-thread (&optional score) | |
9243 "Raise the score of the articles in the current thread with SCORE." | |
9244 (interactive "P") | |
9245 (setq score (gnus-score-default score)) | |
9246 (let (e) | |
9247 (save-excursion | |
9248 (let ((level (gnus-summary-thread-level))) | |
9249 (gnus-summary-raise-score score) | |
9250 (while (and (zerop (gnus-summary-next-subject 1 nil t)) | |
9251 (> (gnus-summary-thread-level) level)) | |
9252 (gnus-summary-raise-score score)) | |
9253 (setq e (point)))) | |
9254 (let ((gnus-summary-check-current t)) | |
9255 (or (zerop (gnus-summary-next-subject 1 t)) | |
9256 (goto-char e)))) | |
9257 (gnus-summary-recenter) | |
9258 (gnus-summary-position-cursor) | |
9259 (gnus-set-mode-line 'summary)) | |
9260 | |
9261 (defun gnus-summary-lower-same-subject-and-select (score) | |
9262 "Raise articles which has the same subject with SCORE and select the next." | |
9263 (interactive "p") | |
9264 (gnus-summary-raise-same-subject-and-select (- score))) | |
9265 | |
9266 (defun gnus-summary-lower-same-subject (score) | |
9267 "Raise articles which has the same subject with SCORE." | |
9268 (interactive "p") | |
9269 (gnus-summary-raise-same-subject (- score))) | |
9270 | |
9271 (defun gnus-summary-lower-thread (&optional score) | |
9272 "Lower score of articles in the current thread with SCORE." | |
9273 (interactive "P") | |
9274 (gnus-summary-raise-thread (- (1- (gnus-score-default score))))) | |
9275 | |
9276 (defun gnus-summary-kill-same-subject-and-select (&optional unmark) | |
9277 "Mark articles which has the same subject as read, and then select the next. | |
9278 If UNMARK is positive, remove any kind of mark. | |
9279 If UNMARK is negative, tick articles." | |
9280 (interactive "P") | |
9281 (if unmark | |
9282 (setq unmark (prefix-numeric-value unmark))) | |
9283 (let ((count | |
9284 (gnus-summary-mark-same-subject | |
9285 (gnus-summary-subject-string) unmark))) | |
9286 ;; Select next unread article. If auto-select-same mode, should | |
9287 ;; select the first unread article. | |
9288 (gnus-summary-next-article t (and gnus-auto-select-same | |
9289 (gnus-summary-subject-string))) | |
9290 (gnus-message 7 "%d article%s marked as %s" | |
9291 count (if (= count 1) " is" "s are") | |
9292 (if unmark "unread" "read")))) | |
9293 | |
9294 (defun gnus-summary-kill-same-subject (&optional unmark) | |
9295 "Mark articles which has the same subject as read. | |
9296 If UNMARK is positive, remove any kind of mark. | |
9297 If UNMARK is negative, tick articles." | |
9298 (interactive "P") | |
9299 (if unmark | |
9300 (setq unmark (prefix-numeric-value unmark))) | |
9301 (let ((count | |
9302 (gnus-summary-mark-same-subject | |
9303 (gnus-summary-subject-string) unmark))) | |
9304 ;; If marked as read, go to next unread subject. | |
9305 (if (null unmark) | |
9306 ;; Go to next unread subject. | |
9307 (gnus-summary-next-subject 1 t)) | |
9308 (gnus-message 7 "%d articles are marked as %s" | |
9309 count (if unmark "unread" "read")))) | |
9310 | |
9311 (defun gnus-summary-mark-same-subject (subject &optional unmark) | |
9312 "Mark articles with same SUBJECT as read, and return marked number. | |
9313 If optional argument UNMARK is positive, remove any kinds of marks. | |
9314 If optional argument UNMARK is negative, mark articles as unread instead." | |
9315 (let ((count 1)) | |
9316 (save-excursion | |
9317 (cond | |
9318 ((null unmark) ; Mark as read. | |
9319 (while (and | |
9320 (progn | |
9321 (gnus-summary-mark-article-as-read gnus-killed-mark) | |
9322 (gnus-summary-show-thread) t) | |
9323 (gnus-summary-search-forward nil subject)) | |
9324 (setq count (1+ count)))) | |
9325 ((> unmark 0) ; Tick. | |
9326 (while (and | |
9327 (progn | |
9328 (gnus-summary-mark-article-as-unread gnus-ticked-mark) | |
9329 (gnus-summary-show-thread) t) | |
9330 (gnus-summary-search-forward nil subject)) | |
9331 (setq count (1+ count)))) | |
9332 (t ; Mark as unread. | |
9333 (while (and | |
9334 (progn | |
9335 (gnus-summary-mark-article-as-unread gnus-unread-mark) | |
9336 (gnus-summary-show-thread) t) | |
9337 (gnus-summary-search-forward nil subject)) | |
9338 (setq count (1+ count))))) | |
9339 (gnus-set-mode-line 'summary) | |
9340 ;; Return the number of marked articles. | |
9341 count))) | |
9342 | |
9343 (defun gnus-summary-mark-as-processable (n &optional unmark) | |
9344 "Set the process mark on the next N articles. | |
9345 If N is negative, mark backward instead. If UNMARK is non-nil, remove | |
9346 the process mark instead. The difference between N and the actual | |
9347 number of articles marked is returned." | |
9348 (interactive "p") | |
9349 (let ((backward (< n 0)) | |
9350 (n (abs n))) | |
9351 (while (and | |
9352 (> n 0) | |
9353 (if unmark | |
9354 (gnus-summary-remove-process-mark | |
9355 (gnus-summary-article-number)) | |
9356 (gnus-summary-set-process-mark (gnus-summary-article-number))) | |
9357 (zerop (gnus-summary-next-subject (if backward -1 1) nil t))) | |
9358 (setq n (1- n))) | |
9359 (if (/= 0 n) (gnus-message 7 "No more articles")) | |
9360 (gnus-summary-recenter) | |
9361 (gnus-summary-position-cursor) | |
9362 n)) | |
9363 | |
9364 (defun gnus-summary-unmark-as-processable (n) | |
9365 "Remove the process mark from the next N articles. | |
9366 If N is negative, mark backward instead. The difference between N and | |
9367 the actual number of articles marked is returned." | |
9368 (interactive "p") | |
9369 (gnus-summary-mark-as-processable n t)) | |
9370 | |
9371 (defun gnus-summary-unmark-all-processable () | |
9372 "Remove the process mark from all articles." | |
9373 (interactive) | |
9374 (save-excursion | |
9375 (while gnus-newsgroup-processable | |
9376 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable)))) | |
9377 (gnus-summary-position-cursor)) | |
9378 | |
9379 (defun gnus-summary-mark-as-expirable (n) | |
9380 "Mark N articles forward as expirable. | |
9381 If N is negative, mark backward instead. The difference between N and | |
9382 the actual number of articles marked is returned." | |
9383 (interactive "p") | |
9384 (gnus-summary-mark-forward n gnus-expirable-mark)) | |
9385 | |
9386 (defun gnus-summary-mark-article-as-replied (article) | |
9387 "Mark ARTICLE replied and update the summary line." | |
9388 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied)) | |
9389 (let ((buffer-read-only nil)) | |
9390 (if (gnus-summary-goto-subject article) | |
9391 (progn | |
9392 (gnus-summary-update-mark gnus-replied-mark 'replied) | |
9393 t)))) | |
9394 | |
9395 (defun gnus-summary-set-bookmark (article) | |
9396 "Set a bookmark in current article." | |
9397 (interactive (list (gnus-summary-article-number))) | |
9398 (if (or (not (get-buffer gnus-article-buffer)) | |
9399 (not gnus-current-article) | |
9400 (not gnus-article-current) | |
9401 (not (equal gnus-newsgroup-name (car gnus-article-current)))) | |
9402 (error "No current article selected")) | |
9403 ;; Remove old bookmark, if one exists. | |
9404 (let ((old (assq article gnus-newsgroup-bookmarks))) | |
9405 (if old (setq gnus-newsgroup-bookmarks | |
9406 (delq old gnus-newsgroup-bookmarks)))) | |
9407 ;; Set the new bookmark, which is on the form | |
9408 ;; (article-number . line-number-in-body). | |
9409 (setq gnus-newsgroup-bookmarks | |
9410 (cons | |
9411 (cons article | |
9412 (save-excursion | |
9413 (set-buffer gnus-article-buffer) | |
9414 (count-lines | |
9415 (min (point) | |
9416 (save-excursion | |
9417 (goto-char (point-min)) | |
9418 (search-forward "\n\n" nil t) | |
9419 (point))) | |
9420 (point)))) | |
9421 gnus-newsgroup-bookmarks)) | |
9422 (gnus-message 6 "A bookmark has been added to the current article.")) | |
9423 | |
9424 (defun gnus-summary-remove-bookmark (article) | |
9425 "Remove the bookmark from the current article." | |
9426 (interactive (list (gnus-summary-article-number))) | |
9427 ;; Remove old bookmark, if one exists. | |
9428 (let ((old (assq article gnus-newsgroup-bookmarks))) | |
9429 (if old | |
9430 (progn | |
9431 (setq gnus-newsgroup-bookmarks | |
9432 (delq old gnus-newsgroup-bookmarks)) | |
9433 (gnus-message 6 "Removed bookmark.")) | |
9434 (gnus-message 6 "No bookmark in current article.")))) | |
9435 | |
9436 ;; Suggested by Daniel Quinlan <quinlan@best.com>. | |
9437 (defun gnus-summary-mark-as-dormant (n) | |
9438 "Mark N articles forward as dormant. | |
9439 If N is negative, mark backward instead. The difference between N and | |
9440 the actual number of articles marked is returned." | |
9441 (interactive "p") | |
9442 (gnus-summary-mark-forward n gnus-dormant-mark)) | |
9443 | |
9444 (defun gnus-summary-set-process-mark (article) | |
9445 "Set the process mark on ARTICLE and update the summary line." | |
13694
73433c3071a5
* gnus.el (gnus-parse-headers-hook): New hook.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
13579
diff
changeset
|
9446 (setq gnus-newsgroup-processable |
73433c3071a5
* gnus.el (gnus-parse-headers-hook): New hook.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
13579
diff
changeset
|
9447 (cons article |
73433c3071a5
* gnus.el (gnus-parse-headers-hook): New hook.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
13579
diff
changeset
|
9448 (delq article gnus-newsgroup-processable))) |
13401 | 9449 (let ((buffer-read-only nil)) |
9450 (if (gnus-summary-goto-subject article) | |
9451 (progn | |
9452 (gnus-summary-show-thread) | |
9453 (and (eq (gnus-summary-article-mark) gnus-dummy-mark) | |
9454 (forward-line 1)) | |
9455 (gnus-summary-update-mark gnus-process-mark 'replied) | |
9456 t)))) | |
9457 | |
9458 (defun gnus-summary-remove-process-mark (article) | |
9459 "Remove the process mark from ARTICLE and update the summary line." | |
9460 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable)) | |
9461 (let ((buffer-read-only nil)) | |
9462 (if (gnus-summary-goto-subject article) | |
9463 (progn | |
9464 (gnus-summary-show-thread) | |
9465 (and (eq (gnus-summary-article-mark) gnus-dummy-mark) | |
9466 (forward-line 1)) | |
9467 (gnus-summary-update-mark ? 'replied) | |
9468 (if (memq article gnus-newsgroup-replied) | |
9469 (gnus-summary-update-mark gnus-replied-mark 'replied)) | |
9470 t)))) | |
9471 | |
9472 (defun gnus-summary-mark-forward (n &optional mark no-expire) | |
9473 "Mark N articles as read forwards. | |
9474 If N is negative, mark backwards instead. | |
9475 Mark with MARK. If MARK is ? , ?! or ??, articles will be | |
9476 marked as unread. | |
9477 The difference between N and the actual number of articles marked is | |
9478 returned." | |
9479 (interactive "p") | |
9480 (gnus-set-global-variables) | |
9481 (let ((backward (< n 0)) | |
9482 (gnus-summary-goto-unread | |
9483 (and gnus-summary-goto-unread | |
9484 (not (memq mark (list gnus-unread-mark | |
9485 gnus-ticked-mark gnus-dormant-mark))))) | |
9486 (n (abs n)) | |
9487 (mark (or mark gnus-del-mark))) | |
9488 (while (and (> n 0) | |
9489 (gnus-summary-mark-article nil mark no-expire) | |
9490 (zerop (gnus-summary-next-subject | |
9491 (if backward -1 1) gnus-summary-goto-unread t))) | |
9492 (setq n (1- n))) | |
9493 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread "))) | |
9494 (gnus-summary-recenter) | |
9495 (gnus-summary-position-cursor) | |
9496 (gnus-set-mode-line 'summary) | |
9497 n)) | |
9498 | |
9499 (defun gnus-summary-mark-article-as-read (mark) | |
9500 "Mark the current article quickly as read with MARK." | |
9501 (let ((article (gnus-summary-article-number))) | |
9502 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads)) | |
9503 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)) | |
9504 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)) | |
9505 (setq gnus-newsgroup-reads | |
9506 (cons (cons article mark) gnus-newsgroup-reads)) | |
9507 ;; Possibly remove from cache, if that is used. | |
9508 (and gnus-use-cache (gnus-cache-enter-remove-article article)) | |
9509 (and gnus-newsgroup-auto-expire | |
9510 (or (= mark gnus-killed-mark) (= mark gnus-del-mark) | |
9511 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark) | |
9512 (= mark gnus-read-mark)) | |
9513 (progn | |
9514 (setq mark gnus-expirable-mark) | |
9515 (setq gnus-newsgroup-expirable | |
9516 (cons article gnus-newsgroup-expirable)))) | |
9517 (while (eq (gnus-summary-article-mark) gnus-dummy-mark) | |
9518 (forward-line 1)) | |
9519 ;; Fix the mark. | |
9520 (gnus-summary-update-mark mark 'unread) | |
9521 t)) | |
9522 | |
9523 (defun gnus-summary-mark-article-as-unread (mark) | |
9524 "Mark the current article quickly as unread with MARK." | |
9525 (let ((article (gnus-summary-article-number))) | |
9526 (or (memq article gnus-newsgroup-unreads) | |
9527 (setq gnus-newsgroup-unreads (cons article gnus-newsgroup-unreads))) | |
9528 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)) | |
9529 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)) | |
9530 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)) | |
9531 (setq gnus-newsgroup-reads | |
9532 (delq (assq article gnus-newsgroup-reads) | |
9533 gnus-newsgroup-reads)) | |
9534 (if (= mark gnus-ticked-mark) | |
9535 (setq gnus-newsgroup-marked (cons article gnus-newsgroup-marked))) | |
9536 (if (= mark gnus-dormant-mark) | |
9537 (setq gnus-newsgroup-dormant (cons article gnus-newsgroup-dormant))) | |
9538 | |
9539 ;; See whether the article is to be put in the cache. | |
9540 (and gnus-use-cache | |
9541 (vectorp (gnus-get-header-by-num article)) | |
9542 (save-excursion | |
9543 (gnus-cache-possibly-enter-article | |
9544 gnus-newsgroup-name article | |
9545 (gnus-get-header-by-num article) | |
9546 (= mark gnus-ticked-mark) | |
9547 (= mark gnus-dormant-mark) (= mark gnus-unread-mark)))) | |
9548 | |
9549 (while (eq (gnus-summary-article-mark) gnus-dummy-mark) | |
9550 (forward-line 1)) | |
9551 ;; Fix the mark. | |
9552 (gnus-summary-update-mark mark 'unread) | |
9553 t)) | |
9554 | |
9555 (defun gnus-summary-mark-article (&optional article mark no-expire) | |
9556 "Mark ARTICLE with MARK. MARK can be any character. | |
9557 Four MARK strings are reserved: `? ' (unread), `?!' (ticked), `??' | |
9558 (dormant) and `?E' (expirable). | |
9559 If MARK is nil, then the default character `?D' is used. | |
9560 If ARTICLE is nil, then the article on the current line will be | |
9561 marked." | |
9562 (and (stringp mark) | |
9563 (setq mark (aref mark 0))) | |
9564 ;; If no mark is given, then we check auto-expiring. | |
9565 (and (not no-expire) | |
9566 gnus-newsgroup-auto-expire | |
9567 (or (not mark) | |
9568 (and (numberp mark) | |
9569 (or (= mark gnus-killed-mark) (= mark gnus-del-mark) | |
9570 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark) | |
9571 (= mark gnus-read-mark)))) | |
9572 (setq mark gnus-expirable-mark)) | |
9573 (let* ((mark (or mark gnus-del-mark)) | |
9574 (article (or article (gnus-summary-article-number)))) | |
9575 (or article (error "No article on current line")) | |
9576 (if (or (= mark gnus-unread-mark) | |
9577 (= mark gnus-ticked-mark) | |
9578 (= mark gnus-dormant-mark)) | |
9579 (gnus-mark-article-as-unread article mark) | |
9580 (gnus-mark-article-as-read article mark)) | |
9581 | |
9582 ;; See whether the article is to be put in the cache. | |
9583 (and gnus-use-cache | |
9584 (not (= mark gnus-canceled-mark)) | |
9585 (vectorp (gnus-get-header-by-num article)) | |
9586 (save-excursion | |
9587 (gnus-cache-possibly-enter-article | |
9588 gnus-newsgroup-name article | |
9589 (gnus-get-header-by-num article) | |
9590 (= mark gnus-ticked-mark) | |
9591 (= mark gnus-dormant-mark) (= mark gnus-unread-mark)))) | |
9592 | |
9593 (if (gnus-summary-goto-subject article) | |
9594 (let ((buffer-read-only nil)) | |
9595 (gnus-summary-show-thread) | |
9596 (and (eq (gnus-summary-article-mark) gnus-dummy-mark) | |
9597 (forward-line 1)) | |
9598 ;; Fix the mark. | |
9599 (gnus-summary-update-mark mark 'unread) | |
9600 t)))) | |
9601 | |
9602 (defun gnus-summary-update-mark (mark type) | |
9603 (beginning-of-line) | |
9604 (let ((forward (cdr (assq type gnus-summary-mark-positions))) | |
9605 (buffer-read-only nil) | |
9606 plist) | |
9607 (if (not forward) | |
9608 () | |
9609 (forward-char forward) | |
9610 (setq plist (text-properties-at (point))) | |
9611 (delete-char 1) | |
9612 (insert mark) | |
9613 (and plist (add-text-properties (1- (point)) (point) plist)) | |
9614 (and (eq type 'unread) | |
9615 (progn | |
9616 (add-text-properties (1- (point)) (point) (list 'gnus-mark mark)) | |
9617 (gnus-summary-update-line (eq mark gnus-unread-mark))))))) | |
9618 | |
9619 (defun gnus-mark-article-as-read (article &optional mark) | |
9620 "Enter ARTICLE in the pertinent lists and remove it from others." | |
9621 ;; Make the article expirable. | |
9622 (let ((mark (or mark gnus-del-mark))) | |
9623 (if (= mark gnus-expirable-mark) | |
9624 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable)) | |
9625 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))) | |
9626 ;; Remove from unread and marked lists. | |
9627 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads)) | |
9628 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)) | |
9629 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)) | |
9630 (setq gnus-newsgroup-reads | |
9631 (cons (cons article mark) gnus-newsgroup-reads)) | |
9632 ;; Possibly remove from cache, if that is used. | |
9633 (and gnus-use-cache (gnus-cache-enter-remove-article article)))) | |
9634 | |
9635 (defun gnus-mark-article-as-unread (article &optional mark) | |
9636 "Enter ARTICLE in the pertinent lists and remove it from others." | |
9637 (let ((mark (or mark gnus-ticked-mark))) | |
9638 ;; Add to unread list. | |
9639 (or (memq article gnus-newsgroup-unreads) | |
9640 (setq gnus-newsgroup-unreads (cons article gnus-newsgroup-unreads))) | |
9641 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)) | |
9642 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)) | |
9643 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)) | |
9644 (setq gnus-newsgroup-reads | |
9645 (delq (assq article gnus-newsgroup-reads) | |
9646 gnus-newsgroup-reads)) | |
9647 (if (= mark gnus-ticked-mark) | |
9648 (setq gnus-newsgroup-marked (cons article gnus-newsgroup-marked))) | |
9649 (if (= mark gnus-dormant-mark) | |
9650 (setq gnus-newsgroup-dormant (cons article gnus-newsgroup-dormant))))) | |
9651 | |
9652 (defalias 'gnus-summary-mark-as-unread-forward | |
9653 'gnus-summary-tick-article-forward) | |
9654 (make-obsolete 'gnus-summary-mark-as-unread-forward | |
9655 'gnus-summary-tick-article-forward) | |
9656 (defun gnus-summary-tick-article-forward (n) | |
9657 "Tick N articles forwards. | |
9658 If N is negative, tick backwards instead. | |
9659 The difference between N and the number of articles ticked is returned." | |
9660 (interactive "p") | |
9661 (gnus-summary-mark-forward n gnus-ticked-mark)) | |
9662 | |
9663 (defalias 'gnus-summary-mark-as-unread-backward | |
9664 'gnus-summary-tick-article-backward) | |
9665 (make-obsolete 'gnus-summary-mark-as-unread-backward | |
9666 'gnus-summary-tick-article-backward) | |
9667 (defun gnus-summary-tick-article-backward (n) | |
9668 "Tick N articles backwards. | |
9669 The difference between N and the number of articles ticked is returned." | |
9670 (interactive "p") | |
9671 (gnus-summary-mark-forward (- n) gnus-ticked-mark)) | |
9672 | |
9673 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article) | |
9674 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article) | |
9675 (defun gnus-summary-tick-article (&optional article clear-mark) | |
9676 "Mark current article as unread. | |
9677 Optional 1st argument ARTICLE specifies article number to be marked as unread. | |
9678 Optional 2nd argument CLEAR-MARK remove any kinds of mark." | |
9679 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark | |
9680 gnus-ticked-mark))) | |
9681 | |
9682 (defun gnus-summary-mark-as-read-forward (n) | |
9683 "Mark N articles as read forwards. | |
9684 If N is negative, mark backwards instead. | |
9685 The difference between N and the actual number of articles marked is | |
9686 returned." | |
9687 (interactive "p") | |
9688 (gnus-summary-mark-forward n gnus-del-mark t)) | |
9689 | |
9690 (defun gnus-summary-mark-as-read-backward (n) | |
9691 "Mark the N articles as read backwards. | |
9692 The difference between N and the actual number of articles marked is | |
9693 returned." | |
9694 (interactive "p") | |
9695 (gnus-summary-mark-forward (- n) gnus-del-mark t)) | |
9696 | |
9697 (defun gnus-summary-mark-as-read (&optional article mark) | |
9698 "Mark current article as read. | |
9699 ARTICLE specifies the article to be marked as read. | |
9700 MARK specifies a string to be inserted at the beginning of the line." | |
9701 (gnus-summary-mark-article article mark)) | |
9702 | |
9703 (defun gnus-summary-clear-mark-forward (n) | |
9704 "Clear marks from N articles forward. | |
9705 If N is negative, clear backward instead. | |
9706 The difference between N and the number of marks cleared is returned." | |
9707 (interactive "p") | |
9708 (gnus-summary-mark-forward n gnus-unread-mark)) | |
9709 | |
9710 (defun gnus-summary-clear-mark-backward (n) | |
9711 "Clear marks from N articles backward. | |
9712 The difference between N and the number of marks cleared is returned." | |
9713 (interactive "p") | |
9714 (gnus-summary-mark-forward (- n) gnus-unread-mark)) | |
9715 | |
9716 (defun gnus-summary-mark-unread-as-read () | |
9717 "Intended to be used by `gnus-summary-mark-article-hook'." | |
9718 (or (memq gnus-current-article gnus-newsgroup-marked) | |
9719 (memq gnus-current-article gnus-newsgroup-dormant) | |
9720 (memq gnus-current-article gnus-newsgroup-expirable) | |
9721 (gnus-summary-mark-article gnus-current-article gnus-read-mark))) | |
9722 | |
9723 (defun gnus-summary-mark-region-as-read (point mark all) | |
9724 "Mark all unread articles between point and mark as read. | |
9725 If given a prefix, mark all articles between point and mark as read, | |
9726 even ticked and dormant ones." | |
9727 (interactive "r\nP") | |
9728 (save-excursion | |
9729 (goto-char point) | |
9730 (beginning-of-line) | |
9731 (while (and | |
9732 (< (point) mark) | |
9733 (progn | |
9734 (and | |
9735 (or all | |
9736 (and | |
9737 (not (memq (gnus-summary-article-number) | |
9738 gnus-newsgroup-marked)) | |
9739 (not (memq (gnus-summary-article-number) | |
9740 gnus-newsgroup-dormant)))) | |
9741 (gnus-summary-mark-article | |
9742 (gnus-summary-article-number) gnus-del-mark)) | |
9743 t) | |
9744 (zerop (forward-line 1)))))) | |
9745 | |
9746 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>. | |
9747 (defalias 'gnus-summary-delete-marked-as-read | |
9748 'gnus-summary-remove-lines-marked-as-read) | |
9749 (make-obsolete 'gnus-summary-delete-marked-as-read | |
9750 'gnus-summary-remove-lines-marked-as-read) | |
9751 (defun gnus-summary-remove-lines-marked-as-read () | |
9752 "Remove lines that are marked as read." | |
9753 (interactive) | |
9754 (gnus-summary-remove-lines-marked-with | |
9755 (concat (mapconcat | |
9756 (lambda (char) (char-to-string (symbol-value char))) | |
9757 '(gnus-del-mark gnus-read-mark gnus-ancient-mark | |
9758 gnus-killed-mark gnus-kill-file-mark | |
9759 gnus-low-score-mark gnus-expirable-mark | |
9760 gnus-canceled-mark gnus-catchup-mark) | |
9761 "")))) | |
9762 | |
9763 (defalias 'gnus-summary-delete-marked-with | |
9764 'gnus-summary-remove-lines-marked-with) | |
9765 (make-obsolete 'gnus-summary-delete-marked-with | |
9766 'gnus-summary-remove-lines-marked-with) | |
9767 ;; Rewrite by Daniel Quinlan <quinlan@best.com>. | |
9768 (defun gnus-summary-remove-lines-marked-with (marks) | |
9769 "Remove lines that are marked with MARKS (e.g. \"DK\")." | |
9770 (interactive "sMarks: ") | |
9771 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>. | |
9772 (gnus-set-global-variables) | |
9773 (let ((buffer-read-only nil) | |
13694
73433c3071a5
* gnus.el (gnus-parse-headers-hook): New hook.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
13579
diff
changeset
|
9774 (orig-article |
73433c3071a5
* gnus.el (gnus-parse-headers-hook): New hook.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
13579
diff
changeset
|
9775 (progn |
73433c3071a5
* gnus.el (gnus-parse-headers-hook): New hook.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
13579
diff
changeset
|
9776 (gnus-summary-search-forward t) |
73433c3071a5
* gnus.el (gnus-parse-headers-hook): New hook.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
13579
diff
changeset
|
9777 (gnus-summary-article-number))) |
13401 | 9778 (marks (concat "^[" marks "]"))) |
9779 (goto-char (point-min)) | |
9780 (if gnus-newsgroup-adaptive | |
9781 (gnus-score-remove-lines-adaptive marks) | |
9782 (while (re-search-forward marks nil t) | |
9783 (gnus-delete-line))) | |
9784 ;; If we use dummy roots, we have to do an additional sweep over | |
9785 ;; the buffer. | |
9786 (if (not (eq gnus-summary-make-false-root 'dummy)) | |
9787 () | |
9788 (goto-char (point-min)) | |
9789 (setq marks (concat "^[" (char-to-string gnus-dummy-mark) "]")) | |
9790 (while (re-search-forward marks nil t) | |
9791 (if (gnus-subject-equal | |
9792 (gnus-summary-subject-string) | |
9793 (progn | |
9794 (forward-line 1) | |
9795 (gnus-summary-subject-string))) | |
9796 () | |
9797 (forward-line -1) | |
9798 (gnus-delete-line)))) | |
9799 (or (zerop (buffer-size)) | |
9800 (gnus-summary-goto-subject orig-article) | |
9801 (if (eobp) | |
9802 (gnus-summary-prev-subject 1) | |
9803 (gnus-summary-position-cursor))))) | |
9804 | |
9805 (defun gnus-summary-expunge-below (&optional score) | |
9806 "Remove articles with score less than SCORE." | |
9807 (interactive "P") | |
9808 (gnus-set-global-variables) | |
9809 (setq score (if score | |
9810 (prefix-numeric-value score) | |
9811 (or gnus-summary-default-score 0))) | |
9812 (save-excursion | |
9813 (set-buffer gnus-summary-buffer) | |
9814 (goto-char (point-min)) | |
9815 (let ((buffer-read-only nil) | |
9816 beg) | |
9817 (while (not (eobp)) | |
9818 (if (< (gnus-summary-article-score) score) | |
9819 (progn | |
9820 (setq beg (point)) | |
9821 (forward-line 1) | |
9822 (delete-region beg (point))) | |
9823 (forward-line 1))) | |
9824 ;; Adjust point. | |
9825 (or (zerop (buffer-size)) | |
9826 (if (eobp) | |
9827 (gnus-summary-prev-subject 1) | |
9828 (gnus-summary-position-cursor)))))) | |
9829 | |
9830 (defun gnus-summary-mark-below (score mark) | |
9831 "Mark articles with score less than SCORE with MARK." | |
9832 (interactive "P\ncMark: ") | |
9833 (gnus-set-global-variables) | |
9834 (setq score (if score | |
9835 (prefix-numeric-value score) | |
9836 (or gnus-summary-default-score 0))) | |
9837 (save-excursion | |
9838 (set-buffer gnus-summary-buffer) | |
9839 (goto-char (point-min)) | |
9840 (while (not (eobp)) | |
9841 (and (< (gnus-summary-article-score) score) | |
9842 (gnus-summary-mark-article nil mark)) | |
9843 (forward-line 1)))) | |
9844 | |
9845 (defun gnus-summary-kill-below (&optional score) | |
9846 "Mark articles with score below SCORE as read." | |
9847 (interactive "P") | |
9848 (gnus-set-global-variables) | |
9849 (gnus-summary-mark-below score gnus-killed-mark)) | |
9850 | |
9851 (defun gnus-summary-clear-above (&optional score) | |
9852 "Clear all marks from articles with score above SCORE." | |
9853 (interactive "P") | |
9854 (gnus-set-global-variables) | |
9855 (gnus-summary-mark-above score gnus-unread-mark)) | |
9856 | |
9857 (defun gnus-summary-tick-above (&optional score) | |
9858 "Tick all articles with score above SCORE." | |
9859 (interactive "P") | |
9860 (gnus-set-global-variables) | |
9861 (gnus-summary-mark-above score gnus-ticked-mark)) | |
9862 | |
9863 (defun gnus-summary-mark-above (score mark) | |
9864 "Mark articles with score over SCORE with MARK." | |
9865 (interactive "P\ncMark: ") | |
9866 (gnus-set-global-variables) | |
9867 (setq score (if score | |
9868 (prefix-numeric-value score) | |
9869 (or gnus-summary-default-score 0))) | |
9870 (save-excursion | |
9871 (set-buffer gnus-summary-buffer) | |
9872 (goto-char (point-min)) | |
9873 (while (not (eobp)) | |
9874 (if (> (gnus-summary-article-score) score) | |
9875 (progn | |
9876 (gnus-summary-mark-article nil mark) | |
9877 (forward-line 1)) | |
9878 (forward-line 1))))) | |
9879 | |
9880 ;; Suggested by Daniel Quinlan <quinlan@best.com>. | |
9881 (defun gnus-summary-show-all-expunged () | |
9882 "Display all the hidden articles that were expunged for low scores." | |
9883 (interactive) | |
9884 (gnus-set-global-variables) | |
9885 (let ((buffer-read-only nil)) | |
9886 (let ((scored gnus-newsgroup-scored) | |
9887 headers h) | |
9888 (while scored | |
9889 (or (gnus-summary-goto-subject (car (car scored))) | |
9890 (and (setq h (gnus-get-header-by-num (car (car scored)))) | |
9891 (< (cdr (car scored)) gnus-summary-expunge-below) | |
9892 (setq headers (cons h headers)))) | |
9893 (setq scored (cdr scored))) | |
9894 (or headers (error "No expunged articles hidden.")) | |
9895 (goto-char (point-min)) | |
9896 (save-excursion | |
9897 (gnus-summary-update-lines | |
9898 (point) | |
9899 (progn | |
9900 (gnus-summary-prepare-unthreaded (nreverse headers)) | |
9901 (point))))) | |
9902 (goto-char (point-min)) | |
9903 (gnus-summary-position-cursor))) | |
9904 | |
9905 (defun gnus-summary-show-all-dormant () | |
9906 "Display all the hidden articles that are marked as dormant." | |
9907 (interactive) | |
9908 (gnus-set-global-variables) | |
9909 (let ((buffer-read-only nil)) | |
9910 (let ((dormant gnus-newsgroup-dormant) | |
9911 headers h) | |
9912 (while dormant | |
9913 (or (gnus-summary-goto-subject (car dormant)) | |
9914 (and (setq h (gnus-get-header-by-num (car dormant))) | |
9915 (setq headers (cons h headers)))) | |
9916 (setq dormant (cdr dormant))) | |
9917 (or headers (error "No dormant articles hidden.")) | |
9918 (goto-char (point-min)) | |
9919 (save-excursion | |
9920 (gnus-summary-update-lines | |
9921 (point) | |
9922 (progn | |
9923 (gnus-summary-prepare-unthreaded (nreverse headers)) | |
9924 (point))))) | |
9925 (goto-char (point-min)) | |
9926 (gnus-summary-position-cursor))) | |
9927 | |
9928 (defun gnus-summary-hide-all-dormant () | |
9929 "Hide all dormant articles." | |
9930 (interactive) | |
9931 (gnus-set-global-variables) | |
9932 (gnus-summary-remove-lines-marked-with (char-to-string gnus-dormant-mark)) | |
9933 (gnus-summary-position-cursor)) | |
9934 | |
9935 (defun gnus-summary-catchup (&optional all quietly to-here not-mark) | |
9936 "Mark all articles not marked as unread in this newsgroup as read. | |
9937 If prefix argument ALL is non-nil, all articles are marked as read. | |
9938 If QUIETLY is non-nil, no questions will be asked. | |
9939 If TO-HERE is non-nil, it should be a point in the buffer. All | |
9940 articles before this point will be marked as read. | |
9941 The number of articles marked as read is returned." | |
9942 (interactive "P") | |
9943 (gnus-set-global-variables) | |
9944 (prog1 | |
9945 (if (or quietly | |
9946 (not gnus-interactive-catchup) ;Without confirmation? | |
9947 gnus-expert-user | |
9948 (gnus-y-or-n-p | |
9949 (if all | |
9950 "Mark absolutely all articles as read? " | |
9951 "Mark all unread articles as read? "))) | |
9952 (if (and not-mark | |
9953 (not gnus-newsgroup-adaptive) | |
9954 (not gnus-newsgroup-auto-expire)) | |
9955 (progn | |
9956 (and all (setq gnus-newsgroup-marked nil | |
9957 gnus-newsgroup-dormant nil)) | |
9958 (setq gnus-newsgroup-unreads | |
9959 (append gnus-newsgroup-marked gnus-newsgroup-dormant))) | |
9960 ;; We actually mark all articles as canceled, which we | |
9961 ;; have to do when using auto-expiry or adaptive scoring. | |
9962 (gnus-summary-show-all-threads) | |
9963 (if (gnus-summary-first-subject (not all)) | |
9964 (while (and | |
9965 (if to-here (< (point) to-here) t) | |
9966 (gnus-summary-mark-article-as-read gnus-catchup-mark) | |
9967 (gnus-summary-search-subject nil (not all))))) | |
9968 (or to-here | |
9969 (setq gnus-newsgroup-unreads | |
9970 (append gnus-newsgroup-marked | |
9971 gnus-newsgroup-dormant))))) | |
9972 (let ((method (gnus-find-method-for-group gnus-newsgroup-name))) | |
9973 (if (and (not to-here) (eq 'nnvirtual (car method))) | |
9974 (nnvirtual-catchup-group | |
9975 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all))) | |
9976 (gnus-summary-position-cursor))) | |
9977 | |
9978 (defun gnus-summary-catchup-to-here (&optional all) | |
9979 "Mark all unticked articles before the current one as read. | |
9980 If ALL is non-nil, also mark ticked and dormant articles as read." | |
9981 (interactive "P") | |
9982 (gnus-set-global-variables) | |
9983 (save-excursion | |
9984 (and (zerop (forward-line -1)) | |
9985 (progn | |
9986 (end-of-line) | |
9987 (gnus-summary-catchup all t (point)) | |
9988 (gnus-set-mode-line 'summary)))) | |
9989 (gnus-summary-position-cursor)) | |
9990 | |
9991 (defun gnus-summary-catchup-all (&optional quietly) | |
9992 "Mark all articles in this newsgroup as read." | |
9993 (interactive "P") | |
9994 (gnus-set-global-variables) | |
9995 (gnus-summary-catchup t quietly)) | |
9996 | |
9997 (defun gnus-summary-catchup-and-exit (&optional all quietly) | |
9998 "Mark all articles not marked as unread in this newsgroup as read, then exit. | |
9999 If prefix argument ALL is non-nil, all articles are marked as read." | |
10000 (interactive "P") | |
10001 (gnus-set-global-variables) | |
10002 (gnus-summary-catchup all quietly nil 'fast) | |
10003 ;; Select next newsgroup or exit. | |
10004 (if (and (eq gnus-auto-select-next 'quietly) | |
10005 (not (gnus-ephemeral-group-p gnus-newsgroup-name))) | |
10006 (gnus-summary-next-group nil) | |
10007 (gnus-summary-exit))) | |
10008 | |
10009 (defun gnus-summary-catchup-all-and-exit (&optional quietly) | |
10010 "Mark all articles in this newsgroup as read, and then exit." | |
10011 (interactive "P") | |
10012 (gnus-set-global-variables) | |
10013 (gnus-summary-catchup-and-exit t quietly)) | |
10014 | |
10015 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>. | |
10016 (defun gnus-summary-catchup-and-goto-next-group (&optional all) | |
10017 "Mark all articles in this group as read and select the next group. | |
10018 If given a prefix, mark all articles, unread as well as ticked, as | |
10019 read." | |
10020 (interactive "P") | |
10021 (gnus-set-global-variables) | |
10022 (gnus-summary-catchup all) | |
10023 (gnus-summary-next-group)) | |
10024 | |
10025 ;; Thread-based commands. | |
10026 | |
10027 (defun gnus-summary-toggle-threads (&optional arg) | |
10028 "Toggle showing conversation threads. | |
10029 If ARG is positive number, turn showing conversation threads on." | |
10030 (interactive "P") | |
10031 (gnus-set-global-variables) | |
10032 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end))) | |
10033 (setq gnus-show-threads | |
10034 (if (null arg) (not gnus-show-threads) | |
10035 (> (prefix-numeric-value arg) 0))) | |
10036 (gnus-summary-prepare) | |
10037 (gnus-summary-goto-subject current) | |
10038 (gnus-summary-position-cursor))) | |
10039 | |
10040 (defun gnus-summary-show-all-threads () | |
10041 "Show all threads." | |
10042 (interactive) | |
10043 (gnus-set-global-variables) | |
10044 (save-excursion | |
10045 (let ((buffer-read-only nil)) | |
10046 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t))) | |
10047 (gnus-summary-position-cursor)) | |
10048 | |
10049 (defun gnus-summary-show-thread () | |
10050 "Show thread subtrees. | |
10051 Returns nil if no thread was there to be shown." | |
10052 (interactive) | |
10053 (gnus-set-global-variables) | |
10054 (let ((buffer-read-only nil) | |
10055 (orig (prog1 (point) (gnus-summary-hide-thread))) | |
10056 ;; first goto end then to beg, to have point at beg after let | |
10057 (end (progn (end-of-line) (point))) | |
10058 (beg (progn (beginning-of-line) (point)))) | |
10059 (prog1 | |
10060 ;; Any hidden lines here? | |
10061 (search-forward "\r" end t) | |
10062 (subst-char-in-region beg end ?\^M ?\n t) | |
10063 (goto-char orig) | |
10064 (gnus-summary-position-cursor)))) | |
10065 | |
10066 (defun gnus-summary-hide-all-threads () | |
10067 "Hide all thread subtrees." | |
10068 (interactive) | |
10069 (gnus-set-global-variables) | |
10070 (save-excursion | |
10071 (goto-char (point-min)) | |
10072 (gnus-summary-hide-thread) | |
10073 (while (and (not (eobp)) (zerop (forward-line 1))) | |
10074 (gnus-summary-hide-thread))) | |
10075 (gnus-summary-position-cursor)) | |
10076 | |
10077 (defun gnus-summary-hide-thread () | |
10078 "Hide thread subtrees. | |
10079 Returns nil if no threads were there to be hidden." | |
10080 (interactive) | |
10081 (gnus-set-global-variables) | |
10082 (let ((buffer-read-only nil) | |
10083 (start (point)) | |
10084 (level (gnus-summary-thread-level)) | |
10085 (end (point))) | |
10086 ;; Go forward until either the buffer ends or the subthread | |
10087 ;; ends. | |
10088 (if (eobp) | |
10089 () | |
10090 (while (and (zerop (forward-line 1)) | |
10091 (> (gnus-summary-thread-level) level)) | |
10092 (setq end (point))) | |
10093 (prog1 | |
10094 (save-excursion | |
10095 (goto-char end) | |
10096 (search-backward "\n" start t)) | |
10097 (subst-char-in-region start end ?\n ?\^M t) | |
10098 (forward-line -1) | |
10099 (gnus-summary-position-cursor))))) | |
10100 | |
10101 (defun gnus-summary-go-to-next-thread (&optional previous) | |
10102 "Go to the same level (or less) next thread. | |
10103 If PREVIOUS is non-nil, go to previous thread instead. | |
10104 Return the article number moved to, or nil if moving was impossible." | |
10105 (let ((level (gnus-summary-thread-level)) | |
10106 (article (gnus-summary-article-number))) | |
10107 (if previous | |
10108 (while (and (zerop (forward-line -1)) | |
10109 (> (gnus-summary-thread-level) level))) | |
10110 (while (and (save-excursion | |
10111 (forward-line 1) | |
10112 (not (eobp))) | |
10113 (zerop (forward-line 1)) | |
10114 (> (gnus-summary-thread-level) level)))) | |
10115 (gnus-summary-recenter) | |
10116 (gnus-summary-position-cursor) | |
10117 (let ((oart (gnus-summary-article-number))) | |
10118 (and (/= oart article) oart)))) | |
10119 | |
10120 (defun gnus-summary-next-thread (n) | |
10121 "Go to the same level next N'th thread. | |
10122 If N is negative, search backward instead. | |
10123 Returns the difference between N and the number of skips actually | |
10124 done." | |
10125 (interactive "p") | |
10126 (gnus-set-global-variables) | |
10127 (let ((backward (< n 0)) | |
10128 (n (abs n))) | |
10129 (while (and (> n 0) | |
10130 (gnus-summary-go-to-next-thread backward)) | |
10131 (setq n (1- n))) | |
10132 (gnus-summary-position-cursor) | |
10133 (if (/= 0 n) (gnus-message 7 "No more threads")) | |
10134 n)) | |
10135 | |
10136 (defun gnus-summary-prev-thread (n) | |
10137 "Go to the same level previous N'th thread. | |
10138 Returns the difference between N and the number of skips actually | |
10139 done." | |
10140 (interactive "p") | |
10141 (gnus-set-global-variables) | |
10142 (gnus-summary-next-thread (- n))) | |
10143 | |
10144 (defun gnus-summary-go-down-thread (&optional same) | |
10145 "Go down one level in the current thread. | |
10146 If SAME is non-nil, also move to articles of the same level." | |
10147 (let ((level (gnus-summary-thread-level)) | |
10148 (start (point))) | |
10149 (if (and (zerop (forward-line 1)) | |
10150 (> (gnus-summary-thread-level) level)) | |
10151 t | |
10152 (goto-char start) | |
10153 nil))) | |
10154 | |
10155 (defun gnus-summary-go-up-thread () | |
10156 "Go up one level in the current thread." | |
10157 (let ((level (gnus-summary-thread-level)) | |
10158 (start (point))) | |
10159 (while (and (zerop (forward-line -1)) | |
10160 (>= (gnus-summary-thread-level) level))) | |
10161 (if (>= (gnus-summary-thread-level) level) | |
10162 (progn | |
10163 (goto-char start) | |
10164 nil) | |
10165 t))) | |
10166 | |
10167 (defun gnus-summary-down-thread (n) | |
10168 "Go down thread N steps. | |
10169 If N is negative, go up instead. | |
10170 Returns the difference between N and how many steps down that were | |
10171 taken." | |
10172 (interactive "p") | |
10173 (gnus-set-global-variables) | |
10174 (let ((up (< n 0)) | |
10175 (n (abs n))) | |
10176 (while (and (> n 0) | |
10177 (if up (gnus-summary-go-up-thread) | |
10178 (gnus-summary-go-down-thread))) | |
10179 (setq n (1- n))) | |
10180 (gnus-summary-position-cursor) | |
10181 (if (/= 0 n) (gnus-message 7 "Can't go further")) | |
10182 n)) | |
10183 | |
10184 (defun gnus-summary-up-thread (n) | |
10185 "Go up thread N steps. | |
10186 If N is negative, go up instead. | |
10187 Returns the difference between N and how many steps down that were | |
10188 taken." | |
10189 (interactive "p") | |
10190 (gnus-set-global-variables) | |
10191 (gnus-summary-down-thread (- n))) | |
10192 | |
10193 (defun gnus-summary-kill-thread (&optional unmark) | |
10194 "Mark articles under current thread as read. | |
10195 If the prefix argument is positive, remove any kinds of marks. | |
10196 If the prefix argument is negative, tick articles instead." | |
10197 (interactive "P") | |
10198 (gnus-set-global-variables) | |
10199 (if unmark | |
10200 (setq unmark (prefix-numeric-value unmark))) | |
10201 (let ((killing t) | |
10202 (level (gnus-summary-thread-level))) | |
10203 (save-excursion | |
10204 ;; Expand the thread. | |
10205 (gnus-summary-show-thread) | |
10206 (while killing | |
10207 ;; Mark the article... | |
10208 (cond ((null unmark) (gnus-summary-mark-article-as-read | |
10209 gnus-killed-mark)) | |
10210 ((> unmark 0) (gnus-summary-mark-article-as-unread | |
10211 gnus-unread-mark)) | |
10212 (t (gnus-summary-mark-article-as-unread gnus-ticked-mark))) | |
10213 ;; ...and go forward until either the buffer ends or the subtree | |
10214 ;; ends. | |
10215 (if (not (and (zerop (forward-line 1)) | |
10216 (> (gnus-summary-thread-level) level))) | |
10217 (setq killing nil)))) | |
10218 ;; Hide killed subtrees. | |
10219 (and (null unmark) | |
10220 gnus-thread-hide-killed | |
10221 (gnus-summary-hide-thread)) | |
10222 ;; If marked as read, go to next unread subject. | |
10223 (if (null unmark) | |
10224 ;; Go to next unread subject. | |
10225 (gnus-summary-next-subject 1 t))) | |
10226 (gnus-set-mode-line 'summary)) | |
10227 | |
10228 ;; Summary sorting commands | |
10229 | |
10230 (defun gnus-summary-sort-by-number (&optional reverse) | |
10231 "Sort summary buffer by article number. | |
10232 Argument REVERSE means reverse order." | |
10233 (interactive "P") | |
10234 (gnus-set-global-variables) | |
10235 (gnus-summary-sort | |
10236 ;; `gnus-summary-article-number' is a macro, and `sort-subr' wants | |
10237 ;; a function, so we wrap it. | |
10238 (cons (lambda () (gnus-summary-article-number)) | |
10239 'gnus-thread-sort-by-number) reverse)) | |
10240 | |
10241 (defun gnus-summary-sort-by-author (&optional reverse) | |
10242 "Sort summary buffer by author name alphabetically. | |
10243 If case-fold-search is non-nil, case of letters is ignored. | |
10244 Argument REVERSE means reverse order." | |
10245 (interactive "P") | |
10246 (gnus-set-global-variables) | |
10247 (gnus-summary-sort | |
10248 (cons | |
10249 (lambda () | |
10250 (let* ((header (gnus-get-header-by-num (gnus-summary-article-number))) | |
13694
73433c3071a5
* gnus.el (gnus-parse-headers-hook): New hook.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
13579
diff
changeset
|
10251 extract) |
73433c3071a5
* gnus.el (gnus-parse-headers-hook): New hook.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
13579
diff
changeset
|
10252 (if (not (vectorp header)) |
73433c3071a5
* gnus.el (gnus-parse-headers-hook): New hook.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
13579
diff
changeset
|
10253 "" |
73433c3071a5
* gnus.el (gnus-parse-headers-hook): New hook.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
13579
diff
changeset
|
10254 (setq extract (funcall gnus-extract-address-components |
73433c3071a5
* gnus.el (gnus-parse-headers-hook): New hook.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
13579
diff
changeset
|
10255 (mail-header-from header))) |
73433c3071a5
* gnus.el (gnus-parse-headers-hook): New hook.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
13579
diff
changeset
|
10256 (concat (or (car extract) (cdr extract)) |
73433c3071a5
* gnus.el (gnus-parse-headers-hook): New hook.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
13579
diff
changeset
|
10257 "\r" (int-to-string (mail-header-number header)) |
73433c3071a5
* gnus.el (gnus-parse-headers-hook): New hook.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
13579
diff
changeset
|
10258 "\r" (mail-header-subject header))))) |
13401 | 10259 'gnus-thread-sort-by-author) |
10260 reverse)) | |
10261 | |
10262 (defun gnus-summary-sort-by-subject (&optional reverse) | |
10263 "Sort summary buffer by subject alphabetically. `Re:'s are ignored. | |
10264 If case-fold-search is non-nil, case of letters is ignored. | |
10265 Argument REVERSE means reverse order." | |
10266 (interactive "P") | |
10267 (gnus-set-global-variables) | |
10268 (gnus-summary-sort | |
10269 (cons | |
10270 (lambda () | |
10271 (let* ((header (gnus-get-header-by-num (gnus-summary-article-number))) | |
13694
73433c3071a5
* gnus.el (gnus-parse-headers-hook): New hook.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
13579
diff
changeset
|
10272 extract) |
73433c3071a5
* gnus.el (gnus-parse-headers-hook): New hook.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
13579
diff
changeset
|
10273 (if (not (vectorp header)) |
73433c3071a5
* gnus.el (gnus-parse-headers-hook): New hook.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
13579
diff
changeset
|
10274 "" |
73433c3071a5
* gnus.el (gnus-parse-headers-hook): New hook.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
13579
diff
changeset
|
10275 (setq extract (funcall gnus-extract-address-components |
73433c3071a5
* gnus.el (gnus-parse-headers-hook): New hook.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
13579
diff
changeset
|
10276 (mail-header-from header))) |
73433c3071a5
* gnus.el (gnus-parse-headers-hook): New hook.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
13579
diff
changeset
|
10277 (concat |
73433c3071a5
* gnus.el (gnus-parse-headers-hook): New hook.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
13579
diff
changeset
|
10278 (downcase (gnus-simplify-subject (gnus-summary-subject-string) t)) |
73433c3071a5
* gnus.el (gnus-parse-headers-hook): New hook.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
13579
diff
changeset
|
10279 "\r" (int-to-string (mail-header-number header)) |
73433c3071a5
* gnus.el (gnus-parse-headers-hook): New hook.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
13579
diff
changeset
|
10280 "\r" (or (car extract) (cdr extract)))))) |
13401 | 10281 'gnus-thread-sort-by-subject) |
10282 reverse)) | |
10283 | |
10284 (defun gnus-summary-sort-by-date (&optional reverse) | |
10285 "Sort summary buffer by date. | |
10286 Argument REVERSE means reverse order." | |
10287 (interactive "P") | |
10288 (gnus-set-global-variables) | |
10289 (gnus-summary-sort | |
10290 (cons | |
10291 (lambda () | |
10292 (gnus-sortable-date | |
10293 (mail-header-date | |
10294 (gnus-get-header-by-num (gnus-summary-article-number))))) | |
10295 'gnus-thread-sort-by-date) | |
10296 reverse)) | |
10297 | |
10298 (defun gnus-summary-sort-by-score (&optional reverse) | |
10299 "Sort summary buffer by score. | |
10300 Argument REVERSE means reverse order." | |
10301 (interactive "P") | |
10302 (gnus-set-global-variables) | |
10303 (gnus-summary-sort | |
10304 (cons (lambda () (gnus-summary-article-score)) | |
10305 'gnus-thread-sort-by-score) | |
10306 (not reverse))) | |
10307 | |
10308 (defvar gnus-summary-already-sorted nil) | |
10309 (defun gnus-summary-sort (predicate reverse) | |
10310 ;; Sort summary buffer by PREDICATE. REVERSE means reverse order. | |
10311 (if gnus-summary-already-sorted | |
10312 () | |
10313 (let (buffer-read-only) | |
10314 (if (not gnus-show-threads) | |
10315 ;; We do untreaded sorting... | |
10316 (progn | |
10317 (goto-char (point-min)) | |
10318 (sort-subr reverse 'forward-line 'end-of-line (car predicate))) | |
10319 ;; ... or we do threaded sorting. | |
10320 (let ((gnus-thread-sort-functions (list (cdr predicate))) | |
10321 (gnus-summary-prepare-hook nil) | |
10322 (gnus-summary-already-sorted nil)) | |
10323 ;; We do that by simply regenerating the threads. | |
10324 (gnus-summary-prepare) | |
10325 (and gnus-show-threads | |
10326 gnus-thread-hide-subtree | |
10327 (gnus-summary-hide-all-threads)) | |
10328 ;; If in async mode, we send some info to the backend. | |
10329 (and gnus-newsgroup-async | |
10330 (setq gnus-newsgroup-threads (nreverse gnus-newsgroup-threads)) | |
10331 (gnus-request-asynchronous | |
10332 gnus-newsgroup-name | |
10333 (if (and gnus-asynchronous-article-function | |
10334 (fboundp gnus-asynchronous-article-function)) | |
10335 (funcall gnus-asynchronous-article-function | |
10336 gnus-newsgroup-threads) | |
10337 gnus-newsgroup-threads)))))))) | |
10338 | |
10339 | |
10340 (defun gnus-sortable-date (date) | |
10341 "Make sortable string by string-lessp from DATE. | |
10342 Timezone package is used." | |
10343 (let* ((date (timezone-fix-time date nil nil)) ;[Y M D H M S] | |
10344 (year (aref date 0)) | |
10345 (month (aref date 1)) | |
10346 (day (aref date 2))) | |
10347 (timezone-make-sortable-date | |
10348 year month day | |
10349 (timezone-make-time-string | |
10350 (aref date 3) (aref date 4) (aref date 5))))) | |
10351 | |
10352 | |
10353 ;; Summary saving commands. | |
10354 | |
10355 (defun gnus-summary-save-article (&optional n) | |
10356 "Save the current article using the default saver function. | |
10357 If N is a positive number, save the N next articles. | |
10358 If N is a negative number, save the N previous articles. | |
10359 If N is nil and any articles have been marked with the process mark, | |
10360 save those articles instead. | |
10361 The variable `gnus-default-article-saver' specifies the saver function." | |
10362 (interactive "P") | |
10363 (gnus-set-global-variables) | |
10364 (let ((articles (gnus-summary-work-articles n))) | |
10365 (while articles | |
10366 (let ((header (gnus-get-header-by-num (car articles)))) | |
10367 (if (vectorp header) | |
10368 (progn | |
10369 (save-window-excursion | |
10370 (gnus-summary-select-article t nil nil (car articles))) | |
10371 (or gnus-save-all-headers | |
10372 (gnus-article-hide-headers t)) | |
10373 ;; Remove any X-Gnus lines. | |
10374 (save-excursion | |
10375 (save-restriction | |
10376 (set-buffer gnus-article-buffer) | |
10377 (let ((buffer-read-only nil)) | |
10378 (goto-char (point-min)) | |
10379 (narrow-to-region (point) (or (search-forward "\n\n" nil t) | |
10380 (point-max))) | |
10381 (while (re-search-forward "^X-Gnus" nil t) | |
10382 (beginning-of-line) | |
10383 (delete-region (point) | |
10384 (progn (forward-line 1) (point)))) | |
10385 (widen)))) | |
10386 (save-window-excursion | |
10387 (if gnus-default-article-saver | |
10388 (funcall gnus-default-article-saver) | |
10389 (error "No default saver is defined.")))) | |
10390 (if (assq 'name header) | |
10391 (gnus-copy-file (cdr (assq 'name header))) | |
10392 (gnus-message 1 "Article %d is unsaveable" (car articles))))) | |
10393 (gnus-summary-remove-process-mark (car articles)) | |
10394 (setq articles (cdr articles))) | |
10395 (gnus-summary-position-cursor) | |
10396 n)) | |
10397 | |
10398 (defun gnus-summary-pipe-output (&optional arg) | |
10399 "Pipe the current article to a subprocess. | |
10400 If N is a positive number, pipe the N next articles. | |
10401 If N is a negative number, pipe the N previous articles. | |
10402 If N is nil and any articles have been marked with the process mark, | |
10403 pipe those articles instead." | |
10404 (interactive "P") | |
10405 (gnus-set-global-variables) | |
10406 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe)) | |
10407 (gnus-summary-save-article arg))) | |
10408 | |
10409 (defun gnus-summary-save-article-mail (&optional arg) | |
10410 "Append the current article to an mail file. | |
10411 If N is a positive number, save the N next articles. | |
10412 If N is a negative number, save the N previous articles. | |
10413 If N is nil and any articles have been marked with the process mark, | |
10414 save those articles instead." | |
10415 (interactive "P") | |
10416 (gnus-set-global-variables) | |
10417 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail)) | |
10418 (gnus-summary-save-article arg))) | |
10419 | |
10420 (defun gnus-summary-save-article-rmail (&optional arg) | |
10421 "Append the current article to an rmail file. | |
10422 If N is a positive number, save the N next articles. | |
10423 If N is a negative number, save the N previous articles. | |
10424 If N is nil and any articles have been marked with the process mark, | |
10425 save those articles instead." | |
10426 (interactive "P") | |
10427 (gnus-set-global-variables) | |
10428 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail)) | |
10429 (gnus-summary-save-article arg))) | |
10430 | |
10431 (defun gnus-summary-save-article-file (&optional arg) | |
10432 "Append the current article to a file. | |
10433 If N is a positive number, save the N next articles. | |
10434 If N is a negative number, save the N previous articles. | |
10435 If N is nil and any articles have been marked with the process mark, | |
10436 save those articles instead." | |
10437 (interactive "P") | |
10438 (gnus-set-global-variables) | |
10439 (let ((gnus-default-article-saver 'gnus-summary-save-in-file)) | |
10440 (gnus-summary-save-article arg))) | |
10441 | |
10442 (defun gnus-read-save-file-name (prompt default-name) | |
10443 (let ((methods gnus-split-methods) | |
10444 split-name) | |
10445 (if (not gnus-split-methods) | |
10446 () | |
10447 (save-excursion | |
10448 (set-buffer gnus-article-buffer) | |
10449 (gnus-narrow-to-headers) | |
10450 (while methods | |
10451 (goto-char (point-min)) | |
10452 (and (condition-case () | |
10453 (re-search-forward (car (car methods)) nil t) | |
10454 (error nil)) | |
10455 (setq split-name (cons (nth 1 (car methods)) split-name))) | |
10456 (setq methods (cdr methods))) | |
10457 (widen))) | |
10458 (cond ((null split-name) | |
10459 (read-file-name | |
10460 (concat prompt " (default " | |
10461 (file-name-nondirectory default-name) ") ") | |
10462 (file-name-directory default-name) | |
10463 default-name)) | |
10464 ((= 1 (length split-name)) | |
10465 (read-file-name | |
10466 (concat prompt " (default " (car split-name) ") ") | |
10467 gnus-article-save-directory | |
10468 (concat gnus-article-save-directory (car split-name)))) | |
10469 (t | |
10470 (setq split-name (mapcar (lambda (el) (list el)) | |
10471 (nreverse split-name))) | |
10472 (let ((result (completing-read | |
10473 (concat prompt " ") | |
10474 split-name nil nil))) | |
10475 (concat gnus-article-save-directory | |
10476 (if (string= result "") | |
10477 (car (car split-name)) | |
10478 result))))))) | |
10479 | |
10480 (defun gnus-summary-save-in-rmail (&optional filename) | |
10481 "Append this article to Rmail file. | |
10482 Optional argument FILENAME specifies file name. | |
10483 Directory to save to is default to `gnus-article-save-directory' which | |
10484 is initialized from the SAVEDIR environment variable." | |
10485 (interactive) | |
10486 (gnus-set-global-variables) | |
10487 (let ((default-name | |
10488 (funcall gnus-rmail-save-name gnus-newsgroup-name | |
10489 gnus-current-headers gnus-newsgroup-last-rmail))) | |
10490 (or filename | |
10491 (setq filename (gnus-read-save-file-name | |
10492 "Save in rmail file:" default-name))) | |
10493 (gnus-make-directory (file-name-directory filename)) | |
10494 (gnus-eval-in-buffer-window | |
10495 gnus-article-buffer | |
10496 (save-excursion | |
10497 (save-restriction | |
10498 (widen) | |
10499 (gnus-output-to-rmail filename)))) | |
10500 ;; Remember the directory name to save articles | |
10501 (setq gnus-newsgroup-last-rmail filename))) | |
10502 | |
10503 (defun gnus-summary-save-in-mail (&optional filename) | |
10504 "Append this article to Unix mail file. | |
10505 Optional argument FILENAME specifies file name. | |
10506 Directory to save to is default to `gnus-article-save-directory' which | |
10507 is initialized from the SAVEDIR environment variable." | |
10508 (interactive) | |
10509 (gnus-set-global-variables) | |
10510 (let ((default-name | |
10511 (funcall gnus-mail-save-name gnus-newsgroup-name | |
10512 gnus-current-headers gnus-newsgroup-last-mail))) | |
10513 (or filename | |
10514 (setq filename (gnus-read-save-file-name | |
10515 "Save in Unix mail file:" default-name))) | |
10516 (setq filename | |
10517 (expand-file-name filename | |
10518 (and default-name | |
10519 (file-name-directory default-name)))) | |
10520 (gnus-make-directory (file-name-directory filename)) | |
10521 (gnus-eval-in-buffer-window | |
10522 gnus-article-buffer | |
10523 (save-excursion | |
10524 (save-restriction | |
10525 (widen) | |
10526 (if (and (file-readable-p filename) (mail-file-babyl-p filename)) | |
10527 (gnus-output-to-rmail filename) | |
10528 (rmail-output filename 1 t t))))) | |
10529 ;; Remember the directory name to save articles. | |
10530 (setq gnus-newsgroup-last-mail filename))) | |
10531 | |
10532 (defun gnus-summary-save-in-file (&optional filename) | |
10533 "Append this article to file. | |
10534 Optional argument FILENAME specifies file name. | |
10535 Directory to save to is default to `gnus-article-save-directory' which | |
10536 is initialized from the SAVEDIR environment variable." | |
10537 (interactive) | |
10538 (gnus-set-global-variables) | |
10539 (let ((default-name | |
10540 (funcall gnus-file-save-name gnus-newsgroup-name | |
10541 gnus-current-headers gnus-newsgroup-last-file))) | |
10542 (or filename | |
10543 (setq filename (gnus-read-save-file-name | |
10544 "Save in file:" default-name))) | |
10545 (gnus-make-directory (file-name-directory filename)) | |
10546 (gnus-eval-in-buffer-window | |
10547 gnus-article-buffer | |
10548 (save-excursion | |
10549 (save-restriction | |
10550 (widen) | |
10551 (gnus-output-to-file filename)))) | |
10552 ;; Remember the directory name to save articles. | |
10553 (setq gnus-newsgroup-last-file filename))) | |
10554 | |
10555 (defun gnus-summary-save-in-pipe (&optional command) | |
10556 "Pipe this article to subprocess." | |
10557 (interactive) | |
10558 (gnus-set-global-variables) | |
10559 (let ((command (read-string "Shell command on article: " | |
10560 gnus-last-shell-command))) | |
10561 (if (string-equal command "") | |
10562 (setq command gnus-last-shell-command)) | |
10563 (gnus-eval-in-buffer-window | |
10564 gnus-article-buffer | |
10565 (save-restriction | |
10566 (widen) | |
10567 (shell-command-on-region (point-min) (point-max) command nil))) | |
10568 (setq gnus-last-shell-command command))) | |
10569 | |
10570 ;; Summary extract commands | |
10571 | |
10572 (defun gnus-summary-insert-pseudos (pslist &optional not-view) | |
10573 (let ((buffer-read-only nil) | |
10574 (article (gnus-summary-article-number)) | |
10575 b) | |
10576 (or (gnus-summary-goto-subject article) | |
10577 (error (format "No such article: %d" article))) | |
10578 (gnus-summary-position-cursor) | |
10579 ;; If all commands are to be bunched up on one line, we collect | |
10580 ;; them here. | |
10581 (if gnus-view-pseudos-separately | |
10582 () | |
10583 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<))) | |
10584 files action) | |
10585 (while ps | |
10586 (setq action (cdr (assq 'action (car ps)))) | |
10587 (setq files (list (cdr (assq 'name (car ps))))) | |
10588 (while (and ps (cdr ps) | |
10589 (string= (or action "1") | |
10590 (or (cdr (assq 'action (car (cdr ps)))) "2"))) | |
10591 (setq files (cons (cdr (assq 'name (car (cdr ps)))) files)) | |
10592 (setcdr ps (cdr (cdr ps)))) | |
10593 (if (not files) | |
10594 () | |
10595 (if (not (string-match "%s" action)) | |
10596 (setq files (cons " " files))) | |
10597 (setq files (cons " " files)) | |
10598 (and (assq 'execute (car ps)) | |
10599 (setcdr (assq 'execute (car ps)) | |
10600 (funcall (if (string-match "%s" action) | |
10601 'format 'concat) | |
10602 action | |
10603 (mapconcat (lambda (f) f) files " "))))) | |
10604 (setq ps (cdr ps))))) | |
10605 (if (and gnus-view-pseudos (not not-view)) | |
10606 (while pslist | |
10607 (and (assq 'execute (car pslist)) | |
10608 (gnus-execute-command (cdr (assq 'execute (car pslist))) | |
10609 (eq gnus-view-pseudos 'not-confirm))) | |
10610 (setq pslist (cdr pslist))) | |
10611 (save-excursion | |
10612 (while pslist | |
10613 (gnus-summary-goto-subject (or (cdr (assq 'article (car pslist))) | |
10614 (gnus-summary-article-number))) | |
10615 (forward-line 1) | |
10616 (setq b (point)) | |
10617 (insert " " (file-name-nondirectory | |
10618 (cdr (assq 'name (car pslist)))) | |
10619 ": " (or (cdr (assq 'execute (car pslist))) "") "\n") | |
10620 (add-text-properties | |
10621 b (1+ b) (list 'gnus-number gnus-reffed-article-number | |
10622 'gnus-mark gnus-unread-mark | |
10623 'gnus-level 0 | |
10624 'gnus-pseudo (car pslist))) | |
10625 (forward-line -1) | |
10626 (gnus-sethash (int-to-string gnus-reffed-article-number) | |
10627 (car pslist) gnus-newsgroup-headers-hashtb-by-number) | |
10628 (setq gnus-newsgroup-unreads | |
10629 (cons gnus-reffed-article-number gnus-newsgroup-unreads)) | |
10630 (setq gnus-reffed-article-number (1- gnus-reffed-article-number)) | |
10631 (setq pslist (cdr pslist))))))) | |
10632 | |
10633 (defun gnus-pseudos< (p1 p2) | |
10634 (let ((c1 (cdr (assq 'action p1))) | |
10635 (c2 (cdr (assq 'action p2)))) | |
10636 (and c1 c2 (string< c1 c2)))) | |
10637 | |
10638 (defun gnus-request-pseudo-article (props) | |
10639 (cond ((assq 'execute props) | |
10640 (gnus-execute-command (cdr (assq 'execute props))))) | |
10641 (let ((gnus-current-article (gnus-summary-article-number))) | |
10642 (run-hooks 'gnus-mark-article-hook))) | |
10643 | |
10644 (defun gnus-execute-command (command &optional automatic) | |
10645 (save-excursion | |
10646 (gnus-article-setup-buffer) | |
10647 (set-buffer gnus-article-buffer) | |
10648 (let ((command (if automatic command (read-string "Command: " command))) | |
10649 (buffer-read-only nil)) | |
10650 (erase-buffer) | |
10651 (insert "$ " command "\n\n") | |
10652 (if gnus-view-pseudo-asynchronously | |
10653 (start-process "gnus-execute" nil "sh" "-c" command) | |
10654 (call-process "sh" nil t nil "-c" command))))) | |
10655 | |
10656 (defun gnus-copy-file (file &optional to) | |
10657 "Copy FILE to TO." | |
10658 (interactive | |
10659 (list (read-file-name "Copy file: " default-directory) | |
10660 (read-file-name "Copy file to: " default-directory))) | |
10661 (gnus-set-global-variables) | |
10662 (or to (setq to (read-file-name "Copy file to: " default-directory))) | |
10663 (and (file-directory-p to) | |
10664 (setq to (concat (file-name-as-directory to) | |
10665 (file-name-nondirectory file)))) | |
10666 (copy-file file to)) | |
10667 | |
10668 ;; Summary kill commands. | |
10669 | |
10670 (defun gnus-summary-edit-global-kill (article) | |
10671 "Edit the \"global\" kill file." | |
10672 (interactive (list (gnus-summary-article-number))) | |
10673 (gnus-set-global-variables) | |
10674 (gnus-group-edit-global-kill article)) | |
10675 | |
10676 (defun gnus-summary-edit-local-kill () | |
10677 "Edit a local kill file applied to the current newsgroup." | |
10678 (interactive) | |
10679 (gnus-set-global-variables) | |
10680 (setq gnus-current-headers | |
10681 (gnus-gethash | |
10682 (int-to-string (gnus-summary-article-number)) | |
10683 gnus-newsgroup-headers-hashtb-by-number)) | |
10684 (gnus-set-global-variables) | |
10685 (gnus-group-edit-local-kill | |
10686 (gnus-summary-article-number) gnus-newsgroup-name)) | |
10687 | |
10688 | |
10689 ;;; | |
10690 ;;; Gnus article mode | |
10691 ;;; | |
10692 | |
10693 (put 'gnus-article-mode 'mode-class 'special) | |
10694 | |
10695 (defvar gnus-boogaboo nil) | |
10696 | |
10697 (if gnus-article-mode-map | |
10698 nil | |
10699 (setq gnus-article-mode-map (make-keymap)) | |
10700 (suppress-keymap gnus-article-mode-map) | |
10701 (define-key gnus-article-mode-map " " 'gnus-article-next-page) | |
10702 (define-key gnus-article-mode-map "\177" 'gnus-article-prev-page) | |
10703 (define-key gnus-article-mode-map "\C-c^" 'gnus-article-refer-article) | |
10704 (define-key gnus-article-mode-map "h" 'gnus-article-show-summary) | |
10705 (define-key gnus-article-mode-map "s" 'gnus-article-show-summary) | |
10706 (define-key gnus-article-mode-map "\C-c\C-m" 'gnus-article-mail) | |
10707 (define-key gnus-article-mode-map "?" 'gnus-article-describe-briefly) | |
10708 (define-key gnus-article-mode-map gnus-mouse-2 'gnus-article-push-button) | |
10709 (define-key gnus-article-mode-map "\r" 'gnus-article-press-button) | |
10710 (define-key gnus-article-mode-map "\t" 'gnus-article-next-button) | |
10711 (define-key gnus-article-mode-map "\C-c\C-b" 'gnus-bug) | |
10712 | |
10713 ;; Duplicate almost all summary keystrokes in the article mode map. | |
10714 (let ((commands | |
10715 (list | |
10716 "p" "N" "P" "\M-\C-n" "\M-\C-p" | |
10717 "\M-n" "\M-p" "." "," "\M-s" "\M-r" "<" ">" "j" | |
10718 "u" "!" "U" "d" "D" "E" "\M-u" "\M-U" "k" "\C-k" "\M-\C-k" | |
10719 "\M-\C-l" "e" "#" "\M-#" "\M-\C-t" "\M-\C-s" "\M-\C-h" | |
10720 "\M-\C-f" "\M-\C-b" "\M-\C-u" "\M-\C-d" "&" "\C-w" | |
10721 "\C-t" "?" "\C-c\M-\C-s" "\C-c\C-s\C-n" "\C-c\C-s\C-a" | |
10722 "\C-c\C-s\C-s" "\C-c\C-s\C-d" "\C-c\C-s\C-i" "\C-x\C-s" | |
10723 "\M-g" "w" "\C-c\C-r" "\M-t" "C" | |
10724 "o" "\C-o" "|" "\M-k" "\M-K" "V" "\C-c\C-d" | |
10725 "\C-c\C-i" "x" "X" "t" "g" "?" "l" | |
10726 "\C-c\C-v\C-v" "\C-d" "v" | |
10727 ;; "Mt" "M!" "Md" "Mr" | |
10728 ;; "Mc" "M " "Me" "Mx" "M?" "Mb" "MB" "M#" "M\M-#" "M\M-r" | |
10729 ;; "M\M-\C-r" "MD" "M\M-D" "MS" "MC" "MH" "M\C-c" "Mk" "MK" | |
10730 ;; "Ms" "Mc" "Mu" "Mm" "Mk" "Gn" "Gp" "GN" "GP" "G\C-n" "G\C-p" | |
10731 ;; "G\M-n" "G\M-p" "Gf" "Gb" "Gg" "Gl" "Gp" "Tk" "Tl" "Ti" "TT" | |
10732 ;; "Ts" "TS" "Th" "TH" "Tn" "Tp" "Tu" "Td" "T#" "A " "An" "A\177" "Ap" | |
10733 ;; "A\r" "A<" "A>" "Ab" "Ae" "A^" "Ar" "Aw" "Ac" "Ag" "At" "Am" | |
10734 ;; "As" "Wh" "Ws" "Wc" "Wo" "Ww" "Wd" "Wq" "Wf" "Wt" "W\C-t" | |
10735 ;; "WT" "WA" "Wa" "WH" "WC" "WS" "Wb" "Hv" "Hf" "Hd" "Hh" "Hi" | |
10736 ;; "Be" "B\177" "Bm" "Br" "Bw" "Bc" "Bq" "Bi" "Oo" "Om" "Or" | |
10737 ;; "Of" "Oh" "Ov" "Op" "Vu" "V\C-s" "V\C-r" "Vr" "V&" "VT" "Ve" | |
10738 ;; "VD" "Vk" "VK" "Vsn" "Vsa" "Vss" "Vsd" "Vsi" | |
10739 ))) | |
10740 (while (and gnus-boogaboo commands) ; disabled | |
10741 (define-key gnus-article-mode-map (car commands) | |
10742 'gnus-article-summary-command) | |
10743 (setq commands (cdr commands)))) | |
10744 | |
10745 (let ((commands (list "q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F" | |
10746 ;; "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP" | |
10747 "=" "n" "^" "\M-^"))) | |
10748 (while (and gnus-boogaboo commands) ; disabled | |
10749 (define-key gnus-article-mode-map (car commands) | |
10750 'gnus-article-summary-command-nosave) | |
10751 (setq commands (cdr commands))))) | |
10752 | |
10753 | |
10754 (defun gnus-article-mode () | |
10755 "Major mode for displaying an article. | |
10756 | |
10757 All normal editing commands are switched off. | |
10758 | |
10759 The following commands are available: | |
10760 | |
10761 \\<gnus-article-mode-map> | |
10762 \\[gnus-article-next-page]\t Scroll the article one page forwards | |
10763 \\[gnus-article-prev-page]\t Scroll the article one page backwards | |
10764 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point | |
10765 \\[gnus-article-show-summary]\t Display the summary buffer | |
10766 \\[gnus-article-mail]\t Send a reply to the address near point | |
10767 \\[gnus-article-describe-briefly]\t Describe the current mode briefly | |
10768 \\[gnus-info-find-node]\t Go to the Gnus info node" | |
10769 (interactive) | |
10770 (if gnus-visual (gnus-article-make-menu-bar)) | |
10771 (kill-all-local-variables) | |
10772 (setq mode-line-modified "-- ") | |
10773 (make-local-variable 'mode-line-format) | |
10774 (setq mode-line-format (copy-sequence mode-line-format)) | |
10775 (and (equal (nth 3 mode-line-format) " ") | |
10776 (setcar (nthcdr 3 mode-line-format) "")) | |
10777 (setq mode-name "Article") | |
10778 (setq major-mode 'gnus-article-mode) | |
10779 (make-local-variable 'minor-mode-alist) | |
10780 (or (assq 'gnus-show-mime minor-mode-alist) | |
10781 (setq minor-mode-alist | |
10782 (cons (list 'gnus-show-mime " MIME") minor-mode-alist))) | |
10783 (use-local-map gnus-article-mode-map) | |
10784 (make-local-variable 'page-delimiter) | |
10785 (setq page-delimiter gnus-page-delimiter) | |
10786 (buffer-disable-undo (current-buffer)) | |
10787 (setq buffer-read-only t) ;Disable modification | |
10788 (run-hooks 'gnus-article-mode-hook)) | |
10789 | |
10790 (defun gnus-article-setup-buffer () | |
10791 "Initialize article mode buffer." | |
10792 ;; Returns the article buffer. | |
10793 (if (get-buffer gnus-article-buffer) | |
10794 (save-excursion | |
10795 (set-buffer gnus-article-buffer) | |
10796 (buffer-disable-undo (current-buffer)) | |
10797 (setq buffer-read-only t) | |
10798 (gnus-add-current-to-buffer-list) | |
10799 (or (eq major-mode 'gnus-article-mode) | |
10800 (gnus-article-mode)) | |
10801 (current-buffer)) | |
10802 (save-excursion | |
10803 (set-buffer (get-buffer-create gnus-article-buffer)) | |
10804 (gnus-add-current-to-buffer-list) | |
10805 (gnus-article-mode) | |
10806 (current-buffer)))) | |
10807 | |
10808 ;; Set article window start at LINE, where LINE is the number of lines | |
10809 ;; from the head of the article. | |
10810 (defun gnus-article-set-window-start (&optional line) | |
10811 (set-window-start | |
10812 (get-buffer-window gnus-article-buffer) | |
10813 (save-excursion | |
10814 (set-buffer gnus-article-buffer) | |
10815 (goto-char (point-min)) | |
10816 (if (not line) | |
10817 (point-min) | |
10818 (gnus-message 6 "Moved to bookmark") | |
10819 (search-forward "\n\n" nil t) | |
10820 (forward-line line) | |
10821 (point))))) | |
10822 | |
10823 (defun gnus-request-article-this-buffer (article group) | |
10824 "Get an article and insert it into this buffer." | |
10825 (setq group (or group gnus-newsgroup-name)) | |
10826 | |
10827 ;; Open server if it has closed. | |
10828 (gnus-check-server (gnus-find-method-for-group group)) | |
10829 | |
10830 ;; Using `gnus-request-article' directly will insert the article into | |
10831 ;; `nntp-server-buffer' - so we'll save some time by not having to | |
10832 ;; copy it from the server buffer into the article buffer. | |
10833 | |
10834 ;; We only request an article by message-id when we do not have the | |
10835 ;; headers for it, so we'll have to get those. | |
10836 (and (stringp article) | |
10837 (let ((gnus-override-method gnus-refer-article-method)) | |
10838 (gnus-read-header article))) | |
10839 | |
10840 ;; If the article number is negative, that means that this article | |
10841 ;; doesn't belong in this newsgroup (possibly), so we find its | |
10842 ;; message-id and request it by id instead of number. | |
10843 (if (not (numberp article)) | |
10844 () | |
10845 (save-excursion | |
10846 (set-buffer gnus-summary-buffer) | |
10847 (let ((header (gnus-get-header-by-num article))) | |
10848 (if (< article 0) | |
10849 (if (vectorp header) | |
10850 ;; It's a real article. | |
10851 (setq article (mail-header-id header)) | |
10852 ;; It is an extracted pseudo-article. | |
10853 (setq article 'pseudo) | |
10854 (gnus-request-pseudo-article header))) | |
10855 | |
10856 (let ((method (gnus-find-method-for-group gnus-newsgroup-name))) | |
10857 (if (not (eq (car method) 'nneething)) | |
10858 () | |
10859 (let ((dir (concat (file-name-as-directory (nth 1 method)) | |
10860 (mail-header-subject header)))) | |
10861 (if (file-directory-p dir) | |
10862 (progn | |
10863 (setq article 'nneething) | |
10864 (gnus-group-enter-directory dir))))))))) | |
10865 | |
10866 ;; Check the cache. | |
10867 (if (and gnus-use-cache | |
10868 (numberp article) | |
10869 (gnus-cache-request-article article group)) | |
10870 'article | |
10871 ;; Get the article and put into the article buffer. | |
10872 (if (or (stringp article) (numberp article)) | |
10873 (progn | |
10874 (erase-buffer) | |
10875 ;; There may be some overlays that we have to kill... | |
10876 (insert "i") | |
13694
73433c3071a5
* gnus.el (gnus-parse-headers-hook): New hook.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
13579
diff
changeset
|
10877 (let ((overlays (and (fboundp 'overlays-at) |
73433c3071a5
* gnus.el (gnus-parse-headers-hook): New hook.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
13579
diff
changeset
|
10878 (overlays-at (point-min))))) |
13401 | 10879 (while overlays |
10880 (delete-overlay (car overlays)) | |
10881 (setq overlays (cdr overlays)))) | |
10882 (erase-buffer) | |
10883 (let ((gnus-override-method | |
10884 (and (stringp article) gnus-refer-article-method))) | |
10885 (and (gnus-request-article article group (current-buffer)) | |
10886 'article))) | |
10887 article))) | |
10888 | |
10889 (defun gnus-read-header (id) | |
10890 "Read the headers of article ID and enter them into the Gnus system." | |
10891 (let (header) | |
10892 (if (not (setq header | |
10893 (car (if (let ((gnus-nov-is-evil t)) | |
10894 (gnus-retrieve-headers | |
10895 (list id) gnus-newsgroup-name)) | |
10896 (gnus-get-newsgroup-headers))))) | |
10897 nil | |
10898 (if (stringp id) | |
10899 (mail-header-set-number header gnus-reffed-article-number)) | |
10900 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers)) | |
10901 (gnus-sethash (int-to-string (mail-header-number header)) header | |
10902 gnus-newsgroup-headers-hashtb-by-number) | |
10903 (if (stringp id) | |
10904 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))) | |
10905 (setq gnus-current-headers header) | |
10906 header))) | |
10907 | |
10908 (defun gnus-article-prepare (article &optional all-headers header) | |
10909 "Prepare ARTICLE in article mode buffer. | |
10910 ARTICLE should either be an article number or a Message-ID. | |
10911 If ARTICLE is an id, HEADER should be the article headers. | |
10912 If ALL-HEADERS is non-nil, no headers are hidden." | |
10913 (save-excursion | |
10914 ;; Make sure we start in a summary buffer. | |
10915 (or (eq major-mode 'gnus-summary-mode) | |
10916 (set-buffer gnus-summary-buffer)) | |
10917 (setq gnus-summary-buffer (current-buffer)) | |
10918 ;; Make sure the connection to the server is alive. | |
10919 (or (gnus-server-opened (gnus-find-method-for-group gnus-newsgroup-name)) | |
10920 (progn | |
10921 (gnus-check-server | |
10922 (gnus-find-method-for-group gnus-newsgroup-name)) | |
10923 (gnus-request-group gnus-newsgroup-name t))) | |
10924 (let* ((article (if header (mail-header-number header) article)) | |
10925 (summary-buffer (current-buffer)) | |
10926 (internal-hook gnus-article-internal-prepare-hook) | |
10927 (group gnus-newsgroup-name) | |
10928 result) | |
10929 (save-excursion | |
10930 (gnus-article-setup-buffer) | |
10931 (set-buffer gnus-article-buffer) | |
10932 (if (not (setq result (let ((buffer-read-only nil)) | |
10933 (gnus-request-article-this-buffer | |
10934 article group)))) | |
10935 ;; There is no such article. | |
10936 (save-excursion | |
10937 (if (not (numberp article)) | |
10938 () | |
10939 (setq gnus-article-current | |
10940 (cons gnus-newsgroup-name article)) | |
10941 (set-buffer gnus-summary-buffer) | |
10942 (setq gnus-current-article article) | |
10943 (gnus-summary-mark-article article gnus-canceled-mark)) | |
10944 (gnus-message 1 "No such article (may be canceled)") | |
10945 (ding) | |
10946 nil) | |
10947 (if (or (eq result 'pseudo) (eq result 'nneething)) | |
10948 (progn | |
10949 (save-excursion | |
10950 (set-buffer summary-buffer) | |
10951 (setq gnus-last-article gnus-current-article | |
10952 gnus-newsgroup-history (cons gnus-current-article | |
10953 gnus-newsgroup-history) | |
10954 gnus-current-article 0 | |
10955 gnus-current-headers nil | |
10956 gnus-article-current nil) | |
10957 (if (eq result 'nneething) | |
10958 (gnus-configure-windows 'summary) | |
10959 (gnus-configure-windows 'article)) | |
10960 (gnus-set-global-variables)) | |
10961 (gnus-set-mode-line 'article)) | |
10962 ;; The result from the `request' was an actual article - | |
10963 ;; or at least some text that is now displayed in the | |
10964 ;; article buffer. | |
10965 (if (and (numberp article) | |
10966 (not (eq article gnus-current-article))) | |
10967 ;; Seems like a new article has been selected. | |
10968 ;; `gnus-current-article' must be an article number. | |
10969 (save-excursion | |
10970 (set-buffer summary-buffer) | |
10971 (setq gnus-last-article gnus-current-article | |
10972 gnus-newsgroup-history (cons gnus-current-article | |
10973 gnus-newsgroup-history) | |
10974 gnus-current-article article | |
10975 gnus-current-headers | |
10976 (gnus-get-header-by-num gnus-current-article) | |
10977 gnus-article-current | |
10978 (cons gnus-newsgroup-name gnus-current-article)) | |
10979 (gnus-summary-show-thread) | |
10980 (run-hooks 'gnus-mark-article-hook) | |
10981 (gnus-set-mode-line 'summary) | |
10982 (and gnus-visual | |
10983 (run-hooks 'gnus-visual-mark-article-hook)) | |
10984 ;; Set the global newsgroup variables here. | |
10985 ;; Suggested by Jim Sisolak | |
10986 ;; <sisolak@trans4.neep.wisc.edu>. | |
10987 (gnus-set-global-variables) | |
10988 (setq gnus-have-all-headers | |
10989 (or all-headers gnus-show-all-headers)) | |
10990 (and gnus-use-cache | |
10991 (vectorp (gnus-get-header-by-number article)) | |
10992 (gnus-cache-possibly-enter-article | |
10993 group article | |
10994 (gnus-get-header-by-number article) | |
10995 (memq article gnus-newsgroup-marked) | |
10996 (memq article gnus-newsgroup-dormant) | |
10997 (memq article gnus-newsgroup-unreads))))) | |
10998 ;; Hooks for getting information from the article. | |
10999 ;; This hook must be called before being narrowed. | |
11000 (let (buffer-read-only) | |
11001 (run-hooks 'internal-hook) | |
11002 (run-hooks 'gnus-article-prepare-hook) | |
11003 ;; Decode MIME message. | |
11004 (if (and gnus-show-mime | |
11005 (or (not gnus-strict-mime) | |
11006 (gnus-fetch-field "Mime-Version"))) | |
11007 (funcall gnus-show-mime-method)) | |
11008 ;; Perform the article display hooks. | |
11009 (run-hooks 'gnus-article-display-hook)) | |
11010 ;; Do page break. | |
11011 (goto-char (point-min)) | |
11012 (and gnus-break-pages (gnus-narrow-to-page)) | |
11013 (gnus-set-mode-line 'article) | |
11014 (gnus-configure-windows 'article) | |
11015 (goto-char (point-min)) | |
11016 t)))))) | |
11017 | |
11018 (defun gnus-article-show-all-headers () | |
11019 "Show all article headers in article mode buffer." | |
11020 (save-excursion | |
11021 (gnus-article-setup-buffer) | |
11022 (set-buffer gnus-article-buffer) | |
11023 (let ((buffer-read-only nil)) | |
11024 (remove-text-properties (point-min) (point-max) | |
11025 gnus-hidden-properties)))) | |
11026 | |
11027 (defun gnus-article-hide-headers-if-wanted () | |
11028 "Hide unwanted headers if `gnus-have-all-headers' is nil. | |
11029 Provided for backwards compatability." | |
11030 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers) | |
11031 (gnus-article-hide-headers))) | |
11032 | |
11033 (defun gnus-article-hide-headers (&optional delete) | |
11034 "Hide unwanted headers and possibly sort them as well." | |
11035 (interactive "P") | |
11036 (save-excursion | |
11037 (set-buffer gnus-article-buffer) | |
11038 (save-restriction | |
11039 (let ((sorted gnus-sorted-header-list) | |
11040 (buffer-read-only nil) | |
11041 want-list beg want-l) | |
11042 ;; First we narrow to just the headers. | |
11043 (widen) | |
11044 (goto-char (point-min)) | |
11045 ;; Hide any "From " lines at the beginning of (mail) articles. | |
11046 (while (looking-at "From ") | |
11047 (forward-line 1)) | |
11048 (or (bobp) | |
11049 (add-text-properties (point-min) (point) gnus-hidden-properties)) | |
11050 ;; Then treat the rest of the header lines. | |
11051 (narrow-to-region | |
11052 (point) | |
11053 (progn (search-forward "\n\n" nil t) (forward-line -1) (point))) | |
11054 ;; Then we use the two regular expressions | |
11055 ;; `gnus-ignored-headers' and `gnus-visible-headers' to | |
11056 ;; select which header lines is to remain visible in the | |
11057 ;; article buffer. | |
11058 (goto-char (point-min)) | |
11059 (while (re-search-forward "^[^ \t]*:" nil t) | |
11060 (beginning-of-line) | |
11061 ;; We add the headers we want to keep to a list and delete | |
11062 ;; them from the buffer. | |
11063 (if (or (and (stringp gnus-visible-headers) | |
11064 (looking-at gnus-visible-headers)) | |
11065 (and (not (stringp gnus-visible-headers)) | |
11066 (stringp gnus-ignored-headers) | |
11067 (not (looking-at gnus-ignored-headers)))) | |
11068 (progn | |
11069 (setq beg (point)) | |
11070 (forward-line 1) | |
11071 ;; Be sure to get multi-line headers... | |
11072 (re-search-forward "^[^ \t]*:" nil t) | |
11073 (beginning-of-line) | |
11074 (setq want-list | |
11075 (cons (buffer-substring beg (point)) want-list)) | |
11076 (delete-region beg (point)) | |
11077 (goto-char beg)) | |
11078 (forward-line 1))) | |
11079 ;; Next we perform the sorting by looking at | |
11080 ;; `gnus-sorted-header-list'. | |
11081 (goto-char (point-min)) | |
11082 (while (and sorted want-list) | |
11083 (setq want-l want-list) | |
11084 (while (and want-l | |
11085 (not (string-match (car sorted) (car want-l)))) | |
11086 (setq want-l (cdr want-l))) | |
11087 (if want-l | |
11088 (progn | |
11089 (insert (car want-l)) | |
11090 (setq want-list (delq (car want-l) want-list)))) | |
11091 (setq sorted (cdr sorted))) | |
11092 ;; Any headers that were not matched by the sorted list we | |
11093 ;; just tack on the end of the visible header list. | |
11094 (while want-list | |
11095 (insert (car want-list)) | |
11096 (setq want-list (cdr want-list))) | |
11097 ;; And finally we make the unwanted headers invisible. | |
11098 (if delete | |
11099 (delete-region (point) (point-max)) | |
11100 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>. | |
11101 (add-text-properties (point) (point-max) gnus-hidden-properties)))))) | |
11102 | |
11103 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>. | |
11104 (defun gnus-article-treat-overstrike () | |
11105 "Translate overstrikes into bold text." | |
11106 (interactive) | |
11107 (save-excursion | |
11108 (set-buffer gnus-article-buffer) | |
11109 (let ((buffer-read-only nil)) | |
11110 (while (search-forward "\b" nil t) | |
11111 (let ((next (following-char)) | |
11112 (previous (char-after (- (point) 2)))) | |
11113 (cond ((eq next previous) | |
11114 (put-text-property (- (point) 2) (point) | |
11115 'invisible t) | |
11116 (put-text-property (point) (1+ (point)) | |
11117 'face 'bold)) | |
11118 ((eq next ?_) | |
11119 (put-text-property (1- (point)) (1+ (point)) | |
11120 'invisible t) | |
11121 (put-text-property (1- (point)) (point) | |
11122 'face 'underline)) | |
11123 ((eq previous ?_) | |
11124 (put-text-property (- (point) 2) (point) | |
11125 'invisible t) | |
11126 (put-text-property (point) (1+ (point)) | |
11127 'face 'underline)))))))) | |
11128 | |
11129 (defun gnus-article-word-wrap () | |
11130 "Format too long lines." | |
11131 (interactive) | |
11132 (save-excursion | |
11133 (set-buffer gnus-article-buffer) | |
11134 (let ((buffer-read-only nil)) | |
11135 (goto-char (point-min)) | |
11136 (search-forward "\n\n" nil t) | |
11137 (end-of-line 1) | |
11138 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$") | |
11139 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?") | |
11140 (adaptive-fill-mode t)) | |
11141 (while (not (eobp)) | |
11142 (and (>= (current-column) (min fill-column (window-width))) | |
11143 (/= (preceding-char) ?:) | |
11144 (fill-paragraph nil)) | |
11145 (end-of-line 2)))))) | |
11146 | |
11147 (defun gnus-article-remove-cr () | |
11148 "Remove carriage returns from an article." | |
11149 (interactive) | |
11150 (save-excursion | |
11151 (set-buffer gnus-article-buffer) | |
11152 (let ((buffer-read-only nil)) | |
11153 (goto-char (point-min)) | |
11154 (while (search-forward "\r" nil t) | |
11155 (replace-match "" t t))))) | |
11156 | |
11157 (defun gnus-article-display-x-face (&optional force) | |
11158 "Look for an X-Face header and display it if present." | |
11159 (interactive (list 'force)) | |
11160 (save-excursion | |
11161 (set-buffer gnus-article-buffer) | |
11162 (let ((inhibit-point-motion-hooks t) | |
11163 (case-fold-search nil) | |
11164 from) | |
11165 (save-restriction | |
11166 (goto-char (point-min)) | |
11167 (search-forward "\n\n") | |
11168 (narrow-to-region (point-min) (point)) | |
11169 (goto-char (point-min)) | |
11170 (setq from (mail-fetch-field "from")) | |
11171 (if (not (and gnus-article-x-face-command | |
11172 (or force | |
11173 (not gnus-article-x-face-too-ugly) | |
11174 (and gnus-article-x-face-too-ugly from | |
11175 (not (string-match gnus-article-x-face-too-ugly | |
11176 from)))) | |
11177 (progn | |
11178 (goto-char (point-min)) | |
11179 (re-search-forward "^X-Face: " nil t)))) | |
11180 nil | |
11181 (let ((beg (point)) | |
11182 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t)))) | |
11183 (if (symbolp gnus-article-x-face-command) | |
11184 (and (or (fboundp gnus-article-x-face-command) | |
11185 (error "%s is not a function" | |
11186 gnus-article-x-face-command)) | |
11187 (funcall gnus-article-x-face-command beg end)) | |
11188 (call-process-region beg end "sh" nil 0 nil | |
11189 "-c" gnus-article-x-face-command)))))))) | |
11190 | |
11191 (defun gnus-article-de-quoted-unreadable (&optional force) | |
11192 "Do a naive translation of a quoted-printable-encoded article. | |
11193 This is in no way, shape or form meant as a replacement for real MIME | |
11194 processing, but is simply a stop-gap measure until MIME support is | |
11195 written. | |
11196 If FORCE, decode the article whether it is marked as quoted-printable | |
11197 or not." | |
11198 (interactive (list 'force)) | |
11199 (save-excursion | |
11200 (set-buffer gnus-article-buffer) | |
11201 (let ((case-fold-search t) | |
11202 (buffer-read-only nil) | |
11203 (type (gnus-fetch-field "content-transfer-encoding"))) | |
11204 (if (or force (and type (string-match "quoted-printable" type))) | |
11205 (progn | |
11206 (goto-char (point-min)) | |
11207 (search-forward "\n\n" nil 'move) | |
11208 (gnus-mime-decode-quoted-printable (point) (point-max))))))) | |
11209 | |
11210 (defun gnus-mime-decode-quoted-printable (from to) | |
11211 ;; Decode quoted-printable from region between FROM and TO. | |
11212 (save-excursion | |
11213 (goto-char from) | |
11214 (while (search-forward "=" to t) | |
11215 (cond ((eq (following-char) ?\n) | |
11216 (delete-char -1) | |
11217 (delete-char 1)) | |
11218 ((looking-at "[0-9A-F][0-9A-F]") | |
11219 (delete-char -1) | |
11220 (insert (hexl-hex-string-to-integer | |
11221 (buffer-substring (point) (+ 2 (point))))) | |
11222 (delete-char 2)) | |
11223 ((looking-at "=") | |
11224 (delete-char 1)) | |
11225 ((gnus-message 3 "Malformed MIME quoted-printable message")))))) | |
11226 | |
11227 (defvar gnus-article-time-units | |
11228 (list (cons 'year (* 365.25 24 60 60)) | |
11229 (cons 'week (* 7 24 60 60)) | |
11230 (cons 'day (* 24 60 60)) | |
11231 (cons 'hour (* 60 60)) | |
11232 (cons 'minute 60) | |
11233 (cons 'second 1))) | |
11234 | |
11235 (defun gnus-article-date-ut (&optional type) | |
11236 "Convert DATE date to universal time in the current article. | |
11237 If TYPE is `local', convert to local time; if it is `lapsed', output | |
11238 how much time has lapsed since DATE." | |
11239 (interactive (list 'ut)) | |
11240 (let ((date (mail-header-date (or gnus-current-headers | |
11241 (gnus-get-header-by-number | |
11242 (gnus-summary-article-number))""))) | |
11243 (date-regexp "^Date: \\|^X-Sent: ")) | |
11244 (if (or (not date) | |
11245 (string= date "")) | |
11246 () | |
11247 (save-excursion | |
11248 (set-buffer gnus-article-buffer) | |
11249 (let ((buffer-read-only nil)) | |
11250 (goto-char (point-min)) | |
11251 (if (and (re-search-forward date-regexp nil t) | |
11252 (progn | |
11253 (beginning-of-line) | |
11254 (looking-at date-regexp))) | |
11255 (delete-region (gnus-point-at-bol) | |
11256 (progn (end-of-line) (1+ (point)))) | |
11257 (goto-char (point-min)) | |
11258 (goto-char (- (search-forward "\n\n") 2))) | |
11259 (insert | |
11260 (cond | |
11261 ((eq type 'local) | |
11262 (concat "Date: " (condition-case () | |
11263 (timezone-make-date-arpa-standard date) | |
11264 (error date)) | |
11265 "\n")) | |
11266 ((eq type 'ut) | |
11267 (concat "Date: " | |
11268 (condition-case () | |
11269 (timezone-make-date-arpa-standard date nil "UT") | |
11270 (error date)) | |
11271 "\n")) | |
11272 ((eq type 'lapsed) | |
11273 ;; If the date is seriously mangled, the timezone | |
11274 ;; functions are liable to bug out, so we condition-case | |
11275 ;; the entire thing. | |
11276 (let* ((real-sec (condition-case () | |
11277 (- (gnus-seconds-since-epoch | |
11278 (timezone-make-date-arpa-standard | |
11279 (current-time-string) | |
11280 (current-time-zone) "UT")) | |
11281 (gnus-seconds-since-epoch | |
11282 (timezone-make-date-arpa-standard | |
11283 date nil "UT"))) | |
11284 (error 0))) | |
11285 (sec (abs real-sec)) | |
11286 num prev) | |
11287 (if (zerop sec) | |
11288 "X-Sent: Now\n" | |
11289 (concat | |
11290 "X-Sent: " | |
11291 (mapconcat | |
11292 (lambda (unit) | |
11293 (if (zerop (setq num (ffloor (/ sec (cdr unit))))) | |
11294 "" | |
11295 (setq sec (- sec (* num (cdr unit)))) | |
11296 (prog1 | |
11297 (concat (if prev ", " "") (int-to-string | |
11298 (floor num)) | |
11299 " " (symbol-name (car unit)) | |
11300 (if (> num 1) "s" "")) | |
11301 (setq prev t)))) | |
11302 gnus-article-time-units "") | |
11303 (if (> real-sec 0) | |
11304 " ago\n" | |
11305 " in the future\n"))))) | |
11306 (t | |
11307 (error "Unknown conversion type: %s" type))))))))) | |
11308 | |
11309 (defun gnus-article-date-local () | |
11310 "Convert the current article date to the local timezone." | |
11311 (interactive) | |
11312 (gnus-article-date-ut 'local)) | |
11313 | |
11314 (defun gnus-article-date-lapsed () | |
11315 "Convert the current article date to time lapsed since it was sent." | |
11316 (interactive) | |
11317 (gnus-article-date-ut 'lapsed)) | |
11318 | |
11319 (defun gnus-article-maybe-highlight () | |
11320 "Do some article highlighting if `gnus-visual' is non-nil." | |
11321 (if gnus-visual (gnus-article-highlight-some))) | |
11322 | |
11323 ;; Article savers. | |
11324 | |
11325 (defun gnus-output-to-rmail (file-name) | |
11326 "Append the current article to an Rmail file named FILE-NAME." | |
11327 (require 'rmail) | |
11328 ;; Most of these codes are borrowed from rmailout.el. | |
11329 (setq file-name (expand-file-name file-name)) | |
11330 (setq rmail-default-rmail-file file-name) | |
11331 (let ((artbuf (current-buffer)) | |
11332 (tmpbuf (get-buffer-create " *Gnus-output*"))) | |
11333 (save-excursion | |
11334 (or (get-file-buffer file-name) | |
11335 (file-exists-p file-name) | |
11336 (if (gnus-yes-or-no-p | |
11337 (concat "\"" file-name "\" does not exist, create it? ")) | |
11338 (let ((file-buffer (create-file-buffer file-name))) | |
11339 (save-excursion | |
11340 (set-buffer file-buffer) | |
11341 (rmail-insert-rmail-file-header) | |
11342 (let ((require-final-newline nil)) | |
11343 (write-region (point-min) (point-max) file-name t 1))) | |
11344 (kill-buffer file-buffer)) | |
11345 (error "Output file does not exist"))) | |
11346 (set-buffer tmpbuf) | |
11347 (buffer-disable-undo (current-buffer)) | |
11348 (erase-buffer) | |
11349 (insert-buffer-substring artbuf) | |
11350 (gnus-convert-article-to-rmail) | |
11351 ;; Decide whether to append to a file or to an Emacs buffer. | |
11352 (let ((outbuf (get-file-buffer file-name))) | |
11353 (if (not outbuf) | |
11354 (append-to-file (point-min) (point-max) file-name) | |
11355 ;; File has been visited, in buffer OUTBUF. | |
11356 (set-buffer outbuf) | |
11357 (let ((buffer-read-only nil) | |
11358 (msg (and (boundp 'rmail-current-message) | |
11359 (symbol-value 'rmail-current-message)))) | |
11360 ;; If MSG is non-nil, buffer is in RMAIL mode. | |
11361 (if msg | |
11362 (progn (widen) | |
11363 (narrow-to-region (point-max) (point-max)))) | |
11364 (insert-buffer-substring tmpbuf) | |
11365 (if msg | |
11366 (progn | |
11367 (goto-char (point-min)) | |
11368 (widen) | |
11369 (search-backward "\^_") | |
11370 (narrow-to-region (point) (point-max)) | |
11371 (goto-char (1+ (point-min))) | |
11372 (rmail-count-new-messages t) | |
11373 (rmail-show-message msg))))))) | |
11374 (kill-buffer tmpbuf))) | |
11375 | |
11376 (defun gnus-output-to-file (file-name) | |
11377 "Append the current article to a file named FILE-NAME." | |
11378 (setq file-name (expand-file-name file-name)) | |
11379 (let ((artbuf (current-buffer)) | |
11380 (tmpbuf (get-buffer-create " *Gnus-output*"))) | |
11381 (save-excursion | |
11382 (set-buffer tmpbuf) | |
11383 (buffer-disable-undo (current-buffer)) | |
11384 (erase-buffer) | |
11385 (insert-buffer-substring artbuf) | |
11386 ;; Append newline at end of the buffer as separator, and then | |
11387 ;; save it to file. | |
11388 (goto-char (point-max)) | |
11389 (insert "\n") | |
11390 (append-to-file (point-min) (point-max) file-name)) | |
11391 (kill-buffer tmpbuf))) | |
11392 | |
11393 (defun gnus-convert-article-to-rmail () | |
11394 "Convert article in current buffer to Rmail message format." | |
11395 (let ((buffer-read-only nil)) | |
11396 ;; Convert article directly into Babyl format. | |
11397 ;; Suggested by Rob Austein <sra@lcs.mit.edu> | |
11398 (goto-char (point-min)) | |
11399 (insert "\^L\n0, unseen,,\n*** EOOH ***\n") | |
11400 (while (search-forward "\n\^_" nil t) ;single char | |
11401 (replace-match "\n^_" t t)) ;2 chars: "^" and "_" | |
11402 (goto-char (point-max)) | |
11403 (insert "\^_"))) | |
11404 | |
11405 (defun gnus-narrow-to-page (&optional arg) | |
11406 "Make text outside current page invisible except for page delimiter. | |
11407 A numeric arg specifies to move forward or backward by that many pages, | |
11408 thus showing a page other than the one point was originally in." | |
11409 (interactive "P") | |
11410 (setq arg (if arg (prefix-numeric-value arg) 0)) | |
11411 (save-excursion | |
11412 (forward-page -1) ;Beginning of current page. | |
11413 (widen) | |
11414 (if (> arg 0) | |
11415 (forward-page arg) | |
11416 (if (< arg 0) | |
11417 (forward-page (1- arg)))) | |
11418 ;; Find the end of the page. | |
11419 (forward-page) | |
11420 ;; If we stopped due to end of buffer, stay there. | |
11421 ;; If we stopped after a page delimiter, put end of restriction | |
11422 ;; at the beginning of that line. | |
11423 ;; These are commented out. | |
11424 ;; (if (save-excursion (beginning-of-line) | |
11425 ;; (looking-at page-delimiter)) | |
11426 ;; (beginning-of-line)) | |
11427 (narrow-to-region (point) | |
11428 (progn | |
11429 ;; Find the top of the page. | |
11430 (forward-page -1) | |
11431 ;; If we found beginning of buffer, stay there. | |
11432 ;; If extra text follows page delimiter on same line, | |
11433 ;; include it. | |
11434 ;; Otherwise, show text starting with following line. | |
11435 (if (and (eolp) (not (bobp))) | |
11436 (forward-line 1)) | |
11437 (point))))) | |
11438 | |
11439 (defun gnus-gmt-to-local () | |
11440 "Rewrite Date header described in GMT to local in current buffer. | |
11441 Intended to be used with gnus-article-prepare-hook." | |
11442 (save-excursion | |
11443 (save-restriction | |
11444 (widen) | |
11445 (goto-char (point-min)) | |
11446 (narrow-to-region (point-min) | |
11447 (progn (search-forward "\n\n" nil 'move) (point))) | |
11448 (goto-char (point-min)) | |
11449 (if (re-search-forward "^Date:[ \t]\\(.*\\)$" nil t) | |
11450 (let ((buffer-read-only nil) | |
11451 (date (buffer-substring-no-properties | |
11452 (match-beginning 1) (match-end 1)))) | |
11453 (delete-region (match-beginning 1) (match-end 1)) | |
11454 (insert | |
11455 (timezone-make-date-arpa-standard | |
11456 date nil (current-time-zone)))))))) | |
11457 | |
11458 | |
11459 ;; Article mode commands | |
11460 | |
11461 (defun gnus-article-next-page (&optional lines) | |
11462 "Show next page of current article. | |
11463 If end of article, return non-nil. Otherwise return nil. | |
11464 Argument LINES specifies lines to be scrolled up." | |
11465 (interactive "P") | |
11466 (move-to-window-line -1) | |
11467 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo) | |
11468 (if (save-excursion | |
11469 (end-of-line) | |
11470 (and (pos-visible-in-window-p) ;Not continuation line. | |
11471 (eobp))) | |
11472 ;; Nothing in this page. | |
11473 (if (or (not gnus-break-pages) | |
11474 (save-excursion | |
11475 (save-restriction | |
11476 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer? | |
11477 t ;Nothing more. | |
11478 (gnus-narrow-to-page 1) ;Go to next page. | |
11479 nil) | |
11480 ;; More in this page. | |
11481 (condition-case () | |
11482 (scroll-up lines) | |
11483 (end-of-buffer | |
11484 ;; Long lines may cause an end-of-buffer error. | |
11485 (goto-char (point-max)))) | |
11486 nil)) | |
11487 | |
11488 (defun gnus-article-prev-page (&optional lines) | |
11489 "Show previous page of current article. | |
11490 Argument LINES specifies lines to be scrolled down." | |
11491 (interactive "P") | |
11492 (move-to-window-line 0) | |
11493 (if (and gnus-break-pages | |
11494 (bobp) | |
11495 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer? | |
11496 (progn | |
11497 (gnus-narrow-to-page -1) ;Go to previous page. | |
11498 (goto-char (point-max)) | |
11499 (recenter -1)) | |
11500 (scroll-down lines))) | |
11501 | |
11502 (defun gnus-article-refer-article () | |
11503 "Read article specified by message-id around point." | |
11504 (interactive) | |
11505 (search-forward ">" nil t) ;Move point to end of "<....>". | |
11506 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t) | |
11507 (let ((message-id | |
11508 (buffer-substring (match-beginning 1) (match-end 1)))) | |
11509 (set-buffer gnus-summary-buffer) | |
11510 (gnus-summary-refer-article message-id)) | |
11511 (error "No references around point"))) | |
11512 | |
11513 (defun gnus-article-show-summary () | |
11514 "Reconfigure windows to show summary buffer." | |
11515 (interactive) | |
11516 (gnus-configure-windows 'article) | |
11517 (gnus-summary-goto-subject gnus-current-article)) | |
11518 | |
11519 (defun gnus-article-describe-briefly () | |
11520 "Describe article mode commands briefly." | |
11521 (interactive) | |
11522 (gnus-message 6 | |
11523 (substitute-command-keys "\\<gnus-article-mode-map>\\[gnus-article-next-page]:Next page \\[gnus-article-prev-page]:Prev page \\[gnus-article-show-summary]:Show summary \\[gnus-info-find-node]:Run Info \\[gnus-article-describe-briefly]:This help"))) | |
11524 | |
11525 (defun gnus-article-summary-command () | |
11526 "Execute the last keystroke in the summary buffer." | |
11527 (interactive) | |
11528 (let ((obuf (current-buffer)) | |
11529 (owin (current-window-configuration)) | |
11530 func) | |
11531 (switch-to-buffer gnus-summary-buffer 'norecord) | |
11532 (setq func (lookup-key (current-local-map) (this-command-keys))) | |
11533 (call-interactively func) | |
11534 (set-buffer obuf) | |
11535 (set-window-configuration owin) | |
11536 (set-window-point (get-buffer-window (current-buffer)) (point)))) | |
11537 | |
11538 (defun gnus-article-summary-command-nosave () | |
11539 "Execute the last keystroke in the summary buffer." | |
11540 (interactive) | |
11541 (let (func) | |
11542 (pop-to-buffer gnus-summary-buffer 'norecord) | |
11543 (setq func (lookup-key (current-local-map) (this-command-keys))) | |
11544 (call-interactively func))) | |
11545 | |
11546 | |
11547 ;; Basic ideas by emv@math.lsa.umich.edu (Edward Vielmetti) | |
11548 | |
11549 ;;;###autoload | |
11550 (defalias 'gnus-batch-kill 'gnus-batch-score) | |
11551 ;;;###autoload | |
11552 (defun gnus-batch-score () | |
11553 "Run batched scoring. | |
11554 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ... | |
11555 Newsgroups is a list of strings in Bnews format. If you want to score | |
11556 the comp hierarchy, you'd say \"comp.all\". If you would not like to | |
11557 score the alt hierarchy, you'd say \"!alt.all\"." | |
11558 (interactive) | |
11559 (let* ((yes-and-no | |
11560 (gnus-newsrc-parse-options | |
11561 (apply (function concat) | |
11562 (mapcar (lambda (g) (concat g " ")) | |
11563 command-line-args-left)))) | |
11564 (gnus-expert-user t) | |
11565 (nnmail-spool-file nil) | |
11566 (gnus-use-dribble-file nil) | |
11567 (yes (car yes-and-no)) | |
11568 (no (cdr yes-and-no)) | |
11569 group newsrc entry | |
11570 ;; Disable verbose message. | |
11571 gnus-novice-user gnus-large-newsgroup) | |
11572 ;; Eat all arguments. | |
11573 (setq command-line-args-left nil) | |
11574 ;; Start Gnus. | |
11575 (gnus) | |
11576 ;; Apply kills to specified newsgroups in command line arguments. | |
11577 (setq newsrc (cdr gnus-newsrc-alist)) | |
11578 (while newsrc | |
11579 (setq group (car (car newsrc))) | |
11580 (setq entry (gnus-gethash group gnus-newsrc-hashtb)) | |
11581 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed) | |
11582 (and (car entry) | |
11583 (or (eq (car entry) t) | |
11584 (not (zerop (car entry))))) | |
11585 (if yes (string-match yes group) t) | |
11586 (or (null no) (not (string-match no group)))) | |
11587 (progn | |
11588 (gnus-summary-read-group group nil t) | |
11589 (and (eq (current-buffer) (get-buffer gnus-summary-buffer)) | |
11590 (gnus-summary-exit)))) | |
11591 (setq newsrc (cdr newsrc))) | |
11592 ;; Exit Emacs. | |
11593 (switch-to-buffer gnus-group-buffer) | |
11594 (gnus-group-save-newsrc))) | |
11595 | |
11596 (defun gnus-apply-kill-file () | |
11597 "Apply a kill file to the current newsgroup. | |
11598 Returns the number of articles marked as read." | |
11599 (if (or (file-exists-p (gnus-newsgroup-kill-file nil)) | |
11600 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name))) | |
11601 (gnus-apply-kill-file-internal) | |
11602 0)) | |
11603 | |
11604 (defun gnus-kill-save-kill-buffer () | |
11605 (save-excursion | |
11606 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name))) | |
11607 (if (get-file-buffer file) | |
11608 (progn | |
11609 (set-buffer (get-file-buffer file)) | |
11610 (and (buffer-modified-p) (save-buffer)) | |
11611 (kill-buffer (current-buffer))))))) | |
11612 | |
11613 (defvar gnus-kill-file-name "KILL" | |
11614 "Suffix of the kill files.") | |
11615 | |
11616 (defun gnus-newsgroup-kill-file (newsgroup) | |
11617 "Return the name of a kill file name for NEWSGROUP. | |
11618 If NEWSGROUP is nil, return the global kill file name instead." | |
11619 (cond ((or (null newsgroup) | |
11620 (string-equal newsgroup "")) | |
11621 ;; The global KILL file is placed at top of the directory. | |
11622 (expand-file-name gnus-kill-file-name | |
11623 (or gnus-kill-files-directory "~/News"))) | |
11624 ((gnus-use-long-file-name 'not-kill) | |
11625 ;; Append ".KILL" to newsgroup name. | |
11626 (expand-file-name (concat (gnus-newsgroup-saveable-name newsgroup) | |
11627 "." gnus-kill-file-name) | |
11628 (or gnus-kill-files-directory "~/News"))) | |
11629 (t | |
11630 ;; Place "KILL" under the hierarchical directory. | |
11631 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup) | |
11632 "/" gnus-kill-file-name) | |
11633 (or gnus-kill-files-directory "~/News"))))) | |
11634 | |
11635 | |
11636 ;;; | |
11637 ;;; Dribble file | |
11638 ;;; | |
11639 | |
11640 (defvar gnus-dribble-ignore nil) | |
11641 (defvar gnus-dribble-eval-file nil) | |
11642 | |
11643 (defun gnus-dribble-file-name () | |
11644 (concat gnus-current-startup-file "-dribble")) | |
11645 | |
11646 (defun gnus-dribble-enter (string) | |
11647 (if (and (not gnus-dribble-ignore) | |
11648 gnus-dribble-buffer | |
11649 (buffer-name gnus-dribble-buffer)) | |
11650 (let ((obuf (current-buffer))) | |
11651 (set-buffer gnus-dribble-buffer) | |
11652 (insert string "\n") | |
11653 (set-window-point (get-buffer-window (current-buffer)) (point-max)) | |
11654 (set-buffer obuf)))) | |
11655 | |
11656 (defun gnus-dribble-read-file () | |
11657 (let ((dribble-file (gnus-dribble-file-name))) | |
11658 (save-excursion | |
11659 (set-buffer (setq gnus-dribble-buffer | |
11660 (get-buffer-create | |
11661 (file-name-nondirectory dribble-file)))) | |
11662 (gnus-add-current-to-buffer-list) | |
11663 (erase-buffer) | |
11664 (set-visited-file-name dribble-file) | |
11665 (buffer-disable-undo (current-buffer)) | |
11666 (bury-buffer (current-buffer)) | |
11667 (set-buffer-modified-p nil) | |
11668 (let ((auto (make-auto-save-file-name)) | |
11669 (gnus-dribble-ignore t)) | |
11670 (if (or (file-exists-p auto) (file-exists-p dribble-file)) | |
11671 (progn | |
11672 (if (file-newer-than-file-p auto dribble-file) | |
11673 (setq dribble-file auto)) | |
11674 (insert-file-contents dribble-file) | |
11675 (if (not (zerop (buffer-size))) | |
11676 (set-buffer-modified-p t)) | |
11677 (if (gnus-y-or-n-p | |
11678 "Auto-save file exists. Do you want to read it? ") | |
11679 (setq gnus-dribble-eval-file t)))))))) | |
11680 | |
11681 (defun gnus-dribble-eval-file () | |
11682 (if (not gnus-dribble-eval-file) | |
11683 () | |
11684 (setq gnus-dribble-eval-file nil) | |
11685 (save-excursion | |
11686 (let ((gnus-dribble-ignore t)) | |
11687 (set-buffer gnus-dribble-buffer) | |
11688 (eval-buffer (current-buffer)))))) | |
11689 | |
11690 (defun gnus-dribble-delete-file () | |
11691 (if (file-exists-p (gnus-dribble-file-name)) | |
11692 (delete-file (gnus-dribble-file-name))) | |
11693 (if gnus-dribble-buffer | |
11694 (save-excursion | |
11695 (set-buffer gnus-dribble-buffer) | |
11696 (let ((auto (make-auto-save-file-name))) | |
11697 (if (file-exists-p auto) | |
11698 (delete-file auto)) | |
11699 (erase-buffer) | |
11700 (set-buffer-modified-p nil))))) | |
11701 | |
11702 (defun gnus-dribble-save () | |
11703 (if (and gnus-dribble-buffer | |
11704 (buffer-name gnus-dribble-buffer)) | |
11705 (save-excursion | |
11706 (set-buffer gnus-dribble-buffer) | |
11707 (save-buffer)))) | |
11708 | |
11709 (defun gnus-dribble-clear () | |
11710 (save-excursion | |
11711 (if (gnus-buffer-exists-p gnus-dribble-buffer) | |
11712 (progn | |
11713 (set-buffer gnus-dribble-buffer) | |
11714 (erase-buffer) | |
11715 (set-buffer-modified-p nil) | |
11716 (setq buffer-saved-size (buffer-size)))))) | |
11717 | |
11718 ;;; | |
11719 ;;; Server Communication | |
11720 ;;; | |
11721 | |
11722 (defun gnus-start-news-server (&optional confirm) | |
11723 "Open a method for getting news. | |
11724 If CONFIRM is non-nil, the user will be asked for an NNTP server." | |
11725 (let (how) | |
11726 (if gnus-current-select-method | |
11727 ;; Stream is already opened. | |
11728 nil | |
11729 ;; Open NNTP server. | |
11730 (if (null gnus-nntp-service) (setq gnus-nntp-server nil)) | |
11731 (if confirm | |
11732 (progn | |
11733 ;; Read server name with completion. | |
11734 (setq gnus-nntp-server | |
11735 (completing-read "NNTP server: " | |
11736 (mapcar (lambda (server) (list server)) | |
11737 (cons (list gnus-nntp-server) | |
11738 gnus-secondary-servers)) | |
11739 nil nil gnus-nntp-server)))) | |
11740 | |
11741 (if (and gnus-nntp-server | |
11742 (stringp gnus-nntp-server) | |
11743 (not (string= gnus-nntp-server ""))) | |
11744 (setq gnus-select-method | |
11745 (cond ((or (string= gnus-nntp-server "") | |
11746 (string= gnus-nntp-server "::")) | |
11747 (list 'nnspool (system-name))) | |
11748 ((string-match "^:" gnus-nntp-server) | |
11749 (list 'nnmh gnus-nntp-server | |
11750 (list 'nnmh-directory | |
11751 (file-name-as-directory | |
11752 (expand-file-name | |
11753 (concat "~/" (substring | |
11754 gnus-nntp-server 1))))) | |
11755 (list 'nnmh-get-new-mail nil))) | |
11756 (t | |
11757 (list 'nntp gnus-nntp-server))))) | |
11758 | |
11759 (setq how (car gnus-select-method)) | |
11760 (cond ((eq how 'nnspool) | |
11761 (require 'nnspool) | |
11762 (gnus-message 5 "Looking up local news spool...")) | |
11763 ((eq how 'nnmh) | |
11764 (require 'nnmh) | |
11765 (gnus-message 5 "Looking up mh spool...")) | |
11766 (t | |
11767 (require 'nntp))) | |
11768 (setq gnus-current-select-method gnus-select-method) | |
11769 (run-hooks 'gnus-open-server-hook) | |
11770 (or | |
11771 ;; gnus-open-server-hook might have opened it | |
11772 (gnus-server-opened gnus-select-method) | |
11773 (gnus-open-server gnus-select-method) | |
11774 (gnus-y-or-n-p | |
11775 (format | |
11776 "%s open error: '%s'. Continue? " | |
11777 (nth 1 gnus-select-method) | |
11778 (gnus-status-message gnus-select-method))) | |
11779 (progn | |
11780 (gnus-message 1 "Couldn't open server on %s" | |
11781 (nth 1 gnus-select-method)) | |
11782 (ding) | |
11783 nil))))) | |
11784 | |
11785 (defun gnus-check-server (&optional method) | |
11786 "If the news server is down, start it up again." | |
11787 (let ((method (if method method gnus-select-method))) | |
11788 (and (stringp method) | |
11789 (setq method (gnus-server-to-method method))) | |
11790 (if (gnus-server-opened method) | |
11791 ;; Stream is already opened. | |
11792 t | |
11793 ;; Open server. | |
11794 (gnus-message 5 "Opening server %s on %s..." (car method) (nth 1 method)) | |
11795 (run-hooks 'gnus-open-server-hook) | |
11796 (prog1 | |
11797 (gnus-open-server method) | |
11798 (message ""))))) | |
11799 | |
11800 (defun gnus-nntp-message (&optional message) | |
11801 "Check the status of the NNTP server. | |
11802 If the status of the server is clear and MESSAGE is non-nil, MESSAGE | |
11803 is returned insted of the status string." | |
11804 (let ((status (gnus-status-message (gnus-find-method-for-group | |
11805 gnus-newsgroup-name))) | |
11806 (message (or message ""))) | |
11807 (if (and (stringp status) (> (length status) 0)) | |
11808 status message))) | |
11809 | |
11810 (defun gnus-get-function (method function) | |
11811 (and (stringp method) | |
11812 (setq method (gnus-server-to-method method))) | |
11813 (let ((func (intern (format "%s-%s" (car method) function)))) | |
11814 (if (not (fboundp func)) | |
11815 (progn | |
11816 (require (car method)) | |
11817 (if (not (fboundp func)) | |
11818 (error "No such function: %s" func)))) | |
11819 func)) | |
11820 | |
11821 ;;; Interface functions to the backends. | |
11822 | |
11823 (defun gnus-open-server (method) | |
11824 (funcall (gnus-get-function method 'open-server) | |
11825 (nth 1 method) (nthcdr 2 method))) | |
11826 | |
11827 (defun gnus-close-server (method) | |
11828 (funcall (gnus-get-function method 'close-server) (nth 1 method))) | |
11829 | |
11830 (defun gnus-request-list (method) | |
11831 (funcall (gnus-get-function method 'request-list) (nth 1 method))) | |
11832 | |
11833 (defun gnus-request-list-newsgroups (method) | |
11834 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method))) | |
11835 | |
11836 (defun gnus-request-newgroups (date method) | |
11837 (funcall (gnus-get-function method 'request-newgroups) | |
11838 date (nth 1 method))) | |
11839 | |
11840 (defun gnus-server-opened (method) | |
11841 (funcall (gnus-get-function method 'server-opened) (nth 1 method))) | |
11842 | |
11843 (defun gnus-status-message (method) | |
11844 (let ((method (if (stringp method) (gnus-find-method-for-group method) | |
11845 method))) | |
11846 (funcall (gnus-get-function method 'status-message) (nth 1 method)))) | |
11847 | |
11848 (defun gnus-request-group (group &optional dont-check) | |
11849 (let ((method (gnus-find-method-for-group group))) | |
11850 (funcall (gnus-get-function method 'request-group) | |
11851 (gnus-group-real-name group) (nth 1 method) dont-check))) | |
11852 | |
11853 (defun gnus-request-asynchronous (group &optional articles) | |
11854 (let ((method (gnus-find-method-for-group group))) | |
11855 (funcall (gnus-get-function method 'request-asynchronous) | |
11856 (gnus-group-real-name group) (nth 1 method) articles))) | |
11857 | |
11858 (defun gnus-list-active-group (group) | |
11859 (let ((method (gnus-find-method-for-group group)) | |
11860 (func 'list-active-group)) | |
11861 (and (gnus-check-backend-function func group) | |
11862 (funcall (gnus-get-function method func) | |
11863 (gnus-group-real-name group) (nth 1 method))))) | |
11864 | |
11865 (defun gnus-request-group-description (group) | |
11866 (let ((method (gnus-find-method-for-group group)) | |
11867 (func 'request-group-description)) | |
11868 (and (gnus-check-backend-function func group) | |
11869 (funcall (gnus-get-function method func) | |
11870 (gnus-group-real-name group) (nth 1 method))))) | |
11871 | |
11872 (defun gnus-close-group (group) | |
11873 (let ((method (gnus-find-method-for-group group))) | |
11874 (funcall (gnus-get-function method 'close-group) | |
11875 (gnus-group-real-name group) (nth 1 method)))) | |
11876 | |
11877 (defun gnus-retrieve-headers (articles group) | |
11878 (let ((method (gnus-find-method-for-group group))) | |
11879 (if (and gnus-use-cache (numberp (car articles))) | |
11880 (gnus-cache-retrieve-headers articles group) | |
11881 (funcall (gnus-get-function method 'retrieve-headers) | |
11882 articles (gnus-group-real-name group) (nth 1 method))))) | |
11883 | |
11884 (defun gnus-retrieve-groups (groups method) | |
11885 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method))) | |
11886 | |
11887 (defun gnus-request-article (article group &optional buffer) | |
11888 (let ((method (gnus-find-method-for-group group))) | |
11889 (funcall (gnus-get-function method 'request-article) | |
11890 article (gnus-group-real-name group) (nth 1 method) buffer))) | |
11891 | |
11892 (defun gnus-request-head (article group) | |
11893 (let ((method (gnus-find-method-for-group group))) | |
11894 (funcall (gnus-get-function method 'request-head) | |
11895 article (gnus-group-real-name group) (nth 1 method)))) | |
11896 | |
11897 (defun gnus-request-body (article group) | |
11898 (let ((method (gnus-find-method-for-group group))) | |
11899 (funcall (gnus-get-function method 'request-body) | |
11900 article (gnus-group-real-name group) (nth 1 method)))) | |
11901 | |
11902 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>. | |
11903 (defun gnus-request-post-buffer (post group subject header artbuf | |
11904 info follow-to respect-poster) | |
11905 (let* ((info (or info (and group (nth 2 (gnus-gethash | |
11906 group gnus-newsrc-hashtb))))) | |
11907 (method | |
11908 (if (and gnus-post-method | |
11909 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>. | |
11910 (memq 'post (assoc | |
11911 (format "%s" (car (gnus-find-method-for-group | |
11912 gnus-newsgroup-name))) | |
11913 gnus-valid-select-methods))) | |
11914 gnus-post-method | |
11915 (gnus-find-method-for-group gnus-newsgroup-name)))) | |
11916 (or (gnus-check-server method) | |
11917 (error "Can't open server %s:%s" (car method) (nth 1 method))) | |
11918 (let ((mail-self-blind nil) | |
11919 (mail-archive-file-name nil)) | |
11920 (funcall (gnus-get-function method 'request-post-buffer) | |
11921 post group subject header artbuf info follow-to | |
11922 respect-poster)))) | |
11923 | |
11924 (defun gnus-request-post (method &optional force) | |
11925 (and (stringp method) | |
11926 (setq method (gnus-server-to-method method))) | |
11927 (and (not force) gnus-post-method | |
11928 (memq 'post (assoc (format "%s" (car method)) | |
11929 gnus-valid-select-methods)) | |
11930 (setq method gnus-post-method)) | |
11931 (funcall (gnus-get-function method 'request-post) | |
11932 (nth 1 method))) | |
11933 | |
11934 (defun gnus-request-expire-articles (articles group &optional force) | |
11935 (let ((method (gnus-find-method-for-group group))) | |
11936 (funcall (gnus-get-function method 'request-expire-articles) | |
11937 articles (gnus-group-real-name group) (nth 1 method) | |
11938 force))) | |
11939 | |
11940 (defun gnus-request-move-article | |
11941 (article group server accept-function &optional last) | |
11942 (let ((method (gnus-find-method-for-group group))) | |
11943 (funcall (gnus-get-function method 'request-move-article) | |
11944 article (gnus-group-real-name group) | |
11945 (nth 1 method) accept-function last))) | |
11946 | |
11947 (defun gnus-request-accept-article (group &optional last) | |
11948 (let ((func (if (symbolp group) group | |
11949 (car (gnus-find-method-for-group group))))) | |
11950 (funcall (intern (format "%s-request-accept-article" func)) | |
11951 (if (stringp group) (gnus-group-real-name group) group) | |
11952 last))) | |
11953 | |
11954 (defun gnus-request-replace-article (article group buffer) | |
11955 (let ((func (car (gnus-find-method-for-group group)))) | |
11956 (funcall (intern (format "%s-request-replace-article" func)) | |
11957 article (gnus-group-real-name group) buffer))) | |
11958 | |
11959 (defun gnus-request-create-group (group) | |
11960 (let ((method (gnus-find-method-for-group group))) | |
11961 (funcall (gnus-get-function method 'request-create-group) | |
11962 (gnus-group-real-name group) (nth 1 method)))) | |
11963 | |
11964 (defun gnus-member-of-valid (symbol group) | |
11965 (memq symbol (assoc | |
11966 (format "%s" (car (gnus-find-method-for-group group))) | |
11967 gnus-valid-select-methods))) | |
11968 | |
11969 (defun gnus-secondary-method-p (method) | |
11970 (let ((methods gnus-secondary-select-methods) | |
11971 (gmethod (gnus-server-get-method nil method))) | |
11972 (while (and methods | |
11973 (not (equal (gnus-server-get-method nil (car methods)) | |
11974 gmethod))) | |
11975 (setq methods (cdr methods))) | |
11976 methods)) | |
11977 | |
11978 (defun gnus-find-method-for-group (group &optional info) | |
11979 (or gnus-override-method | |
11980 (and (not group) | |
11981 gnus-select-method) | |
11982 (let ((info (or info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))) | |
11983 method) | |
11984 (if (or (not info) | |
11985 (not (setq method (nth 4 info)))) | |
11986 (setq method gnus-select-method) | |
11987 (setq method | |
11988 (cond ((stringp method) | |
11989 (gnus-server-to-method method)) | |
11990 ((stringp (car method)) | |
11991 (gnus-server-extend-method group method)) | |
11992 (t | |
11993 method)))) | |
11994 (gnus-server-add-address method)))) | |
11995 | |
11996 (defun gnus-check-backend-function (func group) | |
11997 (let ((method (if (stringp group) (car (gnus-find-method-for-group group)) | |
11998 group))) | |
11999 (fboundp (intern (format "%s-%s" method func))))) | |
12000 | |
12001 (defun gnus-methods-using (method) | |
12002 (let ((valids gnus-valid-select-methods) | |
12003 outs) | |
12004 (while valids | |
12005 (if (memq method (car valids)) | |
12006 (setq outs (cons (car valids) outs))) | |
12007 (setq valids (cdr valids))) | |
12008 outs)) | |
12009 | |
12010 ;;; | |
12011 ;;; Active & Newsrc File Handling | |
12012 ;;; | |
12013 | |
12014 ;; Newsrc related functions. | |
12015 ;; Gnus internal format of gnus-newsrc-alist: | |
12016 ;; (("alt.general" 3 (1 . 1)) | |
12017 ;; ("alt.misc" 3 ((1 . 10) (12 . 15))) | |
12018 ;; ("alt.test" 7 (1 . 99) (45 57 93)) ...) | |
12019 ;; The first item is the group name; the second is the subscription | |
12020 ;; level; the third is either a range of a list of ranges of read | |
12021 ;; articles, the optional fourth element is a list of marked articles, | |
12022 ;; the optional fifth element is the select method. | |
12023 ;; | |
12024 ;; Gnus internal format of gnus-newsrc-hashtb: | |
12025 ;; (95 ("alt.general" 3 (1 . 1)) ("alt.misc" 3 ((1 . 10) (12 . 15))) ...) | |
12026 ;; This is the entry for "alt.misc". The first element is the number | |
12027 ;; of unread articles in "alt.misc". The cdr of this entry is the | |
12028 ;; element *before* "alt.misc" in gnus-newsrc-alist, which makes is | |
12029 ;; trivial to remove or add new elements into gnus-newsrc-alist | |
12030 ;; without scanning the entire list. So, to get the actual information | |
12031 ;; of "alt.misc", you'd say something like | |
12032 ;; (nth 2 (gnus-gethash "alt.misc" gnus-newsrc-hashtb)) | |
12033 ;; | |
12034 ;; Gnus internal format of gnus-active-hashtb: | |
12035 ;; ((1 . 1)) | |
12036 ;; (5 . 10)) | |
12037 ;; (67 . 99)) ...) | |
12038 ;; The only element in each entry in this hash table is a range of | |
12039 ;; (possibly) available articles. (Articles in this range may have | |
12040 ;; been expired or canceled.) | |
12041 ;; | |
12042 ;; Gnus internal format of gnus-killed-list and gnus-zombie-list: | |
12043 ;; ("alt.misc" "alt.test" "alt.general" ...) | |
12044 | |
12045 (defun gnus-setup-news (&optional rawfile level) | |
12046 "Setup news information. | |
12047 If RAWFILE is non-nil, the .newsrc file will also be read. | |
12048 If LEVEL is non-nil, the news will be set up at level LEVEL." | |
12049 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile))))) | |
12050 ;; Clear some variables to re-initialize news information. | |
12051 (if init (setq gnus-newsrc-alist nil | |
12052 gnus-active-hashtb nil)) | |
12053 | |
12054 ;; Read the newsrc file and create `gnus-newsrc-hashtb'. | |
12055 (if init (gnus-read-newsrc-file rawfile)) | |
12056 | |
12057 ;; If we don't read the complete active file, we fill in the | |
12058 ;; hashtb here. | |
12059 (if (or (null gnus-read-active-file) | |
12060 (eq gnus-read-active-file 'some)) | |
12061 (gnus-update-active-hashtb-from-killed)) | |
12062 | |
12063 ;; Read the active file and create `gnus-active-hashtb'. | |
12064 ;; If `gnus-read-active-file' is nil, then we just create an empty | |
12065 ;; hash table. The partial filling out of the hash table will be | |
12066 ;; done in `gnus-get-unread-articles'. | |
12067 (and gnus-read-active-file | |
12068 (not level) | |
12069 (gnus-read-active-file)) | |
12070 | |
12071 (or gnus-active-hashtb | |
12072 (setq gnus-active-hashtb (make-vector 4095 0))) | |
12073 | |
12074 ;; Possibly eval the dribble file. | |
12075 (and init gnus-use-dribble-file (gnus-dribble-eval-file)) | |
12076 | |
12077 (gnus-update-format-specifications) | |
12078 | |
12079 ;; Find new newsgroups and treat them. | |
12080 (if (and init gnus-check-new-newsgroups gnus-read-active-file (not level) | |
13694
73433c3071a5
* gnus.el (gnus-parse-headers-hook): New hook.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
13579
diff
changeset
|
12081 (gnus-check-server gnus-select-method)) |
13401 | 12082 (gnus-find-new-newsgroups)) |
12083 | |
12084 ;; Find the number of unread articles in each non-dead group. | |
12085 (let ((gnus-read-active-file (and (not level) gnus-read-active-file))) | |
12086 (gnus-get-unread-articles (or level (1+ gnus-level-subscribed)))) | |
12087 | |
12088 (if (and init gnus-check-bogus-newsgroups | |
12089 gnus-read-active-file (not level) | |
12090 (gnus-server-opened gnus-select-method)) | |
12091 (gnus-check-bogus-newsgroups)))) | |
12092 | |
12093 (defun gnus-find-new-newsgroups () | |
12094 "Search for new newsgroups and add them. | |
12095 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.' | |
12096 The `-n' option line from .newsrc is respected." | |
12097 (interactive) | |
12098 (or (gnus-check-first-time-used) | |
12099 (if (or (consp gnus-check-new-newsgroups) | |
12100 (eq gnus-check-new-newsgroups 'ask-server)) | |
12101 (gnus-ask-server-for-new-groups) | |
12102 (let ((groups 0) | |
12103 group new-newsgroups) | |
12104 (gnus-message 5 "Looking for new newsgroups...") | |
12105 (or gnus-have-read-active-file (gnus-read-active-file)) | |
12106 (setq gnus-newsrc-last-checked-date (current-time-string)) | |
12107 (if (not gnus-killed-hashtb) (gnus-make-hashtable-from-killed)) | |
12108 ;; Go though every newsgroup in `gnus-active-hashtb' and compare | |
12109 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'. | |
12110 (mapatoms | |
12111 (lambda (sym) | |
12112 (if (or (null (setq group (symbol-name sym))) | |
12113 (null (symbol-value sym)) | |
12114 (gnus-gethash group gnus-killed-hashtb) | |
12115 (gnus-gethash group gnus-newsrc-hashtb)) | |
12116 () | |
12117 (let ((do-sub (gnus-matches-options-n group))) | |
12118 (cond | |
12119 ((eq do-sub 'subscribe) | |
12120 (setq groups (1+ groups)) | |
12121 (gnus-sethash group group gnus-killed-hashtb) | |
12122 (funcall gnus-subscribe-options-newsgroup-method group)) | |
12123 ((eq do-sub 'ignore) | |
12124 nil) | |
12125 (t | |
12126 (setq groups (1+ groups)) | |
12127 (gnus-sethash group group gnus-killed-hashtb) | |
12128 (if gnus-subscribe-hierarchical-interactive | |
12129 (setq new-newsgroups (cons group new-newsgroups)) | |
12130 (funcall gnus-subscribe-newsgroup-method group))))))) | |
12131 gnus-active-hashtb) | |
12132 (if new-newsgroups | |
12133 (gnus-subscribe-hierarchical-interactive new-newsgroups)) | |
12134 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>. | |
12135 (if (> groups 0) | |
12136 (gnus-message 6 "%d new newsgroup%s arrived." | |
12137 groups (if (> groups 1) "s have" " has")) | |
12138 (gnus-message 6 "No new newsgroups.")))))) | |
12139 | |
12140 (defun gnus-matches-options-n (group) | |
12141 ;; Returns `subscribe' if the group is to be uncoditionally | |
12142 ;; subscribed, `ignore' if it is to be ignored, and nil if there is | |
12143 ;; no match for the group. | |
12144 | |
12145 ;; First we check the two user variables. | |
12146 (cond | |
12147 ((and gnus-options-subscribe | |
12148 (string-match gnus-options-subscribe group)) | |
12149 'subscribe) | |
12150 ((and gnus-options-not-subscribe | |
12151 (string-match gnus-options-not-subscribe group)) | |
12152 'ignore) | |
12153 ;; Then we go through the list that was retrieved from the .newsrc | |
12154 ;; file. This list has elements on the form | |
12155 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list | |
12156 ;; is in the reverse order of the options line) is returned. | |
12157 (t | |
12158 (let ((regs gnus-newsrc-options-n)) | |
12159 (while (and regs | |
12160 (not (string-match (car (car regs)) group))) | |
12161 (setq regs (cdr regs))) | |
12162 (and regs (cdr (car regs))))))) | |
12163 | |
12164 (defun gnus-ask-server-for-new-groups () | |
12165 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string))) | |
12166 (methods (cons gnus-select-method | |
12167 (append | |
12168 (and (consp gnus-check-new-newsgroups) | |
12169 gnus-check-new-newsgroups) | |
12170 gnus-secondary-select-methods))) | |
12171 (groups 0) | |
12172 (new-date (current-time-string)) | |
12173 (hashtb (gnus-make-hashtable 100)) | |
12174 group new-newsgroups got-new method) | |
12175 ;; Go through both primary and secondary select methods and | |
12176 ;; request new newsgroups. | |
12177 (while methods | |
12178 (setq method (gnus-server-get-method nil (car methods))) | |
12179 (and (gnus-check-server method) | |
12180 (gnus-request-newgroups date method) | |
12181 (save-excursion | |
12182 (setq got-new t) | |
12183 (set-buffer nntp-server-buffer) | |
12184 ;; Enter all the new groups in a hashtable. | |
12185 (gnus-active-to-gnus-format method hashtb 'ignore))) | |
12186 (setq methods (cdr methods))) | |
12187 (and got-new (setq gnus-newsrc-last-checked-date new-date)) | |
12188 ;; Now all new groups from all select methods are in `hashtb'. | |
12189 (mapatoms | |
12190 (lambda (group-sym) | |
12191 (setq group (symbol-name group-sym)) | |
12192 (if (or (null group) | |
12193 (null (symbol-value group-sym)) | |
12194 (gnus-gethash group gnus-newsrc-hashtb) | |
12195 (member group gnus-zombie-list) | |
12196 (member group gnus-killed-list)) | |
12197 ;; The group is already known. | |
12198 () | |
12199 (and (symbol-value group-sym) | |
12200 (gnus-sethash group (symbol-value group-sym) gnus-active-hashtb)) | |
12201 (let ((do-sub (gnus-matches-options-n group))) | |
12202 (cond ((eq do-sub 'subscribe) | |
12203 (setq groups (1+ groups)) | |
12204 (gnus-sethash group group gnus-killed-hashtb) | |
12205 (funcall | |
12206 gnus-subscribe-options-newsgroup-method group)) | |
12207 ((eq do-sub 'ignore) | |
12208 nil) | |
12209 (t | |
12210 (setq groups (1+ groups)) | |
12211 (gnus-sethash group group gnus-killed-hashtb) | |
12212 (if gnus-subscribe-hierarchical-interactive | |
12213 (setq new-newsgroups (cons group new-newsgroups)) | |
12214 (funcall gnus-subscribe-newsgroup-method group))))))) | |
12215 hashtb) | |
12216 (if new-newsgroups | |
12217 (gnus-subscribe-hierarchical-interactive new-newsgroups)) | |
12218 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>. | |
12219 (if (> groups 0) | |
12220 (gnus-message 6 "%d new newsgroup%s arrived." | |
12221 groups (if (> groups 1) "s have" " has"))) | |
12222 got-new)) | |
12223 | |
12224 (defun gnus-check-first-time-used () | |
12225 (if (or (> (length gnus-newsrc-alist) 1) | |
12226 (file-exists-p gnus-startup-file) | |
12227 (file-exists-p (concat gnus-startup-file ".el")) | |
12228 (file-exists-p (concat gnus-startup-file ".eld"))) | |
12229 nil | |
12230 (gnus-message 6 "First time user; subscribing you to default groups") | |
12231 (or gnus-have-read-active-file (gnus-read-active-file)) | |
12232 (setq gnus-newsrc-last-checked-date (current-time-string)) | |
12233 (let ((groups gnus-default-subscribed-newsgroups) | |
12234 group) | |
12235 (if (eq groups t) | |
12236 nil | |
12237 (setq groups (or groups gnus-backup-default-subscribed-newsgroups)) | |
12238 (mapatoms | |
12239 (lambda (sym) | |
12240 (if (null (setq group (symbol-name sym))) | |
12241 () | |
12242 (let ((do-sub (gnus-matches-options-n group))) | |
12243 (cond | |
12244 ((eq do-sub 'subscribe) | |
12245 (gnus-sethash group group gnus-killed-hashtb) | |
12246 (funcall gnus-subscribe-options-newsgroup-method group)) | |
12247 ((eq do-sub 'ignore) | |
12248 nil) | |
12249 (t | |
12250 (setq gnus-killed-list (cons group gnus-killed-list))))))) | |
12251 gnus-active-hashtb) | |
12252 (while groups | |
12253 (if (gnus-gethash (car groups) gnus-active-hashtb) | |
12254 (gnus-group-change-level | |
12255 (car groups) gnus-level-default-subscribed gnus-level-killed)) | |
12256 (setq groups (cdr groups))) | |
12257 (gnus-group-make-help-group) | |
12258 (and gnus-novice-user | |
12259 (gnus-message 7 "`A k' to list killed groups")))))) | |
12260 | |
12261 (defun gnus-subscribe-group (group previous &optional method) | |
12262 (gnus-group-change-level | |
12263 (if method | |
12264 (list t group gnus-level-default-subscribed nil nil method) | |
12265 group) | |
12266 gnus-level-default-subscribed gnus-level-killed previous t)) | |
12267 | |
12268 ;; `gnus-group-change-level' is the fundamental function for changing | |
12269 ;; subscription levels of newsgroups. This might mean just changing | |
12270 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back | |
12271 ;; again, which subscribes/unsubscribes a group, which is equally | |
12272 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and | |
12273 ;; from 8-9 to 1-7 means that you remove the group from the list of | |
12274 ;; killed (or zombie) groups and add them to the (kinda) subscribed | |
12275 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8, | |
12276 ;; which is trivial. | |
12277 ;; ENTRY can either be a string (newsgroup name) or a list (if | |
12278 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST), | |
12279 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb' | |
12280 ;; entries. | |
12281 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and | |
12282 ;; PREVIOUS is the group (in hashtb entry format) to insert this group | |
12283 ;; after. | |
12284 (defun gnus-group-change-level (entry level &optional oldlevel | |
12285 previous fromkilled) | |
12286 (let (group info active num) | |
12287 ;; Glean what info we can from the arguments | |
12288 (if (consp entry) | |
12289 (if fromkilled (setq group (nth 1 entry)) | |
12290 (setq group (car (nth 2 entry)))) | |
12291 (setq group entry)) | |
12292 (if (and (stringp entry) | |
12293 oldlevel | |
12294 (< oldlevel gnus-level-zombie)) | |
12295 (setq entry (gnus-gethash entry gnus-newsrc-hashtb))) | |
12296 (if (and (not oldlevel) | |
12297 (consp entry)) | |
12298 (setq oldlevel (car (cdr (nth 2 entry))))) | |
12299 (if (stringp previous) | |
12300 (setq previous (gnus-gethash previous gnus-newsrc-hashtb))) | |
12301 | |
12302 (if (and (>= oldlevel gnus-level-zombie) | |
12303 (gnus-gethash group gnus-newsrc-hashtb)) | |
12304 ;; We are trying to subscribe a group that is already | |
12305 ;; subscribed. | |
12306 () ; Do nothing. | |
12307 | |
12308 (or (gnus-ephemeral-group-p group) | |
12309 (gnus-dribble-enter | |
12310 (format "(gnus-group-change-level %S %S %S %S %S)" | |
12311 group level oldlevel (car (nth 2 previous)) fromkilled))) | |
12312 | |
12313 ;; Then we remove the newgroup from any old structures, if needed. | |
12314 ;; If the group was killed, we remove it from the killed or zombie | |
12315 ;; list. If not, and it is in fact going to be killed, we remove | |
12316 ;; it from the newsrc hash table and assoc. | |
12317 (cond ((>= oldlevel gnus-level-zombie) | |
12318 (if (= oldlevel gnus-level-zombie) | |
12319 (setq gnus-zombie-list (delete group gnus-zombie-list)) | |
12320 (setq gnus-killed-list (delete group gnus-killed-list)))) | |
12321 (t | |
12322 (if (and (>= level gnus-level-zombie) | |
12323 entry) | |
12324 (progn | |
12325 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb) | |
12326 (if (nth 3 entry) | |
12327 (setcdr (gnus-gethash (car (nth 3 entry)) | |
12328 gnus-newsrc-hashtb) | |
12329 (cdr entry))) | |
12330 (setcdr (cdr entry) (cdr (cdr (cdr entry)))))))) | |
12331 | |
12332 ;; Finally we enter (if needed) the list where it is supposed to | |
12333 ;; go, and change the subscription level. If it is to be killed, | |
12334 ;; we enter it into the killed or zombie list. | |
12335 (cond ((>= level gnus-level-zombie) | |
12336 ;; Remove from the hash table. | |
12337 (gnus-sethash group nil gnus-newsrc-hashtb) | |
12338 (or (gnus-group-foreign-p group) | |
12339 ;; We do not enter foreign groups into the list of dead | |
12340 ;; groups. | |
12341 (if (= level gnus-level-zombie) | |
12342 (setq gnus-zombie-list (cons group gnus-zombie-list)) | |
12343 (setq gnus-killed-list (cons group gnus-killed-list))))) | |
12344 (t | |
12345 ;; If the list is to be entered into the newsrc assoc, and | |
12346 ;; it was killed, we have to create an entry in the newsrc | |
12347 ;; hashtb format and fix the pointers in the newsrc assoc. | |
12348 (if (>= oldlevel gnus-level-zombie) | |
12349 (progn | |
12350 (if (listp entry) | |
12351 (progn | |
12352 (setq info (cdr entry)) | |
12353 (setq num (car entry))) | |
12354 (setq active (gnus-gethash group gnus-active-hashtb)) | |
12355 (setq num | |
12356 (if active (- (1+ (cdr active)) (car active)) t)) | |
12357 ;; Check whether the group is foreign. If so, the | |
12358 ;; foreign select method has to be entered into the | |
12359 ;; info. | |
12360 (let ((method (gnus-group-method-name group))) | |
12361 (if (eq method gnus-select-method) | |
12362 (setq info (list group level nil)) | |
12363 (setq info (list group level nil nil method))))) | |
12364 (or previous | |
12365 (setq previous | |
12366 (let ((p gnus-newsrc-alist)) | |
12367 (while (cdr (cdr p)) | |
12368 (setq p (cdr p))) | |
12369 p))) | |
12370 (setq entry (cons info (cdr (cdr previous)))) | |
12371 (if (cdr previous) | |
12372 (progn | |
12373 (setcdr (cdr previous) entry) | |
12374 (gnus-sethash group (cons num (cdr previous)) | |
12375 gnus-newsrc-hashtb)) | |
12376 (setcdr previous entry) | |
12377 (gnus-sethash group (cons num previous) | |
12378 gnus-newsrc-hashtb)) | |
12379 (if (cdr entry) | |
12380 (setcdr (gnus-gethash (car (car (cdr entry))) | |
12381 gnus-newsrc-hashtb) | |
12382 entry))) | |
12383 ;; It was alive, and it is going to stay alive, so we | |
12384 ;; just change the level and don't change any pointers or | |
12385 ;; hash table entries. | |
12386 (setcar (cdr (car (cdr (cdr entry)))) level))))))) | |
12387 | |
12388 (defun gnus-kill-newsgroup (newsgroup) | |
12389 "Obsolete function. Kills a newsgroup." | |
12390 (gnus-group-change-level | |
12391 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed)) | |
12392 | |
12393 (defun gnus-check-bogus-newsgroups (&optional confirm) | |
12394 "Remove bogus newsgroups. | |
12395 If CONFIRM is non-nil, the user has to confirm the deletion of every | |
12396 newsgroup." | |
12397 (let ((newsrc (cdr gnus-newsrc-alist)) | |
12398 bogus group entry) | |
12399 (gnus-message 5 "Checking bogus newsgroups...") | |
12400 (or gnus-have-read-active-file (gnus-read-active-file)) | |
12401 ;; Find all bogus newsgroup that are subscribed. | |
12402 (while newsrc | |
12403 (setq group (car (car newsrc))) | |
12404 (if (or (gnus-gethash group gnus-active-hashtb) ; Active | |
12405 (nth 4 (car newsrc)) ; Foreign | |
12406 (and confirm | |
12407 (not (gnus-y-or-n-p | |
12408 (format "Remove bogus newsgroup: %s " group))))) | |
12409 ;; Don't remove. | |
12410 () | |
12411 ;; Found a bogus newsgroup. | |
12412 (setq bogus (cons group bogus))) | |
12413 (setq newsrc (cdr newsrc))) | |
12414 ;; Remove all bogus subscribed groups by first killing them, and | |
12415 ;; then removing them from the list of killed groups. | |
12416 (while bogus | |
12417 (and (setq entry (gnus-gethash (car bogus) gnus-newsrc-hashtb)) | |
12418 (progn | |
12419 (gnus-group-change-level entry gnus-level-killed) | |
12420 (setq gnus-killed-list (delete (car bogus) gnus-killed-list)))) | |
12421 (setq bogus (cdr bogus))) | |
12422 ;; Then we remove all bogus groups from the list of killed and | |
12423 ;; zombie groups. They are are removed without confirmation. | |
12424 (let ((dead-lists '(gnus-killed-list gnus-zombie-list)) | |
12425 killed) | |
12426 (while dead-lists | |
12427 (setq killed (symbol-value (car dead-lists))) | |
12428 (while killed | |
12429 (setq group (car killed)) | |
12430 (or (gnus-gethash group gnus-active-hashtb) | |
12431 ;; The group is bogus. | |
12432 (set (car dead-lists) | |
12433 (delete group (symbol-value (car dead-lists))))) | |
12434 (setq killed (cdr killed))) | |
12435 (setq dead-lists (cdr dead-lists)))) | |
12436 (gnus-message 5 "Checking bogus newsgroups...done"))) | |
12437 | |
12438 (defun gnus-check-duplicate-killed-groups () | |
12439 "Remove duplicates from the list of killed groups." | |
12440 (interactive) | |
12441 (let ((killed gnus-killed-list)) | |
12442 (while killed | |
12443 (gnus-message 9 "%d" (length killed)) | |
12444 (setcdr killed (delete (car killed) (cdr killed))) | |
12445 (setq killed (cdr killed))))) | |
12446 | |
12447 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb' | |
12448 ;; and compute how many unread articles there are in each group. | |
12449 (defun gnus-get-unread-articles (&optional level) | |
12450 (let* ((newsrc (cdr gnus-newsrc-alist)) | |
12451 (level (or level (1+ gnus-level-subscribed))) | |
12452 (foreign-level | |
12453 (min | |
12454 (cond ((and gnus-activate-foreign-newsgroups | |
12455 (not (numberp gnus-activate-foreign-newsgroups))) | |
12456 (1+ gnus-level-subscribed)) | |
12457 ((numberp gnus-activate-foreign-newsgroups) | |
12458 gnus-activate-foreign-newsgroups) | |
12459 (t 0)) | |
12460 level)) | |
12461 info group active virtuals method) | |
12462 (gnus-message 5 "Checking new news...") | |
12463 | |
12464 (while newsrc | |
12465 (setq info (car newsrc) | |
12466 group (car info) | |
12467 active (gnus-gethash group gnus-active-hashtb)) | |
12468 | |
12469 ;; Check newsgroups. If the user doesn't want to check them, or | |
12470 ;; they can't be checked (for instance, if the news server can't | |
12471 ;; be reached) we just set the number of unread articles in this | |
12472 ;; newsgroup to t. This means that Gnus thinks that there are | |
12473 ;; unread articles, but it has no idea how many. | |
12474 (if (and (setq method (nth 4 info)) | |
12475 (not (gnus-server-equal gnus-select-method | |
12476 (gnus-server-get-method nil method))) | |
12477 (not (gnus-secondary-method-p method))) | |
12478 ;; These groups are foreign. Check the level. | |
12479 (if (<= (nth 1 info) foreign-level) | |
12480 (if (eq (car (if (stringp method) | |
12481 (gnus-server-to-method method) | |
12482 (nth 4 info))) 'nnvirtual) | |
12483 ;; We have to activate the virtual groups after all | |
12484 ;; the others, so we just pop them on a list for | |
12485 ;; now. | |
12486 (setq virtuals (cons info virtuals)) | |
12487 (and (setq active (gnus-activate-group (car info))) | |
12488 ;; Close the groups as we look at them! | |
12489 (gnus-close-group group)))) | |
12490 | |
12491 ;; These groups are native or secondary. | |
12492 (if (and (not gnus-read-active-file) | |
12493 (<= (nth 1 info) level)) | |
12494 (progn | |
12495 (or gnus-read-active-file (gnus-check-server method)) | |
12496 (setq active (gnus-activate-group (car info)))))) | |
12497 | |
12498 (if active | |
12499 (gnus-get-unread-articles-in-group info active) | |
12500 ;; The group couldn't be reached, so we nix out the number of | |
12501 ;; unread articles and stuff. | |
12502 (gnus-sethash group nil gnus-active-hashtb) | |
12503 (setcar (gnus-gethash group gnus-newsrc-hashtb) t)) | |
12504 | |
12505 (setq newsrc (cdr newsrc))) | |
12506 | |
12507 ;; Activate the virtual groups. This has to be done after all the | |
12508 ;; other groups. | |
12509 ;; !!! If one virtual group contains another virtual group, even | |
12510 ;; doing it this way might cause problems. | |
12511 (while virtuals | |
12512 (and (setq active (gnus-activate-group (car (car virtuals)))) | |
12513 (gnus-get-unread-articles-in-group (car virtuals) active)) | |
12514 (setq virtuals (cdr virtuals))) | |
12515 | |
12516 (gnus-message 5 "Checking new news...done"))) | |
12517 | |
12518 ;; Create a hash table out of the newsrc alist. The `car's of the | |
12519 ;; alist elements are used as keys. | |
12520 (defun gnus-make-hashtable-from-newsrc-alist () | |
12521 (let ((alist gnus-newsrc-alist) | |
12522 (ohashtb gnus-newsrc-hashtb) | |
12523 prev) | |
12524 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist))) | |
12525 (setq alist | |
12526 (setq prev (setq gnus-newsrc-alist | |
12527 (if (equal (car (car gnus-newsrc-alist)) | |
12528 "dummy.group") | |
12529 gnus-newsrc-alist | |
12530 (cons (list "dummy.group" 0 nil) alist))))) | |
12531 (while alist | |
12532 (gnus-sethash (car (car alist)) | |
12533 (cons (and ohashtb (car (gnus-gethash | |
12534 (car (car alist)) ohashtb))) | |
12535 prev) gnus-newsrc-hashtb) | |
12536 (setq prev alist | |
12537 alist (cdr alist))))) | |
12538 | |
12539 (defun gnus-make-hashtable-from-killed () | |
12540 "Create a hash table from the killed and zombie lists." | |
12541 (let ((lists '(gnus-killed-list gnus-zombie-list)) | |
12542 list) | |
12543 (setq gnus-killed-hashtb | |
12544 (gnus-make-hashtable | |
12545 (+ (length gnus-killed-list) (length gnus-zombie-list)))) | |
12546 (while lists | |
12547 (setq list (symbol-value (car lists))) | |
12548 (setq lists (cdr lists)) | |
12549 (while list | |
12550 (gnus-sethash (car list) (car list) gnus-killed-hashtb) | |
12551 (setq list (cdr list)))))) | |
12552 | |
12553 (defun gnus-get-unread-articles-in-group (info active) | |
12554 (let* ((range (nth 2 info)) | |
12555 (num 0) | |
12556 (marked (nth 3 info))) | |
12557 ;; If a cache is present, we may have to alter the active info. | |
12558 (and gnus-use-cache | |
12559 (gnus-cache-possibly-alter-active (car info) active)) | |
12560 ;; Modify the list of read articles according to what articles | |
12561 ;; are available; then tally the unread articles and add the | |
12562 ;; number to the group hash table entry. | |
12563 (cond | |
12564 ((zerop (cdr active)) | |
12565 (setq num 0)) | |
12566 ((not range) | |
12567 (setq num (- (1+ (cdr active)) (car active)))) | |
12568 ((not (listp (cdr range))) | |
12569 ;; Fix a single (num . num) range according to the | |
12570 ;; active hash table. | |
12571 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>. | |
12572 (and (< (cdr range) (car active)) (setcdr range (1- (car active)))) | |
12573 (and (> (cdr range) (cdr active)) (setcdr range (cdr active))) | |
12574 ;; Compute number of unread articles. | |
12575 (setq num (max 0 (- (cdr active) (- (1+ (cdr range)) (car range)))))) | |
12576 (t | |
12577 ;; The read list is a list of ranges. Fix them according to | |
12578 ;; the active hash table. | |
12579 ;; First peel off any elements that are below the lower | |
12580 ;; active limit. | |
12581 (while (and (cdr range) | |
12582 (>= (car active) | |
12583 (or (and (atom (car (cdr range))) (car (cdr range))) | |
12584 (car (car (cdr range)))))) | |
12585 (if (numberp (car range)) | |
12586 (setcar range | |
12587 (cons (car range) | |
12588 (or (and (numberp (car (cdr range))) | |
12589 (car (cdr range))) | |
12590 (cdr (car (cdr range)))))) | |
12591 (setcdr (car range) | |
12592 (or (and (numberp (nth 1 range)) (nth 1 range)) | |
12593 (cdr (car (cdr range)))))) | |
12594 (setcdr range (cdr (cdr range)))) | |
12595 ;; Adjust the first element to be the same as the lower limit. | |
12596 (if (and (not (atom (car range))) | |
12597 (< (cdr (car range)) (car active))) | |
12598 (setcdr (car range) (1- (car active)))) | |
12599 ;; Then we want to peel off any elements that are higher | |
12600 ;; than the upper active limit. | |
12601 (let ((srange range)) | |
12602 ;; Go past all legal elements. | |
12603 (while (and (cdr srange) | |
12604 (<= (or (and (atom (car (cdr srange))) | |
12605 (car (cdr srange))) | |
12606 (car (car (cdr srange)))) (cdr active))) | |
12607 (setq srange (cdr srange))) | |
12608 (if (cdr srange) | |
12609 ;; Nuke all remaining illegal elements. | |
12610 (setcdr srange nil)) | |
12611 | |
12612 ;; Adjust the final element. | |
12613 (if (and (not (atom (car srange))) | |
12614 (> (cdr (car srange)) (cdr active))) | |
12615 (setcdr (car srange) (cdr active)))) | |
12616 ;; Compute the number of unread articles. | |
12617 (while range | |
12618 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range)) | |
12619 (cdr (car range)))) | |
12620 (or (and (atom (car range)) (car range)) | |
12621 (car (car range)))))) | |
12622 (setq range (cdr range))) | |
12623 (setq num (max 0 (- (cdr active) num))))) | |
12624 (and info | |
12625 (progn | |
12626 (and (assq 'tick marked) | |
12627 (inline (gnus-remove-illegal-marked-articles | |
12628 (assq 'tick marked) (nth 2 info)))) | |
12629 (and (assq 'dormant marked) | |
12630 (inline (gnus-remove-illegal-marked-articles | |
12631 (assq 'dormant marked) (nth 2 info)))) | |
12632 (setcar | |
12633 (gnus-gethash (car info) gnus-newsrc-hashtb) | |
12634 (setq num (max 0 (- num (length (cdr (assq 'tick marked))) | |
12635 (length (cdr (assq 'dormant marked))))))))) | |
12636 num)) | |
12637 | |
12638 (defun gnus-remove-illegal-marked-articles (marked ranges) | |
12639 (let ((m (cdr marked))) | |
12640 ;; Make sure that all ticked articles are a subset of the unread | |
12641 ;; articles. | |
12642 (while m | |
12643 (if (gnus-member-of-range (car m) ranges) | |
12644 (setcdr marked (cdr m)) | |
12645 (setq marked m)) | |
12646 (setq m (cdr m))))) | |
12647 | |
12648 (defun gnus-activate-group (group) | |
12649 ;; Check whether a group has been activated or not. | |
12650 (let ((method (gnus-find-method-for-group group)) | |
12651 active) | |
12652 (and (gnus-check-server method) | |
12653 ;; We escape all bugs and quit here to make it possible to | |
12654 ;; continue if a group is so out-there that it reports bugs | |
12655 ;; and stuff. | |
12656 (condition-case () | |
12657 (gnus-request-group group) | |
12658 (error nil) | |
12659 (quit nil)) | |
12660 (save-excursion | |
12661 (set-buffer nntp-server-buffer) | |
12662 (goto-char (point-min)) | |
12663 ;; Parse the result we got from `gnus-request-group'. | |
12664 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+") | |
12665 (progn | |
12666 (goto-char (match-beginning 1)) | |
12667 (gnus-sethash | |
12668 group (setq active (cons (read (current-buffer)) | |
12669 (read (current-buffer)))) | |
12670 gnus-active-hashtb)) | |
12671 ;; Return the new active info. | |
12672 active))))) | |
12673 | |
12674 (defun gnus-update-read-articles | |
12675 (group unread unselected ticked &optional domarks replied expirable killed | |
12676 dormant bookmark score) | |
12677 "Update the list of read and ticked articles in GROUP using the | |
12678 UNREAD and TICKED lists. | |
12679 Note: UNSELECTED has to be sorted over `<'. | |
12680 Returns whether the updating was successful." | |
12681 (let* ((active (or gnus-newsgroup-active | |
12682 (gnus-gethash group gnus-active-hashtb))) | |
12683 (entry (gnus-gethash group gnus-newsrc-hashtb)) | |
12684 (info (nth 2 entry)) | |
12685 (marked (nth 3 info)) | |
12686 (prev 1) | |
12687 (unread (sort (copy-sequence unread) (function <))) | |
12688 read) | |
12689 (if (or (not info) (not active)) | |
12690 ;; There is no info on this group if it was, in fact, | |
12691 ;; killed. Gnus stores no information on killed groups, so | |
12692 ;; there's nothing to be done. | |
12693 ;; One could store the information somewhere temporarily, | |
12694 ;; perhaps... Hmmm... | |
12695 () | |
12696 ;; Remove any negative articles numbers. | |
12697 (while (and unread (< (car unread) 0)) | |
12698 (setq unread (cdr unread))) | |
12699 ;; Remove any expired article numbers | |
12700 (while (and unread (< (car unread) (car active))) | |
12701 (setq unread (cdr unread))) | |
12702 (while (and ticked (< (car ticked) (car active))) | |
12703 (setq ticked (cdr ticked))) | |
12704 (while (and dormant (< (car dormant) (car active))) | |
12705 (setq dormant (cdr dormant))) | |
12706 (setq unread (sort (append unselected unread) '<)) | |
12707 ;; Compute the ranges of read articles by looking at the list of | |
12708 ;; unread articles. | |
12709 (while unread | |
12710 (if (/= (car unread) prev) | |
12711 (setq read (cons (if (= prev (1- (car unread))) prev | |
12712 (cons prev (1- (car unread)))) read))) | |
12713 (setq prev (1+ (car unread))) | |
12714 (setq unread (cdr unread))) | |
12715 (if (<= prev (cdr active)) | |
12716 (setq read (cons (cons prev (cdr active)) read))) | |
12717 ;; Enter this list into the group info. | |
12718 (setcar (cdr (cdr info)) | |
12719 (if (> (length read) 1) (nreverse read) read)) | |
12720 ;; Enter the list of ticked articles. | |
12721 (gnus-set-marked-articles | |
12722 info ticked | |
12723 (if domarks replied (cdr (assq 'reply marked))) | |
12724 (if domarks expirable (cdr (assq 'expire marked))) | |
12725 (if domarks killed (cdr (assq 'killed marked))) | |
12726 (if domarks dormant (cdr (assq 'dormant marked))) | |
12727 (if domarks bookmark (cdr (assq 'bookmark marked))) | |
12728 (if domarks score (cdr (assq 'score marked)))) | |
12729 ;; Set the number of unread articles in gnus-newsrc-hashtb. | |
12730 (gnus-get-unread-articles-in-group | |
12731 info (gnus-gethash group gnus-active-hashtb)) | |
12732 t))) | |
12733 | |
12734 (defun gnus-make-articles-unread (group articles) | |
12735 "Mark ARTICLES in GROUP as unread." | |
12736 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb) | |
12737 (gnus-gethash (gnus-group-real-name group) | |
12738 gnus-newsrc-hashtb)))) | |
12739 (ranges (nth 2 info)) | |
12740 news) | |
12741 (while articles | |
12742 (and (gnus-member-of-range (car articles) ranges) | |
12743 (setq news (cons (car articles) news))) | |
12744 (setq articles (cdr articles))) | |
12745 (if (not news) | |
12746 () | |
12747 (setcar (nthcdr 2 info) | |
12748 (gnus-remove-from-range (nth 2 info) (nreverse news))) | |
12749 (gnus-group-update-group group t)))) | |
12750 | |
12751 ;; Enter all dead groups into the hashtb. | |
12752 (defun gnus-update-active-hashtb-from-killed () | |
12753 (let ((hashtb (setq gnus-active-hashtb (make-vector 4095 0))) | |
12754 (lists (list gnus-killed-list gnus-zombie-list)) | |
12755 killed) | |
12756 (while lists | |
12757 (setq killed (car lists)) | |
12758 (while killed | |
12759 (gnus-sethash (car killed) nil hashtb) | |
12760 (setq killed (cdr killed))) | |
12761 (setq lists (cdr lists))))) | |
12762 | |
12763 ;; Get the active file(s) from the backend(s). | |
12764 (defun gnus-read-active-file () | |
12765 (gnus-group-set-mode-line) | |
12766 (let ((methods (if (gnus-check-server gnus-select-method) | |
12767 ;; The native server is available. | |
12768 (cons gnus-select-method gnus-secondary-select-methods) | |
12769 ;; The native server is down, so we just do the | |
12770 ;; secondary ones. | |
12771 gnus-secondary-select-methods)) | |
12772 list-type) | |
12773 (setq gnus-have-read-active-file nil) | |
12774 (save-excursion | |
12775 (set-buffer nntp-server-buffer) | |
12776 (while methods | |
12777 (let* ((method (gnus-server-get-method nil (car methods))) | |
12778 (where (nth 1 method)) | |
12779 (mesg (format "Reading active file%s via %s..." | |
12780 (if (and where (not (zerop (length where)))) | |
12781 (concat " from " where) "") | |
12782 (car method)))) | |
12783 (gnus-message 5 mesg) | |
12784 (if (not (gnus-check-server method)) | |
12785 () | |
12786 (cond | |
12787 ((and (eq gnus-read-active-file 'some) | |
12788 (gnus-check-backend-function 'retrieve-groups (car method))) | |
12789 (let ((newsrc (cdr gnus-newsrc-alist)) | |
12790 (gmethod (gnus-server-get-method nil method)) | |
12791 groups) | |
12792 (while newsrc | |
12793 (and (gnus-server-equal | |
12794 (gnus-find-method-for-group | |
12795 (car (car newsrc)) (car newsrc)) | |
12796 gmethod) | |
12797 (setq groups (cons (gnus-group-real-name | |
12798 (car (car newsrc))) groups))) | |
12799 (setq newsrc (cdr newsrc))) | |
12800 (gnus-check-server method) | |
12801 (setq list-type (gnus-retrieve-groups groups method)) | |
12802 (cond | |
12803 ((not list-type) | |
12804 (gnus-message | |
12805 1 "Cannot read partial active file from %s server." | |
12806 (car method)) | |
12807 (ding) | |
12808 (sit-for 2)) | |
12809 ((eq list-type 'active) | |
12810 (gnus-active-to-gnus-format method gnus-active-hashtb)) | |
12811 (t | |
12812 (gnus-groups-to-gnus-format method gnus-active-hashtb))))) | |
12813 (t | |
12814 (if (not (gnus-request-list method)) | |
12815 (progn | |
12816 (gnus-message 1 "Cannot read active file from %s server." | |
12817 (car method)) | |
12818 (ding)) | |
12819 (gnus-active-to-gnus-format method) | |
12820 ;; We mark this active file as read. | |
12821 (setq gnus-have-read-active-file | |
12822 (cons method gnus-have-read-active-file)) | |
12823 (gnus-message 5 "%sdone" mesg)))))) | |
12824 (setq methods (cdr methods)))))) | |
12825 | |
12826 ;; Read an active file and place the results in `gnus-active-hashtb'. | |
12827 (defun gnus-active-to-gnus-format (method &optional hashtb ignore-errors) | |
12828 (let ((cur (current-buffer)) | |
12829 (hashtb (or hashtb | |
12830 (if (and gnus-active-hashtb | |
12831 (not (equal method gnus-select-method))) | |
12832 gnus-active-hashtb | |
12833 (setq gnus-active-hashtb | |
12834 (if (equal method gnus-select-method) | |
12835 (gnus-make-hashtable | |
12836 (count-lines (point-min) (point-max))) | |
12837 (gnus-make-hashtable 4096)))))) | |
12838 (flag-hashtb (gnus-make-hashtable 60))) | |
12839 ;; Delete unnecessary lines. | |
12840 (goto-char (point-min)) | |
12841 (while (search-forward "\nto." nil t) | |
12842 (delete-region (1+ (match-beginning 0)) | |
12843 (progn (forward-line 1) (point)))) | |
12844 (or (string= gnus-ignored-newsgroups "") | |
12845 (progn | |
12846 (goto-char (point-min)) | |
12847 (delete-matching-lines gnus-ignored-newsgroups))) | |
12848 ;; Make the group names readable as a lisp expression even if they | |
12849 ;; contain special characters. | |
12850 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>. | |
12851 (goto-char (point-max)) | |
12852 (while (re-search-backward "[][';?()#]" nil t) | |
12853 (insert ?\\)) | |
12854 ;; If these are groups from a foreign select method, we insert the | |
12855 ;; group prefix in front of the group names. | |
12856 (and method (not (gnus-server-equal | |
12857 (gnus-server-get-method nil method) | |
12858 (gnus-server-get-method nil gnus-select-method))) | |
12859 (let ((prefix (gnus-group-prefixed-name "" method))) | |
12860 (goto-char (point-min)) | |
12861 (while (and (not (eobp)) | |
12862 (progn (insert prefix) | |
12863 (zerop (forward-line 1))))))) | |
12864 ;; Store the active file in a hash table. | |
12865 (goto-char (point-min)) | |
12866 (if (string-match "%[oO]" gnus-group-line-format) | |
12867 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>. | |
12868 ;; If we want information on moderated groups, we use this | |
12869 ;; loop... | |
12870 (let* ((mod-hashtb (make-vector 7 0)) | |
12871 (m (intern "m" mod-hashtb)) | |
12872 group max min) | |
12873 (while (not (eobp)) | |
12874 (condition-case nil | |
12875 (progn | |
12876 (narrow-to-region (point) (gnus-point-at-eol)) | |
12877 (setq group (let ((obarray hashtb)) (read cur))) | |
12878 (if (and (numberp (setq max (read cur))) | |
12879 (numberp (setq min (read cur))) | |
12880 (progn | |
12881 (skip-chars-forward " \t") | |
12882 (not | |
12883 (or (= (following-char) ?=) | |
12884 (= (following-char) ?x) | |
12885 (= (following-char) ?j))))) | |
12886 (set group (cons min max)) | |
12887 (set group nil)) | |
12888 ;; Enter moderated groups into a list. | |
12889 (if (eq (let ((obarray mod-hashtb)) (read cur)) m) | |
12890 (setq gnus-moderated-list | |
12891 (cons (symbol-name group) gnus-moderated-list)))) | |
12892 (error | |
12893 (and group | |
12894 (symbolp group) | |
12895 (set group nil)))) | |
12896 (widen) | |
12897 (forward-line 1))) | |
12898 ;; And if we do not care about moderation, we use this loop, | |
12899 ;; which is faster. | |
12900 (let (group max min) | |
12901 (while (not (eobp)) | |
12902 (condition-case () | |
12903 (progn | |
12904 (narrow-to-region (point) (gnus-point-at-eol)) | |
12905 ;; group gets set to a symbol interned in the hash table | |
12906 ;; (what a hack!!) - jwz | |
12907 (setq group (let ((obarray hashtb)) (read cur))) | |
12908 (if (and (numberp (setq max (read cur))) | |
12909 (numberp (setq min (read cur))) | |
12910 (progn | |
12911 (skip-chars-forward " \t") | |
12912 (not | |
12913 (or (= (following-char) ?=) | |
12914 (= (following-char) ?x) | |
12915 (= (following-char) ?j))))) | |
12916 (set group (cons min max)) | |
12917 (set group nil))) | |
12918 (error | |
12919 (progn | |
12920 (and group | |
12921 (symbolp group) | |
12922 (set group nil)) | |
12923 (or ignore-errors | |
12924 (gnus-message 3 "Warning - illegal active: %s" | |
12925 (buffer-substring | |
12926 (gnus-point-at-bol) (gnus-point-at-eol))))))) | |
12927 (widen) | |
12928 (forward-line 1)))))) | |
12929 | |
12930 (defun gnus-groups-to-gnus-format (method &optional hashtb) | |
12931 ;; Parse a "groups" active file. | |
12932 (let ((cur (current-buffer)) | |
12933 (hashtb (or hashtb | |
12934 (if (and method gnus-active-hashtb) | |
12935 gnus-active-hashtb | |
12936 (setq gnus-active-hashtb | |
12937 (gnus-make-hashtable | |
12938 (count-lines (point-min) (point-max))))))) | |
12939 (prefix (and method | |
12940 (not (gnus-server-equal | |
12941 (gnus-server-get-method nil method) | |
12942 (gnus-server-get-method nil gnus-select-method))) | |
12943 (gnus-group-prefixed-name "" method)))) | |
12944 | |
12945 (goto-char (point-min)) | |
12946 ;; We split this into to separate loops, one with the prefix | |
12947 ;; and one without to speed the reading up somewhat. | |
12948 (if prefix | |
12949 (let (min max opoint group) | |
12950 (while (not (eobp)) | |
12951 (condition-case () | |
12952 (progn | |
12953 (read cur) (read cur) | |
12954 (setq min (read cur) | |
12955 max (read cur) | |
12956 opoint (point)) | |
12957 (skip-chars-forward " \t") | |
12958 (insert prefix) | |
12959 (goto-char opoint) | |
12960 (set (let ((obarray hashtb)) (read cur)) | |
12961 (cons min max))) | |
12962 (error (and group (symbolp group) (set group nil)))) | |
12963 (forward-line 1))) | |
12964 (let (min max group) | |
12965 (while (not (eobp)) | |
12966 (condition-case () | |
12967 (if (= (following-char) ?2) | |
12968 (progn | |
12969 (read cur) (read cur) | |
12970 (setq min (read cur) | |
12971 max (read cur)) | |
12972 (set (setq group (let ((obarray hashtb)) (read cur))) | |
12973 (cons min max)))) | |
12974 (error (and group (symbolp group) (set group nil)))) | |
12975 (forward-line 1)))))) | |
12976 | |
12977 (defun gnus-read-newsrc-file (&optional force) | |
12978 "Read startup file. | |
12979 If FORCE is non-nil, the .newsrc file is read." | |
12980 ;; Reset variables that might be defined in the .newsrc.eld file. | |
12981 (let ((variables gnus-variable-list)) | |
12982 (while variables | |
12983 (set (car variables) nil) | |
12984 (setq variables (cdr variables)))) | |
12985 (let* ((newsrc-file gnus-current-startup-file) | |
12986 (quick-file (concat newsrc-file ".el"))) | |
12987 (save-excursion | |
12988 ;; We always load the .newsrc.eld file. If always contains | |
12989 ;; much information that can not be gotten from the .newsrc | |
12990 ;; file (ticked articles, killed groups, foreign methods, etc.) | |
12991 (gnus-read-newsrc-el-file quick-file) | |
12992 | |
12993 (if (or force | |
12994 (and (file-newer-than-file-p newsrc-file quick-file) | |
12995 (file-newer-than-file-p newsrc-file | |
12996 (concat quick-file "d"))) | |
12997 (not gnus-newsrc-alist)) | |
12998 ;; We read the .newsrc file. Note that if there if a | |
12999 ;; .newsrc.eld file exists, it has already been read, and | |
13000 ;; the `gnus-newsrc-hashtb' has been created. While reading | |
13001 ;; the .newsrc file, Gnus will only use the information it | |
13002 ;; can find there for changing the data already read - | |
13003 ;; ie. reading the .newsrc file will not trash the data | |
13004 ;; already read (except for read articles). | |
13005 (save-excursion | |
13006 (gnus-message 5 "Reading %s..." newsrc-file) | |
13007 (set-buffer (find-file-noselect newsrc-file)) | |
13008 (buffer-disable-undo (current-buffer)) | |
13009 (gnus-newsrc-to-gnus-format) | |
13010 (kill-buffer (current-buffer)) | |
13011 (gnus-message 5 "Reading %s...done" newsrc-file)))))) | |
13012 | |
13013 (defun gnus-read-newsrc-el-file (file) | |
13014 (let ((ding-file (concat file "d"))) | |
13015 ;; We always, always read the .eld file. | |
13016 (gnus-message 5 "Reading %s..." ding-file) | |
13017 (let (gnus-newsrc-assoc) | |
13018 (condition-case nil | |
13019 (load ding-file t t t) | |
13020 (error nil)) | |
13021 (and gnus-newsrc-assoc (setq gnus-newsrc-alist gnus-newsrc-assoc))) | |
13022 (let ((inhibit-quit t)) | |
13023 (gnus-uncompress-newsrc-alist)) | |
13024 (gnus-make-hashtable-from-newsrc-alist) | |
13025 (if (not (file-newer-than-file-p file ding-file)) | |
13026 () | |
13027 ;; Old format quick file | |
13028 (gnus-message 5 "Reading %s..." file) | |
13029 ;; The .el file is newer than the .eld file, so we read that one | |
13030 ;; as well. | |
13031 (gnus-read-old-newsrc-el-file file)))) | |
13032 | |
13033 ;; Parse the old-style quick startup file | |
13034 (defun gnus-read-old-newsrc-el-file (file) | |
13035 (let (newsrc killed marked group m) | |
13036 (prog1 | |
13037 (let ((gnus-killed-assoc nil) | |
13038 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc) | |
13039 (prog1 | |
13040 (condition-case nil | |
13041 (load file t t t) | |
13042 (error nil)) | |
13043 (setq newsrc gnus-newsrc-assoc | |
13044 killed gnus-killed-assoc | |
13045 marked gnus-marked-assoc))) | |
13046 (setq gnus-newsrc-alist nil) | |
13047 (while newsrc | |
13048 (setq group (car newsrc)) | |
13049 (let ((info (nth 2 (gnus-gethash (car group) gnus-newsrc-hashtb)))) | |
13050 (if info | |
13051 (progn | |
13052 (setcar (nthcdr 2 info) (cdr (cdr group))) | |
13053 (setcar (cdr info) | |
13054 (if (nth 1 group) gnus-level-default-subscribed | |
13055 gnus-level-default-unsubscribed)) | |
13056 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist))) | |
13057 (setq gnus-newsrc-alist | |
13058 (cons | |
13059 (setq info | |
13060 (list (car group) | |
13061 (if (nth 1 group) gnus-level-default-subscribed | |
13062 gnus-level-default-unsubscribed) | |
13063 (cdr (cdr group)))) | |
13064 gnus-newsrc-alist))) | |
13065 (if (setq m (assoc (car group) marked)) | |
13066 (setcdr (cdr (cdr info)) | |
13067 (cons (list (cons 'tick (cdr m))) nil)))) | |
13068 (setq newsrc (cdr newsrc))) | |
13069 (setq newsrc killed) | |
13070 (while newsrc | |
13071 (setcar newsrc (car (car newsrc))) | |
13072 (setq newsrc (cdr newsrc))) | |
13073 (setq gnus-killed-list killed)) | |
13074 ;; The .el file version of this variable does not begin with | |
13075 ;; "options", while the .eld version does, so we just add it if it | |
13076 ;; isn't there. | |
13077 (and | |
13078 gnus-newsrc-options | |
13079 (progn | |
13080 (and (not (string-match "^ *options" gnus-newsrc-options)) | |
13081 (setq gnus-newsrc-options (concat "options " gnus-newsrc-options))) | |
13082 (and (not (string-match "\n$" gnus-newsrc-options)) | |
13083 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n"))) | |
13084 ;; Finally, if we read some options lines, we parse them. | |
13085 (or (string= gnus-newsrc-options "") | |
13086 (gnus-newsrc-parse-options gnus-newsrc-options)))) | |
13087 | |
13088 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)) | |
13089 (gnus-make-hashtable-from-newsrc-alist))) | |
13090 | |
13091 (defun gnus-make-newsrc-file (file) | |
13092 "Make server dependent file name by catenating FILE and server host name." | |
13093 (let* ((file (expand-file-name file nil)) | |
13094 (real-file (concat file "-" (nth 1 gnus-select-method)))) | |
13095 (if (or (file-exists-p real-file) | |
13096 (file-exists-p (concat real-file ".el")) | |
13097 (file-exists-p (concat real-file ".eld"))) | |
13098 real-file file))) | |
13099 | |
13100 (defun gnus-uncompress-newsrc-alist () | |
13101 ;; Uncompress all lists of marked articles in the newsrc assoc. | |
13102 (let ((newsrc gnus-newsrc-alist) | |
13103 marked) | |
13104 (while newsrc | |
13105 (if (not (setq marked (nth 3 (car newsrc)))) | |
13106 () | |
13107 (while marked | |
13108 (or (eq 'score (car (car marked))) | |
13109 (eq 'bookmark (car (car marked))) | |
13110 (eq 'killed (car (car marked))) | |
13111 (setcdr (car marked) (gnus-uncompress-range (cdr (car marked))))) | |
13112 (setq marked (cdr marked)))) | |
13113 (setq newsrc (cdr newsrc))))) | |
13114 | |
13115 (defun gnus-compress-newsrc-alist () | |
13116 ;; Compress all lists of marked articles in the newsrc assoc. | |
13117 (let ((newsrc gnus-newsrc-alist) | |
13118 marked) | |
13119 (while newsrc | |
13120 (if (not (setq marked (nth 3 (car newsrc)))) | |
13121 () | |
13122 (while marked | |
13123 (or (eq 'score (car (car marked))) | |
13124 (eq 'bookmark (car (car marked))) | |
13125 (eq 'killed (car (car marked))) | |
13126 (setcdr (car marked) | |
13127 (condition-case () | |
13128 (gnus-compress-sequence | |
13129 (sort (cdr (car marked)) '<) t) | |
13130 (error (cdr (car marked)))))) | |
13131 (setq marked (cdr marked)))) | |
13132 (setq newsrc (cdr newsrc))))) | |
13133 | |
13134 (defun gnus-newsrc-to-gnus-format () | |
13135 (setq gnus-newsrc-options "") | |
13136 (setq gnus-newsrc-options-n nil) | |
13137 | |
13138 (or gnus-active-hashtb | |
13139 (setq gnus-active-hashtb (make-vector 4095 0))) | |
13140 (let ((buf (current-buffer)) | |
13141 (already-read (> (length gnus-newsrc-alist) 1)) | |
13142 group subscribed options-symbol newsrc Options-symbol | |
13143 symbol reads num1) | |
13144 (goto-char (point-min)) | |
13145 ;; We intern the symbol `options' in the active hashtb so that we | |
13146 ;; can `eq' against it later. | |
13147 (set (setq options-symbol (intern "options" gnus-active-hashtb)) nil) | |
13148 (set (setq Options-symbol (intern "Options" gnus-active-hashtb)) nil) | |
13149 | |
13150 (while (not (eobp)) | |
13151 ;; We first read the first word on the line by narrowing and | |
13152 ;; then reading into `gnus-active-hashtb'. Most groups will | |
13153 ;; already exist in that hashtb, so this will save some string | |
13154 ;; space. | |
13155 (narrow-to-region | |
13156 (point) | |
13157 (progn (skip-chars-forward "^ \t!:\n") (point))) | |
13158 (goto-char (point-min)) | |
13159 (setq symbol | |
13160 (and (/= (point-min) (point-max)) | |
13161 (let ((obarray gnus-active-hashtb)) (read buf)))) | |
13162 (widen) | |
13163 ;; Now, the symbol we have read is either `options' or a group | |
13164 ;; name. If it is an options line, we just add it to a string. | |
13165 (cond | |
13166 ((or (eq symbol options-symbol) | |
13167 (eq symbol Options-symbol)) | |
13168 (setq gnus-newsrc-options | |
13169 ;; This concatting is quite inefficient, but since our | |
13170 ;; thorough studies show that approx 99.37% of all | |
13171 ;; .newsrc files only contain a single options line, we | |
13172 ;; don't give a damn, frankly, my dear. | |
13173 (concat gnus-newsrc-options | |
13174 (buffer-substring | |
13175 (gnus-point-at-bol) | |
13176 ;; Options may continue on the next line. | |
13177 (or (and (re-search-forward "^[^ \t]" nil 'move) | |
13178 (progn (beginning-of-line) (point))) | |
13179 (point))))) | |
13180 (forward-line -1)) | |
13181 (symbol | |
13182 (or (boundp symbol) (set symbol nil)) | |
13183 ;; It was a group name. | |
13184 (setq subscribed (= (following-char) ?:) | |
13185 group (symbol-name symbol) | |
13186 reads nil) | |
13187 (if (eolp) | |
13188 ;; If the line ends here, this is clearly a buggy line, so | |
13189 ;; we put point a the beginning of line and let the cond | |
13190 ;; below do the error handling. | |
13191 (beginning-of-line) | |
13192 ;; We skip to the beginning of the ranges. | |
13193 (skip-chars-forward "!: \t")) | |
13194 ;; We are now at the beginning of the list of read articles. | |
13195 ;; We read them range by range. | |
13196 (while | |
13197 (cond | |
13198 ((looking-at "[0-9]+") | |
13199 ;; We narrow and read a number instead of buffer-substring/ | |
13200 ;; string-to-int because it's faster. narrow/widen is | |
13201 ;; faster than save-restriction/narrow, and save-restriction | |
13202 ;; produces a garbage object. | |
13203 (setq num1 (progn | |
13204 (narrow-to-region (match-beginning 0) (match-end 0)) | |
13205 (read buf))) | |
13206 (widen) | |
13207 ;; If the next character is a dash, then this is a range. | |
13208 (if (= (following-char) ?-) | |
13209 (progn | |
13210 ;; We read the upper bound of the range. | |
13211 (forward-char 1) | |
13212 (if (not (looking-at "[0-9]+")) | |
13213 ;; This is a buggy line, by we pretend that | |
13214 ;; it's kinda OK. Perhaps the user should be | |
13215 ;; dinged? | |
13216 (setq reads (cons num1 reads)) | |
13217 (setq reads | |
13218 (cons | |
13219 (cons num1 | |
13220 (progn | |
13221 (narrow-to-region (match-beginning 0) | |
13222 (match-end 0)) | |
13223 (read buf))) | |
13224 reads)) | |
13225 (widen))) | |
13226 ;; It was just a simple number, so we add it to the | |
13227 ;; list of ranges. | |
13228 (setq reads (cons num1 reads))) | |
13229 ;; If the next char in ?\n, then we have reached the end | |
13230 ;; of the line and return nil. | |
13231 (/= (following-char) ?\n)) | |
13232 ((= (following-char) ?\n) | |
13233 ;; End of line, so we end. | |
13234 nil) | |
13235 (t | |
13236 ;; Not numbers and not eol, so this might be a buggy | |
13237 ;; line... | |
13238 (or (eobp) | |
13239 ;; If it was eob instead of ?\n, we allow it. | |
13240 (progn | |
13241 ;; The line was buggy. | |
13242 (setq group nil) | |
13243 (gnus-message 3 "Mangled line: %s" | |
13244 (buffer-substring (gnus-point-at-bol) | |
13245 (gnus-point-at-eol))) | |
13246 (ding) | |
13247 (sit-for 1))) | |
13248 nil)) | |
13249 ;; Skip past ", ". Spaces are illegal in these ranges, but | |
13250 ;; we allow them, because it's a common mistake to put a | |
13251 ;; space after the comma. | |
13252 (skip-chars-forward ", ")) | |
13253 | |
13254 ;; We have already read .newsrc.eld, so we gently update the | |
13255 ;; data in the hash table with the information we have just | |
13256 ;; read. | |
13257 (if (not group) | |
13258 () | |
13259 (let ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))) | |
13260 level) | |
13261 (if info | |
13262 ;; There is an entry for this file in the alist. | |
13263 (progn | |
13264 (setcar (nthcdr 2 info) (nreverse reads)) | |
13265 ;; We update the level very gently. In fact, we | |
13266 ;; only change it if there's been a status change | |
13267 ;; from subscribed to unsubscribed, or vice versa. | |
13268 (setq level (nth 1 info)) | |
13269 (cond ((and (<= level gnus-level-subscribed) | |
13270 (not subscribed)) | |
13271 (setq level (if reads | |
13272 gnus-level-default-unsubscribed | |
13273 (1+ gnus-level-default-unsubscribed)))) | |
13274 ((and (> level gnus-level-subscribed) subscribed) | |
13275 (setq level gnus-level-default-subscribed))) | |
13276 (setcar (cdr info) level)) | |
13277 ;; This is a new group. | |
13278 (setq info (list group | |
13279 (if subscribed | |
13280 gnus-level-default-subscribed | |
13281 (if reads | |
13282 (1+ gnus-level-subscribed) | |
13283 gnus-level-default-unsubscribed)) | |
13284 (nreverse reads)))) | |
13285 (setq newsrc (cons info newsrc)))))) | |
13286 (forward-line 1)) | |
13287 | |
13288 (setq newsrc (nreverse newsrc)) | |
13289 | |
13290 (if (not already-read) | |
13291 () | |
13292 ;; We now have two newsrc lists - `newsrc', which is what we | |
13293 ;; have read from .newsrc, and `gnus-newsrc-alist', which is | |
13294 ;; what we've read from .newsrc.eld. We have to merge these | |
13295 ;; lists. We do this by "attaching" any (foreign) groups in the | |
13296 ;; gnus-newsrc-alist to the (native) group that precedes them. | |
13297 (let ((rc (cdr gnus-newsrc-alist)) | |
13298 (prev gnus-newsrc-alist) | |
13299 entry mentry) | |
13300 (while rc | |
13301 (or (null (nth 4 (car rc))) ; It's a native group. | |
13302 (assoc (car (car rc)) newsrc) ; It's already in the alist. | |
13303 (if (setq entry (assoc (car (car prev)) newsrc)) | |
13304 (setcdr (setq mentry (memq entry newsrc)) | |
13305 (cons (car rc) (cdr mentry))) | |
13306 (setq newsrc (cons (car rc) newsrc)))) | |
13307 (setq prev rc | |
13308 rc (cdr rc))))) | |
13309 | |
13310 (setq gnus-newsrc-alist newsrc) | |
13311 ;; We make the newsrc hashtb. | |
13312 (gnus-make-hashtable-from-newsrc-alist) | |
13313 | |
13314 ;; Finally, if we read some options lines, we parse them. | |
13315 (or (string= gnus-newsrc-options "") | |
13316 (gnus-newsrc-parse-options gnus-newsrc-options)))) | |
13317 | |
13318 ;; Parse options lines to find "options -n !all rec.all" and stuff. | |
13319 ;; The return value will be a list on the form | |
13320 ;; ((regexp1 . ignore) | |
13321 ;; (regexp2 . subscribe)...) | |
13322 ;; When handling new newsgroups, groups that match a `ignore' regexp | |
13323 ;; will be ignored, and groups that match a `subscribe' regexp will be | |
13324 ;; subscribed. A line like | |
13325 ;; options -n !all rec.all | |
13326 ;; will lead to a list that looks like | |
13327 ;; (("^rec\\..+" . subscribe) | |
13328 ;; ("^.+" . ignore)) | |
13329 ;; So all "rec.*" groups will be subscribed, while all the other | |
13330 ;; groups will be ignored. Note that "options -n !all rec.all" is very | |
13331 ;; different from "options -n rec.all !all". | |
13332 (defun gnus-newsrc-parse-options (options) | |
13333 (let (out eol) | |
13334 (save-excursion | |
13335 (gnus-set-work-buffer) | |
13336 (insert (regexp-quote options)) | |
13337 ;; First we treat all continuation lines. | |
13338 (goto-char (point-min)) | |
13339 (while (re-search-forward "\n[ \t]+" nil t) | |
13340 (replace-match " " t t)) | |
13341 ;; Then we transform all "all"s into ".+"s. | |
13342 (goto-char (point-min)) | |
13343 (while (re-search-forward "\\ball\\b" nil t) | |
13344 (replace-match ".+" t t)) | |
13345 (goto-char (point-min)) | |
13346 ;; We remove all other options than the "-n" ones. | |
13347 (while (re-search-forward "[ \t]-[^n][^-]*" nil t) | |
13348 (replace-match " ") | |
13349 (forward-char -1)) | |
13350 (goto-char (point-min)) | |
13351 | |
13352 ;; We are only interested in "options -n" lines - we | |
13353 ;; ignore the other option lines. | |
13354 (while (re-search-forward "[ \t]-n" nil t) | |
13355 (setq eol | |
13356 (or (save-excursion | |
13357 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t) | |
13358 (- (point) 2))) | |
13359 (gnus-point-at-eol))) | |
13360 ;; Search for all "words"... | |
13361 (while (re-search-forward "[^ \t,\n]+" eol t) | |
13362 (if (= (char-after (match-beginning 0)) ?!) | |
13363 ;; If the word begins with a bang (!), this is a "not" | |
13364 ;; spec. We put this spec (minus the bang) and the | |
13365 ;; symbol `ignore' into the list. | |
13366 (setq out (cons (cons (concat | |
13367 "^" (buffer-substring | |
13368 (1+ (match-beginning 0)) | |
13369 (match-end 0))) | |
13370 'ignore) out)) | |
13371 ;; There was no bang, so this is a "yes" spec. | |
13372 (setq out (cons (cons (concat | |
13373 "^" (buffer-substring (match-beginning 0) | |
13374 (match-end 0))) | |
13375 'subscribe) out))))) | |
13376 | |
13377 (setq gnus-newsrc-options-n out)))) | |
13378 | |
13379 | |
13380 (defun gnus-save-newsrc-file () | |
13381 "Save .newsrc file." | |
13382 ;; Note: We cannot save .newsrc file if all newsgroups are removed | |
13383 ;; from the variable gnus-newsrc-alist. | |
13384 (and (or gnus-newsrc-alist gnus-killed-list) | |
13385 gnus-current-startup-file | |
13386 (progn | |
13387 (run-hooks 'gnus-save-newsrc-hook) | |
13388 (save-excursion | |
13389 (if (and gnus-use-dribble-file | |
13390 (or (not gnus-dribble-buffer) | |
13391 (not (buffer-name gnus-dribble-buffer)) | |
13392 (zerop (save-excursion | |
13393 (set-buffer gnus-dribble-buffer) | |
13394 (buffer-size))))) | |
13395 (gnus-message 4 "(No changes need to be saved)") | |
13396 (if gnus-save-newsrc-file | |
13397 (progn | |
13398 (gnus-message 5 "Saving %s..." gnus-current-startup-file) | |
13399 ;; Make backup file of master newsrc. | |
13400 (gnus-gnus-to-newsrc-format) | |
13401 (gnus-message 5 "Saving %s...done" | |
13402 gnus-current-startup-file))) | |
13403 ;; Quickly loadable .newsrc. | |
13404 (set-buffer (get-buffer-create " *Gnus-newsrc*")) | |
13405 (setq buffer-file-name (concat gnus-current-startup-file ".eld")) | |
13406 (gnus-add-current-to-buffer-list) | |
13407 (buffer-disable-undo (current-buffer)) | |
13408 (erase-buffer) | |
13409 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file) | |
13410 (gnus-gnus-to-quick-newsrc-format) | |
13411 (save-buffer) | |
13412 (kill-buffer (current-buffer)) | |
13413 (gnus-message 5 "Saving %s.eld...done" gnus-current-startup-file) | |
13414 (gnus-dribble-delete-file)))))) | |
13415 | |
13416 (defun gnus-gnus-to-quick-newsrc-format () | |
13417 "Insert Gnus variables such as gnus-newsrc-alist in lisp format." | |
13418 (insert ";; Gnus startup file.\n") | |
13419 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n") | |
13420 (insert ";; to read .newsrc.\n") | |
13421 (insert "(setq gnus-newsrc-file-version " | |
13422 (prin1-to-string gnus-version) ")\n") | |
13423 (let ((variables gnus-variable-list) | |
13424 (inhibit-quit t) | |
13425 (gnus-newsrc-alist (cdr gnus-newsrc-alist)) | |
13426 variable) | |
13427 ;; insert lisp expressions. | |
13428 (gnus-compress-newsrc-alist) | |
13429 (while variables | |
13430 (setq variable (car variables)) | |
13431 (and (boundp variable) | |
13432 (symbol-value variable) | |
13433 (or gnus-save-killed-list (not (eq variable 'gnus-killed-list))) | |
13434 (insert "(setq " (symbol-name variable) " '" | |
13435 (prin1-to-string (symbol-value variable)) | |
13436 ")\n")) | |
13437 (setq variables (cdr variables))) | |
13438 (gnus-uncompress-newsrc-alist))) | |
13439 | |
13440 | |
13441 (defun gnus-gnus-to-newsrc-format () | |
13442 ;; Generate and save the .newsrc file. | |
13443 (let ((newsrc (cdr gnus-newsrc-alist)) | |
13444 info ranges range) | |
13445 (save-excursion | |
13446 (set-buffer (create-file-buffer gnus-current-startup-file)) | |
13447 (setq buffer-file-name gnus-current-startup-file) | |
13448 (buffer-disable-undo (current-buffer)) | |
13449 (erase-buffer) | |
13450 ;; Write options. | |
13451 (if gnus-newsrc-options (insert gnus-newsrc-options)) | |
13452 ;; Write subscribed and unsubscribed. | |
13453 (while newsrc | |
13454 (setq info (car newsrc)) | |
13455 (if (not (nth 4 info)) ;Don't write foreign groups to .newsrc. | |
13456 (progn | |
13457 (insert (car info) (if (> (nth 1 info) gnus-level-subscribed) | |
13458 "!" ":")) | |
13459 (if (setq ranges (nth 2 info)) | |
13460 (progn | |
13461 (insert " ") | |
13462 (if (not (listp (cdr ranges))) | |
13463 (if (= (car ranges) (cdr ranges)) | |
13464 (insert (int-to-string (car ranges))) | |
13465 (insert (int-to-string (car ranges)) "-" | |
13466 (int-to-string (cdr ranges)))) | |
13467 (while ranges | |
13468 (setq range (car ranges) | |
13469 ranges (cdr ranges)) | |
13470 (if (or (atom range) (= (car range) (cdr range))) | |
13471 (insert (int-to-string | |
13472 (or (and (atom range) range) | |
13473 (car range)))) | |
13474 (insert (int-to-string (car range)) "-" | |
13475 (int-to-string (cdr range)))) | |
13476 (if ranges (insert ",")))))) | |
13477 (insert "\n"))) | |
13478 (setq newsrc (cdr newsrc))) | |
13479 ;; It has been reported that sometime the modtime on the .newsrc | |
13480 ;; file seems to be off. We really do want to overwrite it, so | |
13481 ;; we clear the modtime here before saving. It's a bit odd, | |
13482 ;; though... | |
13483 ;; sometimes the modtime clear isn't sufficient. most brute force: | |
13484 ;; delete the silly thing entirely first. but this fails to provide | |
13485 ;; such niceties as .newsrc~ creation. | |
13486 (if gnus-modtime-botch | |
13487 (delete-file gnus-startup-file) | |
13488 (clear-visited-file-modtime)) | |
13489 (save-buffer) | |
13490 (kill-buffer (current-buffer))))) | |
13491 | |
13492 (defun gnus-read-all-descriptions-files () | |
13493 (let ((methods (cons gnus-select-method gnus-secondary-select-methods))) | |
13494 (while methods | |
13495 (gnus-read-descriptions-file (car methods)) | |
13496 (setq methods (cdr methods))) | |
13497 t)) | |
13498 | |
13499 (defun gnus-read-descriptions-file (&optional method) | |
13500 (let ((method (or method gnus-select-method))) | |
13501 ;; We create the hashtable whether we manage to read the desc file | |
13502 ;; to avoid trying to re-read after a failed read. | |
13503 (or gnus-description-hashtb | |
13504 (setq gnus-description-hashtb | |
13505 (gnus-make-hashtable (length gnus-active-hashtb)))) | |
13506 ;; Mark this method's desc file as read. | |
13507 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read" | |
13508 gnus-description-hashtb) | |
13509 | |
13510 (gnus-message 5 "Reading descriptions file via %s..." (car method)) | |
13511 (cond | |
13512 ((not (gnus-check-server method)) | |
13513 (gnus-message 1 "Couldn't open server") | |
13514 nil) | |
13515 ((not (gnus-request-list-newsgroups method)) | |
13516 (gnus-message 1 "Couldn't read newsgroups descriptions") | |
13517 nil) | |
13518 (t | |
13519 (let (group) | |
13520 (save-excursion | |
13521 (save-restriction | |
13522 (set-buffer nntp-server-buffer) | |
13523 (goto-char (point-min)) | |
13524 (if (or (search-forward "\n.\n" nil t) | |
13525 (goto-char (point-max))) | |
13526 (progn | |
13527 (beginning-of-line) | |
13528 (narrow-to-region (point-min) (point)))) | |
13529 (goto-char (point-min)) | |
13530 (while (not (eobp)) | |
13531 ;; If we get an error, we set group to 0, which is not a | |
13532 ;; symbol... | |
13533 (setq group | |
13534 (condition-case () | |
13535 (let ((obarray gnus-description-hashtb)) | |
13536 ;; Group is set to a symbol interned in this | |
13537 ;; hash table. | |
13538 (read nntp-server-buffer)) | |
13539 (error 0))) | |
13540 (skip-chars-forward " \t") | |
13541 ;; ... which leads to this line being effectively ignored. | |
13542 (and (symbolp group) | |
13543 (set group (buffer-substring | |
13544 (point) (progn (end-of-line) (point))))) | |
13545 (forward-line 1)))) | |
13546 (gnus-message 5 "Reading descriptions file...done") | |
13547 t))))) | |
13548 | |
13549 (defun gnus-group-get-description (group) | |
13550 ;; Get the description of a group by sending XGTITLE to the server. | |
13551 (and (gnus-request-group-description group) | |
13552 (save-excursion | |
13553 (set-buffer nntp-server-buffer) | |
13554 (goto-char (point-min)) | |
13555 (and (looking-at "[^ \t]+[ \t]+\\(.*\\)") | |
13556 (buffer-substring (match-beginning 1) (match-end 1)))))) | |
13557 | |
13558 ;;; | |
13559 ;;; Server | |
13560 ;;; | |
13561 | |
13562 (defvar gnus-server-mode-hook nil | |
13563 "Hook run in `gnus-server-mode' buffers.") | |
13564 | |
13565 (defconst gnus-server-line-format " {%(%h:%w%)}\n" | |
13566 "Format of server lines. | |
13567 It works along the same lines as a normal formatting string, | |
13568 with some simple extensions.") | |
13569 | |
13570 (defvar gnus-server-mode-line-format "Gnus List of servers" | |
13571 "The format specification for the server mode line.") | |
13572 | |
13573 (defconst gnus-server-line-format-alist | |
13574 (list (list ?h 'how ?s) | |
13575 (list ?n 'name ?s) | |
13576 (list ?w 'where ?s) | |
13577 )) | |
13578 | |
13579 (defconst gnus-server-mode-line-format-alist | |
13580 (list (list ?S 'news-server ?s) | |
13581 (list ?M 'news-method ?s) | |
13582 (list ?u 'user-defined ?s))) | |
13583 | |
13584 (defvar gnus-server-line-format-spec nil) | |
13585 (defvar gnus-server-mode-line-format-spec nil) | |
13586 (defvar gnus-server-killed-servers nil) | |
13587 | |
13588 (defvar gnus-server-mode-map nil) | |
13589 (put 'gnus-server-mode 'mode-class 'special) | |
13590 | |
13591 (if gnus-server-mode-map | |
13592 nil | |
13593 (setq gnus-server-mode-map (make-sparse-keymap)) | |
13594 (suppress-keymap gnus-server-mode-map) | |
13595 (define-key gnus-server-mode-map " " 'gnus-server-read-server) | |
13596 (define-key gnus-server-mode-map "\r" 'gnus-server-read-server) | |
13597 (define-key gnus-server-mode-map gnus-mouse-2 'gnus-server-pick-server) | |
13598 (define-key gnus-server-mode-map "q" 'gnus-server-exit) | |
13599 (define-key gnus-server-mode-map "l" 'gnus-server-list-servers) | |
13600 (define-key gnus-server-mode-map "k" 'gnus-server-kill-server) | |
13601 (define-key gnus-server-mode-map "y" 'gnus-server-yank-server) | |
13602 (define-key gnus-server-mode-map "c" 'gnus-server-copy-server) | |
13603 (define-key gnus-server-mode-map "a" 'gnus-server-add-server) | |
13604 (define-key gnus-server-mode-map "e" 'gnus-server-edit-server)) | |
13605 | |
13606 (defun gnus-server-mode () | |
13607 "Major mode for listing and editing servers. | |
13608 | |
13609 All normal editing commands are switched off. | |
13610 \\<gnus-server-mode-map> | |
13611 | |
13612 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]'). | |
13613 | |
13614 The following commands are available: | |
13615 | |
13616 \\{gnus-server-mode-map}" | |
13617 (interactive) | |
13618 (if gnus-visual (gnus-server-make-menu-bar)) | |
13619 (kill-all-local-variables) | |
13620 (setq mode-line-modified "-- ") | |
13621 (make-local-variable 'mode-line-format) | |
13622 (setq mode-line-format (copy-sequence mode-line-format)) | |
13623 (and (equal (nth 3 mode-line-format) " ") | |
13624 (setcar (nthcdr 3 mode-line-format) "")) | |
13625 (setq major-mode 'gnus-server-mode) | |
13626 (setq mode-name "Server") | |
13627 ; (gnus-group-set-mode-line) | |
13628 (setq mode-line-process nil) | |
13629 (use-local-map gnus-server-mode-map) | |
13630 (buffer-disable-undo (current-buffer)) | |
13631 (setq truncate-lines t) | |
13632 (setq buffer-read-only t) | |
13633 (run-hooks 'gnus-server-mode-hook)) | |
13634 | |
13635 (defun gnus-server-insert-server-line (sformat name method) | |
13636 (let* ((sformat (or sformat gnus-server-line-format-spec)) | |
13637 (how (car method)) | |
13638 (where (nth 1 method)) | |
13639 b) | |
13640 (beginning-of-line) | |
13641 (setq b (point)) | |
13642 ;; Insert the text. | |
13643 (insert (eval sformat)) | |
13644 (add-text-properties b (1+ b) (list 'gnus-server (intern name))))) | |
13645 | |
13646 (defun gnus-server-setup-buffer () | |
13647 (if (get-buffer gnus-server-buffer) | |
13648 () | |
13649 (save-excursion | |
13650 (set-buffer (get-buffer-create gnus-server-buffer)) | |
13651 (gnus-server-mode) | |
13652 (and gnus-carpal (gnus-carpal-setup-buffer 'server))))) | |
13653 | |
13654 (defun gnus-server-prepare () | |
13655 (setq gnus-server-mode-line-format-spec | |
13656 (gnus-parse-format gnus-server-mode-line-format | |
13657 gnus-server-mode-line-format-alist)) | |
13658 (setq gnus-server-line-format-spec | |
13659 (gnus-parse-format gnus-server-line-format | |
13660 gnus-server-line-format-alist)) | |
13661 (let ((alist gnus-server-alist) | |
13662 (buffer-read-only nil)) | |
13663 (erase-buffer) | |
13664 (while alist | |
13665 (gnus-server-insert-server-line nil (car (car alist)) (cdr (car alist))) | |
13666 (setq alist (cdr alist)))) | |
13667 (goto-char (point-min)) | |
13668 (gnus-server-position-cursor)) | |
13669 | |
13670 (defun gnus-server-server-name () | |
13671 (let ((server (get-text-property (gnus-point-at-bol) 'gnus-server))) | |
13672 (and server (symbol-name server)))) | |
13673 | |
13674 (defalias 'gnus-server-position-cursor 'gnus-goto-colon) | |
13675 | |
13676 (defconst gnus-server-edit-buffer "*Gnus edit server*") | |
13677 | |
13678 (defun gnus-server-update-server (server) | |
13679 (save-excursion | |
13680 (set-buffer gnus-server-buffer) | |
13681 (let ((buffer-read-only nil) | |
13682 (info (cdr (assoc server gnus-server-alist)))) | |
13683 (gnus-dribble-enter | |
13684 (concat "(gnus-server-set-info \"" server "\" '" | |
13685 (prin1-to-string info) ")")) | |
13686 ;; Buffer may be narrowed. | |
13687 (save-restriction | |
13688 (widen) | |
13689 (if (gnus-server-goto-server server) | |
13690 (delete-region (progn (beginning-of-line) (point)) | |
13691 (progn (forward-line 1) (point)))) | |
13692 (let ((entry (assoc server gnus-server-alist))) | |
13693 (gnus-server-insert-server-line nil (car entry) (cdr entry)) | |
13694 (gnus-server-position-cursor)))))) | |
13695 | |
13696 (defun gnus-server-set-info (server info) | |
13697 ;; Enter a select method into the virtual server alist. | |
13698 (gnus-dribble-enter | |
13699 (concat "(gnus-server-set-info \"" server "\" '" | |
13700 (prin1-to-string info) ")")) | |
13701 (let* ((server (nth 1 info)) | |
13702 (entry (assoc server gnus-server-alist))) | |
13703 (if entry (setcdr entry info) | |
13704 (setq gnus-server-alist | |
13705 (nconc gnus-server-alist (list (cons server info))))))) | |
13706 | |
13707 (defun gnus-server-to-method (server) | |
13708 ;; Map virtual server names to select methods. | |
13709 (or (and (equal server "native") gnus-select-method) | |
13710 (cdr (assoc server gnus-server-alist)))) | |
13711 | |
13712 (defun gnus-server-extend-method (group method) | |
13713 ;; This function "extends" a virtual server. If the server is | |
13714 ;; "hello", and the select method is ("hello" (my-var "something")) | |
13715 ;; in the group "alt.alt", this will result in a new virtual server | |
13716 ;; called "helly+alt.alt". | |
13717 (let ((entry | |
13718 (gnus-copy-sequence | |
13719 (if (equal (car method) "native") gnus-select-method | |
13720 (cdr (assoc (car method) gnus-server-alist)))))) | |
13721 (setcar (cdr entry) (concat (nth 1 entry) "+" group)) | |
13722 (nconc entry (cdr method)))) | |
13723 | |
13724 (defun gnus-server-get-method (group method) | |
13725 ;; Input either a server name, and extended server name, or a | |
13726 ;; select method, and return a select method. | |
13727 (cond ((stringp method) | |
13728 (gnus-server-to-method method)) | |
13729 ((and (stringp (car method)) group) | |
13730 (gnus-server-extend-method group method)) | |
13731 (t | |
13732 (gnus-server-add-address method)))) | |
13733 | |
13734 (defun gnus-server-add-address (method) | |
13735 (let ((method-name (symbol-name (car method)))) | |
13736 (if (and (memq 'address (assoc method-name gnus-valid-select-methods)) | |
13737 (not (assq (intern (concat method-name "-address")) method))) | |
13738 (append method (list (list (intern (concat method-name "-address")) | |
13739 (nth 1 method)))) | |
13740 method))) | |
13741 | |
13742 (defun gnus-server-equal (s1 s2) | |
13743 (or (equal s1 s2) | |
13744 (and (= (length s1) (length s2)) | |
13745 (progn | |
13746 (while (and s1 (member (car s1) s2)) | |
13747 (setq s1 (cdr s1))) | |
13748 (null s1))))) | |
13749 | |
13750 ;;; Interactive server functions. | |
13751 | |
13752 (defun gnus-server-kill-server (server) | |
13753 "Kill the server on the current line." | |
13754 (interactive (list (gnus-server-server-name))) | |
13755 (or (gnus-server-goto-server server) | |
13756 (if server (error "No such server: %s" server) | |
13757 (error "No server on the current line"))) | |
13758 (gnus-dribble-enter "") | |
13759 (let ((buffer-read-only nil)) | |
13760 (delete-region (progn (beginning-of-line) (point)) | |
13761 (progn (forward-line 1) (point)))) | |
13762 (setq gnus-server-killed-servers | |
13763 (cons (assoc server gnus-server-alist) gnus-server-killed-servers)) | |
13764 (setq gnus-server-alist (delq (car gnus-server-killed-servers) | |
13765 gnus-server-alist)) | |
13766 (gnus-server-position-cursor)) | |
13767 | |
13768 (defun gnus-server-yank-server () | |
13769 "Yank the previously killed server." | |
13770 (interactive) | |
13771 (or gnus-server-killed-servers | |
13772 (error "No killed servers to be yanked")) | |
13773 (let ((alist gnus-server-alist) | |
13774 (server (gnus-server-server-name)) | |
13775 (killed (car gnus-server-killed-servers))) | |
13776 (if (not server) | |
13777 (setq gnus-server-alist (nconc gnus-server-alist (list killed))) | |
13778 (if (string= server (car (car gnus-server-alist))) | |
13779 (setq gnus-server-alist (cons killed gnus-server-alist)) | |
13780 (while (and (cdr alist) | |
13781 (not (string= server (car (car (cdr alist)))))) | |
13782 (setq alist (cdr alist))) | |
13783 (setcdr alist (cons killed (cdr alist))))) | |
13784 (gnus-server-update-server (car killed)) | |
13785 (setq gnus-server-killed-servers (cdr gnus-server-killed-servers)) | |
13786 (gnus-server-position-cursor))) | |
13787 | |
13788 (defun gnus-server-exit () | |
13789 "Return to the group buffer." | |
13790 (interactive) | |
13791 (kill-buffer (current-buffer)) | |
13792 (switch-to-buffer gnus-group-buffer)) | |
13793 | |
13794 (defun gnus-server-list-servers () | |
13795 "List all available servers." | |
13796 (interactive) | |
13797 (let ((cur (gnus-server-server-name))) | |
13798 (gnus-server-prepare) | |
13799 (if cur (gnus-server-goto-server cur) | |
13800 (goto-char (point-max)) | |
13801 (forward-line -1)) | |
13802 (gnus-server-position-cursor))) | |
13803 | |
13804 (defun gnus-server-copy-server (from to) | |
13805 (interactive | |
13806 (list | |
13807 (or (gnus-server-server-name) | |
13808 (error "No server on the current line")) | |
13809 (read-string "Copy to: "))) | |
13810 (or from (error "No server on current line")) | |
13811 (or (and to (not (string= to ""))) (error "No name to copy to")) | |
13812 (and (assoc to gnus-server-alist) (error "%s already exists" to)) | |
13813 (or (assoc from gnus-server-alist) | |
13814 (error "%s: no such server" from)) | |
13815 (let ((to-entry (gnus-copy-sequence (assoc from gnus-server-alist)))) | |
13816 (setcar to-entry to) | |
13817 (setcar (nthcdr 2 to-entry) to) | |
13818 (setq gnus-server-killed-servers | |
13819 (cons to-entry gnus-server-killed-servers)) | |
13820 (gnus-server-yank-server))) | |
13821 | |
13822 (defun gnus-server-add-server (how where) | |
13823 (interactive | |
13824 (list (intern (completing-read "Server method: " | |
13825 gnus-valid-select-methods nil t)) | |
13826 (read-string "Server name: "))) | |
13827 (setq gnus-server-killed-servers | |
13828 (cons (list where how where) gnus-server-killed-servers)) | |
13829 (gnus-server-yank-server)) | |
13830 | |
13831 (defun gnus-server-goto-server (server) | |
13832 "Jump to a server line." | |
13833 (interactive | |
13834 (list (completing-read "Goto server: " gnus-server-alist nil t))) | |
13835 (let ((to (text-property-any (point-min) (point-max) | |
13836 'gnus-server (intern server)))) | |
13837 (and to | |
13838 (progn | |
13839 (goto-char to) | |
13840 (gnus-server-position-cursor))))) | |
13841 | |
13842 (defun gnus-server-edit-server (server) | |
13843 "Edit the server on the current line." | |
13844 (interactive (list (gnus-server-server-name))) | |
13845 (or server | |
13846 (error "No server on current line")) | |
13847 (let ((winconf (current-window-configuration))) | |
13848 (get-buffer-create gnus-server-edit-buffer) | |
13849 (gnus-configure-windows 'edit-server) | |
13850 (gnus-add-current-to-buffer-list) | |
13851 (emacs-lisp-mode) | |
13852 (make-local-variable 'gnus-prev-winconf) | |
13853 (setq gnus-prev-winconf winconf) | |
13854 (use-local-map (copy-keymap (current-local-map))) | |
13855 (let ((done-func '(lambda () | |
13856 "Exit editing mode and update the information." | |
13857 (interactive) | |
13858 (gnus-server-edit-server-done 'group)))) | |
13859 (setcar (cdr (nth 4 done-func)) server) | |
13860 (local-set-key "\C-c\C-c" done-func)) | |
13861 (erase-buffer) | |
13862 (insert ";; Type `C-c C-c' after you have edited the server.\n\n") | |
13863 (insert (pp-to-string (cdr (assoc server gnus-server-alist)))))) | |
13864 | |
13865 (defun gnus-server-edit-server-done (server) | |
13866 (interactive) | |
13867 (set-buffer (get-buffer-create gnus-server-edit-buffer)) | |
13868 (goto-char (point-min)) | |
13869 (let ((form (read (current-buffer))) | |
13870 (winconf gnus-prev-winconf)) | |
13871 (gnus-server-set-info server form) | |
13872 (kill-buffer (current-buffer)) | |
13873 (and winconf (set-window-configuration winconf)) | |
13874 (set-buffer gnus-server-buffer) | |
13875 (gnus-server-update-server (gnus-server-server-name)) | |
13876 (gnus-server-list-servers) | |
13877 (gnus-server-position-cursor))) | |
13878 | |
13879 (defun gnus-server-read-server (server) | |
13880 "Browse a server." | |
13881 (interactive (list (gnus-server-server-name))) | |
13882 (gnus-browse-foreign-server (gnus-server-to-method server) (current-buffer))) | |
13883 | |
13884 (defun gnus-mouse-pick-server (e) | |
13885 (interactive "e") | |
13886 (mouse-set-point e) | |
13887 (gnus-server-read-server (gnus-server-server-name))) | |
13888 | |
13889 ;;; | |
13890 ;;; entry points into gnus-score.el | |
13891 ;;; | |
13892 | |
13893 ;;; Finding score files. | |
13894 | |
13895 (defvar gnus-global-score-files nil | |
13896 "*List of global score files and directories. | |
13897 Set this variable if you want to use people's score files. One entry | |
13898 for each score file or each score file directory. Gnus will decide | |
13899 by itself what score files are applicable to which group. | |
13900 | |
13901 Say you want to use the single score file | |
13902 \"/ftp.ifi.uio.no@ftp:/pub/larsi/ding/score/soc.motss.SCORE\" and all | |
13903 score files in the \"/ftp.some-where:/pub/score\" directory. | |
13904 | |
13905 (setq gnus-global-score-files | |
13906 '(\"/ftp.ifi.uio.no:/pub/larsi/ding/score/soc.motss.SCORE\" | |
13907 \"/ftp.some-where:/pub/score\"))") | |
13908 | |
13909 (defun gnus-score-score-files (group) | |
13910 "Return a list of all possible score files." | |
13911 ;; Search and set any global score files. | |
13912 (and gnus-global-score-files | |
13913 (or gnus-internal-global-score-files | |
13914 (gnus-score-search-global-directories gnus-global-score-files))) | |
13915 ;; Fix the kill-file dir variable. | |
13916 (setq gnus-kill-files-directory | |
13917 (file-name-as-directory | |
13918 (or gnus-kill-files-directory "~/News/"))) | |
13919 ;; If we can't read it, there are no score files. | |
13920 (if (not (file-exists-p (expand-file-name gnus-kill-files-directory))) | |
13921 (setq gnus-score-file-list nil) | |
13922 (if (gnus-use-long-file-name 'not-score) | |
13923 ;; We want long file names. | |
13924 (if (or (not gnus-score-file-list) | |
13925 (not (car gnus-score-file-list)) | |
13926 (gnus-file-newer-than gnus-kill-files-directory | |
13927 (car gnus-score-file-list))) | |
13928 (setq gnus-score-file-list | |
13929 (cons (nth 5 (file-attributes gnus-kill-files-directory)) | |
13930 (nreverse | |
13931 (directory-files | |
13932 gnus-kill-files-directory t | |
13933 (gnus-score-file-regexp)))))) | |
13934 ;; We do not use long file names, so we have to do some | |
13935 ;; directory traversing. | |
13936 (let ((mdir (length (expand-file-name gnus-kill-files-directory))) | |
13937 (suffixes (list gnus-score-file-suffix gnus-adaptive-file-suffix)) | |
13938 dir files suffix) | |
13939 (while suffixes | |
13940 (setq dir (expand-file-name | |
13941 (concat gnus-kill-files-directory | |
13942 (gnus-replace-chars-in-string group ?. ?/)))) | |
13943 (setq dir (gnus-replace-chars-in-string dir ?: ?/)) | |
13944 (setq suffix (car suffixes) | |
13945 suffixes (cdr suffixes)) | |
13946 (if (file-exists-p (concat dir "/" suffix)) | |
13947 (setq files (cons (concat dir "/" suffix) files))) | |
13948 (while (>= (1+ (length dir)) mdir) | |
13949 (and (file-exists-p (concat dir "/all/" suffix)) | |
13950 (setq files (cons (concat dir "/all/" suffix) files))) | |
13951 (string-match "/[^/]*$" dir) | |
13952 (setq dir (substring dir 0 (match-beginning 0))))) | |
13953 (setq gnus-score-file-list | |
13954 (cons nil (nreverse files))))) | |
13955 (cdr gnus-score-file-list))) | |
13956 | |
13957 (defun gnus-score-file-regexp () | |
13958 (concat "\\(" gnus-score-file-suffix | |
13959 "\\|" gnus-adaptive-file-suffix "\\)$")) | |
13960 | |
13961 (defun gnus-score-find-bnews (group) | |
13962 "Return a list of score files for GROUP. | |
13963 The score files are those files in the ~/News directory which matches | |
13964 GROUP using BNews sys file syntax." | |
13965 (let* ((sfiles (append (gnus-score-score-files group) | |
13966 gnus-internal-global-score-files)) | |
13967 (kill-dir (file-name-as-directory | |
13968 (expand-file-name gnus-kill-files-directory))) | |
13969 (klen (length kill-dir)) | |
13970 ofiles not-match regexp) | |
13971 (save-excursion | |
13972 (set-buffer (get-buffer-create "*gnus score files*")) | |
13973 (buffer-disable-undo (current-buffer)) | |
13974 ;; Go through all score file names and create regexp with them | |
13975 ;; as the source. | |
13976 (while sfiles | |
13977 (erase-buffer) | |
13978 (insert (car sfiles)) | |
13979 (goto-char (point-min)) | |
13980 ;; First remove the suffix itself. | |
13981 (re-search-forward (concat "." (gnus-score-file-regexp))) | |
13982 (replace-match "" t t) | |
13983 (goto-char (point-min)) | |
13984 (if (looking-at (regexp-quote kill-dir)) | |
13985 ;; If the file name was just "SCORE", `klen' is one character | |
13986 ;; too much. | |
13987 (delete-char (min (1- (point-max)) klen)) | |
13988 (goto-char (point-max)) | |
13989 (search-backward "/") | |
13990 (delete-region (1+ (point)) (point-min))) | |
13991 ;; If short file names were used, we have to translate slashes. | |
13992 (goto-char (point-min)) | |
13993 (while (re-search-forward "[/:]" nil t) | |
13994 (replace-match "." t t)) | |
13995 ;; Cludge to get rid of "nntp+" problems. | |
13996 (goto-char (point-min)) | |
13997 (and (looking-at "nn[a-z]+\\+") | |
13998 (progn | |
13999 (search-forward "+") | |
14000 (forward-char -1) | |
14001 (insert "\\"))) | |
14002 ;; Translate ".all" to "[./].*"; | |
14003 (while (search-forward ".all" nil t) | |
14004 (replace-match "[./:].*" t t)) | |
14005 (goto-char (point-min)) | |
14006 ;; Translate "all" to ".*". | |
14007 (while (search-forward "all" nil t) | |
14008 (replace-match ".*" t t)) | |
14009 (goto-char (point-min)) | |
14010 ;; Deal with "not."s. | |
14011 (if (looking-at "not.") | |
14012 (progn | |
14013 (setq not-match t) | |
14014 (setq regexp (buffer-substring 5 (point-max)))) | |
14015 (setq regexp (buffer-substring 1 (point-max))) | |
14016 (setq not-match nil)) | |
14017 ;; Finally - if this resulting regexp matches the group name, | |
14018 ;; we add this score file to the list of score files | |
14019 ;; applicable to this group. | |
14020 (if (or (and not-match | |
14021 (not (string-match regexp group))) | |
14022 (and (not not-match) | |
14023 (string-match regexp group))) | |
14024 (setq ofiles (cons (car sfiles) ofiles))) | |
14025 (setq sfiles (cdr sfiles))) | |
14026 (kill-buffer (current-buffer)) | |
14027 ;; Slight kludge here - the last score file returned should be | |
14028 ;; the local score file, whether it exists or not. This is so | |
14029 ;; that any score commands the user enters will go to the right | |
14030 ;; file, and not end up in some global score file. | |
14031 (let ((localscore | |
14032 (expand-file-name | |
14033 (if (gnus-use-long-file-name 'not-score) | |
14034 (concat gnus-kill-files-directory group "." | |
14035 gnus-score-file-suffix) | |
14036 (concat gnus-kill-files-directory | |
14037 (gnus-replace-chars-in-string group ?. ?/ ?: ?/) | |
14038 "/" gnus-score-file-suffix))))) | |
14039 ;; The localest score file might already be there, but it's | |
14040 ;; supposed to be the very last file, so we delete it from the | |
14041 ;; list if it's already there, and add it to the head of the | |
14042 ;; list. | |
14043 (setq ofiles (cons localscore (delete localscore ofiles)))) | |
14044 (nreverse ofiles)))) | |
14045 | |
14046 (defun gnus-score-find-single (group) | |
14047 "Return list containing the score file for GROUP." | |
14048 (list (gnus-score-file-name group gnus-adaptive-file-suffix) | |
14049 (gnus-score-file-name group))) | |
14050 | |
14051 (defun gnus-score-find-hierarchical (group) | |
14052 "Return list of score files for GROUP. | |
14053 This includes the score file for the group and all its parents." | |
14054 (let ((all (copy-sequence '(nil))) | |
14055 (start 0)) | |
14056 (while (string-match "\\." group (1+ start)) | |
14057 (setq start (match-beginning 0)) | |
14058 (setq all (cons (substring group 0 start) all))) | |
14059 (setq all (cons group all)) | |
14060 (nconc | |
14061 (mapcar (lambda (newsgroup) | |
14062 (gnus-score-file-name newsgroup gnus-adaptive-file-suffix)) | |
14063 (setq all (nreverse all))) | |
14064 (mapcar 'gnus-score-file-name all)))) | |
14065 | |
14066 (defvar gnus-score-file-alist-cache nil) | |
14067 | |
14068 (defun gnus-score-find-alist (group) | |
14069 "Return list of score files for GROUP. | |
14070 The list is determined from the variable gnus-score-file-alist." | |
14071 (let ((alist gnus-score-file-multiple-match-alist) | |
14072 score-files) | |
14073 ;; if this group has been seen before, return the cached entry | |
14074 (if (setq score-files (assoc group gnus-score-file-alist-cache)) | |
14075 (cdr score-files) ;ensures caching groups with no matches | |
14076 ;; handle the multiple match alist | |
14077 (while alist | |
14078 (and (string-match (car (car alist)) group) | |
14079 (setq score-files | |
14080 (nconc score-files (copy-sequence (cdr (car alist)))))) | |
14081 (setq alist (cdr alist))) | |
14082 (setq alist gnus-score-file-single-match-alist) | |
14083 ;; handle the single match alist | |
14084 (while alist | |
14085 (and (string-match (car (car alist)) group) | |
14086 ;; progn used just in case ("regexp") has no files | |
14087 ;; and score-files is still nil. -sj | |
14088 ;; this can be construed as a "stop searching here" feature :> | |
14089 ;; and used to simplify regexps in the single-alist | |
14090 (progn | |
14091 (setq score-files | |
14092 (nconc score-files (copy-sequence (cdr (car alist))))) | |
14093 (setq alist nil))) | |
14094 (setq alist (cdr alist))) | |
14095 ;; cache the score files | |
14096 (setq gnus-score-file-alist-cache | |
14097 (cons (cons group score-files) gnus-score-file-alist-cache)) | |
14098 score-files))) | |
14099 | |
14100 | |
14101 (defun gnus-possibly-score-headers (&optional trace) | |
14102 (let ((func gnus-score-find-score-files-function) | |
14103 score-files) | |
14104 (and func (not (listp func)) | |
14105 (setq func (list func))) | |
14106 ;; Go through all the functions for finding score files (or actual | |
14107 ;; scores) and add them to a list. | |
14108 (setq score-files (gnus-score-find-alist gnus-newsgroup-name)) | |
14109 (while func | |
14110 (and (symbolp (car func)) | |
14111 (fboundp (car func)) | |
14112 (setq score-files | |
14113 (nconc score-files (funcall (car func) gnus-newsgroup-name)))) | |
14114 (setq func (cdr func))) | |
14115 (if score-files (gnus-score-headers score-files trace)))) | |
14116 | |
14117 (defun gnus-score-file-name (newsgroup &optional suffix) | |
14118 "Return the name of a score file for NEWSGROUP." | |
14119 (let ((suffix (or suffix gnus-score-file-suffix))) | |
14120 (cond | |
14121 ((or (null newsgroup) | |
14122 (string-equal newsgroup "")) | |
14123 ;; The global score file is placed at top of the directory. | |
14124 (expand-file-name | |
14125 suffix (or gnus-kill-files-directory "~/News"))) | |
14126 ((gnus-use-long-file-name 'not-score) | |
14127 ;; Append ".SCORE" to newsgroup name. | |
14128 (expand-file-name (concat (gnus-newsgroup-saveable-name newsgroup) | |
14129 "." suffix) | |
14130 (or gnus-kill-files-directory "~/News"))) | |
14131 (t | |
14132 ;; Place "SCORE" under the hierarchical directory. | |
14133 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup) | |
14134 "/" suffix) | |
14135 (or gnus-kill-files-directory "~/News")))))) | |
14136 | |
14137 (defun gnus-score-search-global-directories (files) | |
14138 "Scan all global score directories for score files." | |
14139 ;; Set the variable `gnus-internal-global-score-files' to all | |
14140 ;; available global score files. | |
14141 (interactive (list gnus-global-score-files)) | |
14142 (let (out) | |
14143 (while files | |
14144 (if (string-match "/$" (car files)) | |
14145 (setq out (nconc (directory-files | |
14146 (car files) t | |
14147 (concat (gnus-score-file-regexp) "$")))) | |
14148 (setq out (cons (car files) out))) | |
14149 (setq files (cdr files))) | |
14150 (setq gnus-internal-global-score-files out))) | |
14151 | |
14152 ;; Allow redefinition of Gnus functions. | |
14153 | |
14154 (gnus-ems-redefine) | |
14155 | |
14156 (provide 'gnus) | |
14157 | |
14158 ;;; gnus.el ends here |