Mercurial > hg > xemacs-beta
comparison lisp/gnus/gnus.el @ 0:376386a54a3c r19-14
Import from CVS: tag r19-14
author | cvs |
---|---|
date | Mon, 13 Aug 2007 08:45:50 +0200 |
parents | |
children | ac2d302a0011 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:376386a54a3c |
---|---|
1 ;;; gnus.el --- a newsreader for GNU Emacs | |
2 ;; Copyright (C) 1987,88,89,90,93,94,95,96 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 the | |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 ;; Boston, MA 02111-1307, USA. | |
24 | |
25 ;;; Commentary: | |
26 | |
27 ;;; Code: | |
28 | |
29 (eval '(run-hooks 'gnus-load-hook)) | |
30 | |
31 (require 'mail-utils) | |
32 (require 'timezone) | |
33 (require 'nnheader) | |
34 (require 'message) | |
35 (require 'nnmail) | |
36 (require 'backquote) | |
37 | |
38 (eval-when-compile (require 'cl)) | |
39 | |
40 (defvar gnus-directory (or (getenv "SAVEDIR") "~/News/") | |
41 "*Directory variable from which all other Gnus file variables are derived.") | |
42 | |
43 ;; Site dependent variables. These variables should be defined in | |
44 ;; paths.el. | |
45 | |
46 (defvar gnus-default-nntp-server nil | |
47 "Specify a default NNTP server. | |
48 This variable should be defined in paths.el, and should never be set | |
49 by the user. | |
50 If you want to change servers, you should use `gnus-select-method'. | |
51 See the documentation to that variable.") | |
52 | |
53 (defvar gnus-backup-default-subscribed-newsgroups | |
54 '("news.announce.newusers" "news.groups.questions" "gnu.emacs.gnus") | |
55 "Default default new newsgroups the first time Gnus is run. | |
56 Should be set in paths.el, and shouldn't be touched by the user.") | |
57 | |
58 (defvar gnus-local-domain nil | |
59 "Local domain name without a host name. | |
60 The DOMAINNAME environment variable is used instead if it is defined. | |
61 If the `system-name' function returns the full Internet name, there is | |
62 no need to set this variable.") | |
63 | |
64 (defvar gnus-local-organization nil | |
65 "String with a description of what organization (if any) the user belongs to. | |
66 The ORGANIZATION environment variable is used instead if it is defined. | |
67 If this variable contains a function, this function will be called | |
68 with the current newsgroup name as the argument. The function should | |
69 return a string. | |
70 | |
71 In any case, if the string (either in the variable, in the environment | |
72 variable, or returned by the function) is a file name, the contents of | |
73 this file will be used as the organization.") | |
74 | |
75 ;; Customization variables | |
76 | |
77 ;; Don't touch this variable. | |
78 (defvar gnus-nntp-service "nntp" | |
79 "*NNTP service name (\"nntp\" or 119). | |
80 This is an obsolete variable, which is scarcely used. If you use an | |
81 nntp server for your newsgroup and want to change the port number | |
82 used to 899, you would say something along these lines: | |
83 | |
84 (setq gnus-select-method '(nntp \"my.nntp.server\" (nntp-port-number 899)))") | |
85 | |
86 (defvar gnus-nntpserver-file "/etc/nntpserver" | |
87 "*A file with only the name of the nntp server in it.") | |
88 | |
89 ;; This function is used to check both the environment variable | |
90 ;; NNTPSERVER and the /etc/nntpserver file to see whether one can find | |
91 ;; an nntp server name default. | |
92 (defun gnus-getenv-nntpserver () | |
93 (or (getenv "NNTPSERVER") | |
94 (and (file-readable-p gnus-nntpserver-file) | |
95 (save-excursion | |
96 (set-buffer (get-buffer-create " *gnus nntp*")) | |
97 (buffer-disable-undo (current-buffer)) | |
98 (insert-file-contents gnus-nntpserver-file) | |
99 (let ((name (buffer-string))) | |
100 (prog1 | |
101 (if (string-match "^[ \t\n]*$" name) | |
102 nil | |
103 name) | |
104 (kill-buffer (current-buffer)))))))) | |
105 | |
106 (defvar gnus-select-method | |
107 (nconc | |
108 (list 'nntp (or (condition-case () | |
109 (gnus-getenv-nntpserver) | |
110 (error nil)) | |
111 (if (and gnus-default-nntp-server | |
112 (not (string= gnus-default-nntp-server ""))) | |
113 gnus-default-nntp-server) | |
114 (system-name))) | |
115 (if (or (null gnus-nntp-service) | |
116 (equal gnus-nntp-service "nntp")) | |
117 nil | |
118 (list gnus-nntp-service))) | |
119 "*Default method for selecting a newsgroup. | |
120 This variable should be a list, where the first element is how the | |
121 news is to be fetched, the second is the address. | |
122 | |
123 For instance, if you want to get your news via NNTP from | |
124 \"flab.flab.edu\", you could say: | |
125 | |
126 (setq gnus-select-method '(nntp \"flab.flab.edu\")) | |
127 | |
128 If you want to use your local spool, say: | |
129 | |
130 (setq gnus-select-method (list 'nnspool (system-name))) | |
131 | |
132 If you use this variable, you must set `gnus-nntp-server' to nil. | |
133 | |
134 There is a lot more to know about select methods and virtual servers - | |
135 see the manual for details.") | |
136 | |
137 (defvar gnus-message-archive-method | |
138 `(nnfolder | |
139 "archive" | |
140 (nnfolder-directory ,(nnheader-concat message-directory "archive")) | |
141 (nnfolder-active-file | |
142 ,(nnheader-concat message-directory "archive/active")) | |
143 (nnfolder-get-new-mail nil) | |
144 (nnfolder-inhibit-expiry t)) | |
145 "*Method used for archiving messages you've sent. | |
146 This should be a mail method. | |
147 | |
148 It's probably not a very effective to change this variable once you've | |
149 run Gnus once. After doing that, you must edit this server from the | |
150 server buffer.") | |
151 | |
152 (defvar gnus-refer-article-method nil | |
153 "*Preferred method for fetching an article by Message-ID. | |
154 If you are reading news from the local spool (with nnspool), fetching | |
155 articles by Message-ID is painfully slow. By setting this method to an | |
156 nntp method, you might get acceptable results. | |
157 | |
158 The value of this variable must be a valid select method as discussed | |
159 in the documentation of `gnus-select-method'.") | |
160 | |
161 (defvar gnus-secondary-select-methods nil | |
162 "*A list of secondary methods that will be used for reading news. | |
163 This is a list where each element is a complete select method (see | |
164 `gnus-select-method'). | |
165 | |
166 If, for instance, you want to read your mail with the nnml backend, | |
167 you could set this variable: | |
168 | |
169 (setq gnus-secondary-select-methods '((nnml \"\")))") | |
170 | |
171 (defvar gnus-secondary-servers nil | |
172 "*List of NNTP servers that the user can choose between interactively. | |
173 To make Gnus query you for a server, you have to give `gnus' a | |
174 non-numeric prefix - `C-u M-x gnus', in short.") | |
175 | |
176 (defvar gnus-nntp-server nil | |
177 "*The name of the host running the NNTP server. | |
178 This variable is semi-obsolete. Use the `gnus-select-method' | |
179 variable instead.") | |
180 | |
181 (defvar gnus-startup-file "~/.newsrc" | |
182 "*Your `.newsrc' file. | |
183 `.newsrc-SERVER' will be used instead if that exists.") | |
184 | |
185 (defvar gnus-init-file "~/.gnus" | |
186 "*Your Gnus elisp startup file. | |
187 If a file with the .el or .elc suffixes exist, it will be read | |
188 instead.") | |
189 | |
190 (defvar gnus-group-faq-directory | |
191 '("/ftp@mirrors.aol.com:/pub/rtfm/usenet/" | |
192 "/ftp@sunsite.auc.dk:/pub/usenet/" | |
193 "/ftp@sunsite.doc.ic.ac.uk:/pub/usenet/news-faqs/" | |
194 "/ftp@src.doc.ic.ac.uk:/usenet/news-FAQS/" | |
195 "/ftp@ftp.seas.gwu.edu:/pub/rtfm/" | |
196 "/ftp@rtfm.mit.edu:/pub/usenet/" | |
197 "/ftp@ftp.uni-paderborn.de:/pub/FAQ/" | |
198 "/ftp@ftp.sunet.se:/pub/usenet/" | |
199 "/ftp@nctuccca.edu.tw:/USENET/FAQ/" | |
200 "/ftp@hwarang.postech.ac.kr:/pub/usenet/" | |
201 "/ftp@ftp.hk.super.net:/mirror/faqs/") | |
202 "*Directory where the group FAQs are stored. | |
203 This will most commonly be on a remote machine, and the file will be | |
204 fetched by ange-ftp. | |
205 | |
206 This variable can also be a list of directories. In that case, the | |
207 first element in the list will be used by default, and the others will | |
208 be used as backup sites. | |
209 | |
210 Note that Gnus uses an aol machine as the default directory. If this | |
211 feels fundamentally unclean, just think of it as a way to finally get | |
212 something of value back from them. | |
213 | |
214 If the default site is too slow, try one of these: | |
215 | |
216 North America: mirrors.aol.com /pub/rtfm/usenet | |
217 ftp.seas.gwu.edu /pub/rtfm | |
218 rtfm.mit.edu /pub/usenet | |
219 Europe: ftp.uni-paderborn.de /pub/FAQ | |
220 src.doc.ic.ac.uk /usenet/news-FAQS | |
221 ftp.sunet.se /pub/usenet | |
222 sunsite.auc.dk /pub/usenet | |
223 Asia: nctuccca.edu.tw /USENET/FAQ | |
224 hwarang.postech.ac.kr /pub/usenet | |
225 ftp.hk.super.net /mirror/faqs") | |
226 | |
227 (defvar gnus-group-archive-directory | |
228 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/" | |
229 "*The address of the (ding) archives.") | |
230 | |
231 (defvar gnus-group-recent-archive-directory | |
232 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/" | |
233 "*The address of the most recent (ding) articles.") | |
234 | |
235 (defvar gnus-default-subscribed-newsgroups nil | |
236 "*This variable lists what newsgroups should be subscribed the first time Gnus is used. | |
237 It should be a list of strings. | |
238 If it is `t', Gnus will not do anything special the first time it is | |
239 started; it'll just use the normal newsgroups subscription methods.") | |
240 | |
241 (defvar gnus-use-cross-reference t | |
242 "*Non-nil means that cross referenced articles will be marked as read. | |
243 If nil, ignore cross references. If t, mark articles as read in | |
244 subscribed newsgroups. If neither t nor nil, mark as read in all | |
245 newsgroups.") | |
246 | |
247 (defvar gnus-single-article-buffer t | |
248 "*If non-nil, display all articles in the same buffer. | |
249 If nil, each group will get its own article buffer.") | |
250 | |
251 (defvar gnus-use-dribble-file t | |
252 "*Non-nil means that Gnus will use a dribble file to store user updates. | |
253 If Emacs should crash without saving the .newsrc files, complete | |
254 information can be restored from the dribble file.") | |
255 | |
256 (defvar gnus-dribble-directory nil | |
257 "*The directory where dribble files will be saved. | |
258 If this variable is nil, the directory where the .newsrc files are | |
259 saved will be used.") | |
260 | |
261 (defvar gnus-asynchronous nil | |
262 "*If non-nil, Gnus will supply backends with data needed for async article fetching.") | |
263 | |
264 (defvar gnus-kill-summary-on-exit t | |
265 "*If non-nil, kill the summary buffer when you exit from it. | |
266 If nil, the summary will become a \"*Dead Summary*\" buffer, and | |
267 it will be killed sometime later.") | |
268 | |
269 (defvar gnus-large-newsgroup 200 | |
270 "*The number of articles which indicates a large newsgroup. | |
271 If the number of articles in a newsgroup is greater than this value, | |
272 confirmation is required for selecting the newsgroup.") | |
273 | |
274 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>. | |
275 (defvar gnus-no-groups-message "No news is horrible news" | |
276 "*Message displayed by Gnus when no groups are available.") | |
277 | |
278 (defvar gnus-use-long-file-name (not (memq system-type '(usg-unix-v xenix))) | |
279 "*Non-nil means that the default name of a file to save articles in is the group name. | |
280 If it's nil, the directory form of the group name is used instead. | |
281 | |
282 If this variable is a list, and the list contains the element | |
283 `not-score', long file names will not be used for score files; if it | |
284 contains the element `not-save', long file names will not be used for | |
285 saving; and if it contains the element `not-kill', long file names | |
286 will not be used for kill files. | |
287 | |
288 Note that the default for this variable varies according to what system | |
289 type you're using. On `usg-unix-v' and `xenix' this variable defaults | |
290 to nil while on all other systems it defaults to t.") | |
291 | |
292 (defvar gnus-article-save-directory gnus-directory | |
293 "*Name of the directory articles will be saved in (default \"~/News\").") | |
294 | |
295 (defvar gnus-kill-files-directory gnus-directory | |
296 "*Name of the directory where kill files will be stored (default \"~/News\").") | |
297 | |
298 (defvar gnus-default-article-saver 'gnus-summary-save-in-rmail | |
299 "*A function to save articles in your favorite format. | |
300 The function must be interactively callable (in other words, it must | |
301 be an Emacs command). | |
302 | |
303 Gnus provides the following functions: | |
304 | |
305 * gnus-summary-save-in-rmail (Rmail format) | |
306 * gnus-summary-save-in-mail (Unix mail format) | |
307 * gnus-summary-save-in-folder (MH folder) | |
308 * gnus-summary-save-in-file (article format). | |
309 * gnus-summary-save-in-vm (use VM's folder format).") | |
310 | |
311 (defvar gnus-prompt-before-saving 'always | |
312 "*This variable says how much prompting is to be done when saving articles. | |
313 If it is nil, no prompting will be done, and the articles will be | |
314 saved to the default files. If this variable is `always', each and | |
315 every article that is saved will be preceded by a prompt, even when | |
316 saving large batches of articles. If this variable is neither nil not | |
317 `always', there the user will be prompted once for a file name for | |
318 each invocation of the saving commands.") | |
319 | |
320 (defvar gnus-rmail-save-name (function gnus-plain-save-name) | |
321 "*A function generating a file name to save articles in Rmail format. | |
322 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.") | |
323 | |
324 (defvar gnus-mail-save-name (function gnus-plain-save-name) | |
325 "*A function generating a file name to save articles in Unix mail format. | |
326 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.") | |
327 | |
328 (defvar gnus-folder-save-name (function gnus-folder-save-name) | |
329 "*A function generating a file name to save articles in MH folder. | |
330 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.") | |
331 | |
332 (defvar gnus-file-save-name (function gnus-numeric-save-name) | |
333 "*A function generating a file name to save articles in article format. | |
334 The function is called with NEWSGROUP, HEADERS, and optional | |
335 LAST-FILE.") | |
336 | |
337 (defvar gnus-split-methods | |
338 '((gnus-article-archive-name)) | |
339 "*Variable used to suggest where articles are to be saved. | |
340 For instance, if you would like to save articles related to Gnus in | |
341 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\", | |
342 you could set this variable to something like: | |
343 | |
344 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\") | |
345 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\")) | |
346 | |
347 This variable is an alist where the where the key is the match and the | |
348 value is a list of possible files to save in if the match is non-nil. | |
349 | |
350 If the match is a string, it is used as a regexp match on the | |
351 article. If the match is a symbol, that symbol will be funcalled | |
352 from the buffer of the article to be saved with the newsgroup as the | |
353 parameter. If it is a list, it will be evaled in the same buffer. | |
354 | |
355 If this form or function returns a string, this string will be used as | |
356 a possible file name; and if it returns a non-nil list, that list will | |
357 be used as possible file names.") | |
358 | |
359 (defvar gnus-move-split-methods nil | |
360 "*Variable used to suggest where articles are to be moved to. | |
361 It uses the same syntax as the `gnus-split-methods' variable.") | |
362 | |
363 (defvar gnus-save-score nil | |
364 "*If non-nil, save group scoring info.") | |
365 | |
366 (defvar gnus-use-adaptive-scoring nil | |
367 "*If non-nil, use some adaptive scoring scheme.") | |
368 | |
369 (defvar gnus-use-cache 'passive | |
370 "*If nil, Gnus will ignore the article cache. | |
371 If `passive', it will allow entering (and reading) articles | |
372 explicitly entered into the cache. If anything else, use the | |
373 cache to the full extent of the law.") | |
374 | |
375 (defvar gnus-use-trees nil | |
376 "*If non-nil, display a thread tree buffer.") | |
377 | |
378 (defvar gnus-use-grouplens nil | |
379 "*If non-nil, use GroupLens ratings.") | |
380 | |
381 (defvar gnus-keep-backlog nil | |
382 "*If non-nil, Gnus will keep read articles for later re-retrieval. | |
383 If it is a number N, then Gnus will only keep the last N articles | |
384 read. If it is neither nil nor a number, Gnus will keep all read | |
385 articles. This is not a good idea.") | |
386 | |
387 (defvar gnus-use-nocem nil | |
388 "*If non-nil, Gnus will read NoCeM cancel messages.") | |
389 | |
390 (defvar gnus-use-demon nil | |
391 "If non-nil, Gnus might use some demons.") | |
392 | |
393 (defvar gnus-use-scoring t | |
394 "*If non-nil, enable scoring.") | |
395 | |
396 (defvar gnus-use-picons nil | |
397 "*If non-nil, display picons.") | |
398 | |
399 (defvar gnus-fetch-old-headers nil | |
400 "*Non-nil means that Gnus will try to build threads by grabbing old headers. | |
401 If an unread article in the group refers to an older, already read (or | |
402 just marked as read) article, the old article will not normally be | |
403 displayed in the Summary buffer. If this variable is non-nil, Gnus | |
404 will attempt to grab the headers to the old articles, and thereby | |
405 build complete threads. If it has the value `some', only enough | |
406 headers to connect otherwise loose threads will be displayed. | |
407 This variable can also be a number. In that case, no more than that | |
408 number of old headers will be fetched. | |
409 | |
410 The server has to support NOV for any of this to work.") | |
411 | |
412 ;see gnus-cus.el | |
413 ;(defvar gnus-visual t | |
414 ; "*If non-nil, will do various highlighting. | |
415 ;If nil, no mouse highlights (or any other highlights) will be | |
416 ;performed. This might speed up Gnus some when generating large group | |
417 ;and summary buffers.") | |
418 | |
419 (defvar gnus-novice-user t | |
420 "*Non-nil means that you are a usenet novice. | |
421 If non-nil, verbose messages may be displayed and confirmations may be | |
422 required.") | |
423 | |
424 (defvar gnus-expert-user nil | |
425 "*Non-nil means that you will never be asked for confirmation about anything. | |
426 And that means *anything*.") | |
427 | |
428 (defvar gnus-verbose 7 | |
429 "*Integer that says how verbose Gnus should be. | |
430 The higher the number, the more messages Gnus will flash to say what | |
431 it's doing. At zero, Gnus will be totally mute; at five, Gnus will | |
432 display most important messages; and at ten, Gnus will keep on | |
433 jabbering all the time.") | |
434 | |
435 (defvar gnus-keep-same-level nil | |
436 "*Non-nil means that the next newsgroup after the current will be on the same level. | |
437 When you type, for instance, `n' after reading the last article in the | |
438 current newsgroup, you will go to the next newsgroup. If this variable | |
439 is nil, the next newsgroup will be the next from the group | |
440 buffer. | |
441 If this variable is non-nil, Gnus will either put you in the | |
442 next newsgroup with the same level, or, if no such newsgroup is | |
443 available, the next newsgroup with the lowest possible level higher | |
444 than the current level. | |
445 If this variable is `best', Gnus will make the next newsgroup the one | |
446 with the best level.") | |
447 | |
448 (defvar gnus-summary-make-false-root 'adopt | |
449 "*nil means that Gnus won't gather loose threads. | |
450 If the root of a thread has expired or been read in a previous | |
451 session, the information necessary to build a complete thread has been | |
452 lost. Instead of having many small sub-threads from this original thread | |
453 scattered all over the summary buffer, Gnus can gather them. | |
454 | |
455 If non-nil, Gnus will try to gather all loose sub-threads from an | |
456 original thread into one large thread. | |
457 | |
458 If this variable is non-nil, it should be one of `none', `adopt', | |
459 `dummy' or `empty'. | |
460 | |
461 If this variable is `none', Gnus will not make a false root, but just | |
462 present the sub-threads after another. | |
463 If this variable is `dummy', Gnus will create a dummy root that will | |
464 have all the sub-threads as children. | |
465 If this variable is `adopt', Gnus will make one of the \"children\" | |
466 the parent and mark all the step-children as such. | |
467 If this variable is `empty', the \"children\" are printed with empty | |
468 subject fields. (Or rather, they will be printed with a string | |
469 given by the `gnus-summary-same-subject' variable.)") | |
470 | |
471 (defvar gnus-summary-gather-exclude-subject "^ *$\\|^(none)$" | |
472 "*A regexp to match subjects to be excluded from loose thread gathering. | |
473 As loose thread gathering is done on subjects only, that means that | |
474 there can be many false gatherings performed. By rooting out certain | |
475 common subjects, gathering might become saner.") | |
476 | |
477 (defvar gnus-summary-gather-subject-limit nil | |
478 "*Maximum length of subject comparisons when gathering loose threads. | |
479 Use nil to compare full subjects. Setting this variable to a low | |
480 number will help gather threads that have been corrupted by | |
481 newsreaders chopping off subject lines, but it might also mean that | |
482 unrelated articles that have subject that happen to begin with the | |
483 same few characters will be incorrectly gathered. | |
484 | |
485 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when | |
486 comparing subjects.") | |
487 | |
488 (defvar gnus-simplify-ignored-prefixes nil | |
489 "*Regexp, matches for which are removed from subject lines when simplifying.") | |
490 | |
491 (defvar gnus-build-sparse-threads nil | |
492 "*If non-nil, fill in the gaps in threads. | |
493 If `some', only fill in the gaps that are needed to tie loose threads | |
494 together. If `more', fill in all leaf nodes that Gnus can find. If | |
495 non-nil and non-`some', fill in all gaps that Gnus manages to guess.") | |
496 | |
497 (defvar gnus-summary-thread-gathering-function 'gnus-gather-threads-by-subject | |
498 "Function used for gathering loose threads. | |
499 There are two pre-defined functions: `gnus-gather-threads-by-subject', | |
500 which only takes Subjects into consideration; and | |
501 `gnus-gather-threads-by-references', which compared the References | |
502 headers of the articles to find matches.") | |
503 | |
504 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>. | |
505 (defvar gnus-summary-same-subject "" | |
506 "*String indicating that the current article has the same subject as the previous. | |
507 This variable will only be used if the value of | |
508 `gnus-summary-make-false-root' is `empty'.") | |
509 | |
510 (defvar gnus-summary-goto-unread t | |
511 "*If non-nil, marking commands will go to the next unread article. | |
512 If `never', \\<gnus-summary-mode-map>\\[gnus-summary-next-page] will go to the next article, | |
513 whether it is read or not.") | |
514 | |
515 (defvar gnus-group-goto-unread t | |
516 "*If non-nil, movement commands will go to the next unread and subscribed group.") | |
517 | |
518 (defvar gnus-goto-next-group-when-activating t | |
519 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group.") | |
520 | |
521 (defvar gnus-check-new-newsgroups t | |
522 "*Non-nil means that Gnus will add new newsgroups at startup. | |
523 If this variable is `ask-server', Gnus will ask the server for new | |
524 groups since the last time it checked. This means that the killed list | |
525 is no longer necessary, so you could set `gnus-save-killed-list' to | |
526 nil. | |
527 | |
528 A variant is to have this variable be a list of select methods. Gnus | |
529 will then use the `ask-server' method on all these select methods to | |
530 query for new groups from all those servers. | |
531 | |
532 Eg. | |
533 (setq gnus-check-new-newsgroups | |
534 '((nntp \"some.server\") (nntp \"other.server\"))) | |
535 | |
536 If this variable is nil, then you have to tell Gnus explicitly to | |
537 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].") | |
538 | |
539 (defvar gnus-check-bogus-newsgroups nil | |
540 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup. | |
541 If this variable is nil, then you have to tell Gnus explicitly to | |
542 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].") | |
543 | |
544 (defvar gnus-read-active-file t | |
545 "*Non-nil means that Gnus will read the entire active file at startup. | |
546 If this variable is nil, Gnus will only know about the groups in your | |
547 `.newsrc' file. | |
548 | |
549 If this variable is `some', Gnus will try to only read the relevant | |
550 parts of the active file from the server. Not all servers support | |
551 this, and it might be quite slow with other servers, but this should | |
552 generally be faster than both the t and nil value. | |
553 | |
554 If you set this variable to nil or `some', you probably still want to | |
555 be told about new newsgroups that arrive. To do that, set | |
556 `gnus-check-new-newsgroups' to `ask-server'. This may not work | |
557 properly with all servers.") | |
558 | |
559 (defvar gnus-level-subscribed 5 | |
560 "*Groups with levels less than or equal to this variable are subscribed.") | |
561 | |
562 (defvar gnus-level-unsubscribed 7 | |
563 "*Groups with levels less than or equal to this variable are unsubscribed. | |
564 Groups with levels less than `gnus-level-subscribed', which should be | |
565 less than this variable, are subscribed.") | |
566 | |
567 (defvar gnus-level-zombie 8 | |
568 "*Groups with this level are zombie groups.") | |
569 | |
570 (defvar gnus-level-killed 9 | |
571 "*Groups with this level are killed.") | |
572 | |
573 (defvar gnus-level-default-subscribed 3 | |
574 "*New subscribed groups will be subscribed at this level.") | |
575 | |
576 (defvar gnus-level-default-unsubscribed 6 | |
577 "*New unsubscribed groups will be unsubscribed at this level.") | |
578 | |
579 (defvar gnus-activate-level (1+ gnus-level-subscribed) | |
580 "*Groups higher than this level won't be activated on startup. | |
581 Setting this variable to something log might save lots of time when | |
582 you have many groups that you aren't interested in.") | |
583 | |
584 (defvar gnus-activate-foreign-newsgroups 4 | |
585 "*If nil, Gnus will not check foreign newsgroups at startup. | |
586 If it is non-nil, it should be a number between one and nine. Foreign | |
587 newsgroups that have a level lower or equal to this number will be | |
588 activated on startup. For instance, if you want to active all | |
589 subscribed newsgroups, but not the rest, you'd set this variable to | |
590 `gnus-level-subscribed'. | |
591 | |
592 If you subscribe to lots of newsgroups from different servers, startup | |
593 might take a while. By setting this variable to nil, you'll save time, | |
594 but you won't be told how many unread articles there are in the | |
595 groups.") | |
596 | |
597 (defvar gnus-save-newsrc-file t | |
598 "*Non-nil means that Gnus will save the `.newsrc' file. | |
599 Gnus always saves its own startup file, which is called | |
600 \".newsrc.eld\". The file called \".newsrc\" is in a format that can | |
601 be readily understood by other newsreaders. If you don't plan on | |
602 using other newsreaders, set this variable to nil to save some time on | |
603 exit.") | |
604 | |
605 (defvar gnus-save-killed-list t | |
606 "*If non-nil, save the list of killed groups to the startup file. | |
607 If you set this variable to nil, you'll save both time (when starting | |
608 and quitting) and space (both memory and disk), but it will also mean | |
609 that Gnus has no record of which groups are new and which are old, so | |
610 the automatic new newsgroups subscription methods become meaningless. | |
611 | |
612 You should always set `gnus-check-new-newsgroups' to `ask-server' or | |
613 nil if you set this variable to nil.") | |
614 | |
615 (defvar gnus-interactive-catchup t | |
616 "*If non-nil, require your confirmation when catching up a group.") | |
617 | |
618 (defvar gnus-interactive-exit t | |
619 "*If non-nil, require your confirmation when exiting Gnus.") | |
620 | |
621 (defvar gnus-kill-killed t | |
622 "*If non-nil, Gnus will apply kill files to already killed articles. | |
623 If it is nil, Gnus will never apply kill files to articles that have | |
624 already been through the scoring process, which might very well save lots | |
625 of time.") | |
626 | |
627 (defvar gnus-extract-address-components 'gnus-extract-address-components | |
628 "*Function for extracting address components from a From header. | |
629 Two pre-defined function exist: `gnus-extract-address-components', | |
630 which is the default, quite fast, and too simplistic solution, and | |
631 `mail-extract-address-components', which works much better, but is | |
632 slower.") | |
633 | |
634 (defvar gnus-summary-default-score 0 | |
635 "*Default article score level. | |
636 If this variable is nil, scoring will be disabled.") | |
637 | |
638 (defvar gnus-summary-zcore-fuzz 0 | |
639 "*Fuzziness factor for the zcore in the summary buffer. | |
640 Articles with scores closer than this to `gnus-summary-default-score' | |
641 will not be marked.") | |
642 | |
643 (defvar gnus-simplify-subject-fuzzy-regexp nil | |
644 "*Strings to be removed when doing fuzzy matches. | |
645 This can either be a regular expression or list of regular expressions | |
646 that will be removed from subject strings if fuzzy subject | |
647 simplification is selected.") | |
648 | |
649 (defvar gnus-permanently-visible-groups nil | |
650 "*Regexp to match groups that should always be listed in the group buffer. | |
651 This means that they will still be listed when there are no unread | |
652 articles in the groups.") | |
653 | |
654 (defvar gnus-list-groups-with-ticked-articles t | |
655 "*If non-nil, list groups that have only ticked articles. | |
656 If nil, only list groups that have unread articles.") | |
657 | |
658 (defvar gnus-group-default-list-level gnus-level-subscribed | |
659 "*Default listing level. | |
660 Ignored if `gnus-group-use-permanent-levels' is non-nil.") | |
661 | |
662 (defvar gnus-group-use-permanent-levels nil | |
663 "*If non-nil, once you set a level, Gnus will use this level.") | |
664 | |
665 (defvar gnus-group-list-inactive-groups t | |
666 "*If non-nil, inactive groups will be listed.") | |
667 | |
668 (defvar gnus-show-mime nil | |
669 "*If non-nil, do mime processing of articles. | |
670 The articles will simply be fed to the function given by | |
671 `gnus-show-mime-method'.") | |
672 | |
673 (defvar gnus-strict-mime t | |
674 "*If nil, MIME-decode even if there is no Mime-Version header in the article.") | |
675 | |
676 (defvar gnus-show-mime-method 'metamail-buffer | |
677 "*Function to process a MIME message. | |
678 The function is called from the article buffer.") | |
679 | |
680 (defvar gnus-decode-encoded-word-method (lambda ()) | |
681 "*Function to decode a MIME encoded-words. | |
682 The function is called from the article buffer.") | |
683 | |
684 (defvar gnus-show-threads t | |
685 "*If non-nil, display threads in summary mode.") | |
686 | |
687 (defvar gnus-thread-hide-subtree nil | |
688 "*If non-nil, hide all threads initially. | |
689 If threads are hidden, you have to run the command | |
690 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook' | |
691 to expose hidden threads.") | |
692 | |
693 (defvar gnus-thread-hide-killed t | |
694 "*If non-nil, hide killed threads automatically.") | |
695 | |
696 (defvar gnus-thread-ignore-subject nil | |
697 "*If non-nil, ignore subjects and do all threading based on the Reference header. | |
698 If nil, which is the default, articles that have different subjects | |
699 from their parents will start separate threads.") | |
700 | |
701 (defvar gnus-thread-operation-ignore-subject t | |
702 "*If non-nil, subjects will be ignored when doing thread commands. | |
703 This affects commands like `gnus-summary-kill-thread' and | |
704 `gnus-summary-lower-thread'. | |
705 | |
706 If this variable is nil, articles in the same thread with different | |
707 subjects will not be included in the operation in question. If this | |
708 variable is `fuzzy', only articles that have subjects that are fuzzily | |
709 equal will be included.") | |
710 | |
711 (defvar gnus-thread-indent-level 4 | |
712 "*Number that says how much each sub-thread should be indented.") | |
713 | |
714 (defvar gnus-ignored-newsgroups | |
715 (purecopy (mapconcat 'identity | |
716 '("^to\\." ; not "real" groups | |
717 "^[0-9. \t]+ " ; all digits in name | |
718 "[][\"#'()]" ; bogus characters | |
719 ) | |
720 "\\|")) | |
721 "*A regexp to match uninteresting newsgroups in the active file. | |
722 Any lines in the active file matching this regular expression are | |
723 removed from the newsgroup list before anything else is done to it, | |
724 thus making them effectively non-existent.") | |
725 | |
726 (defvar gnus-ignored-headers | |
727 "^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:" | |
728 "*All headers that match this regexp will be hidden. | |
729 This variable can also be a list of regexps of headers to be ignored. | |
730 If `gnus-visible-headers' is non-nil, this variable will be ignored.") | |
731 | |
732 (defvar gnus-visible-headers "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-" | |
733 "*All headers that do not match this regexp will be hidden. | |
734 This variable can also be a list of regexp of headers to remain visible. | |
735 If this variable is non-nil, `gnus-ignored-headers' will be ignored.") | |
736 | |
737 (defvar gnus-sorted-header-list | |
738 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:" | |
739 "^Cc:" "^Date:" "^Organization:") | |
740 "*This variable is a list of regular expressions. | |
741 If it is non-nil, headers that match the regular expressions will | |
742 be placed first in the article buffer in the sequence specified by | |
743 this list.") | |
744 | |
745 (defvar gnus-boring-article-headers | |
746 '(empty followup-to reply-to) | |
747 "*Headers that are only to be displayed if they have interesting data. | |
748 Possible values in this list are `empty', `newsgroups', `followup-to', | |
749 `reply-to', and `date'.") | |
750 | |
751 (defvar gnus-show-all-headers nil | |
752 "*If non-nil, don't hide any headers.") | |
753 | |
754 (defvar gnus-save-all-headers t | |
755 "*If non-nil, don't remove any headers before saving.") | |
756 | |
757 (defvar gnus-saved-headers gnus-visible-headers | |
758 "*Headers to keep if `gnus-save-all-headers' is nil. | |
759 If `gnus-save-all-headers' is non-nil, this variable will be ignored. | |
760 If that variable is nil, however, all headers that match this regexp | |
761 will be kept while the rest will be deleted before saving.") | |
762 | |
763 (defvar gnus-inhibit-startup-message nil | |
764 "*If non-nil, the startup message will not be displayed.") | |
765 | |
766 (defvar gnus-signature-separator "^-- *$" | |
767 "Regexp matching signature separator.") | |
768 | |
769 (defvar gnus-signature-limit nil | |
770 "Provide a limit to what is considered a signature. | |
771 If it is a number, no signature may not be longer (in characters) than | |
772 that number. If it is a function, the function will be called without | |
773 any parameters, and if it returns nil, there is no signature in the | |
774 buffer. If it is a string, it will be used as a regexp. If it | |
775 matches, the text in question is not a signature.") | |
776 | |
777 (defvar gnus-auto-extend-newsgroup t | |
778 "*If non-nil, extend newsgroup forward and backward when requested.") | |
779 | |
780 (defvar gnus-auto-select-first t | |
781 "*If nil, don't select the first unread article when entering a group. | |
782 If this variable is `best', select the highest-scored unread article | |
783 in the group. If neither nil nor `best', select the first unread | |
784 article. | |
785 | |
786 If you want to prevent automatic selection of the first unread article | |
787 in some newsgroups, set the variable to nil in | |
788 `gnus-select-group-hook'.") | |
789 | |
790 (defvar gnus-auto-select-next t | |
791 "*If non-nil, offer to go to the next group from the end of the previous. | |
792 If the value is t and the next newsgroup is empty, Gnus will exit | |
793 summary mode and go back to group mode. If the value is neither nil | |
794 nor t, Gnus will select the following unread newsgroup. In | |
795 particular, if the value is the symbol `quietly', the next unread | |
796 newsgroup will be selected without any confirmation, and if it is | |
797 `almost-quietly', the next group will be selected without any | |
798 confirmation if you are located on the last article in the group. | |
799 Finally, if this variable is `slightly-quietly', the `Z n' command | |
800 will go to the next group without confirmation.") | |
801 | |
802 (defvar gnus-auto-select-same nil | |
803 "*If non-nil, select the next article with the same subject.") | |
804 | |
805 (defvar gnus-summary-check-current nil | |
806 "*If non-nil, consider the current article when moving. | |
807 The \"unread\" movement commands will stay on the same line if the | |
808 current article is unread.") | |
809 | |
810 (defvar gnus-auto-center-summary t | |
811 "*If non-nil, always center the current summary buffer. | |
812 In particular, if `vertical' do only vertical recentering. If non-nil | |
813 and non-`vertical', do both horizontal and vertical recentering.") | |
814 | |
815 (defvar gnus-break-pages t | |
816 "*If non-nil, do page breaking on articles. | |
817 The page delimiter is specified by the `gnus-page-delimiter' | |
818 variable.") | |
819 | |
820 (defvar gnus-page-delimiter "^\^L" | |
821 "*Regexp describing what to use as article page delimiters. | |
822 The default value is \"^\^L\", which is a form linefeed at the | |
823 beginning of a line.") | |
824 | |
825 (defvar gnus-use-full-window t | |
826 "*If non-nil, use the entire Emacs screen.") | |
827 | |
828 (defvar gnus-window-configuration nil | |
829 "Obsolete variable. See `gnus-buffer-configuration'.") | |
830 | |
831 (defvar gnus-window-min-width 2 | |
832 "*Minimum width of Gnus buffers.") | |
833 | |
834 (defvar gnus-window-min-height 1 | |
835 "*Minimum height of Gnus buffers.") | |
836 | |
837 (defvar gnus-buffer-configuration | |
838 '((group | |
839 (vertical 1.0 | |
840 (group 1.0 point) | |
841 (if gnus-carpal '(group-carpal 4)))) | |
842 (summary | |
843 (vertical 1.0 | |
844 (summary 1.0 point) | |
845 (if gnus-carpal '(summary-carpal 4)))) | |
846 (article | |
847 (cond | |
848 (gnus-use-picons | |
849 '(frame 1.0 | |
850 (vertical 1.0 | |
851 (summary 0.25 point) | |
852 (if gnus-carpal '(summary-carpal 4)) | |
853 (article 1.0)) | |
854 (vertical ((height . 5) (width . 15) | |
855 (user-position . t) | |
856 (left . -1) (top . 1)) | |
857 (picons 1.0)))) | |
858 (gnus-use-trees | |
859 '(vertical 1.0 | |
860 (summary 0.25 point) | |
861 (tree 0.25) | |
862 (article 1.0))) | |
863 (t | |
864 '(vertical 1.0 | |
865 (summary 0.25 point) | |
866 (if gnus-carpal '(summary-carpal 4)) | |
867 (if gnus-use-trees '(tree 0.25)) | |
868 (article 1.0))))) | |
869 (server | |
870 (vertical 1.0 | |
871 (server 1.0 point) | |
872 (if gnus-carpal '(server-carpal 2)))) | |
873 (browse | |
874 (vertical 1.0 | |
875 (browse 1.0 point) | |
876 (if gnus-carpal '(browse-carpal 2)))) | |
877 (message | |
878 (vertical 1.0 | |
879 (message 1.0 point))) | |
880 (pick | |
881 (vertical 1.0 | |
882 (article 1.0 point))) | |
883 (info | |
884 (vertical 1.0 | |
885 (info 1.0 point))) | |
886 (summary-faq | |
887 (vertical 1.0 | |
888 (summary 0.25) | |
889 (faq 1.0 point))) | |
890 (edit-group | |
891 (vertical 1.0 | |
892 (group 0.5) | |
893 (edit-group 1.0 point))) | |
894 (edit-server | |
895 (vertical 1.0 | |
896 (server 0.5) | |
897 (edit-server 1.0 point))) | |
898 (edit-score | |
899 (vertical 1.0 | |
900 (summary 0.25) | |
901 (edit-score 1.0 point))) | |
902 (post | |
903 (vertical 1.0 | |
904 (post 1.0 point))) | |
905 (reply | |
906 (vertical 1.0 | |
907 (article-copy 0.5) | |
908 (message 1.0 point))) | |
909 (forward | |
910 (vertical 1.0 | |
911 (message 1.0 point))) | |
912 (reply-yank | |
913 (vertical 1.0 | |
914 (message 1.0 point))) | |
915 (mail-bounce | |
916 (vertical 1.0 | |
917 (article 0.5) | |
918 (message 1.0 point))) | |
919 (draft | |
920 (vertical 1.0 | |
921 (draft 1.0 point))) | |
922 (pipe | |
923 (vertical 1.0 | |
924 (summary 0.25 point) | |
925 (if gnus-carpal '(summary-carpal 4)) | |
926 ("*Shell Command Output*" 1.0))) | |
927 (bug | |
928 (vertical 1.0 | |
929 ("*Gnus Help Bug*" 0.5) | |
930 ("*Gnus Bug*" 1.0 point))) | |
931 (compose-bounce | |
932 (vertical 1.0 | |
933 (article 0.5) | |
934 (message 1.0 point)))) | |
935 "Window configuration for all possible Gnus buffers. | |
936 This variable is a list of lists. Each of these lists has a NAME and | |
937 a RULE. The NAMEs are commonsense names like `group', which names a | |
938 rule used when displaying the group buffer; `summary', which names a | |
939 rule for what happens when you enter a group and do not display an | |
940 article buffer; and so on. See the value of this variable for a | |
941 complete list of NAMEs. | |
942 | |
943 Each RULE is a list of vectors. The first element in this vector is | |
944 the name of the buffer to be displayed; the second element is the | |
945 percentage of the screen this buffer is to occupy (a number in the | |
946 0.0-0.99 range); the optional third element is `point', which should | |
947 be present to denote which buffer point is to go to after making this | |
948 buffer configuration.") | |
949 | |
950 (defvar gnus-window-to-buffer | |
951 '((group . gnus-group-buffer) | |
952 (summary . gnus-summary-buffer) | |
953 (article . gnus-article-buffer) | |
954 (server . gnus-server-buffer) | |
955 (browse . "*Gnus Browse Server*") | |
956 (edit-group . gnus-group-edit-buffer) | |
957 (edit-server . gnus-server-edit-buffer) | |
958 (group-carpal . gnus-carpal-group-buffer) | |
959 (summary-carpal . gnus-carpal-summary-buffer) | |
960 (server-carpal . gnus-carpal-server-buffer) | |
961 (browse-carpal . gnus-carpal-browse-buffer) | |
962 (edit-score . gnus-score-edit-buffer) | |
963 (message . gnus-message-buffer) | |
964 (mail . gnus-message-buffer) | |
965 (post-news . gnus-message-buffer) | |
966 (faq . gnus-faq-buffer) | |
967 (picons . "*Picons*") | |
968 (tree . gnus-tree-buffer) | |
969 (info . gnus-info-buffer) | |
970 (article-copy . gnus-article-copy) | |
971 (draft . gnus-draft-buffer)) | |
972 "Mapping from short symbols to buffer names or buffer variables.") | |
973 | |
974 (defvar gnus-carpal nil | |
975 "*If non-nil, display clickable icons.") | |
976 | |
977 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies | |
978 "*Function called with a group name when new group is detected. | |
979 A few pre-made functions are supplied: `gnus-subscribe-randomly' | |
980 inserts new groups at the beginning of the list of groups; | |
981 `gnus-subscribe-alphabetically' inserts new groups in strict | |
982 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups | |
983 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks | |
984 for your decision; `gnus-subscribe-killed' kills all new groups; | |
985 `gnus-subscribe-zombies' will make all new groups into zombies.") | |
986 | |
987 ;; Suggested by a bug report by Hallvard B Furuseth. | |
988 ;; <h.b.furuseth@usit.uio.no>. | |
989 (defvar gnus-subscribe-options-newsgroup-method | |
990 (function gnus-subscribe-alphabetically) | |
991 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines. | |
992 If, for instance, you want to subscribe to all newsgroups in the | |
993 \"no\" and \"alt\" hierarchies, you'd put the following in your | |
994 .newsrc file: | |
995 | |
996 options -n no.all alt.all | |
997 | |
998 Gnus will the subscribe all new newsgroups in these hierarchies with | |
999 the subscription method in this variable.") | |
1000 | |
1001 (defvar gnus-subscribe-hierarchical-interactive nil | |
1002 "*If non-nil, Gnus will offer to subscribe hierarchically. | |
1003 When a new hierarchy appears, Gnus will ask the user: | |
1004 | |
1005 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys): | |
1006 | |
1007 If the user pressed `d', Gnus will descend the hierarchy, `y' will | |
1008 subscribe to all newsgroups in the hierarchy and `s' will skip this | |
1009 hierarchy in its entirety.") | |
1010 | |
1011 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet | |
1012 "*Function used for sorting the group buffer. | |
1013 This function will be called with group info entries as the arguments | |
1014 for the groups to be sorted. Pre-made functions include | |
1015 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-unread', | |
1016 `gnus-group-sort-by-level', `gnus-group-sort-by-score', and | |
1017 `gnus-group-sort-by-rank'. | |
1018 | |
1019 This variable can also be a list of sorting functions. In that case, | |
1020 the most significant sort function should be the last function in the | |
1021 list.") | |
1022 | |
1023 ;; Mark variables suggested by Thomas Michanek | |
1024 ;; <Thomas.Michanek@telelogic.se>. | |
1025 (defvar gnus-unread-mark ? | |
1026 "*Mark used for unread articles.") | |
1027 (defvar gnus-ticked-mark ?! | |
1028 "*Mark used for ticked articles.") | |
1029 (defvar gnus-dormant-mark ?? | |
1030 "*Mark used for dormant articles.") | |
1031 (defvar gnus-del-mark ?r | |
1032 "*Mark used for del'd articles.") | |
1033 (defvar gnus-read-mark ?R | |
1034 "*Mark used for read articles.") | |
1035 (defvar gnus-expirable-mark ?E | |
1036 "*Mark used for expirable articles.") | |
1037 (defvar gnus-killed-mark ?K | |
1038 "*Mark used for killed articles.") | |
1039 (defvar gnus-souped-mark ?F | |
1040 "*Mark used for killed articles.") | |
1041 (defvar gnus-kill-file-mark ?X | |
1042 "*Mark used for articles killed by kill files.") | |
1043 (defvar gnus-low-score-mark ?Y | |
1044 "*Mark used for articles with a low score.") | |
1045 (defvar gnus-catchup-mark ?C | |
1046 "*Mark used for articles that are caught up.") | |
1047 (defvar gnus-replied-mark ?A | |
1048 "*Mark used for articles that have been replied to.") | |
1049 (defvar gnus-cached-mark ?* | |
1050 "*Mark used for articles that are in the cache.") | |
1051 (defvar gnus-saved-mark ?S | |
1052 "*Mark used for articles that have been saved to.") | |
1053 (defvar gnus-process-mark ?# | |
1054 "*Process mark.") | |
1055 (defvar gnus-ancient-mark ?O | |
1056 "*Mark used for ancient articles.") | |
1057 (defvar gnus-sparse-mark ?Q | |
1058 "*Mark used for sparsely reffed articles.") | |
1059 (defvar gnus-canceled-mark ?G | |
1060 "*Mark used for canceled articles.") | |
1061 (defvar gnus-score-over-mark ?+ | |
1062 "*Score mark used for articles with high scores.") | |
1063 (defvar gnus-score-below-mark ?- | |
1064 "*Score mark used for articles with low scores.") | |
1065 (defvar gnus-empty-thread-mark ? | |
1066 "*There is no thread under the article.") | |
1067 (defvar gnus-not-empty-thread-mark ?= | |
1068 "*There is a thread under the article.") | |
1069 | |
1070 (defvar gnus-view-pseudo-asynchronously nil | |
1071 "*If non-nil, Gnus will view pseudo-articles asynchronously.") | |
1072 | |
1073 (defvar gnus-view-pseudos nil | |
1074 "*If `automatic', pseudo-articles will be viewed automatically. | |
1075 If `not-confirm', pseudos will be viewed automatically, and the user | |
1076 will not be asked to confirm the command.") | |
1077 | |
1078 (defvar gnus-view-pseudos-separately t | |
1079 "*If non-nil, one pseudo-article will be created for each file to be viewed. | |
1080 If nil, all files that use the same viewing command will be given as a | |
1081 list of parameters to that command.") | |
1082 | |
1083 (defvar gnus-insert-pseudo-articles t | |
1084 "*If non-nil, insert pseudo-articles when decoding articles.") | |
1085 | |
1086 (defvar gnus-group-line-format "%M%S%p%P%5y: %(%g%)%l\n" | |
1087 "*Format of group lines. | |
1088 It works along the same lines as a normal formatting string, | |
1089 with some simple extensions. | |
1090 | |
1091 %M Only marked articles (character, \"*\" or \" \") | |
1092 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \") | |
1093 %L Level of subscribedness (integer) | |
1094 %N Number of unread articles (integer) | |
1095 %I Number of dormant articles (integer) | |
1096 %i Number of ticked and dormant (integer) | |
1097 %T Number of ticked articles (integer) | |
1098 %R Number of read articles (integer) | |
1099 %t Total number of articles (integer) | |
1100 %y Number of unread, unticked articles (integer) | |
1101 %G Group name (string) | |
1102 %g Qualified group name (string) | |
1103 %D Group description (string) | |
1104 %s Select method (string) | |
1105 %o Moderated group (char, \"m\") | |
1106 %p Process mark (char) | |
1107 %O Moderated group (string, \"(m)\" or \"\") | |
1108 %P Topic indentation (string) | |
1109 %l Whether there are GroupLens predictions for this group (string) | |
1110 %n Select from where (string) | |
1111 %z A string that look like `<%s:%n>' if a foreign select method is used | |
1112 %u User defined specifier. The next character in the format string should | |
1113 be a letter. Gnus will call the function gnus-user-format-function-X, | |
1114 where X is the letter following %u. The function will be passed the | |
1115 current header as argument. The function should return a string, which | |
1116 will be inserted into the buffer just like information from any other | |
1117 group specifier. | |
1118 | |
1119 Text between %( and %) will be highlighted with `gnus-mouse-face' when | |
1120 the mouse point move inside the area. There can only be one such area. | |
1121 | |
1122 Note that this format specification is not always respected. For | |
1123 reasons of efficiency, when listing killed groups, this specification | |
1124 is ignored altogether. If the spec is changed considerably, your | |
1125 output may end up looking strange when listing both alive and killed | |
1126 groups. | |
1127 | |
1128 If you use %o or %O, reading the active file will be slower and quite | |
1129 a bit of extra memory will be used. %D will also worsen performance. | |
1130 Also note that if you change the format specification to include any | |
1131 of these specs, you must probably re-start Gnus to see them go into | |
1132 effect.") | |
1133 | |
1134 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n" | |
1135 "*The format specification of the lines in the summary buffer. | |
1136 | |
1137 It works along the same lines as a normal formatting string, | |
1138 with some simple extensions. | |
1139 | |
1140 %N Article number, left padded with spaces (string) | |
1141 %S Subject (string) | |
1142 %s Subject if it is at the root of a thread, and \"\" otherwise (string) | |
1143 %n Name of the poster (string) | |
1144 %a Extracted name of the poster (string) | |
1145 %A Extracted address of the poster (string) | |
1146 %F Contents of the From: header (string) | |
1147 %x Contents of the Xref: header (string) | |
1148 %D Date of the article (string) | |
1149 %d Date of the article (string) in DD-MMM format | |
1150 %M Message-id of the article (string) | |
1151 %r References of the article (string) | |
1152 %c Number of characters in the article (integer) | |
1153 %L Number of lines in the article (integer) | |
1154 %I Indentation based on thread level (a string of spaces) | |
1155 %T A string with two possible values: 80 spaces if the article | |
1156 is on thread level two or larger and 0 spaces on level one | |
1157 %R \"A\" if this article has been replied to, \" \" otherwise (character) | |
1158 %U Status of this article (character, \"R\", \"K\", \"-\" or \" \") | |
1159 %[ Opening bracket (character, \"[\" or \"<\") | |
1160 %] Closing bracket (character, \"]\" or \">\") | |
1161 %> Spaces of length thread-level (string) | |
1162 %< Spaces of length (- 20 thread-level) (string) | |
1163 %i Article score (number) | |
1164 %z Article zcore (character) | |
1165 %t Number of articles under the current thread (number). | |
1166 %e Whether the thread is empty or not (character). | |
1167 %l GroupLens score (string). | |
1168 %u User defined specifier. The next character in the format string should | |
1169 be a letter. Gnus will call the function gnus-user-format-function-X, | |
1170 where X is the letter following %u. The function will be passed the | |
1171 current header as argument. The function should return a string, which | |
1172 will be inserted into the summary just like information from any other | |
1173 summary specifier. | |
1174 | |
1175 Text between %( and %) will be highlighted with `gnus-mouse-face' | |
1176 when the mouse point is placed inside the area. There can only be one | |
1177 such area. | |
1178 | |
1179 The %U (status), %R (replied) and %z (zcore) specs have to be handled | |
1180 with care. For reasons of efficiency, Gnus will compute what column | |
1181 these characters will end up in, and \"hard-code\" that. This means that | |
1182 it is illegal to have these specs after a variable-length spec. Well, | |
1183 you might not be arrested, but your summary buffer will look strange, | |
1184 which is bad enough. | |
1185 | |
1186 The smart choice is to have these specs as for to the left as | |
1187 possible. | |
1188 | |
1189 This restriction may disappear in later versions of Gnus.") | |
1190 | |
1191 (defvar gnus-summary-dummy-line-format | |
1192 "* %(: :%) %S\n" | |
1193 "*The format specification for the dummy roots in the summary buffer. | |
1194 It works along the same lines as a normal formatting string, | |
1195 with some simple extensions. | |
1196 | |
1197 %S The subject") | |
1198 | |
1199 (defvar gnus-summary-mode-line-format "Gnus: %%b [%A] %Z" | |
1200 "*The format specification for the summary mode line. | |
1201 It works along the same lines as a normal formatting string, | |
1202 with some simple extensions: | |
1203 | |
1204 %G Group name | |
1205 %p Unprefixed group name | |
1206 %A Current article number | |
1207 %V Gnus version | |
1208 %U Number of unread articles in the group | |
1209 %e Number of unselected articles in the group | |
1210 %Z A string with unread/unselected article counts | |
1211 %g Shortish group name | |
1212 %S Subject of the current article | |
1213 %u User-defined spec | |
1214 %s Current score file name | |
1215 %d Number of dormant articles | |
1216 %r Number of articles that have been marked as read in this session | |
1217 %E Number of articles expunged by the score files") | |
1218 | |
1219 (defvar gnus-article-mode-line-format "Gnus: %%b %S" | |
1220 "*The format specification for the article mode line. | |
1221 See `gnus-summary-mode-line-format' for a closer description.") | |
1222 | |
1223 (defvar gnus-group-mode-line-format "Gnus: %%b {%M%:%S}" | |
1224 "*The format specification for the group mode line. | |
1225 It works along the same lines as a normal formatting string, | |
1226 with some simple extensions: | |
1227 | |
1228 %S The native news server. | |
1229 %M The native select method. | |
1230 %: \":\" if %S isn't \"\".") | |
1231 | |
1232 (defvar gnus-valid-select-methods | |
1233 '(("nntp" post address prompt-address) | |
1234 ("nnspool" post address) | |
1235 ("nnvirtual" post-mail virtual prompt-address) | |
1236 ("nnmbox" mail respool address) | |
1237 ("nnml" mail respool address) | |
1238 ("nnmh" mail respool address) | |
1239 ("nndir" post-mail prompt-address address) | |
1240 ("nneething" none address prompt-address) | |
1241 ("nndoc" none address prompt-address) | |
1242 ("nnbabyl" mail address respool) | |
1243 ("nnkiboze" post virtual) | |
1244 ("nnsoup" post-mail address) | |
1245 ("nndraft" post-mail) | |
1246 ("nnfolder" mail respool address)) | |
1247 "An alist of valid select methods. | |
1248 The first element of each list lists should be a string with the name | |
1249 of the select method. The other elements may be be the category of | |
1250 this method (ie. `post', `mail', `none' or whatever) or other | |
1251 properties that this method has (like being respoolable). | |
1252 If you implement a new select method, all you should have to change is | |
1253 this variable. I think.") | |
1254 | |
1255 (defvar gnus-updated-mode-lines '(group article summary tree) | |
1256 "*List of buffers that should update their mode lines. | |
1257 The list may contain the symbols `group', `article' and `summary'. If | |
1258 the corresponding symbol is present, Gnus will keep that mode line | |
1259 updated with information that may be pertinent. | |
1260 If this variable is nil, screen refresh may be quicker.") | |
1261 | |
1262 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>. | |
1263 (defvar gnus-mode-non-string-length nil | |
1264 "*Max length of mode-line non-string contents. | |
1265 If this is nil, Gnus will take space as is needed, leaving the rest | |
1266 of the modeline intact.") | |
1267 | |
1268 ;see gnus-cus.el | |
1269 ;(defvar gnus-mouse-face 'highlight | |
1270 ; "*Face used for mouse highlighting in Gnus. | |
1271 ;No mouse highlights will be done if `gnus-visual' is nil.") | |
1272 | |
1273 (defvar gnus-summary-mark-below 0 | |
1274 "*Mark all articles with a score below this variable as read. | |
1275 This variable is local to each summary buffer and usually set by the | |
1276 score file.") | |
1277 | |
1278 (defvar gnus-article-sort-functions '(gnus-article-sort-by-number) | |
1279 "*List of functions used for sorting articles in the summary buffer. | |
1280 This variable is only used when not using a threaded display.") | |
1281 | |
1282 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number) | |
1283 "*List of functions used for sorting threads in the summary buffer. | |
1284 By default, threads are sorted by article number. | |
1285 | |
1286 Each function takes two threads and return non-nil if the first thread | |
1287 should be sorted before the other. If you use more than one function, | |
1288 the primary sort function should be the last. You should probably | |
1289 always include `gnus-thread-sort-by-number' in the list of sorting | |
1290 functions -- preferably first. | |
1291 | |
1292 Ready-mady functions include `gnus-thread-sort-by-number', | |
1293 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject', | |
1294 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and | |
1295 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').") | |
1296 | |
1297 (defvar gnus-thread-score-function '+ | |
1298 "*Function used for calculating the total score of a thread. | |
1299 | |
1300 The function is called with the scores of the article and each | |
1301 subthread and should then return the score of the thread. | |
1302 | |
1303 Some functions you can use are `+', `max', or `min'.") | |
1304 | |
1305 (defvar gnus-summary-expunge-below nil | |
1306 "All articles that have a score less than this variable will be expunged.") | |
1307 | |
1308 (defvar gnus-thread-expunge-below nil | |
1309 "All threads that have a total score less than this variable will be expunged. | |
1310 See `gnus-thread-score-function' for en explanation of what a | |
1311 \"thread score\" is.") | |
1312 | |
1313 (defvar gnus-auto-subscribed-groups | |
1314 "^nnml\\|^nnfolder\\|^nnmbox\\|^nnmh\\|^nnbabyl" | |
1315 "*All new groups that match this regexp will be subscribed automatically. | |
1316 Note that this variable only deals with new groups. It has no effect | |
1317 whatsoever on old groups.") | |
1318 | |
1319 (defvar gnus-options-subscribe nil | |
1320 "*All new groups matching this regexp will be subscribed unconditionally. | |
1321 Note that this variable deals only with new newsgroups. This variable | |
1322 does not affect old newsgroups.") | |
1323 | |
1324 (defvar gnus-options-not-subscribe nil | |
1325 "*All new groups matching this regexp will be ignored. | |
1326 Note that this variable deals only with new newsgroups. This variable | |
1327 does not affect old (already subscribed) newsgroups.") | |
1328 | |
1329 (defvar gnus-auto-expirable-newsgroups nil | |
1330 "*Groups in which to automatically mark read articles as expirable. | |
1331 If non-nil, this should be a regexp that should match all groups in | |
1332 which to perform auto-expiry. This only makes sense for mail groups.") | |
1333 | |
1334 (defvar gnus-total-expirable-newsgroups nil | |
1335 "*Groups in which to perform expiry of all read articles. | |
1336 Use with extreme caution. All groups that match this regexp will be | |
1337 expiring - which means that all read articles will be deleted after | |
1338 (say) one week. (This only goes for mail groups and the like, of | |
1339 course.)") | |
1340 | |
1341 (defvar gnus-group-uncollapsed-levels 1 | |
1342 "Number of group name elements to leave alone when making a short group name.") | |
1343 | |
1344 (defvar gnus-hidden-properties '(invisible t intangible t) | |
1345 "Property list to use for hiding text.") | |
1346 | |
1347 (defvar gnus-modtime-botch nil | |
1348 "*Non-nil means .newsrc should be deleted prior to save. | |
1349 Its use is due to the bogus appearance that .newsrc was modified on | |
1350 disc.") | |
1351 | |
1352 ;; Hooks. | |
1353 | |
1354 (defvar gnus-group-mode-hook nil | |
1355 "*A hook for Gnus group mode.") | |
1356 | |
1357 (defvar gnus-summary-mode-hook nil | |
1358 "*A hook for Gnus summary mode. | |
1359 This hook is run before any variables are set in the summary buffer.") | |
1360 | |
1361 (defvar gnus-article-mode-hook nil | |
1362 "*A hook for Gnus article mode.") | |
1363 | |
1364 (defvar gnus-summary-prepare-exit-hook nil | |
1365 "*A hook called when preparing to exit from the summary buffer. | |
1366 It calls `gnus-summary-expire-articles' by default.") | |
1367 (add-hook 'gnus-summary-prepare-exit-hook 'gnus-summary-expire-articles) | |
1368 | |
1369 (defvar gnus-summary-exit-hook nil | |
1370 "*A hook called on exit from the summary buffer.") | |
1371 | |
1372 (defvar gnus-group-catchup-group-hook nil | |
1373 "*A hook run when catching up a group from the group buffer.") | |
1374 | |
1375 (defvar gnus-group-update-group-hook nil | |
1376 "*A hook called when updating group lines.") | |
1377 | |
1378 (defvar gnus-open-server-hook nil | |
1379 "*A hook called just before opening connection to the news server.") | |
1380 | |
1381 (defvar gnus-load-hook nil | |
1382 "*A hook run while Gnus is loaded.") | |
1383 | |
1384 (defvar gnus-startup-hook nil | |
1385 "*A hook called at startup. | |
1386 This hook is called after Gnus is connected to the NNTP server.") | |
1387 | |
1388 (defvar gnus-get-new-news-hook nil | |
1389 "*A hook run just before Gnus checks for new news.") | |
1390 | |
1391 (defvar gnus-after-getting-new-news-hook nil | |
1392 "*A hook run after Gnus checks for new news.") | |
1393 | |
1394 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat | |
1395 "*A function that is called to generate the group buffer. | |
1396 The function is called with three arguments: The first is a number; | |
1397 all group with a level less or equal to that number should be listed, | |
1398 if the second is non-nil, empty groups should also be displayed. If | |
1399 the third is non-nil, it is a number. No groups with a level lower | |
1400 than this number should be displayed. | |
1401 | |
1402 The only current function implemented is `gnus-group-prepare-flat'.") | |
1403 | |
1404 (defvar gnus-group-prepare-hook nil | |
1405 "*A hook called after the group buffer has been generated. | |
1406 If you want to modify the group buffer, you can use this hook.") | |
1407 | |
1408 (defvar gnus-summary-prepare-hook nil | |
1409 "*A hook called after the summary buffer has been generated. | |
1410 If you want to modify the summary buffer, you can use this hook.") | |
1411 | |
1412 (defvar gnus-summary-generate-hook nil | |
1413 "*A hook run just before generating the summary buffer. | |
1414 This hook is commonly used to customize threading variables and the | |
1415 like.") | |
1416 | |
1417 (defvar gnus-article-prepare-hook nil | |
1418 "*A hook called after an article has been prepared in the article buffer. | |
1419 If you want to run a special decoding program like nkf, use this hook.") | |
1420 | |
1421 ;(defvar gnus-article-display-hook nil | |
1422 ; "*A hook called after the article is displayed in the article buffer. | |
1423 ;The hook is designed to change the contents of the article | |
1424 ;buffer. Typical functions that this hook may contain are | |
1425 ;`gnus-article-hide-headers' (hide selected headers), | |
1426 ;`gnus-article-maybe-highlight' (perform fancy article highlighting), | |
1427 ;`gnus-article-hide-signature' (hide signature) and | |
1428 ;`gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).") | |
1429 ;(add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted) | |
1430 ;(add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike) | |
1431 ;(add-hook 'gnus-article-display-hook 'gnus-article-maybe-highlight) | |
1432 | |
1433 (defvar gnus-article-x-face-too-ugly nil | |
1434 "Regexp matching posters whose face shouldn't be shown automatically.") | |
1435 | |
1436 (defvar gnus-select-group-hook nil | |
1437 "*A hook called when a newsgroup is selected. | |
1438 | |
1439 If you'd like to simplify subjects like the | |
1440 `gnus-summary-next-same-subject' command does, you can use the | |
1441 following hook: | |
1442 | |
1443 (setq gnus-select-group-hook | |
1444 (list | |
1445 (lambda () | |
1446 (mapcar (lambda (header) | |
1447 (mail-header-set-subject | |
1448 header | |
1449 (gnus-simplify-subject | |
1450 (mail-header-subject header) 're-only))) | |
1451 gnus-newsgroup-headers))))") | |
1452 | |
1453 (defvar gnus-select-article-hook nil | |
1454 "*A hook called when an article is selected.") | |
1455 | |
1456 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file) | |
1457 "*A hook called to apply kill files to a group. | |
1458 This hook is intended to apply a kill file to the selected newsgroup. | |
1459 The function `gnus-apply-kill-file' is called by default. | |
1460 | |
1461 Since a general kill file is too heavy to use only for a few | |
1462 newsgroups, I recommend you to use a lighter hook function. For | |
1463 example, if you'd like to apply a kill file to articles which contains | |
1464 a string `rmgroup' in subject in newsgroup `control', you can use the | |
1465 following hook: | |
1466 | |
1467 (setq gnus-apply-kill-hook | |
1468 (list | |
1469 (lambda () | |
1470 (cond ((string-match \"control\" gnus-newsgroup-name) | |
1471 (gnus-kill \"Subject\" \"rmgroup\") | |
1472 (gnus-expunge \"X\"))))))") | |
1473 | |
1474 (defvar gnus-visual-mark-article-hook | |
1475 (list 'gnus-highlight-selected-summary) | |
1476 "*Hook run after selecting an article in the summary buffer. | |
1477 It is meant to be used for highlighting the article in some way. It | |
1478 is not run if `gnus-visual' is nil.") | |
1479 | |
1480 (defvar gnus-parse-headers-hook nil | |
1481 "*A hook called before parsing the headers.") | |
1482 (add-hook 'gnus-parse-headers-hook 'gnus-decode-rfc1522) | |
1483 | |
1484 (defvar gnus-exit-group-hook nil | |
1485 "*A hook called when exiting (not quitting) summary mode.") | |
1486 | |
1487 (defvar gnus-suspend-gnus-hook nil | |
1488 "*A hook called when suspending (not exiting) Gnus.") | |
1489 | |
1490 (defvar gnus-exit-gnus-hook nil | |
1491 "*A hook called when exiting Gnus.") | |
1492 | |
1493 (defvar gnus-after-exiting-gnus-hook nil | |
1494 "*A hook called after exiting Gnus.") | |
1495 | |
1496 (defvar gnus-save-newsrc-hook nil | |
1497 "*A hook called before saving any of the newsrc files.") | |
1498 | |
1499 (defvar gnus-save-quick-newsrc-hook nil | |
1500 "*A hook called just before saving the quick newsrc file. | |
1501 Can be used to turn version control on or off.") | |
1502 | |
1503 (defvar gnus-save-standard-newsrc-hook nil | |
1504 "*A hook called just before saving the standard newsrc file. | |
1505 Can be used to turn version control on or off.") | |
1506 | |
1507 (defvar gnus-summary-update-hook | |
1508 (list 'gnus-summary-highlight-line) | |
1509 "*A hook called when a summary line is changed. | |
1510 The hook will not be called if `gnus-visual' is nil. | |
1511 | |
1512 The default function `gnus-summary-highlight-line' will | |
1513 highlight the line according to the `gnus-summary-highlight' | |
1514 variable.") | |
1515 | |
1516 (defvar gnus-group-update-hook '(gnus-group-highlight-line) | |
1517 "*A hook called when a group line is changed. | |
1518 The hook will not be called if `gnus-visual' is nil. | |
1519 | |
1520 The default function `gnus-group-highlight-line' will | |
1521 highlight the line according to the `gnus-group-highlight' | |
1522 variable.") | |
1523 | |
1524 (defvar gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read) | |
1525 "*A hook called when an article is selected for the first time. | |
1526 The hook is intended to mark an article as read (or unread) | |
1527 automatically when it is selected.") | |
1528 | |
1529 (defvar gnus-group-change-level-function nil | |
1530 "Function run when a group level is changed. | |
1531 It is called with three parameters -- GROUP, LEVEL and OLDLEVEL.") | |
1532 | |
1533 ;; Remove any hilit infestation. | |
1534 (add-hook 'gnus-startup-hook | |
1535 (lambda () | |
1536 (remove-hook 'gnus-summary-prepare-hook | |
1537 'hilit-rehighlight-buffer-quietly) | |
1538 (remove-hook 'gnus-summary-prepare-hook 'hilit-install-line-hooks) | |
1539 (setq gnus-mark-article-hook | |
1540 '(gnus-summary-mark-read-and-unread-as-read)) | |
1541 (remove-hook 'gnus-article-prepare-hook | |
1542 'hilit-rehighlight-buffer-quietly))) | |
1543 | |
1544 | |
1545 ;; Internal variables | |
1546 | |
1547 (defvar gnus-tree-buffer "*Tree*" | |
1548 "Buffer where Gnus thread trees are displayed.") | |
1549 | |
1550 ;; Dummy variable. | |
1551 (defvar gnus-use-generic-from nil) | |
1552 | |
1553 (defvar gnus-thread-indent-array nil) | |
1554 (defvar gnus-thread-indent-array-level gnus-thread-indent-level) | |
1555 | |
1556 (defvar gnus-newsrc-file-version nil) | |
1557 | |
1558 (defvar gnus-method-history nil) | |
1559 ;; Variable holding the user answers to all method prompts. | |
1560 | |
1561 (defvar gnus-group-history nil) | |
1562 ;; Variable holding the user answers to all group prompts. | |
1563 | |
1564 (defvar gnus-server-alist nil | |
1565 "List of available servers.") | |
1566 | |
1567 (defvar gnus-group-indentation-function nil) | |
1568 | |
1569 (defvar gnus-topic-indentation "") ;; Obsolete variable. | |
1570 | |
1571 (defvar gnus-goto-missing-group-function nil) | |
1572 | |
1573 (defvar gnus-override-subscribe-method nil) | |
1574 | |
1575 (defvar gnus-group-goto-next-group-function nil | |
1576 "Function to override finding the next group after listing groups.") | |
1577 | |
1578 (defconst gnus-article-mark-lists | |
1579 '((marked . tick) (replied . reply) | |
1580 (expirable . expire) (killed . killed) | |
1581 (bookmarks . bookmark) (dormant . dormant) | |
1582 (scored . score) (saved . save) | |
1583 (cached . cache) | |
1584 )) | |
1585 | |
1586 ;; Avoid highlighting in kill files. | |
1587 (defvar gnus-summary-inhibit-highlight nil) | |
1588 (defvar gnus-newsgroup-selected-overlay nil) | |
1589 | |
1590 (defvar gnus-inhibit-hiding nil) | |
1591 (defvar gnus-group-indentation "") | |
1592 (defvar gnus-inhibit-limiting nil) | |
1593 (defvar gnus-created-frames nil) | |
1594 | |
1595 (defvar gnus-article-mode-map nil) | |
1596 (defvar gnus-dribble-buffer nil) | |
1597 (defvar gnus-headers-retrieved-by nil) | |
1598 (defvar gnus-article-reply nil) | |
1599 (defvar gnus-override-method nil) | |
1600 (defvar gnus-article-check-size nil) | |
1601 | |
1602 (defvar gnus-current-score-file nil) | |
1603 (defvar gnus-newsgroup-adaptive-score-file nil) | |
1604 (defvar gnus-scores-exclude-files nil) | |
1605 | |
1606 (defvar gnus-opened-servers nil) | |
1607 | |
1608 (defvar gnus-current-move-group nil) | |
1609 (defvar gnus-current-copy-group nil) | |
1610 (defvar gnus-current-crosspost-group nil) | |
1611 | |
1612 (defvar gnus-newsgroup-dependencies nil) | |
1613 (defvar gnus-newsgroup-async nil) | |
1614 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*") | |
1615 | |
1616 (defvar gnus-newsgroup-adaptive nil) | |
1617 | |
1618 (defvar gnus-summary-display-table nil) | |
1619 (defvar gnus-summary-display-article-function nil) | |
1620 | |
1621 (defvar gnus-summary-highlight-line-function nil | |
1622 "Function called after highlighting a summary line.") | |
1623 | |
1624 (defvar gnus-group-line-format-alist | |
1625 `((?M gnus-tmp-marked-mark ?c) | |
1626 (?S gnus-tmp-subscribed ?c) | |
1627 (?L gnus-tmp-level ?d) | |
1628 (?N (cond ((eq number t) "*" ) | |
1629 ((numberp number) | |
1630 (int-to-string | |
1631 (+ number | |
1632 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) | |
1633 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))))) | |
1634 (t number)) ?s) | |
1635 (?R gnus-tmp-number-of-read ?s) | |
1636 (?t gnus-tmp-number-total ?d) | |
1637 (?y gnus-tmp-number-of-unread ?s) | |
1638 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d) | |
1639 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d) | |
1640 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) | |
1641 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d) | |
1642 (?g gnus-tmp-group ?s) | |
1643 (?G gnus-tmp-qualified-group ?s) | |
1644 (?c (gnus-short-group-name gnus-tmp-group) ?s) | |
1645 (?D gnus-tmp-newsgroup-description ?s) | |
1646 (?o gnus-tmp-moderated ?c) | |
1647 (?O gnus-tmp-moderated-string ?s) | |
1648 (?p gnus-tmp-process-marked ?c) | |
1649 (?s gnus-tmp-news-server ?s) | |
1650 (?n gnus-tmp-news-method ?s) | |
1651 (?P gnus-group-indentation ?s) | |
1652 (?l gnus-tmp-grouplens ?s) | |
1653 (?z gnus-tmp-news-method-string ?s) | |
1654 (?u gnus-tmp-user-defined ?s))) | |
1655 | |
1656 (defvar gnus-summary-line-format-alist | |
1657 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d) | |
1658 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s) | |
1659 (?s gnus-tmp-subject-or-nil ?s) | |
1660 (?n gnus-tmp-name ?s) | |
1661 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from))) | |
1662 ?s) | |
1663 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from)) | |
1664 gnus-tmp-from) ?s) | |
1665 (?F gnus-tmp-from ?s) | |
1666 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s) | |
1667 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s) | |
1668 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s) | |
1669 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s) | |
1670 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s) | |
1671 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d) | |
1672 (?L gnus-tmp-lines ?d) | |
1673 (?I gnus-tmp-indentation ?s) | |
1674 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s) | |
1675 (?R gnus-tmp-replied ?c) | |
1676 (?\[ gnus-tmp-opening-bracket ?c) | |
1677 (?\] gnus-tmp-closing-bracket ?c) | |
1678 (?\> (make-string gnus-tmp-level ? ) ?s) | |
1679 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s) | |
1680 (?i gnus-tmp-score ?d) | |
1681 (?z gnus-tmp-score-char ?c) | |
1682 (?l (bbb-grouplens-score gnus-tmp-header) ?s) | |
1683 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d) | |
1684 (?U gnus-tmp-unread ?c) | |
1685 (?t (gnus-summary-number-of-articles-in-thread | |
1686 (and (boundp 'thread) (car thread)) gnus-tmp-level) | |
1687 ?d) | |
1688 (?e (gnus-summary-number-of-articles-in-thread | |
1689 (and (boundp 'thread) (car thread)) gnus-tmp-level t) | |
1690 ?c) | |
1691 (?u gnus-tmp-user-defined ?s)) | |
1692 "An alist of format specifications that can appear in summary lines, | |
1693 and what variables they correspond with, along with the type of the | |
1694 variable (string, integer, character, etc).") | |
1695 | |
1696 (defvar gnus-summary-dummy-line-format-alist | |
1697 `((?S gnus-tmp-subject ?s) | |
1698 (?N gnus-tmp-number ?d) | |
1699 (?u gnus-tmp-user-defined ?s))) | |
1700 | |
1701 (defvar gnus-summary-mode-line-format-alist | |
1702 `((?G gnus-tmp-group-name ?s) | |
1703 (?g (gnus-short-group-name gnus-tmp-group-name) ?s) | |
1704 (?p (gnus-group-real-name gnus-tmp-group-name) ?s) | |
1705 (?A gnus-tmp-article-number ?d) | |
1706 (?Z gnus-tmp-unread-and-unselected ?s) | |
1707 (?V gnus-version ?s) | |
1708 (?U gnus-tmp-unread-and-unticked ?d) | |
1709 (?S gnus-tmp-subject ?s) | |
1710 (?e gnus-tmp-unselected ?d) | |
1711 (?u gnus-tmp-user-defined ?s) | |
1712 (?d (length gnus-newsgroup-dormant) ?d) | |
1713 (?t (length gnus-newsgroup-marked) ?d) | |
1714 (?r (length gnus-newsgroup-reads) ?d) | |
1715 (?E gnus-newsgroup-expunged-tally ?d) | |
1716 (?s (gnus-current-score-file-nondirectory) ?s))) | |
1717 | |
1718 (defvar gnus-article-mode-line-format-alist | |
1719 gnus-summary-mode-line-format-alist) | |
1720 | |
1721 (defvar gnus-group-mode-line-format-alist | |
1722 `((?S gnus-tmp-news-server ?s) | |
1723 (?M gnus-tmp-news-method ?s) | |
1724 (?u gnus-tmp-user-defined ?s) | |
1725 (?: gnus-tmp-colon ?s))) | |
1726 | |
1727 (defvar gnus-have-read-active-file nil) | |
1728 | |
1729 (defconst gnus-maintainer | |
1730 "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)" | |
1731 "The mail address of the Gnus maintainers.") | |
1732 | |
1733 (defconst gnus-version-number "5.2.25" | |
1734 "Version number for this version of Gnus.") | |
1735 | |
1736 (defconst gnus-version (format "Gnus v%s" gnus-version-number) | |
1737 "Version string for this version of Gnus.") | |
1738 | |
1739 (defvar gnus-info-nodes | |
1740 '((gnus-group-mode "(gnus)The Group Buffer") | |
1741 (gnus-summary-mode "(gnus)The Summary Buffer") | |
1742 (gnus-article-mode "(gnus)The Article Buffer") | |
1743 (gnus-server-mode "(gnus)The Server Buffer") | |
1744 (gnus-browse-mode "(gnus)Browse Foreign Server") | |
1745 (gnus-tree-mode "(gnus)Tree Display") | |
1746 ) | |
1747 "Alist of major modes and related Info nodes.") | |
1748 | |
1749 (defvar gnus-group-buffer "*Group*") | |
1750 (defvar gnus-summary-buffer "*Summary*") | |
1751 (defvar gnus-article-buffer "*Article*") | |
1752 (defvar gnus-server-buffer "*Server*") | |
1753 | |
1754 (defvar gnus-work-buffer " *gnus work*") | |
1755 | |
1756 (defvar gnus-original-article-buffer " *Original Article*") | |
1757 (defvar gnus-original-article nil) | |
1758 | |
1759 (defvar gnus-buffer-list nil | |
1760 "Gnus buffers that should be killed on exit.") | |
1761 | |
1762 (defvar gnus-slave nil | |
1763 "Whether this Gnus is a slave or not.") | |
1764 | |
1765 (defvar gnus-variable-list | |
1766 '(gnus-newsrc-options gnus-newsrc-options-n | |
1767 gnus-newsrc-last-checked-date | |
1768 gnus-newsrc-alist gnus-server-alist | |
1769 gnus-killed-list gnus-zombie-list | |
1770 gnus-topic-topology gnus-topic-alist | |
1771 gnus-format-specs) | |
1772 "Gnus variables saved in the quick startup file.") | |
1773 | |
1774 (defvar gnus-newsrc-options nil | |
1775 "Options line in the .newsrc file.") | |
1776 | |
1777 (defvar gnus-newsrc-options-n nil | |
1778 "List of regexps representing groups to be subscribed/ignored unconditionally.") | |
1779 | |
1780 (defvar gnus-newsrc-last-checked-date nil | |
1781 "Date Gnus last asked server for new newsgroups.") | |
1782 | |
1783 (defvar gnus-topic-topology nil | |
1784 "The complete topic hierarchy.") | |
1785 | |
1786 (defvar gnus-topic-alist nil | |
1787 "The complete topic-group alist.") | |
1788 | |
1789 (defvar gnus-newsrc-alist nil | |
1790 "Assoc list of read articles. | |
1791 gnus-newsrc-hashtb should be kept so that both hold the same information.") | |
1792 | |
1793 (defvar gnus-newsrc-hashtb nil | |
1794 "Hashtable of gnus-newsrc-alist.") | |
1795 | |
1796 (defvar gnus-killed-list nil | |
1797 "List of killed newsgroups.") | |
1798 | |
1799 (defvar gnus-killed-hashtb nil | |
1800 "Hash table equivalent of gnus-killed-list.") | |
1801 | |
1802 (defvar gnus-zombie-list nil | |
1803 "List of almost dead newsgroups.") | |
1804 | |
1805 (defvar gnus-description-hashtb nil | |
1806 "Descriptions of newsgroups.") | |
1807 | |
1808 (defvar gnus-list-of-killed-groups nil | |
1809 "List of newsgroups that have recently been killed by the user.") | |
1810 | |
1811 (defvar gnus-active-hashtb nil | |
1812 "Hashtable of active articles.") | |
1813 | |
1814 (defvar gnus-moderated-list nil | |
1815 "List of moderated newsgroups.") | |
1816 | |
1817 (defvar gnus-group-marked nil) | |
1818 | |
1819 (defvar gnus-current-startup-file nil | |
1820 "Startup file for the current host.") | |
1821 | |
1822 (defvar gnus-last-search-regexp nil | |
1823 "Default regexp for article search command.") | |
1824 | |
1825 (defvar gnus-last-shell-command nil | |
1826 "Default shell command on article.") | |
1827 | |
1828 (defvar gnus-current-select-method nil | |
1829 "The current method for selecting a newsgroup.") | |
1830 | |
1831 (defvar gnus-group-list-mode nil) | |
1832 | |
1833 (defvar gnus-article-internal-prepare-hook nil) | |
1834 | |
1835 (defvar gnus-newsgroup-name nil) | |
1836 (defvar gnus-newsgroup-begin nil) | |
1837 (defvar gnus-newsgroup-end nil) | |
1838 (defvar gnus-newsgroup-last-rmail nil) | |
1839 (defvar gnus-newsgroup-last-mail nil) | |
1840 (defvar gnus-newsgroup-last-folder nil) | |
1841 (defvar gnus-newsgroup-last-file nil) | |
1842 (defvar gnus-newsgroup-auto-expire nil) | |
1843 (defvar gnus-newsgroup-active nil) | |
1844 | |
1845 (defvar gnus-newsgroup-data nil) | |
1846 (defvar gnus-newsgroup-data-reverse nil) | |
1847 (defvar gnus-newsgroup-limit nil) | |
1848 (defvar gnus-newsgroup-limits nil) | |
1849 | |
1850 (defvar gnus-newsgroup-unreads nil | |
1851 "List of unread articles in the current newsgroup.") | |
1852 | |
1853 (defvar gnus-newsgroup-unselected nil | |
1854 "List of unselected unread articles in the current newsgroup.") | |
1855 | |
1856 (defvar gnus-newsgroup-reads nil | |
1857 "Alist of read articles and article marks in the current newsgroup.") | |
1858 | |
1859 (defvar gnus-newsgroup-expunged-tally nil) | |
1860 | |
1861 (defvar gnus-newsgroup-marked nil | |
1862 "List of ticked articles in the current newsgroup (a subset of unread art).") | |
1863 | |
1864 (defvar gnus-newsgroup-killed nil | |
1865 "List of ranges of articles that have been through the scoring process.") | |
1866 | |
1867 (defvar gnus-newsgroup-cached nil | |
1868 "List of articles that come from the article cache.") | |
1869 | |
1870 (defvar gnus-newsgroup-saved nil | |
1871 "List of articles that have been saved.") | |
1872 | |
1873 (defvar gnus-newsgroup-kill-headers nil) | |
1874 | |
1875 (defvar gnus-newsgroup-replied nil | |
1876 "List of articles that have been replied to in the current newsgroup.") | |
1877 | |
1878 (defvar gnus-newsgroup-expirable nil | |
1879 "List of articles in the current newsgroup that can be expired.") | |
1880 | |
1881 (defvar gnus-newsgroup-processable nil | |
1882 "List of articles in the current newsgroup that can be processed.") | |
1883 | |
1884 (defvar gnus-newsgroup-bookmarks nil | |
1885 "List of articles in the current newsgroup that have bookmarks.") | |
1886 | |
1887 (defvar gnus-newsgroup-dormant nil | |
1888 "List of dormant articles in the current newsgroup.") | |
1889 | |
1890 (defvar gnus-newsgroup-scored nil | |
1891 "List of scored articles in the current newsgroup.") | |
1892 | |
1893 (defvar gnus-newsgroup-headers nil | |
1894 "List of article headers in the current newsgroup.") | |
1895 | |
1896 (defvar gnus-newsgroup-threads nil) | |
1897 | |
1898 (defvar gnus-newsgroup-prepared nil | |
1899 "Whether the current group has been prepared properly.") | |
1900 | |
1901 (defvar gnus-newsgroup-ancient nil | |
1902 "List of `gnus-fetch-old-headers' articles in the current newsgroup.") | |
1903 | |
1904 (defvar gnus-newsgroup-sparse nil) | |
1905 | |
1906 (defvar gnus-current-article nil) | |
1907 (defvar gnus-article-current nil) | |
1908 (defvar gnus-current-headers nil) | |
1909 (defvar gnus-have-all-headers nil) | |
1910 (defvar gnus-last-article nil) | |
1911 (defvar gnus-newsgroup-history nil) | |
1912 (defvar gnus-current-kill-article nil) | |
1913 | |
1914 ;; Save window configuration. | |
1915 (defvar gnus-prev-winconf nil) | |
1916 | |
1917 (defvar gnus-summary-mark-positions nil) | |
1918 (defvar gnus-group-mark-positions nil) | |
1919 | |
1920 (defvar gnus-reffed-article-number nil) | |
1921 | |
1922 ;;; Let the byte-compiler know that we know about this variable. | |
1923 (defvar rmail-default-rmail-file) | |
1924 | |
1925 (defvar gnus-cache-removable-articles nil) | |
1926 | |
1927 (defvar gnus-dead-summary nil) | |
1928 | |
1929 (defconst gnus-summary-local-variables | |
1930 '(gnus-newsgroup-name | |
1931 gnus-newsgroup-begin gnus-newsgroup-end | |
1932 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail | |
1933 gnus-newsgroup-last-folder gnus-newsgroup-last-file | |
1934 gnus-newsgroup-auto-expire gnus-newsgroup-unreads | |
1935 gnus-newsgroup-unselected gnus-newsgroup-marked | |
1936 gnus-newsgroup-reads gnus-newsgroup-saved | |
1937 gnus-newsgroup-replied gnus-newsgroup-expirable | |
1938 gnus-newsgroup-processable gnus-newsgroup-killed | |
1939 gnus-newsgroup-bookmarks gnus-newsgroup-dormant | |
1940 gnus-newsgroup-headers gnus-newsgroup-threads | |
1941 gnus-newsgroup-prepared gnus-summary-highlight-line-function | |
1942 gnus-current-article gnus-current-headers gnus-have-all-headers | |
1943 gnus-last-article gnus-article-internal-prepare-hook | |
1944 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay | |
1945 gnus-newsgroup-scored gnus-newsgroup-kill-headers | |
1946 gnus-newsgroup-async gnus-thread-expunge-below | |
1947 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below | |
1948 (gnus-summary-mark-below . global) | |
1949 gnus-newsgroup-active gnus-scores-exclude-files | |
1950 gnus-newsgroup-history gnus-newsgroup-ancient | |
1951 gnus-newsgroup-sparse | |
1952 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring) | |
1953 gnus-newsgroup-adaptive-score-file | |
1954 (gnus-newsgroup-expunged-tally . 0) | |
1955 gnus-cache-removable-articles gnus-newsgroup-cached | |
1956 gnus-newsgroup-data gnus-newsgroup-data-reverse | |
1957 gnus-newsgroup-limit gnus-newsgroup-limits) | |
1958 "Variables that are buffer-local to the summary buffers.") | |
1959 | |
1960 (defconst gnus-bug-message | |
1961 "Sending a bug report to the Gnus Towers. | |
1962 ======================================== | |
1963 | |
1964 The buffer below is a mail buffer. When you press `C-c C-c', it will | |
1965 be sent to the Gnus Bug Exterminators. | |
1966 | |
1967 At the bottom of the buffer you'll see lots of variable settings. | |
1968 Please do not delete those. They will tell the Bug People what your | |
1969 environment is, so that it will be easier to locate the bugs. | |
1970 | |
1971 If you have found a bug that makes Emacs go \"beep\", set | |
1972 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET') | |
1973 and include the backtrace in your bug report. | |
1974 | |
1975 Please describe the bug in annoying, painstaking detail. | |
1976 | |
1977 Thank you for your help in stamping out bugs. | |
1978 ") | |
1979 | |
1980 ;;; End of variables. | |
1981 | |
1982 ;; Define some autoload functions Gnus might use. | |
1983 (eval-and-compile | |
1984 | |
1985 ;; This little mapcar goes through the list below and marks the | |
1986 ;; symbols in question as autoloaded functions. | |
1987 (mapcar | |
1988 (lambda (package) | |
1989 (let ((interactive (nth 1 (memq ':interactive package)))) | |
1990 (mapcar | |
1991 (lambda (function) | |
1992 (let (keymap) | |
1993 (when (consp function) | |
1994 (setq keymap (car (memq 'keymap function))) | |
1995 (setq function (car function))) | |
1996 (autoload function (car package) nil interactive keymap))) | |
1997 (if (eq (nth 1 package) ':interactive) | |
1998 (cdddr package) | |
1999 (cdr package))))) | |
2000 '(("metamail" metamail-buffer) | |
2001 ("info" Info-goto-node) | |
2002 ("hexl" hexl-hex-string-to-integer) | |
2003 ("pp" pp pp-to-string pp-eval-expression) | |
2004 ("mail-extr" mail-extract-address-components) | |
2005 ("nnmail" nnmail-split-fancy nnmail-article-group) | |
2006 ("nnvirtual" nnvirtual-catchup-group) | |
2007 ("timezone" timezone-make-date-arpa-standard timezone-fix-time | |
2008 timezone-make-sortable-date timezone-make-time-string) | |
2009 ("rmailout" rmail-output) | |
2010 ("rmail" rmail-insert-rmail-file-header rmail-count-new-messages | |
2011 rmail-show-message) | |
2012 ("gnus-soup" :interactive t | |
2013 gnus-group-brew-soup gnus-brew-soup gnus-soup-add-article | |
2014 gnus-soup-send-replies gnus-soup-save-areas gnus-soup-pack-packet) | |
2015 ("nnsoup" nnsoup-pack-replies) | |
2016 ("gnus-scomo" :interactive t gnus-score-mode) | |
2017 ("gnus-mh" gnus-mh-mail-setup gnus-summary-save-article-folder | |
2018 gnus-Folder-save-name gnus-folder-save-name) | |
2019 ("gnus-mh" :interactive t gnus-summary-save-in-folder) | |
2020 ("gnus-vis" gnus-group-make-menu-bar gnus-summary-make-menu-bar | |
2021 gnus-server-make-menu-bar gnus-article-make-menu-bar | |
2022 gnus-browse-make-menu-bar gnus-highlight-selected-summary | |
2023 gnus-summary-highlight-line gnus-carpal-setup-buffer | |
2024 gnus-group-highlight-line | |
2025 gnus-article-add-button gnus-insert-next-page-button | |
2026 gnus-insert-prev-page-button gnus-visual-turn-off-edit-menu) | |
2027 ("gnus-vis" :interactive t | |
2028 gnus-article-push-button gnus-article-press-button | |
2029 gnus-article-highlight gnus-article-highlight-some | |
2030 gnus-article-highlight-headers gnus-article-highlight-signature | |
2031 gnus-article-add-buttons gnus-article-add-buttons-to-head | |
2032 gnus-article-next-button gnus-article-prev-button) | |
2033 ("gnus-demon" gnus-demon-add-nocem gnus-demon-add-scanmail | |
2034 gnus-demon-add-disconnection gnus-demon-add-handler | |
2035 gnus-demon-remove-handler) | |
2036 ("gnus-demon" :interactive t | |
2037 gnus-demon-init gnus-demon-cancel) | |
2038 ("gnus-salt" gnus-highlight-selected-tree gnus-possibly-generate-tree | |
2039 gnus-tree-open gnus-tree-close) | |
2040 ("gnus-nocem" gnus-nocem-scan-groups gnus-nocem-close | |
2041 gnus-nocem-unwanted-article-p) | |
2042 ("gnus-srvr" gnus-enter-server-buffer gnus-server-set-info) | |
2043 ("gnus-srvr" gnus-browse-foreign-server) | |
2044 ("gnus-cite" :interactive t | |
2045 gnus-article-highlight-citation gnus-article-hide-citation-maybe | |
2046 gnus-article-hide-citation gnus-article-fill-cited-article | |
2047 gnus-article-hide-citation-in-followups) | |
2048 ("gnus-kill" gnus-kill gnus-apply-kill-file-internal | |
2049 gnus-kill-file-edit-file gnus-kill-file-raise-followups-to-author | |
2050 gnus-execute gnus-expunge) | |
2051 ("gnus-cache" gnus-cache-possibly-enter-article gnus-cache-save-buffers | |
2052 gnus-cache-possibly-remove-articles gnus-cache-request-article | |
2053 gnus-cache-retrieve-headers gnus-cache-possibly-alter-active | |
2054 gnus-cache-enter-remove-article gnus-cached-article-p | |
2055 gnus-cache-open gnus-cache-close gnus-cache-update-article) | |
2056 ("gnus-cache" :interactive t gnus-jog-cache gnus-cache-enter-article | |
2057 gnus-cache-remove-article) | |
2058 ("gnus-score" :interactive t | |
2059 gnus-summary-increase-score gnus-summary-lower-score | |
2060 gnus-score-flush-cache gnus-score-close | |
2061 gnus-score-raise-same-subject-and-select | |
2062 gnus-score-raise-same-subject gnus-score-default | |
2063 gnus-score-raise-thread gnus-score-lower-same-subject-and-select | |
2064 gnus-score-lower-same-subject gnus-score-lower-thread | |
2065 gnus-possibly-score-headers gnus-summary-raise-score | |
2066 gnus-summary-set-score gnus-summary-current-score) | |
2067 ("gnus-score" | |
2068 (gnus-summary-score-map keymap) gnus-score-save gnus-score-headers | |
2069 gnus-current-score-file-nondirectory gnus-score-adaptive | |
2070 gnus-score-find-trace gnus-score-file-name) | |
2071 ("gnus-edit" :interactive t gnus-score-customize) | |
2072 ("gnus-topic" :interactive t gnus-topic-mode) | |
2073 ("gnus-topic" gnus-topic-remove-group) | |
2074 ("gnus-salt" :interactive t gnus-pick-mode gnus-binary-mode) | |
2075 ("gnus-uu" (gnus-uu-extract-map keymap) (gnus-uu-mark-map keymap)) | |
2076 ("gnus-uu" :interactive t | |
2077 gnus-uu-digest-mail-forward gnus-uu-digest-post-forward | |
2078 gnus-uu-mark-series gnus-uu-mark-region gnus-uu-mark-buffer | |
2079 gnus-uu-mark-by-regexp gnus-uu-mark-all | |
2080 gnus-uu-mark-sparse gnus-uu-mark-thread gnus-uu-decode-uu | |
2081 gnus-uu-decode-uu-and-save gnus-uu-decode-unshar | |
2082 gnus-uu-decode-unshar-and-save gnus-uu-decode-save | |
2083 gnus-uu-decode-binhex gnus-uu-decode-uu-view | |
2084 gnus-uu-decode-uu-and-save-view gnus-uu-decode-unshar-view | |
2085 gnus-uu-decode-unshar-and-save-view gnus-uu-decode-save-view | |
2086 gnus-uu-decode-binhex-view) | |
2087 ("gnus-msg" (gnus-summary-send-map keymap) | |
2088 gnus-mail-yank-original gnus-mail-send-and-exit | |
2089 gnus-article-mail gnus-new-mail gnus-mail-reply) | |
2090 ("gnus-msg" :interactive t | |
2091 gnus-group-post-news gnus-group-mail gnus-summary-post-news | |
2092 gnus-summary-followup gnus-summary-followup-with-original | |
2093 gnus-summary-cancel-article gnus-summary-supersede-article | |
2094 gnus-post-news gnus-inews-news | |
2095 gnus-summary-reply gnus-summary-reply-with-original | |
2096 gnus-summary-mail-forward gnus-summary-mail-other-window | |
2097 gnus-bug) | |
2098 ("gnus-picon" :interactive t gnus-article-display-picons | |
2099 gnus-group-display-picons gnus-picons-article-display-x-face) | |
2100 ("gnus-gl" bbb-login bbb-logout bbb-grouplens-group-p | |
2101 gnus-grouplens-mode) | |
2102 ("smiley" :interactive t gnus-smiley-display) | |
2103 ("gnus-vm" gnus-vm-mail-setup) | |
2104 ("gnus-vm" :interactive t gnus-summary-save-in-vm | |
2105 gnus-summary-save-article-vm)))) | |
2106 | |
2107 | |
2108 | |
2109 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>. | |
2110 ;; If you want the cursor to go somewhere else, set these two | |
2111 ;; functions in some startup hook to whatever you want. | |
2112 (defalias 'gnus-summary-position-point 'gnus-goto-colon) | |
2113 (defalias 'gnus-group-position-point 'gnus-goto-colon) | |
2114 | |
2115 ;;; Various macros and substs. | |
2116 | |
2117 (defun gnus-header-from (header) | |
2118 (mail-header-from header)) | |
2119 | |
2120 (defmacro gnus-eval-in-buffer-window (buffer &rest forms) | |
2121 "Pop to BUFFER, evaluate FORMS, and then return to the original window." | |
2122 (let ((tempvar (make-symbol "GnusStartBufferWindow")) | |
2123 (w (make-symbol "w")) | |
2124 (buf (make-symbol "buf"))) | |
2125 `(let* ((,tempvar (selected-window)) | |
2126 (,buf ,buffer) | |
2127 (,w (get-buffer-window ,buf 'visible))) | |
2128 (unwind-protect | |
2129 (progn | |
2130 (if ,w | |
2131 (select-window ,w) | |
2132 (pop-to-buffer ,buf)) | |
2133 ,@forms) | |
2134 (select-window ,tempvar))))) | |
2135 | |
2136 (put 'gnus-eval-in-buffer-window 'lisp-indent-function 1) | |
2137 (put 'gnus-eval-in-buffer-window 'lisp-indent-hook 1) | |
2138 (put 'gnus-eval-in-buffer-window 'edebug-form-spec '(form body)) | |
2139 | |
2140 (defmacro gnus-gethash (string hashtable) | |
2141 "Get hash value of STRING in HASHTABLE." | |
2142 `(symbol-value (intern-soft ,string ,hashtable))) | |
2143 | |
2144 (defmacro gnus-sethash (string value hashtable) | |
2145 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE." | |
2146 `(set (intern ,string ,hashtable) ,value)) | |
2147 | |
2148 (defmacro gnus-intern-safe (string hashtable) | |
2149 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE." | |
2150 `(let ((symbol (intern ,string ,hashtable))) | |
2151 (or (boundp symbol) | |
2152 (set symbol nil)) | |
2153 symbol)) | |
2154 | |
2155 (defmacro gnus-group-unread (group) | |
2156 "Get the currently computed number of unread articles in GROUP." | |
2157 `(car (gnus-gethash ,group gnus-newsrc-hashtb))) | |
2158 | |
2159 (defmacro gnus-group-entry (group) | |
2160 "Get the newsrc entry for GROUP." | |
2161 `(gnus-gethash ,group gnus-newsrc-hashtb)) | |
2162 | |
2163 (defmacro gnus-active (group) | |
2164 "Get active info on GROUP." | |
2165 `(gnus-gethash ,group gnus-active-hashtb)) | |
2166 | |
2167 (defmacro gnus-set-active (group active) | |
2168 "Set GROUP's active info." | |
2169 `(gnus-sethash ,group ,active gnus-active-hashtb)) | |
2170 | |
2171 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp> | |
2172 ;; function `substring' might cut on a middle of multi-octet | |
2173 ;; character. | |
2174 (defun gnus-truncate-string (str width) | |
2175 (substring str 0 width)) | |
2176 | |
2177 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way | |
2178 ;; to limit the length of a string. This function is necessary since | |
2179 ;; `(substr "abc" 0 30)' pukes with "Args out of range". | |
2180 (defsubst gnus-limit-string (str width) | |
2181 (if (> (length str) width) | |
2182 (substring str 0 width) | |
2183 str)) | |
2184 | |
2185 (defsubst gnus-simplify-subject-re (subject) | |
2186 "Remove \"Re:\" from subject lines." | |
2187 (if (string-match "^[Rr][Ee]: *" subject) | |
2188 (substring subject (match-end 0)) | |
2189 subject)) | |
2190 | |
2191 (defsubst gnus-functionp (form) | |
2192 "Return non-nil if FORM is funcallable." | |
2193 (or (and (symbolp form) (fboundp form)) | |
2194 (and (listp form) (eq (car form) 'lambda)))) | |
2195 | |
2196 (defsubst gnus-goto-char (point) | |
2197 (and point (goto-char point))) | |
2198 | |
2199 (defmacro gnus-buffer-exists-p (buffer) | |
2200 `(let ((buffer ,buffer)) | |
2201 (and buffer | |
2202 (funcall (if (stringp buffer) 'get-buffer 'buffer-name) | |
2203 buffer)))) | |
2204 | |
2205 (defmacro gnus-kill-buffer (buffer) | |
2206 `(let ((buf ,buffer)) | |
2207 (if (gnus-buffer-exists-p buf) | |
2208 (kill-buffer buf)))) | |
2209 | |
2210 (defsubst gnus-point-at-bol () | |
2211 "Return point at the beginning of the line." | |
2212 (let ((p (point))) | |
2213 (beginning-of-line) | |
2214 (prog1 | |
2215 (point) | |
2216 (goto-char p)))) | |
2217 | |
2218 (defsubst gnus-point-at-eol () | |
2219 "Return point at the end of the line." | |
2220 (let ((p (point))) | |
2221 (end-of-line) | |
2222 (prog1 | |
2223 (point) | |
2224 (goto-char p)))) | |
2225 | |
2226 (defun gnus-alive-p () | |
2227 "Say whether Gnus is running or not." | |
2228 (and gnus-group-buffer | |
2229 (get-buffer gnus-group-buffer))) | |
2230 | |
2231 (defun gnus-delete-first (elt list) | |
2232 "Delete by side effect the first occurrence of ELT as a member of LIST." | |
2233 (if (equal (car list) elt) | |
2234 (cdr list) | |
2235 (let ((total list)) | |
2236 (while (and (cdr list) | |
2237 (not (equal (cadr list) elt))) | |
2238 (setq list (cdr list))) | |
2239 (when (cdr list) | |
2240 (setcdr list (cddr list))) | |
2241 total))) | |
2242 | |
2243 ;; Delete the current line (and the next N lines.); | |
2244 (defmacro gnus-delete-line (&optional n) | |
2245 `(delete-region (progn (beginning-of-line) (point)) | |
2246 (progn (forward-line ,(or n 1)) (point)))) | |
2247 | |
2248 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>. | |
2249 (defvar gnus-init-inhibit nil) | |
2250 (defun gnus-read-init-file (&optional inhibit-next) | |
2251 (if gnus-init-inhibit | |
2252 (setq gnus-init-inhibit nil) | |
2253 (setq gnus-init-inhibit inhibit-next) | |
2254 (and gnus-init-file | |
2255 (or (and (file-exists-p gnus-init-file) | |
2256 ;; Don't try to load a directory. | |
2257 (not (file-directory-p gnus-init-file))) | |
2258 (file-exists-p (concat gnus-init-file ".el")) | |
2259 (file-exists-p (concat gnus-init-file ".elc"))) | |
2260 (condition-case var | |
2261 (load gnus-init-file nil t) | |
2262 (error | |
2263 (error "Error in %s: %s" gnus-init-file var)))))) | |
2264 | |
2265 ;; Info access macros. | |
2266 | |
2267 (defmacro gnus-info-group (info) | |
2268 `(nth 0 ,info)) | |
2269 (defmacro gnus-info-rank (info) | |
2270 `(nth 1 ,info)) | |
2271 (defmacro gnus-info-read (info) | |
2272 `(nth 2 ,info)) | |
2273 (defmacro gnus-info-marks (info) | |
2274 `(nth 3 ,info)) | |
2275 (defmacro gnus-info-method (info) | |
2276 `(nth 4 ,info)) | |
2277 (defmacro gnus-info-params (info) | |
2278 `(nth 5 ,info)) | |
2279 | |
2280 (defmacro gnus-info-level (info) | |
2281 `(let ((rank (gnus-info-rank ,info))) | |
2282 (if (consp rank) | |
2283 (car rank) | |
2284 rank))) | |
2285 (defmacro gnus-info-score (info) | |
2286 `(let ((rank (gnus-info-rank ,info))) | |
2287 (or (and (consp rank) (cdr rank)) 0))) | |
2288 | |
2289 (defmacro gnus-info-set-group (info group) | |
2290 `(setcar ,info ,group)) | |
2291 (defmacro gnus-info-set-rank (info rank) | |
2292 `(setcar (nthcdr 1 ,info) ,rank)) | |
2293 (defmacro gnus-info-set-read (info read) | |
2294 `(setcar (nthcdr 2 ,info) ,read)) | |
2295 (defmacro gnus-info-set-marks (info marks) | |
2296 `(setcar (nthcdr 3 ,info) ,marks)) | |
2297 (defmacro gnus-info-set-method (info method) | |
2298 `(setcar (nthcdr 4 ,info) ,method)) | |
2299 (defmacro gnus-info-set-params (info params) | |
2300 `(setcar (nthcdr 5 ,info) ,params)) | |
2301 | |
2302 (defmacro gnus-info-set-level (info level) | |
2303 `(let ((rank (cdr ,info))) | |
2304 (if (consp (car rank)) | |
2305 (setcar (car rank) ,level) | |
2306 (setcar rank ,level)))) | |
2307 (defmacro gnus-info-set-score (info score) | |
2308 `(let ((rank (cdr ,info))) | |
2309 (if (consp (car rank)) | |
2310 (setcdr (car rank) ,score) | |
2311 (setcar rank (cons (car rank) ,score))))) | |
2312 | |
2313 (defmacro gnus-get-info (group) | |
2314 `(nth 2 (gnus-gethash ,group gnus-newsrc-hashtb))) | |
2315 | |
2316 (defun gnus-byte-code (func) | |
2317 "Return a form that can be `eval'ed based on FUNC." | |
2318 (let ((fval (symbol-function func))) | |
2319 (if (byte-code-function-p fval) | |
2320 (let ((flist (append fval nil))) | |
2321 (setcar flist 'byte-code) | |
2322 flist) | |
2323 (cons 'progn (cddr fval))))) | |
2324 | |
2325 ;; Find out whether the gnus-visual TYPE is wanted. | |
2326 (defun gnus-visual-p (&optional type class) | |
2327 (and gnus-visual ; Has to be non-nil, at least. | |
2328 (if (not type) ; We don't care about type. | |
2329 gnus-visual | |
2330 (if (listp gnus-visual) ; It's a list, so we check it. | |
2331 (or (memq type gnus-visual) | |
2332 (memq class gnus-visual)) | |
2333 t)))) | |
2334 | |
2335 ;;; Load the compatability functions. | |
2336 | |
2337 (require 'gnus-cus) | |
2338 (require 'gnus-ems) | |
2339 | |
2340 | |
2341 ;;; | |
2342 ;;; Shutdown | |
2343 ;;; | |
2344 | |
2345 (defvar gnus-shutdown-alist nil) | |
2346 | |
2347 (defun gnus-add-shutdown (function &rest symbols) | |
2348 "Run FUNCTION whenever one of SYMBOLS is shut down." | |
2349 (push (cons function symbols) gnus-shutdown-alist)) | |
2350 | |
2351 (defun gnus-shutdown (symbol) | |
2352 "Shut down everything that waits for SYMBOL." | |
2353 (let ((alist gnus-shutdown-alist) | |
2354 entry) | |
2355 (while (setq entry (pop alist)) | |
2356 (when (memq symbol (cdr entry)) | |
2357 (funcall (car entry)))))) | |
2358 | |
2359 | |
2360 | |
2361 ;; Format specs. The chunks below are the machine-generated forms | |
2362 ;; that are to be evaled as the result of the default format strings. | |
2363 ;; We write them in here to get them byte-compiled. That way the | |
2364 ;; default actions will be quite fast, while still retaining the full | |
2365 ;; flexibility of the user-defined format specs. | |
2366 | |
2367 ;; First we have lots of dummy defvars to let the compiler know these | |
2368 ;; are really dynamic variables. | |
2369 | |
2370 (defvar gnus-tmp-unread) | |
2371 (defvar gnus-tmp-replied) | |
2372 (defvar gnus-tmp-score-char) | |
2373 (defvar gnus-tmp-indentation) | |
2374 (defvar gnus-tmp-opening-bracket) | |
2375 (defvar gnus-tmp-lines) | |
2376 (defvar gnus-tmp-name) | |
2377 (defvar gnus-tmp-closing-bracket) | |
2378 (defvar gnus-tmp-subject-or-nil) | |
2379 (defvar gnus-tmp-subject) | |
2380 (defvar gnus-tmp-marked) | |
2381 (defvar gnus-tmp-marked-mark) | |
2382 (defvar gnus-tmp-subscribed) | |
2383 (defvar gnus-tmp-process-marked) | |
2384 (defvar gnus-tmp-number-of-unread) | |
2385 (defvar gnus-tmp-group-name) | |
2386 (defvar gnus-tmp-group) | |
2387 (defvar gnus-tmp-article-number) | |
2388 (defvar gnus-tmp-unread-and-unselected) | |
2389 (defvar gnus-tmp-news-method) | |
2390 (defvar gnus-tmp-news-server) | |
2391 (defvar gnus-tmp-article-number) | |
2392 (defvar gnus-mouse-face) | |
2393 (defvar gnus-mouse-face-prop) | |
2394 | |
2395 (defun gnus-summary-line-format-spec () | |
2396 (insert gnus-tmp-unread gnus-tmp-replied | |
2397 gnus-tmp-score-char gnus-tmp-indentation) | |
2398 (gnus-put-text-property | |
2399 (point) | |
2400 (progn | |
2401 (insert | |
2402 gnus-tmp-opening-bracket | |
2403 (format "%4d: %-20s" | |
2404 gnus-tmp-lines | |
2405 (if (> (length gnus-tmp-name) 20) | |
2406 (substring gnus-tmp-name 0 20) | |
2407 gnus-tmp-name)) | |
2408 gnus-tmp-closing-bracket) | |
2409 (point)) | |
2410 gnus-mouse-face-prop gnus-mouse-face) | |
2411 (insert " " gnus-tmp-subject-or-nil "\n")) | |
2412 | |
2413 (defvar gnus-summary-line-format-spec | |
2414 (gnus-byte-code 'gnus-summary-line-format-spec)) | |
2415 | |
2416 (defun gnus-summary-dummy-line-format-spec () | |
2417 (insert "* ") | |
2418 (gnus-put-text-property | |
2419 (point) | |
2420 (progn | |
2421 (insert ": :") | |
2422 (point)) | |
2423 gnus-mouse-face-prop gnus-mouse-face) | |
2424 (insert " " gnus-tmp-subject "\n")) | |
2425 | |
2426 (defvar gnus-summary-dummy-line-format-spec | |
2427 (gnus-byte-code 'gnus-summary-dummy-line-format-spec)) | |
2428 | |
2429 (defun gnus-group-line-format-spec () | |
2430 (insert gnus-tmp-marked-mark gnus-tmp-subscribed | |
2431 gnus-tmp-process-marked | |
2432 gnus-group-indentation | |
2433 (format "%5s: " gnus-tmp-number-of-unread)) | |
2434 (gnus-put-text-property | |
2435 (point) | |
2436 (progn | |
2437 (insert gnus-tmp-group "\n") | |
2438 (1- (point))) | |
2439 gnus-mouse-face-prop gnus-mouse-face)) | |
2440 (defvar gnus-group-line-format-spec | |
2441 (gnus-byte-code 'gnus-group-line-format-spec)) | |
2442 | |
2443 (defvar gnus-format-specs | |
2444 `((version . ,emacs-version) | |
2445 (group ,gnus-group-line-format ,gnus-group-line-format-spec) | |
2446 (summary-dummy ,gnus-summary-dummy-line-format | |
2447 ,gnus-summary-dummy-line-format-spec) | |
2448 (summary ,gnus-summary-line-format ,gnus-summary-line-format-spec))) | |
2449 | |
2450 (defvar gnus-article-mode-line-format-spec nil) | |
2451 (defvar gnus-summary-mode-line-format-spec nil) | |
2452 (defvar gnus-group-mode-line-format-spec nil) | |
2453 | |
2454 ;;; Phew. All that gruft is over, fortunately. | |
2455 | |
2456 | |
2457 ;;; | |
2458 ;;; Gnus Utility Functions | |
2459 ;;; | |
2460 | |
2461 (defun gnus-extract-address-components (from) | |
2462 (let (name address) | |
2463 ;; First find the address - the thing with the @ in it. This may | |
2464 ;; not be accurate in mail addresses, but does the trick most of | |
2465 ;; the time in news messages. | |
2466 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from) | |
2467 (setq address (substring from (match-beginning 0) (match-end 0)))) | |
2468 ;; Then we check whether the "name <address>" format is used. | |
2469 (and address | |
2470 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp> | |
2471 ;; Linear white space is not required. | |
2472 (string-match (concat "[ \t]*<" (regexp-quote address) ">") from) | |
2473 (and (setq name (substring from 0 (match-beginning 0))) | |
2474 ;; Strip any quotes from the name. | |
2475 (string-match "\".*\"" name) | |
2476 (setq name (substring name 1 (1- (match-end 0)))))) | |
2477 ;; If not, then "address (name)" is used. | |
2478 (or name | |
2479 (and (string-match "(.+)" from) | |
2480 (setq name (substring from (1+ (match-beginning 0)) | |
2481 (1- (match-end 0))))) | |
2482 (and (string-match "()" from) | |
2483 (setq name address)) | |
2484 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>. | |
2485 ;; XOVER might not support folded From headers. | |
2486 (and (string-match "(.*" from) | |
2487 (setq name (substring from (1+ (match-beginning 0)) | |
2488 (match-end 0))))) | |
2489 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>. | |
2490 (list (or name from) (or address from)))) | |
2491 | |
2492 (defun gnus-fetch-field (field) | |
2493 "Return the value of the header FIELD of current article." | |
2494 (save-excursion | |
2495 (save-restriction | |
2496 (let ((case-fold-search t) | |
2497 (inhibit-point-motion-hooks t)) | |
2498 (nnheader-narrow-to-headers) | |
2499 (message-fetch-field field))))) | |
2500 | |
2501 (defun gnus-goto-colon () | |
2502 (beginning-of-line) | |
2503 (search-forward ":" (gnus-point-at-eol) t)) | |
2504 | |
2505 ;;;###autoload | |
2506 (defun gnus-update-format (var) | |
2507 "Update the format specification near point." | |
2508 (interactive | |
2509 (list | |
2510 (save-excursion | |
2511 (eval-defun nil) | |
2512 ;; Find the end of the current word. | |
2513 (re-search-forward "[ \t\n]" nil t) | |
2514 ;; Search backward. | |
2515 (when (re-search-backward "\\(gnus-[-a-z]+-line-format\\)" nil t) | |
2516 (match-string 1))))) | |
2517 (let* ((type (intern (progn (string-match "gnus-\\([-a-z]+\\)-line" var) | |
2518 (match-string 1 var)))) | |
2519 (entry (assq type gnus-format-specs)) | |
2520 value spec) | |
2521 (when entry | |
2522 (setq gnus-format-specs (delq entry gnus-format-specs))) | |
2523 (set | |
2524 (intern (format "%s-spec" var)) | |
2525 (gnus-parse-format (setq value (symbol-value (intern var))) | |
2526 (symbol-value (intern (format "%s-alist" var))) | |
2527 (not (string-match "mode" var)))) | |
2528 (setq spec (symbol-value (intern (format "%s-spec" var)))) | |
2529 (push (list type value spec) gnus-format-specs) | |
2530 | |
2531 (pop-to-buffer "*Gnus Format*") | |
2532 (erase-buffer) | |
2533 (lisp-interaction-mode) | |
2534 (insert (pp-to-string spec)))) | |
2535 | |
2536 (defun gnus-update-format-specifications (&optional force) | |
2537 "Update all (necessary) format specifications." | |
2538 ;; Make the indentation array. | |
2539 (gnus-make-thread-indent-array) | |
2540 | |
2541 ;; See whether all the stored info needs to be flushed. | |
2542 (when (or force | |
2543 (not (equal emacs-version | |
2544 (cdr (assq 'version gnus-format-specs))))) | |
2545 (setq gnus-format-specs nil)) | |
2546 | |
2547 ;; Go through all the formats and see whether they need updating. | |
2548 (let ((types '(summary summary-dummy group | |
2549 summary-mode group-mode article-mode)) | |
2550 new-format entry type val) | |
2551 (while (setq type (pop types)) | |
2552 ;; Jump to the proper buffer to find out the value of | |
2553 ;; the variable, if possible. (It may be buffer-local.) | |
2554 (save-excursion | |
2555 (let ((buffer (intern (format "gnus-%s-buffer" type))) | |
2556 val) | |
2557 (when (and (boundp buffer) | |
2558 (setq val (symbol-value buffer)) | |
2559 (get-buffer val) | |
2560 (buffer-name (get-buffer val))) | |
2561 (set-buffer (get-buffer val))) | |
2562 (setq new-format (symbol-value | |
2563 (intern (format "gnus-%s-line-format" type)))))) | |
2564 (setq entry (cdr (assq type gnus-format-specs))) | |
2565 (if (and entry | |
2566 (equal (car entry) new-format)) | |
2567 ;; Use the old format. | |
2568 (set (intern (format "gnus-%s-line-format-spec" type)) | |
2569 (cadr entry)) | |
2570 ;; This is a new format. | |
2571 (setq val | |
2572 (if (not (stringp new-format)) | |
2573 ;; This is a function call or something. | |
2574 new-format | |
2575 ;; This is a "real" format. | |
2576 (gnus-parse-format | |
2577 new-format | |
2578 (symbol-value | |
2579 (intern (format "gnus-%s-line-format-alist" | |
2580 (if (eq type 'article-mode) | |
2581 'summary-mode type)))) | |
2582 (not (string-match "mode$" (symbol-name type)))))) | |
2583 ;; Enter the new format spec into the list. | |
2584 (if entry | |
2585 (progn | |
2586 (setcar (cdr entry) val) | |
2587 (setcar entry new-format)) | |
2588 (push (list type new-format val) gnus-format-specs)) | |
2589 (set (intern (format "gnus-%s-line-format-spec" type)) val)))) | |
2590 | |
2591 (unless (assq 'version gnus-format-specs) | |
2592 (push (cons 'version emacs-version) gnus-format-specs)) | |
2593 | |
2594 (gnus-update-group-mark-positions) | |
2595 (gnus-update-summary-mark-positions)) | |
2596 | |
2597 (defun gnus-update-summary-mark-positions () | |
2598 "Compute where the summary marks are to go." | |
2599 (save-excursion | |
2600 (when (and gnus-summary-buffer | |
2601 (get-buffer gnus-summary-buffer) | |
2602 (buffer-name (get-buffer gnus-summary-buffer))) | |
2603 (set-buffer gnus-summary-buffer)) | |
2604 (let ((gnus-replied-mark 129) | |
2605 (gnus-score-below-mark 130) | |
2606 (gnus-score-over-mark 130) | |
2607 (thread nil) | |
2608 (gnus-visual nil) | |
2609 (spec gnus-summary-line-format-spec) | |
2610 pos) | |
2611 (save-excursion | |
2612 (gnus-set-work-buffer) | |
2613 (let ((gnus-summary-line-format-spec spec)) | |
2614 (gnus-summary-insert-line | |
2615 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1) | |
2616 (goto-char (point-min)) | |
2617 (setq pos (list (cons 'unread (and (search-forward "\200" nil t) | |
2618 (- (point) 2))))) | |
2619 (goto-char (point-min)) | |
2620 (push (cons 'replied (and (search-forward "\201" nil t) | |
2621 (- (point) 2))) | |
2622 pos) | |
2623 (goto-char (point-min)) | |
2624 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2))) | |
2625 pos))) | |
2626 (setq gnus-summary-mark-positions pos)))) | |
2627 | |
2628 (defun gnus-update-group-mark-positions () | |
2629 (save-excursion | |
2630 (let ((gnus-process-mark 128) | |
2631 (gnus-group-marked '("dummy.group")) | |
2632 (gnus-active-hashtb (make-vector 10 0))) | |
2633 (gnus-set-active "dummy.group" '(0 . 0)) | |
2634 (gnus-set-work-buffer) | |
2635 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil) | |
2636 (goto-char (point-min)) | |
2637 (setq gnus-group-mark-positions | |
2638 (list (cons 'process (and (search-forward "\200" nil t) | |
2639 (- (point) 2)))))))) | |
2640 | |
2641 (defvar gnus-mouse-face-0 'highlight) | |
2642 (defvar gnus-mouse-face-1 'highlight) | |
2643 (defvar gnus-mouse-face-2 'highlight) | |
2644 (defvar gnus-mouse-face-3 'highlight) | |
2645 (defvar gnus-mouse-face-4 'highlight) | |
2646 | |
2647 (defun gnus-mouse-face-function (form type) | |
2648 `(gnus-put-text-property | |
2649 (point) (progn ,@form (point)) | |
2650 gnus-mouse-face-prop | |
2651 ,(if (equal type 0) | |
2652 'gnus-mouse-face | |
2653 `(quote ,(symbol-value (intern (format "gnus-mouse-face-%d" type))))))) | |
2654 | |
2655 (defvar gnus-face-0 'bold) | |
2656 (defvar gnus-face-1 'italic) | |
2657 (defvar gnus-face-2 'bold-italic) | |
2658 (defvar gnus-face-3 'bold) | |
2659 (defvar gnus-face-4 'bold) | |
2660 | |
2661 (defun gnus-face-face-function (form type) | |
2662 `(gnus-put-text-property | |
2663 (point) (progn ,@form (point)) | |
2664 'face ',(symbol-value (intern (format "gnus-face-%d" type))))) | |
2665 | |
2666 (defun gnus-max-width-function (el max-width) | |
2667 (or (numberp max-width) (signal 'wrong-type-argument '(numberp max-width))) | |
2668 (if (symbolp el) | |
2669 `(if (> (length ,el) ,max-width) | |
2670 (substring ,el 0 ,max-width) | |
2671 ,el) | |
2672 `(let ((val (eval ,el))) | |
2673 (if (numberp val) | |
2674 (setq val (int-to-string val))) | |
2675 (if (> (length val) ,max-width) | |
2676 (substring val 0 ,max-width) | |
2677 val)))) | |
2678 | |
2679 (defun gnus-parse-format (format spec-alist &optional insert) | |
2680 ;; This function parses the FORMAT string with the help of the | |
2681 ;; SPEC-ALIST and returns a list that can be eval'ed to return the | |
2682 ;; string. If the FORMAT string contains the specifiers %( and %) | |
2683 ;; the text between them will have the mouse-face text property. | |
2684 (if (string-match | |
2685 "\\`\\(.*\\)%[0-9]?[{(]\\(.*\\)%[0-9]?[})]\\(.*\n?\\)\\'" | |
2686 format) | |
2687 (gnus-parse-complex-format format spec-alist) | |
2688 ;; This is a simple format. | |
2689 (gnus-parse-simple-format format spec-alist insert))) | |
2690 | |
2691 (defun gnus-parse-complex-format (format spec-alist) | |
2692 (save-excursion | |
2693 (gnus-set-work-buffer) | |
2694 (insert format) | |
2695 (goto-char (point-min)) | |
2696 (while (re-search-forward "\"" nil t) | |
2697 (replace-match "\\\"" nil t)) | |
2698 (goto-char (point-min)) | |
2699 (insert "(\"") | |
2700 (while (re-search-forward "%\\([0-9]+\\)?\\([{}()]\\)" nil t) | |
2701 (let ((number (if (match-beginning 1) | |
2702 (match-string 1) "0")) | |
2703 (delim (aref (match-string 2) 0))) | |
2704 (if (or (= delim ?\() (= delim ?\{)) | |
2705 (replace-match (concat "\"(" (if (= delim ?\() "mouse" "face") | |
2706 " " number " \"")) | |
2707 (replace-match "\")\"")))) | |
2708 (goto-char (point-max)) | |
2709 (insert "\")") | |
2710 (goto-char (point-min)) | |
2711 (let ((form (read (current-buffer)))) | |
2712 (cons 'progn (gnus-complex-form-to-spec form spec-alist))))) | |
2713 | |
2714 (defun gnus-complex-form-to-spec (form spec-alist) | |
2715 (delq nil | |
2716 (mapcar | |
2717 (lambda (sform) | |
2718 (if (stringp sform) | |
2719 (gnus-parse-simple-format sform spec-alist t) | |
2720 (funcall (intern (format "gnus-%s-face-function" (car sform))) | |
2721 (gnus-complex-form-to-spec (cddr sform) spec-alist) | |
2722 (nth 1 sform)))) | |
2723 form))) | |
2724 | |
2725 (defun gnus-parse-simple-format (format spec-alist &optional insert) | |
2726 ;; This function parses the FORMAT string with the help of the | |
2727 ;; SPEC-ALIST and returns a list that can be eval'ed to return a | |
2728 ;; string. | |
2729 (let ((max-width 0) | |
2730 spec flist fstring newspec elem beg result dontinsert) | |
2731 (save-excursion | |
2732 (gnus-set-work-buffer) | |
2733 (insert format) | |
2734 (goto-char (point-min)) | |
2735 (while (re-search-forward "%[-0-9]*\\(,[0-9]+\\)?\\([^0-9]\\)\\(.\\)?" | |
2736 nil t) | |
2737 (if (= (setq spec (string-to-char (match-string 2))) ?%) | |
2738 (setq newspec "%" | |
2739 beg (1+ (match-beginning 0))) | |
2740 ;; First check if there are any specs that look anything like | |
2741 ;; "%12,12A", ie. with a "max width specification". These have | |
2742 ;; to be treated specially. | |
2743 (if (setq beg (match-beginning 1)) | |
2744 (setq max-width | |
2745 (string-to-int | |
2746 (buffer-substring | |
2747 (1+ (match-beginning 1)) (match-end 1)))) | |
2748 (setq max-width 0) | |
2749 (setq beg (match-beginning 2))) | |
2750 ;; Find the specification from `spec-alist'. | |
2751 (unless (setq elem (cdr (assq spec spec-alist))) | |
2752 (setq elem '("*" ?s))) | |
2753 ;; Treat user defined format specifiers specially. | |
2754 (when (eq (car elem) 'gnus-tmp-user-defined) | |
2755 (setq elem | |
2756 (list | |
2757 (list (intern (concat "gnus-user-format-function-" | |
2758 (match-string 3))) | |
2759 'gnus-tmp-header) ?s)) | |
2760 (delete-region (match-beginning 3) (match-end 3))) | |
2761 (if (not (zerop max-width)) | |
2762 (let ((el (car elem))) | |
2763 (cond ((= (cadr elem) ?c) | |
2764 (setq el (list 'char-to-string el))) | |
2765 ((= (cadr elem) ?d) | |
2766 (setq el (list 'int-to-string el)))) | |
2767 (setq flist (cons (gnus-max-width-function el max-width) | |
2768 flist)) | |
2769 (setq newspec ?s)) | |
2770 (progn | |
2771 (setq flist (cons (car elem) flist)) | |
2772 (setq newspec (cadr elem))))) | |
2773 ;; Remove the old specification (and possibly a ",12" string). | |
2774 (delete-region beg (match-end 2)) | |
2775 ;; Insert the new specification. | |
2776 (goto-char beg) | |
2777 (insert newspec)) | |
2778 (setq fstring (buffer-substring 1 (point-max)))) | |
2779 ;; Do some postprocessing to increase efficiency. | |
2780 (setq | |
2781 result | |
2782 (cond | |
2783 ;; Emptyness. | |
2784 ((string= fstring "") | |
2785 nil) | |
2786 ;; Not a format string. | |
2787 ((not (string-match "%" fstring)) | |
2788 (list fstring)) | |
2789 ;; A format string with just a single string spec. | |
2790 ((string= fstring "%s") | |
2791 (list (car flist))) | |
2792 ;; A single character. | |
2793 ((string= fstring "%c") | |
2794 (list (car flist))) | |
2795 ;; A single number. | |
2796 ((string= fstring "%d") | |
2797 (setq dontinsert) | |
2798 (if insert | |
2799 (list `(princ ,(car flist))) | |
2800 (list `(int-to-string ,(car flist))))) | |
2801 ;; Just lots of chars and strings. | |
2802 ((string-match "\\`\\(%[cs]\\)+\\'" fstring) | |
2803 (nreverse flist)) | |
2804 ;; A single string spec at the beginning of the spec. | |
2805 ((string-match "\\`%[sc][^%]+\\'" fstring) | |
2806 (list (car flist) (substring fstring 2))) | |
2807 ;; A single string spec in the middle of the spec. | |
2808 ((string-match "\\`\\([^%]+\\)%[sc]\\([^%]+\\)\\'" fstring) | |
2809 (list (match-string 1 fstring) (car flist) (match-string 2 fstring))) | |
2810 ;; A single string spec in the end of the spec. | |
2811 ((string-match "\\`\\([^%]+\\)%[sc]\\'" fstring) | |
2812 (list (match-string 1 fstring) (car flist))) | |
2813 ;; A more complex spec. | |
2814 (t | |
2815 (list (cons 'format (cons fstring (nreverse flist))))))) | |
2816 | |
2817 (if insert | |
2818 (when result | |
2819 (if dontinsert | |
2820 result | |
2821 (cons 'insert result))) | |
2822 (cond ((stringp result) | |
2823 result) | |
2824 ((consp result) | |
2825 (cons 'concat result)) | |
2826 (t ""))))) | |
2827 | |
2828 (defun gnus-eval-format (format &optional alist props) | |
2829 "Eval the format variable FORMAT, using ALIST. | |
2830 If PROPS, insert the result." | |
2831 (let ((form (gnus-parse-format format alist props))) | |
2832 (if props | |
2833 (gnus-add-text-properties (point) (progn (eval form) (point)) props) | |
2834 (eval form)))) | |
2835 | |
2836 (defun gnus-remove-text-with-property (prop) | |
2837 "Delete all text in the current buffer with text property PROP." | |
2838 (save-excursion | |
2839 (goto-char (point-min)) | |
2840 (while (not (eobp)) | |
2841 (while (get-text-property (point) prop) | |
2842 (delete-char 1)) | |
2843 (goto-char (next-single-property-change (point) prop nil (point-max)))))) | |
2844 | |
2845 (defun gnus-set-work-buffer () | |
2846 (if (get-buffer gnus-work-buffer) | |
2847 (progn | |
2848 (set-buffer gnus-work-buffer) | |
2849 (erase-buffer)) | |
2850 (set-buffer (get-buffer-create gnus-work-buffer)) | |
2851 (kill-all-local-variables) | |
2852 (buffer-disable-undo (current-buffer)) | |
2853 (gnus-add-current-to-buffer-list))) | |
2854 | |
2855 ;; Article file names when saving. | |
2856 | |
2857 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file) | |
2858 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE. | |
2859 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num. | |
2860 Otherwise, it is like ~/News/news/group/num." | |
2861 (let ((default | |
2862 (expand-file-name | |
2863 (concat (if (gnus-use-long-file-name 'not-save) | |
2864 (gnus-capitalize-newsgroup newsgroup) | |
2865 (gnus-newsgroup-directory-form newsgroup)) | |
2866 "/" (int-to-string (mail-header-number headers))) | |
2867 gnus-article-save-directory))) | |
2868 (if (and last-file | |
2869 (string-equal (file-name-directory default) | |
2870 (file-name-directory last-file)) | |
2871 (string-match "^[0-9]+$" (file-name-nondirectory last-file))) | |
2872 default | |
2873 (or last-file default)))) | |
2874 | |
2875 (defun gnus-numeric-save-name (newsgroup headers &optional last-file) | |
2876 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE. | |
2877 If variable `gnus-use-long-file-name' is non-nil, it is | |
2878 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num." | |
2879 (let ((default | |
2880 (expand-file-name | |
2881 (concat (if (gnus-use-long-file-name 'not-save) | |
2882 newsgroup | |
2883 (gnus-newsgroup-directory-form newsgroup)) | |
2884 "/" (int-to-string (mail-header-number headers))) | |
2885 gnus-article-save-directory))) | |
2886 (if (and last-file | |
2887 (string-equal (file-name-directory default) | |
2888 (file-name-directory last-file)) | |
2889 (string-match "^[0-9]+$" (file-name-nondirectory last-file))) | |
2890 default | |
2891 (or last-file default)))) | |
2892 | |
2893 (defun gnus-Plain-save-name (newsgroup headers &optional last-file) | |
2894 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE. | |
2895 If variable `gnus-use-long-file-name' is non-nil, it is | |
2896 ~/News/News.group. Otherwise, it is like ~/News/news/group/news." | |
2897 (or last-file | |
2898 (expand-file-name | |
2899 (if (gnus-use-long-file-name 'not-save) | |
2900 (gnus-capitalize-newsgroup newsgroup) | |
2901 (concat (gnus-newsgroup-directory-form newsgroup) "/news")) | |
2902 gnus-article-save-directory))) | |
2903 | |
2904 (defun gnus-plain-save-name (newsgroup headers &optional last-file) | |
2905 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE. | |
2906 If variable `gnus-use-long-file-name' is non-nil, it is | |
2907 ~/News/news.group. Otherwise, it is like ~/News/news/group/news." | |
2908 (or last-file | |
2909 (expand-file-name | |
2910 (if (gnus-use-long-file-name 'not-save) | |
2911 newsgroup | |
2912 (concat (gnus-newsgroup-directory-form newsgroup) "/news")) | |
2913 gnus-article-save-directory))) | |
2914 | |
2915 ;; For subscribing new newsgroup | |
2916 | |
2917 (defun gnus-subscribe-hierarchical-interactive (groups) | |
2918 (let ((groups (sort groups 'string<)) | |
2919 prefixes prefix start ans group starts) | |
2920 (while groups | |
2921 (setq prefixes (list "^")) | |
2922 (while (and groups prefixes) | |
2923 (while (not (string-match (car prefixes) (car groups))) | |
2924 (setq prefixes (cdr prefixes))) | |
2925 (setq prefix (car prefixes)) | |
2926 (setq start (1- (length prefix))) | |
2927 (if (and (string-match "[^\\.]\\." (car groups) start) | |
2928 (cdr groups) | |
2929 (setq prefix | |
2930 (concat "^" (substring (car groups) 0 (match-end 0)))) | |
2931 (string-match prefix (cadr groups))) | |
2932 (progn | |
2933 (setq prefixes (cons prefix prefixes)) | |
2934 (message "Descend hierarchy %s? ([y]nsq): " | |
2935 (substring prefix 1 (1- (length prefix)))) | |
2936 (while (not (memq (setq ans (read-char)) '(?y ?\n ?n ?s ?q))) | |
2937 (ding) | |
2938 (message "Descend hierarchy %s? ([y]nsq): " | |
2939 (substring prefix 1 (1- (length prefix))))) | |
2940 (cond ((= ans ?n) | |
2941 (while (and groups | |
2942 (string-match prefix | |
2943 (setq group (car groups)))) | |
2944 (setq gnus-killed-list | |
2945 (cons group gnus-killed-list)) | |
2946 (gnus-sethash group group gnus-killed-hashtb) | |
2947 (setq groups (cdr groups))) | |
2948 (setq starts (cdr starts))) | |
2949 ((= ans ?s) | |
2950 (while (and groups | |
2951 (string-match prefix | |
2952 (setq group (car groups)))) | |
2953 (gnus-sethash group group gnus-killed-hashtb) | |
2954 (gnus-subscribe-alphabetically (car groups)) | |
2955 (setq groups (cdr groups))) | |
2956 (setq starts (cdr starts))) | |
2957 ((= ans ?q) | |
2958 (while groups | |
2959 (setq group (car groups)) | |
2960 (setq gnus-killed-list (cons group gnus-killed-list)) | |
2961 (gnus-sethash group group gnus-killed-hashtb) | |
2962 (setq groups (cdr groups)))) | |
2963 (t nil))) | |
2964 (message "Subscribe %s? ([n]yq)" (car groups)) | |
2965 (while (not (memq (setq ans (read-char)) '(?y ?\n ?q ?n))) | |
2966 (ding) | |
2967 (message "Subscribe %s? ([n]yq)" (car groups))) | |
2968 (setq group (car groups)) | |
2969 (cond ((= ans ?y) | |
2970 (gnus-subscribe-alphabetically (car groups)) | |
2971 (gnus-sethash group group gnus-killed-hashtb)) | |
2972 ((= ans ?q) | |
2973 (while groups | |
2974 (setq group (car groups)) | |
2975 (setq gnus-killed-list (cons group gnus-killed-list)) | |
2976 (gnus-sethash group group gnus-killed-hashtb) | |
2977 (setq groups (cdr groups)))) | |
2978 (t | |
2979 (setq gnus-killed-list (cons group gnus-killed-list)) | |
2980 (gnus-sethash group group gnus-killed-hashtb))) | |
2981 (setq groups (cdr groups))))))) | |
2982 | |
2983 (defun gnus-subscribe-randomly (newsgroup) | |
2984 "Subscribe new NEWSGROUP by making it the first newsgroup." | |
2985 (gnus-subscribe-newsgroup newsgroup)) | |
2986 | |
2987 (defun gnus-subscribe-alphabetically (newgroup) | |
2988 "Subscribe new NEWSGROUP and insert it in alphabetical order." | |
2989 (let ((groups (cdr gnus-newsrc-alist)) | |
2990 before) | |
2991 (while (and (not before) groups) | |
2992 (if (string< newgroup (caar groups)) | |
2993 (setq before (caar groups)) | |
2994 (setq groups (cdr groups)))) | |
2995 (gnus-subscribe-newsgroup newgroup before))) | |
2996 | |
2997 (defun gnus-subscribe-hierarchically (newgroup) | |
2998 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order." | |
2999 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams) | |
3000 (save-excursion | |
3001 (set-buffer (find-file-noselect gnus-current-startup-file)) | |
3002 (let ((groupkey newgroup) | |
3003 before) | |
3004 (while (and (not before) groupkey) | |
3005 (goto-char (point-min)) | |
3006 (let ((groupkey-re | |
3007 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]"))) | |
3008 (while (and (re-search-forward groupkey-re nil t) | |
3009 (progn | |
3010 (setq before (match-string 1)) | |
3011 (string< before newgroup))))) | |
3012 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b) | |
3013 (setq groupkey | |
3014 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey) | |
3015 (substring groupkey (match-beginning 1) (match-end 1))))) | |
3016 (gnus-subscribe-newsgroup newgroup before)))) | |
3017 | |
3018 (defun gnus-subscribe-interactively (group) | |
3019 "Subscribe the new GROUP interactively. | |
3020 It is inserted in hierarchical newsgroup order if subscribed. If not, | |
3021 it is killed." | |
3022 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " group)) | |
3023 (gnus-subscribe-hierarchically group) | |
3024 (push group gnus-killed-list))) | |
3025 | |
3026 (defun gnus-subscribe-zombies (group) | |
3027 "Make the new GROUP into a zombie group." | |
3028 (push group gnus-zombie-list)) | |
3029 | |
3030 (defun gnus-subscribe-killed (group) | |
3031 "Make the new GROUP a killed group." | |
3032 (push group gnus-killed-list)) | |
3033 | |
3034 (defun gnus-subscribe-newsgroup (newsgroup &optional next) | |
3035 "Subscribe new NEWSGROUP. | |
3036 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made | |
3037 the first newsgroup." | |
3038 ;; We subscribe the group by changing its level to `subscribed'. | |
3039 (gnus-group-change-level | |
3040 newsgroup gnus-level-default-subscribed | |
3041 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb)) | |
3042 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup)) | |
3043 | |
3044 ;; For directories | |
3045 | |
3046 (defun gnus-newsgroup-directory-form (newsgroup) | |
3047 "Make hierarchical directory name from NEWSGROUP name." | |
3048 (let ((newsgroup (gnus-newsgroup-savable-name newsgroup)) | |
3049 (len (length newsgroup)) | |
3050 idx) | |
3051 ;; If this is a foreign group, we don't want to translate the | |
3052 ;; entire name. | |
3053 (if (setq idx (string-match ":" newsgroup)) | |
3054 (aset newsgroup idx ?/) | |
3055 (setq idx 0)) | |
3056 ;; Replace all occurrences of `.' with `/'. | |
3057 (while (< idx len) | |
3058 (if (= (aref newsgroup idx) ?.) | |
3059 (aset newsgroup idx ?/)) | |
3060 (setq idx (1+ idx))) | |
3061 newsgroup)) | |
3062 | |
3063 (defun gnus-newsgroup-savable-name (group) | |
3064 ;; Replace any slashes in a group name (eg. an ange-ftp nndoc group) | |
3065 ;; with dots. | |
3066 (nnheader-replace-chars-in-string group ?/ ?.)) | |
3067 | |
3068 (defun gnus-make-directory (dir) | |
3069 "Make DIRECTORY recursively." | |
3070 ;; Why don't we use `(make-directory dir 'parents)'? That's just one | |
3071 ;; of the many mysteries of the universe. | |
3072 (let* ((dir (expand-file-name dir default-directory)) | |
3073 dirs err) | |
3074 (if (string-match "/$" dir) | |
3075 (setq dir (substring dir 0 (match-beginning 0)))) | |
3076 ;; First go down the path until we find a directory that exists. | |
3077 (while (not (file-exists-p dir)) | |
3078 (setq dirs (cons dir dirs)) | |
3079 (string-match "/[^/]+$" dir) | |
3080 (setq dir (substring dir 0 (match-beginning 0)))) | |
3081 ;; Then create all the subdirs. | |
3082 (while (and dirs (not err)) | |
3083 (condition-case () | |
3084 (make-directory (car dirs)) | |
3085 (error (setq err t))) | |
3086 (setq dirs (cdr dirs))) | |
3087 ;; We return whether we were successful or not. | |
3088 (not dirs))) | |
3089 | |
3090 (defun gnus-capitalize-newsgroup (newsgroup) | |
3091 "Capitalize NEWSGROUP name." | |
3092 (and (not (zerop (length newsgroup))) | |
3093 (concat (char-to-string (upcase (aref newsgroup 0))) | |
3094 (substring newsgroup 1)))) | |
3095 | |
3096 ;; Various... things. | |
3097 | |
3098 (defun gnus-simplify-subject (subject &optional re-only) | |
3099 "Remove `Re:' and words in parentheses. | |
3100 If RE-ONLY is non-nil, strip leading `Re:'s only." | |
3101 (let ((case-fold-search t)) ;Ignore case. | |
3102 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'. | |
3103 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject) | |
3104 (setq subject (substring subject (match-end 0)))) | |
3105 ;; Remove uninteresting prefixes. | |
3106 (if (and (not re-only) | |
3107 gnus-simplify-ignored-prefixes | |
3108 (string-match gnus-simplify-ignored-prefixes subject)) | |
3109 (setq subject (substring subject (match-end 0)))) | |
3110 ;; Remove words in parentheses from end. | |
3111 (unless re-only | |
3112 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject) | |
3113 (setq subject (substring subject 0 (match-beginning 0))))) | |
3114 ;; Return subject string. | |
3115 subject)) | |
3116 | |
3117 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify | |
3118 ;; all whitespace. | |
3119 ;; Written by Stainless Steel Rat <ratinox@ccs.neu.edu>. | |
3120 (defun gnus-simplify-buffer-fuzzy () | |
3121 (let ((case-fold-search t)) | |
3122 (goto-char (point-min)) | |
3123 (while (search-forward "\t" nil t) | |
3124 (replace-match " " t t)) | |
3125 (goto-char (point-min)) | |
3126 (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *" nil t) | |
3127 (goto-char (match-beginning 0)) | |
3128 (while (or | |
3129 (looking-at "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *") | |
3130 (looking-at "^[[].*: .*[]]$")) | |
3131 (goto-char (point-min)) | |
3132 (while (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *" | |
3133 nil t) | |
3134 (replace-match "" t t)) | |
3135 (goto-char (point-min)) | |
3136 (while (re-search-forward "^[[].*: .*[]]$" nil t) | |
3137 (goto-char (match-end 0)) | |
3138 (delete-char -1) | |
3139 (delete-region | |
3140 (progn (goto-char (match-beginning 0))) | |
3141 (re-search-forward ":")))) | |
3142 (goto-char (point-min)) | |
3143 (while (re-search-forward " *[[{(][^()\n]*[]})] *$" nil t) | |
3144 (replace-match "" t t)) | |
3145 (goto-char (point-min)) | |
3146 (while (re-search-forward " +" nil t) | |
3147 (replace-match " " t t)) | |
3148 (goto-char (point-min)) | |
3149 (while (re-search-forward " $" nil t) | |
3150 (replace-match "" t t)) | |
3151 (goto-char (point-min)) | |
3152 (while (re-search-forward "^ +" nil t) | |
3153 (replace-match "" t t)) | |
3154 (goto-char (point-min)) | |
3155 (when gnus-simplify-subject-fuzzy-regexp | |
3156 (if (listp gnus-simplify-subject-fuzzy-regexp) | |
3157 (let ((list gnus-simplify-subject-fuzzy-regexp)) | |
3158 (while list | |
3159 (goto-char (point-min)) | |
3160 (while (re-search-forward (car list) nil t) | |
3161 (replace-match "" t t)) | |
3162 (setq list (cdr list)))) | |
3163 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t) | |
3164 (replace-match "" t t)))))) | |
3165 | |
3166 (defun gnus-simplify-subject-fuzzy (subject) | |
3167 "Siplify a subject string fuzzily." | |
3168 (save-excursion | |
3169 (gnus-set-work-buffer) | |
3170 (let ((case-fold-search t)) | |
3171 (insert subject) | |
3172 (inline (gnus-simplify-buffer-fuzzy)) | |
3173 (buffer-string)))) | |
3174 | |
3175 ;; Add the current buffer to the list of buffers to be killed on exit. | |
3176 (defun gnus-add-current-to-buffer-list () | |
3177 (or (memq (current-buffer) gnus-buffer-list) | |
3178 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list)))) | |
3179 | |
3180 (defun gnus-string> (s1 s2) | |
3181 (not (or (string< s1 s2) | |
3182 (string= s1 s2)))) | |
3183 | |
3184 (defun gnus-read-active-file-p () | |
3185 "Say whether the active file has been read from `gnus-select-method'." | |
3186 (memq gnus-select-method gnus-have-read-active-file)) | |
3187 | |
3188 ;;; General various misc type functions. | |
3189 | |
3190 (defun gnus-clear-system () | |
3191 "Clear all variables and buffers." | |
3192 ;; Clear Gnus variables. | |
3193 (let ((variables gnus-variable-list)) | |
3194 (while variables | |
3195 (set (car variables) nil) | |
3196 (setq variables (cdr variables)))) | |
3197 ;; Clear other internal variables. | |
3198 (setq gnus-list-of-killed-groups nil | |
3199 gnus-have-read-active-file nil | |
3200 gnus-newsrc-alist nil | |
3201 gnus-newsrc-hashtb nil | |
3202 gnus-killed-list nil | |
3203 gnus-zombie-list nil | |
3204 gnus-killed-hashtb nil | |
3205 gnus-active-hashtb nil | |
3206 gnus-moderated-list nil | |
3207 gnus-description-hashtb nil | |
3208 gnus-current-headers nil | |
3209 gnus-thread-indent-array nil | |
3210 gnus-newsgroup-headers nil | |
3211 gnus-newsgroup-name nil | |
3212 gnus-server-alist nil | |
3213 gnus-group-list-mode nil | |
3214 gnus-opened-servers nil | |
3215 gnus-current-select-method nil) | |
3216 (gnus-shutdown 'gnus) | |
3217 ;; Kill the startup file. | |
3218 (and gnus-current-startup-file | |
3219 (get-file-buffer gnus-current-startup-file) | |
3220 (kill-buffer (get-file-buffer gnus-current-startup-file))) | |
3221 ;; Clear the dribble buffer. | |
3222 (gnus-dribble-clear) | |
3223 ;; Kill global KILL file buffer. | |
3224 (when (get-file-buffer (gnus-newsgroup-kill-file nil)) | |
3225 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil)))) | |
3226 (gnus-kill-buffer nntp-server-buffer) | |
3227 ;; Kill Gnus buffers. | |
3228 (while gnus-buffer-list | |
3229 (gnus-kill-buffer (pop gnus-buffer-list))) | |
3230 ;; Remove Gnus frames. | |
3231 (gnus-kill-gnus-frames)) | |
3232 | |
3233 (defun gnus-kill-gnus-frames () | |
3234 "Kill all frames Gnus has created." | |
3235 (while gnus-created-frames | |
3236 (when (frame-live-p (car gnus-created-frames)) | |
3237 ;; We slap a condition-case around this `delete-frame' to ensure | |
3238 ;; against errors if we try do delete the single frame that's left. | |
3239 (condition-case () | |
3240 (delete-frame (car gnus-created-frames)) | |
3241 (error nil))) | |
3242 (pop gnus-created-frames))) | |
3243 | |
3244 (defun gnus-windows-old-to-new (setting) | |
3245 ;; First we take care of the really, really old Gnus 3 actions. | |
3246 (when (symbolp setting) | |
3247 (setq setting | |
3248 ;; Take care of ooold GNUS 3.x values. | |
3249 (cond ((eq setting 'SelectArticle) 'article) | |
3250 ((memq setting '(SelectSubject ExpandSubject)) 'summary) | |
3251 ((memq setting '(SelectNewsgroup ExitNewsgroup)) 'group) | |
3252 (t setting)))) | |
3253 (if (or (listp setting) | |
3254 (not (and gnus-window-configuration | |
3255 (memq setting '(group summary article))))) | |
3256 setting | |
3257 (let* ((setting (if (eq setting 'group) | |
3258 (if (assq 'newsgroup gnus-window-configuration) | |
3259 'newsgroup | |
3260 'newsgroups) setting)) | |
3261 (elem (cadr (assq setting gnus-window-configuration))) | |
3262 (total (apply '+ elem)) | |
3263 (types '(group summary article)) | |
3264 (pbuf (if (eq setting 'newsgroups) 'group 'summary)) | |
3265 (i 0) | |
3266 perc | |
3267 out) | |
3268 (while (< i 3) | |
3269 (or (not (numberp (nth i elem))) | |
3270 (zerop (nth i elem)) | |
3271 (progn | |
3272 (setq perc (if (= i 2) | |
3273 1.0 | |
3274 (/ (float (nth 0 elem)) total))) | |
3275 (setq out (cons (if (eq pbuf (nth i types)) | |
3276 (list (nth i types) perc 'point) | |
3277 (list (nth i types) perc)) | |
3278 out)))) | |
3279 (setq i (1+ i))) | |
3280 `(vertical 1.0 ,@(nreverse out))))) | |
3281 | |
3282 ;;;###autoload | |
3283 (defun gnus-add-configuration (conf) | |
3284 "Add the window configuration CONF to `gnus-buffer-configuration'." | |
3285 (setq gnus-buffer-configuration | |
3286 (cons conf (delq (assq (car conf) gnus-buffer-configuration) | |
3287 gnus-buffer-configuration)))) | |
3288 | |
3289 (defvar gnus-frame-list nil) | |
3290 | |
3291 (defun gnus-configure-frame (split &optional window) | |
3292 "Split WINDOW according to SPLIT." | |
3293 (unless window | |
3294 (setq window (get-buffer-window (current-buffer)))) | |
3295 (select-window window) | |
3296 ;; This might be an old-stylee buffer config. | |
3297 (when (vectorp split) | |
3298 (setq split (append split nil))) | |
3299 (when (or (consp (car split)) | |
3300 (vectorp (car split))) | |
3301 (push 1.0 split) | |
3302 (push 'vertical split)) | |
3303 ;; The SPLIT might be something that is to be evaled to | |
3304 ;; return a new SPLIT. | |
3305 (while (and (not (assq (car split) gnus-window-to-buffer)) | |
3306 (gnus-functionp (car split))) | |
3307 (setq split (eval split))) | |
3308 (let* ((type (car split)) | |
3309 (subs (cddr split)) | |
3310 (len (if (eq type 'horizontal) (window-width) (window-height))) | |
3311 (total 0) | |
3312 (window-min-width (or gnus-window-min-width window-min-width)) | |
3313 (window-min-height (or gnus-window-min-height window-min-height)) | |
3314 s result new-win rest comp-subs size sub) | |
3315 (cond | |
3316 ;; Nothing to do here. | |
3317 ((null split)) | |
3318 ;; Don't switch buffers. | |
3319 ((null type) | |
3320 (and (memq 'point split) window)) | |
3321 ;; This is a buffer to be selected. | |
3322 ((not (memq type '(frame horizontal vertical))) | |
3323 (let ((buffer (cond ((stringp type) type) | |
3324 (t (cdr (assq type gnus-window-to-buffer))))) | |
3325 buf) | |
3326 (unless buffer | |
3327 (error "Illegal buffer type: %s" type)) | |
3328 (unless (setq buf (get-buffer (if (symbolp buffer) | |
3329 (symbol-value buffer) buffer))) | |
3330 (setq buf (get-buffer-create (if (symbolp buffer) | |
3331 (symbol-value buffer) buffer)))) | |
3332 (switch-to-buffer buf) | |
3333 ;; We return the window if it has the `point' spec. | |
3334 (and (memq 'point split) window))) | |
3335 ;; This is a frame split. | |
3336 ((eq type 'frame) | |
3337 (unless gnus-frame-list | |
3338 (setq gnus-frame-list (list (window-frame | |
3339 (get-buffer-window (current-buffer)))))) | |
3340 (let ((i 0) | |
3341 params frame fresult) | |
3342 (while (< i (length subs)) | |
3343 ;; Frame parameter is gotten from the sub-split. | |
3344 (setq params (cadr (elt subs i))) | |
3345 ;; It should be a list. | |
3346 (unless (listp params) | |
3347 (setq params nil)) | |
3348 ;; Create a new frame? | |
3349 (unless (setq frame (elt gnus-frame-list i)) | |
3350 (nconc gnus-frame-list (list (setq frame (make-frame params)))) | |
3351 (push frame gnus-created-frames)) | |
3352 ;; Is the old frame still alive? | |
3353 (unless (frame-live-p frame) | |
3354 (setcar (nthcdr i gnus-frame-list) | |
3355 (setq frame (make-frame params)))) | |
3356 ;; Select the frame in question and do more splits there. | |
3357 (select-frame frame) | |
3358 (setq fresult (or (gnus-configure-frame (elt subs i)) fresult)) | |
3359 (incf i)) | |
3360 ;; Select the frame that has the selected buffer. | |
3361 (when fresult | |
3362 (select-frame (window-frame fresult))))) | |
3363 ;; This is a normal split. | |
3364 (t | |
3365 (when (> (length subs) 0) | |
3366 ;; First we have to compute the sizes of all new windows. | |
3367 (while subs | |
3368 (setq sub (append (pop subs) nil)) | |
3369 (while (and (not (assq (car sub) gnus-window-to-buffer)) | |
3370 (gnus-functionp (car sub))) | |
3371 (setq sub (eval sub))) | |
3372 (when sub | |
3373 (push sub comp-subs) | |
3374 (setq size (cadar comp-subs)) | |
3375 (cond ((equal size 1.0) | |
3376 (setq rest (car comp-subs)) | |
3377 (setq s 0)) | |
3378 ((floatp size) | |
3379 (setq s (floor (* size len)))) | |
3380 ((integerp size) | |
3381 (setq s size)) | |
3382 (t | |
3383 (error "Illegal size: %s" size))) | |
3384 ;; Try to make sure that we are inside the safe limits. | |
3385 (cond ((zerop s)) | |
3386 ((eq type 'horizontal) | |
3387 (setq s (max s window-min-width))) | |
3388 ((eq type 'vertical) | |
3389 (setq s (max s window-min-height)))) | |
3390 (setcar (cdar comp-subs) s) | |
3391 (incf total s))) | |
3392 ;; Take care of the "1.0" spec. | |
3393 (if rest | |
3394 (setcar (cdr rest) (- len total)) | |
3395 (error "No 1.0 specs in %s" split)) | |
3396 ;; The we do the actual splitting in a nice recursive | |
3397 ;; fashion. | |
3398 (setq comp-subs (nreverse comp-subs)) | |
3399 (while comp-subs | |
3400 (if (null (cdr comp-subs)) | |
3401 (setq new-win window) | |
3402 (setq new-win | |
3403 (split-window window (cadar comp-subs) | |
3404 (eq type 'horizontal)))) | |
3405 (setq result (or (gnus-configure-frame | |
3406 (car comp-subs) window) result)) | |
3407 (select-window new-win) | |
3408 (setq window new-win) | |
3409 (setq comp-subs (cdr comp-subs)))) | |
3410 ;; Return the proper window, if any. | |
3411 (when result | |
3412 (select-window result)))))) | |
3413 | |
3414 (defvar gnus-frame-split-p nil) | |
3415 | |
3416 (defun gnus-configure-windows (setting &optional force) | |
3417 (setq setting (gnus-windows-old-to-new setting)) | |
3418 (let ((split (if (symbolp setting) | |
3419 (cadr (assq setting gnus-buffer-configuration)) | |
3420 setting)) | |
3421 all-visible) | |
3422 | |
3423 (setq gnus-frame-split-p nil) | |
3424 | |
3425 (unless split | |
3426 (error "No such setting: %s" setting)) | |
3427 | |
3428 (if (and (setq all-visible (gnus-all-windows-visible-p split)) | |
3429 (not force)) | |
3430 ;; All the windows mentioned are already visible, so we just | |
3431 ;; put point in the assigned buffer, and do not touch the | |
3432 ;; winconf. | |
3433 (select-window all-visible) | |
3434 | |
3435 ;; Either remove all windows or just remove all Gnus windows. | |
3436 (let ((frame (selected-frame))) | |
3437 (unwind-protect | |
3438 (if gnus-use-full-window | |
3439 ;; We want to remove all other windows. | |
3440 (if (not gnus-frame-split-p) | |
3441 ;; This is not a `frame' split, so we ignore the | |
3442 ;; other frames. | |
3443 (delete-other-windows) | |
3444 ;; This is a `frame' split, so we delete all windows | |
3445 ;; on all frames. | |
3446 (mapcar | |
3447 (lambda (frame) | |
3448 (unless (eq (cdr (assq 'minibuffer | |
3449 (frame-parameters frame))) | |
3450 'only) | |
3451 (select-frame frame) | |
3452 (delete-other-windows))) | |
3453 (frame-list))) | |
3454 ;; Just remove some windows. | |
3455 (gnus-remove-some-windows) | |
3456 (switch-to-buffer nntp-server-buffer)) | |
3457 (select-frame frame))) | |
3458 | |
3459 (switch-to-buffer nntp-server-buffer) | |
3460 (gnus-configure-frame split (get-buffer-window (current-buffer)))))) | |
3461 | |
3462 (defun gnus-all-windows-visible-p (split) | |
3463 "Say whether all buffers in SPLIT are currently visible. | |
3464 In particular, the value returned will be the window that | |
3465 should have point." | |
3466 (let ((stack (list split)) | |
3467 (all-visible t) | |
3468 type buffer win buf) | |
3469 (while (and (setq split (pop stack)) | |
3470 all-visible) | |
3471 ;; Be backwards compatible. | |
3472 (when (vectorp split) | |
3473 (setq split (append split nil))) | |
3474 (when (or (consp (car split)) | |
3475 (vectorp (car split))) | |
3476 (push 1.0 split) | |
3477 (push 'vertical split)) | |
3478 ;; The SPLIT might be something that is to be evaled to | |
3479 ;; return a new SPLIT. | |
3480 (while (and (not (assq (car split) gnus-window-to-buffer)) | |
3481 (gnus-functionp (car split))) | |
3482 (setq split (eval split))) | |
3483 | |
3484 (setq type (elt split 0)) | |
3485 (cond | |
3486 ;; Nothing here. | |
3487 ((null split) t) | |
3488 ;; A buffer. | |
3489 ((not (memq type '(horizontal vertical frame))) | |
3490 (setq buffer (cond ((stringp type) type) | |
3491 (t (cdr (assq type gnus-window-to-buffer))))) | |
3492 (unless buffer | |
3493 (error "Illegal buffer type: %s" type)) | |
3494 (when (setq buf (get-buffer (if (symbolp buffer) | |
3495 (symbol-value buffer) | |
3496 buffer))) | |
3497 (setq win (get-buffer-window buf t))) | |
3498 (if win | |
3499 (when (memq 'point split) | |
3500 (setq all-visible win)) | |
3501 (setq all-visible nil))) | |
3502 (t | |
3503 (when (eq type 'frame) | |
3504 (setq gnus-frame-split-p t)) | |
3505 (setq stack (append (cddr split) stack))))) | |
3506 (unless (eq all-visible t) | |
3507 all-visible))) | |
3508 | |
3509 (defun gnus-window-top-edge (&optional window) | |
3510 (nth 1 (window-edges window))) | |
3511 | |
3512 (defun gnus-remove-some-windows () | |
3513 (let ((buffers gnus-window-to-buffer) | |
3514 buf bufs lowest-buf lowest) | |
3515 (save-excursion | |
3516 ;; Remove windows on all known Gnus buffers. | |
3517 (while buffers | |
3518 (setq buf (cdar buffers)) | |
3519 (if (symbolp buf) | |
3520 (setq buf (and (boundp buf) (symbol-value buf)))) | |
3521 (and buf | |
3522 (get-buffer-window buf) | |
3523 (progn | |
3524 (setq bufs (cons buf bufs)) | |
3525 (pop-to-buffer buf) | |
3526 (if (or (not lowest) | |
3527 (< (gnus-window-top-edge) lowest)) | |
3528 (progn | |
3529 (setq lowest (gnus-window-top-edge)) | |
3530 (setq lowest-buf buf))))) | |
3531 (setq buffers (cdr buffers))) | |
3532 ;; Remove windows on *all* summary buffers. | |
3533 (walk-windows | |
3534 (lambda (win) | |
3535 (let ((buf (window-buffer win))) | |
3536 (if (string-match "^\\*Summary" (buffer-name buf)) | |
3537 (progn | |
3538 (setq bufs (cons buf bufs)) | |
3539 (pop-to-buffer buf) | |
3540 (if (or (not lowest) | |
3541 (< (gnus-window-top-edge) lowest)) | |
3542 (progn | |
3543 (setq lowest-buf buf) | |
3544 (setq lowest (gnus-window-top-edge))))))))) | |
3545 (and lowest-buf | |
3546 (progn | |
3547 (pop-to-buffer lowest-buf) | |
3548 (switch-to-buffer nntp-server-buffer))) | |
3549 (while bufs | |
3550 (and (not (eq (car bufs) lowest-buf)) | |
3551 (delete-windows-on (car bufs))) | |
3552 (setq bufs (cdr bufs)))))) | |
3553 | |
3554 (defun gnus-version (&optional arg) | |
3555 "Version number of this version of Gnus. | |
3556 If ARG, insert string at point." | |
3557 (interactive "P") | |
3558 (let ((methods gnus-valid-select-methods) | |
3559 (mess gnus-version) | |
3560 meth) | |
3561 ;; Go through all the legal select methods and add their version | |
3562 ;; numbers to the total version string. Only the backends that are | |
3563 ;; currently in use will have their message numbers taken into | |
3564 ;; consideration. | |
3565 (while methods | |
3566 (setq meth (intern (concat (caar methods) "-version"))) | |
3567 (and (boundp meth) | |
3568 (stringp (symbol-value meth)) | |
3569 (setq mess (concat mess "; " (symbol-value meth)))) | |
3570 (setq methods (cdr methods))) | |
3571 (if arg | |
3572 (insert (message mess)) | |
3573 (message mess)))) | |
3574 | |
3575 (defun gnus-info-find-node () | |
3576 "Find Info documentation of Gnus." | |
3577 (interactive) | |
3578 ;; Enlarge info window if needed. | |
3579 (let ((mode major-mode) | |
3580 gnus-info-buffer) | |
3581 (Info-goto-node (cadr (assq mode gnus-info-nodes))) | |
3582 (setq gnus-info-buffer (current-buffer)) | |
3583 (gnus-configure-windows 'info))) | |
3584 | |
3585 (defun gnus-days-between (date1 date2) | |
3586 ;; Return the number of days between date1 and date2. | |
3587 (- (gnus-day-number date1) (gnus-day-number date2))) | |
3588 | |
3589 (defun gnus-day-number (date) | |
3590 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) ) | |
3591 (timezone-parse-date date)))) | |
3592 (timezone-absolute-from-gregorian | |
3593 (nth 1 dat) (nth 2 dat) (car dat)))) | |
3594 | |
3595 (defun gnus-encode-date (date) | |
3596 "Convert DATE to internal time." | |
3597 (let* ((parse (timezone-parse-date date)) | |
3598 (date (mapcar (lambda (d) (and d (string-to-int d))) parse)) | |
3599 (time (mapcar 'string-to-int (timezone-parse-time (aref parse 3))))) | |
3600 (encode-time (caddr time) (cadr time) (car time) | |
3601 (caddr date) (cadr date) (car date) (nth 4 date)))) | |
3602 | |
3603 (defun gnus-time-minus (t1 t2) | |
3604 "Subtract two internal times." | |
3605 (let ((borrow (< (cadr t1) (cadr t2)))) | |
3606 (list (- (car t1) (car t2) (if borrow 1 0)) | |
3607 (- (+ (if borrow 65536 0) (cadr t1)) (cadr t2))))) | |
3608 | |
3609 (defun gnus-file-newer-than (file date) | |
3610 (let ((fdate (nth 5 (file-attributes file)))) | |
3611 (or (> (car fdate) (car date)) | |
3612 (and (= (car fdate) (car date)) | |
3613 (> (nth 1 fdate) (nth 1 date)))))) | |
3614 | |
3615 (defmacro gnus-local-set-keys (&rest plist) | |
3616 "Set the keys in PLIST in the current keymap." | |
3617 `(gnus-define-keys-1 (current-local-map) ',plist)) | |
3618 | |
3619 (defmacro gnus-define-keys (keymap &rest plist) | |
3620 "Define all keys in PLIST in KEYMAP." | |
3621 `(gnus-define-keys-1 (quote ,keymap) (quote ,plist))) | |
3622 | |
3623 (put 'gnus-define-keys 'lisp-indent-function 1) | |
3624 (put 'gnus-define-keys 'lisp-indent-hook 1) | |
3625 (put 'gnus-define-keymap 'lisp-indent-function 1) | |
3626 (put 'gnus-define-keymap 'lisp-indent-hook 1) | |
3627 | |
3628 (defmacro gnus-define-keymap (keymap &rest plist) | |
3629 "Define all keys in PLIST in KEYMAP." | |
3630 `(gnus-define-keys-1 ,keymap (quote ,plist))) | |
3631 | |
3632 (defun gnus-define-keys-1 (keymap plist) | |
3633 (when (null keymap) | |
3634 (error "Can't set keys in a null keymap")) | |
3635 (cond ((symbolp keymap) | |
3636 (setq keymap (symbol-value keymap))) | |
3637 ((keymapp keymap)) | |
3638 ((listp keymap) | |
3639 (set (car keymap) nil) | |
3640 (define-prefix-command (car keymap)) | |
3641 (define-key (symbol-value (caddr keymap)) (cadr keymap) (car keymap)) | |
3642 (setq keymap (symbol-value (car keymap))))) | |
3643 (let (key) | |
3644 (while plist | |
3645 (when (symbolp (setq key (pop plist))) | |
3646 (setq key (symbol-value key))) | |
3647 (define-key keymap key (pop plist))))) | |
3648 | |
3649 (defun gnus-group-read-only-p (&optional group) | |
3650 "Check whether GROUP supports editing or not. | |
3651 If GROUP is nil, `gnus-newsgroup-name' will be checked instead. Note | |
3652 that that variable is buffer-local to the summary buffers." | |
3653 (let ((group (or group gnus-newsgroup-name))) | |
3654 (not (gnus-check-backend-function 'request-replace-article group)))) | |
3655 | |
3656 (defun gnus-group-total-expirable-p (group) | |
3657 "Check whether GROUP is total-expirable or not." | |
3658 (let ((params (gnus-info-params (gnus-get-info group)))) | |
3659 (or (memq 'total-expire params) | |
3660 (cdr (assq 'total-expire params)) ; (total-expire . t) | |
3661 (and gnus-total-expirable-newsgroups ; Check var. | |
3662 (string-match gnus-total-expirable-newsgroups group))))) | |
3663 | |
3664 (defun gnus-group-auto-expirable-p (group) | |
3665 "Check whether GROUP is total-expirable or not." | |
3666 (let ((params (gnus-info-params (gnus-get-info group)))) | |
3667 (or (memq 'auto-expire params) | |
3668 (cdr (assq 'auto-expire params)) ; (auto-expire . t) | |
3669 (and gnus-auto-expirable-newsgroups ; Check var. | |
3670 (string-match gnus-auto-expirable-newsgroups group))))) | |
3671 | |
3672 (defun gnus-virtual-group-p (group) | |
3673 "Say whether GROUP is virtual or not." | |
3674 (memq 'virtual (assoc (symbol-name (car (gnus-find-method-for-group group))) | |
3675 gnus-valid-select-methods))) | |
3676 | |
3677 (defun gnus-news-group-p (group &optional article) | |
3678 "Return non-nil if GROUP (and ARTICLE) come from a news server." | |
3679 (or (gnus-member-of-valid 'post group) ; Ordinary news group. | |
3680 (and (gnus-member-of-valid 'post-mail group) ; Combined group. | |
3681 (eq (gnus-request-type group article) 'news)))) | |
3682 | |
3683 (defsubst gnus-simplify-subject-fully (subject) | |
3684 "Simplify a subject string according to the user's wishes." | |
3685 (cond | |
3686 ((null gnus-summary-gather-subject-limit) | |
3687 (gnus-simplify-subject-re subject)) | |
3688 ((eq gnus-summary-gather-subject-limit 'fuzzy) | |
3689 (gnus-simplify-subject-fuzzy subject)) | |
3690 ((numberp gnus-summary-gather-subject-limit) | |
3691 (gnus-limit-string (gnus-simplify-subject-re subject) | |
3692 gnus-summary-gather-subject-limit)) | |
3693 (t | |
3694 subject))) | |
3695 | |
3696 (defsubst gnus-subject-equal (s1 s2 &optional simple-first) | |
3697 "Check whether two subjects are equal. If optional argument | |
3698 simple-first is t, first argument is already simplified." | |
3699 (cond | |
3700 ((null simple-first) | |
3701 (equal (gnus-simplify-subject-fully s1) | |
3702 (gnus-simplify-subject-fully s2))) | |
3703 (t | |
3704 (equal s1 | |
3705 (gnus-simplify-subject-fully s2))))) | |
3706 | |
3707 ;; Returns a list of writable groups. | |
3708 (defun gnus-writable-groups () | |
3709 (let ((alist gnus-newsrc-alist) | |
3710 groups group) | |
3711 (while (setq group (car (pop alist))) | |
3712 (unless (gnus-group-read-only-p group) | |
3713 (push group groups))) | |
3714 (nreverse groups))) | |
3715 | |
3716 (defun gnus-completing-read (default prompt &rest args) | |
3717 ;; Like `completing-read', except that DEFAULT is the default argument. | |
3718 (let* ((prompt (if default | |
3719 (concat prompt " (default " default ") ") | |
3720 (concat prompt " "))) | |
3721 (answer (apply 'completing-read prompt args))) | |
3722 (if (or (null answer) (zerop (length answer))) | |
3723 default | |
3724 answer))) | |
3725 | |
3726 ;; Two silly functions to ensure that all `y-or-n-p' questions clear | |
3727 ;; the echo area. | |
3728 (defun gnus-y-or-n-p (prompt) | |
3729 (prog1 | |
3730 (y-or-n-p prompt) | |
3731 (message ""))) | |
3732 | |
3733 (defun gnus-yes-or-no-p (prompt) | |
3734 (prog1 | |
3735 (yes-or-no-p prompt) | |
3736 (message ""))) | |
3737 | |
3738 ;; Check whether to use long file names. | |
3739 (defun gnus-use-long-file-name (symbol) | |
3740 ;; The variable has to be set... | |
3741 (and gnus-use-long-file-name | |
3742 ;; If it isn't a list, then we return t. | |
3743 (or (not (listp gnus-use-long-file-name)) | |
3744 ;; If it is a list, and the list contains `symbol', we | |
3745 ;; return nil. | |
3746 (not (memq symbol gnus-use-long-file-name))))) | |
3747 | |
3748 ;; I suspect there's a better way, but I haven't taken the time to do | |
3749 ;; it yet. -erik selberg@cs.washington.edu | |
3750 (defun gnus-dd-mmm (messy-date) | |
3751 "Return a string like DD-MMM from a big messy string" | |
3752 (let ((datevec (condition-case () (timezone-parse-date messy-date) | |
3753 (error nil)))) | |
3754 (if (not datevec) | |
3755 "??-???" | |
3756 (format "%2s-%s" | |
3757 (condition-case () | |
3758 ;; Make sure leading zeroes are stripped. | |
3759 (number-to-string (string-to-number (aref datevec 2))) | |
3760 (error "??")) | |
3761 (capitalize | |
3762 (or (car | |
3763 (nth (1- (string-to-number (aref datevec 1))) | |
3764 timezone-months-assoc)) | |
3765 "???")))))) | |
3766 | |
3767 (defun gnus-mode-string-quote (string) | |
3768 "Quote all \"%\" in STRING." | |
3769 (save-excursion | |
3770 (gnus-set-work-buffer) | |
3771 (insert string) | |
3772 (goto-char (point-min)) | |
3773 (while (search-forward "%" nil t) | |
3774 (insert "%")) | |
3775 (buffer-string))) | |
3776 | |
3777 ;; Make a hash table (default and minimum size is 255). | |
3778 ;; Optional argument HASHSIZE specifies the table size. | |
3779 (defun gnus-make-hashtable (&optional hashsize) | |
3780 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0)) | |
3781 | |
3782 ;; Make a number that is suitable for hashing; bigger than MIN and one | |
3783 ;; less than 2^x. | |
3784 (defun gnus-create-hash-size (min) | |
3785 (let ((i 1)) | |
3786 (while (< i min) | |
3787 (setq i (* 2 i))) | |
3788 (1- i))) | |
3789 | |
3790 ;; Show message if message has a lower level than `gnus-verbose'. | |
3791 ;; Guideline for numbers: | |
3792 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages | |
3793 ;; for things that take a long time, 7 - not very important messages | |
3794 ;; on stuff, 9 - messages inside loops. | |
3795 (defun gnus-message (level &rest args) | |
3796 (if (<= level gnus-verbose) | |
3797 (apply 'message args) | |
3798 ;; We have to do this format thingy here even if the result isn't | |
3799 ;; shown - the return value has to be the same as the return value | |
3800 ;; from `message'. | |
3801 (apply 'format args))) | |
3802 | |
3803 (defun gnus-error (level &rest args) | |
3804 "Beep an error if `gnus-verbose' is on LEVEL or less." | |
3805 (when (<= (floor level) gnus-verbose) | |
3806 (apply 'message args) | |
3807 (ding) | |
3808 (let (duration) | |
3809 (when (and (floatp level) | |
3810 (not (zerop (setq duration (* 10 (- level (floor level))))))) | |
3811 (sit-for duration)))) | |
3812 nil) | |
3813 | |
3814 ;; Generate a unique new group name. | |
3815 (defun gnus-generate-new-group-name (leaf) | |
3816 (let ((name leaf) | |
3817 (num 0)) | |
3818 (while (gnus-gethash name gnus-newsrc-hashtb) | |
3819 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">"))) | |
3820 name)) | |
3821 | |
3822 (defsubst gnus-hide-text (b e props) | |
3823 "Set text PROPS on the B to E region, extending `intangible' 1 past B." | |
3824 (gnus-add-text-properties b e props) | |
3825 (when (memq 'intangible props) | |
3826 (gnus-put-text-property (max (1- b) (point-min)) | |
3827 b 'intangible (cddr (memq 'intangible props))))) | |
3828 | |
3829 (defsubst gnus-unhide-text (b e) | |
3830 "Remove hidden text properties from region between B and E." | |
3831 (remove-text-properties b e gnus-hidden-properties) | |
3832 (when (memq 'intangible gnus-hidden-properties) | |
3833 (gnus-put-text-property (max (1- b) (point-min)) | |
3834 b 'intangible nil))) | |
3835 | |
3836 (defun gnus-hide-text-type (b e type) | |
3837 "Hide text of TYPE between B and E." | |
3838 (gnus-hide-text b e (cons 'gnus-type (cons type gnus-hidden-properties)))) | |
3839 | |
3840 (defun gnus-parent-headers (headers &optional generation) | |
3841 "Return the headers of the GENERATIONeth parent of HEADERS." | |
3842 (unless generation | |
3843 (setq generation 1)) | |
3844 (let (references parent) | |
3845 (while (and headers (not (zerop generation))) | |
3846 (setq references (mail-header-references headers)) | |
3847 (when (and references | |
3848 (setq parent (gnus-parent-id references)) | |
3849 (setq headers (car (gnus-id-to-thread parent)))) | |
3850 (decf generation))) | |
3851 headers)) | |
3852 | |
3853 (defun gnus-parent-id (references) | |
3854 "Return the last Message-ID in REFERENCES." | |
3855 (when (and references | |
3856 (string-match "\\(<[^\n<>]+>\\)[ \t\n]*\\'" references)) | |
3857 (substring references (match-beginning 1) (match-end 1)))) | |
3858 | |
3859 (defun gnus-split-references (references) | |
3860 "Return a list of Message-IDs in REFERENCES." | |
3861 (let ((beg 0) | |
3862 ids) | |
3863 (while (string-match "<[^>]+>" references beg) | |
3864 (push (substring references (match-beginning 0) (setq beg (match-end 0))) | |
3865 ids)) | |
3866 (nreverse ids))) | |
3867 | |
3868 (defun gnus-buffer-live-p (buffer) | |
3869 "Say whether BUFFER is alive or not." | |
3870 (and buffer | |
3871 (get-buffer buffer) | |
3872 (buffer-name (get-buffer buffer)))) | |
3873 | |
3874 (defun gnus-ephemeral-group-p (group) | |
3875 "Say whether GROUP is ephemeral or not." | |
3876 (gnus-group-get-parameter group 'quit-config)) | |
3877 | |
3878 (defun gnus-group-quit-config (group) | |
3879 "Return the quit-config of GROUP." | |
3880 (gnus-group-get-parameter group 'quit-config)) | |
3881 | |
3882 (defun gnus-simplify-mode-line () | |
3883 "Make mode lines a bit simpler." | |
3884 (setq mode-line-modified "-- ") | |
3885 (when (listp mode-line-format) | |
3886 (make-local-variable 'mode-line-format) | |
3887 (setq mode-line-format (copy-sequence mode-line-format)) | |
3888 (when (equal (nth 3 mode-line-format) " ") | |
3889 (setcar (nthcdr 3 mode-line-format) " ")))) | |
3890 | |
3891 ;;; List and range functions | |
3892 | |
3893 (defun gnus-last-element (list) | |
3894 "Return last element of LIST." | |
3895 (while (cdr list) | |
3896 (setq list (cdr list))) | |
3897 (car list)) | |
3898 | |
3899 (defun gnus-copy-sequence (list) | |
3900 "Do a complete, total copy of a list." | |
3901 (if (and (consp list) (not (consp (cdr list)))) | |
3902 (cons (car list) (cdr list)) | |
3903 (mapcar (lambda (elem) (if (consp elem) | |
3904 (if (consp (cdr elem)) | |
3905 (gnus-copy-sequence elem) | |
3906 (cons (car elem) (cdr elem))) | |
3907 elem)) | |
3908 list))) | |
3909 | |
3910 (defun gnus-set-difference (list1 list2) | |
3911 "Return a list of elements of LIST1 that do not appear in LIST2." | |
3912 (let ((list1 (copy-sequence list1))) | |
3913 (while list2 | |
3914 (setq list1 (delq (car list2) list1)) | |
3915 (setq list2 (cdr list2))) | |
3916 list1)) | |
3917 | |
3918 (defun gnus-sorted-complement (list1 list2) | |
3919 "Return a list of elements of LIST1 that do not appear in LIST2. | |
3920 Both lists have to be sorted over <." | |
3921 (let (out) | |
3922 (if (or (null list1) (null list2)) | |
3923 (or list1 list2) | |
3924 (while (and list1 list2) | |
3925 (cond ((= (car list1) (car list2)) | |
3926 (setq list1 (cdr list1) | |
3927 list2 (cdr list2))) | |
3928 ((< (car list1) (car list2)) | |
3929 (setq out (cons (car list1) out)) | |
3930 (setq list1 (cdr list1))) | |
3931 (t | |
3932 (setq out (cons (car list2) out)) | |
3933 (setq list2 (cdr list2))))) | |
3934 (nconc (nreverse out) (or list1 list2))))) | |
3935 | |
3936 (defun gnus-intersection (list1 list2) | |
3937 (let ((result nil)) | |
3938 (while list2 | |
3939 (if (memq (car list2) list1) | |
3940 (setq result (cons (car list2) result))) | |
3941 (setq list2 (cdr list2))) | |
3942 result)) | |
3943 | |
3944 (defun gnus-sorted-intersection (list1 list2) | |
3945 ;; LIST1 and LIST2 have to be sorted over <. | |
3946 (let (out) | |
3947 (while (and list1 list2) | |
3948 (cond ((= (car list1) (car list2)) | |
3949 (setq out (cons (car list1) out) | |
3950 list1 (cdr list1) | |
3951 list2 (cdr list2))) | |
3952 ((< (car list1) (car list2)) | |
3953 (setq list1 (cdr list1))) | |
3954 (t | |
3955 (setq list2 (cdr list2))))) | |
3956 (nreverse out))) | |
3957 | |
3958 (defun gnus-set-sorted-intersection (list1 list2) | |
3959 ;; LIST1 and LIST2 have to be sorted over <. | |
3960 ;; This function modifies LIST1. | |
3961 (let* ((top (cons nil list1)) | |
3962 (prev top)) | |
3963 (while (and list1 list2) | |
3964 (cond ((= (car list1) (car list2)) | |
3965 (setq prev list1 | |
3966 list1 (cdr list1) | |
3967 list2 (cdr list2))) | |
3968 ((< (car list1) (car list2)) | |
3969 (setcdr prev (cdr list1)) | |
3970 (setq list1 (cdr list1))) | |
3971 (t | |
3972 (setq list2 (cdr list2))))) | |
3973 (setcdr prev nil) | |
3974 (cdr top))) | |
3975 | |
3976 (defun gnus-compress-sequence (numbers &optional always-list) | |
3977 "Convert list of numbers to a list of ranges or a single range. | |
3978 If ALWAYS-LIST is non-nil, this function will always release a list of | |
3979 ranges." | |
3980 (let* ((first (car numbers)) | |
3981 (last (car numbers)) | |
3982 result) | |
3983 (if (null numbers) | |
3984 nil | |
3985 (if (not (listp (cdr numbers))) | |
3986 numbers | |
3987 (while numbers | |
3988 (cond ((= last (car numbers)) nil) ;Omit duplicated number | |
3989 ((= (1+ last) (car numbers)) ;Still in sequence | |
3990 (setq last (car numbers))) | |
3991 (t ;End of one sequence | |
3992 (setq result | |
3993 (cons (if (= first last) first | |
3994 (cons first last)) result)) | |
3995 (setq first (car numbers)) | |
3996 (setq last (car numbers)))) | |
3997 (setq numbers (cdr numbers))) | |
3998 (if (and (not always-list) (null result)) | |
3999 (if (= first last) (list first) (cons first last)) | |
4000 (nreverse (cons (if (= first last) first (cons first last)) | |
4001 result))))))) | |
4002 | |
4003 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range) | |
4004 (defun gnus-uncompress-range (ranges) | |
4005 "Expand a list of ranges into a list of numbers. | |
4006 RANGES is either a single range on the form `(num . num)' or a list of | |
4007 these ranges." | |
4008 (let (first last result) | |
4009 (cond | |
4010 ((null ranges) | |
4011 nil) | |
4012 ((not (listp (cdr ranges))) | |
4013 (setq first (car ranges)) | |
4014 (setq last (cdr ranges)) | |
4015 (while (<= first last) | |
4016 (setq result (cons first result)) | |
4017 (setq first (1+ first))) | |
4018 (nreverse result)) | |
4019 (t | |
4020 (while ranges | |
4021 (if (atom (car ranges)) | |
4022 (if (numberp (car ranges)) | |
4023 (setq result (cons (car ranges) result))) | |
4024 (setq first (caar ranges)) | |
4025 (setq last (cdar ranges)) | |
4026 (while (<= first last) | |
4027 (setq result (cons first result)) | |
4028 (setq first (1+ first)))) | |
4029 (setq ranges (cdr ranges))) | |
4030 (nreverse result))))) | |
4031 | |
4032 (defun gnus-add-to-range (ranges list) | |
4033 "Return a list of ranges that has all articles from both RANGES and LIST. | |
4034 Note: LIST has to be sorted over `<'." | |
4035 (if (not ranges) | |
4036 (gnus-compress-sequence list t) | |
4037 (setq list (copy-sequence list)) | |
4038 (or (listp (cdr ranges)) | |
4039 (setq ranges (list ranges))) | |
4040 (let ((out ranges) | |
4041 ilist lowest highest temp) | |
4042 (while (and ranges list) | |
4043 (setq ilist list) | |
4044 (setq lowest (or (and (atom (car ranges)) (car ranges)) | |
4045 (caar ranges))) | |
4046 (while (and list (cdr list) (< (cadr list) lowest)) | |
4047 (setq list (cdr list))) | |
4048 (if (< (car ilist) lowest) | |
4049 (progn | |
4050 (setq temp list) | |
4051 (setq list (cdr list)) | |
4052 (setcdr temp nil) | |
4053 (setq out (nconc (gnus-compress-sequence ilist t) out)))) | |
4054 (setq highest (or (and (atom (car ranges)) (car ranges)) | |
4055 (cdar ranges))) | |
4056 (while (and list (<= (car list) highest)) | |
4057 (setq list (cdr list))) | |
4058 (setq ranges (cdr ranges))) | |
4059 (if list | |
4060 (setq out (nconc (gnus-compress-sequence list t) out))) | |
4061 (setq out (sort out (lambda (r1 r2) | |
4062 (< (or (and (atom r1) r1) (car r1)) | |
4063 (or (and (atom r2) r2) (car r2)))))) | |
4064 (setq ranges out) | |
4065 (while ranges | |
4066 (if (atom (car ranges)) | |
4067 (if (cdr ranges) | |
4068 (if (atom (cadr ranges)) | |
4069 (if (= (1+ (car ranges)) (cadr ranges)) | |
4070 (progn | |
4071 (setcar ranges (cons (car ranges) | |
4072 (cadr ranges))) | |
4073 (setcdr ranges (cddr ranges)))) | |
4074 (if (= (1+ (car ranges)) (caadr ranges)) | |
4075 (progn | |
4076 (setcar (cadr ranges) (car ranges)) | |
4077 (setcar ranges (cadr ranges)) | |
4078 (setcdr ranges (cddr ranges)))))) | |
4079 (if (cdr ranges) | |
4080 (if (atom (cadr ranges)) | |
4081 (if (= (1+ (cdar ranges)) (cadr ranges)) | |
4082 (progn | |
4083 (setcdr (car ranges) (cadr ranges)) | |
4084 (setcdr ranges (cddr ranges)))) | |
4085 (if (= (1+ (cdar ranges)) (caadr ranges)) | |
4086 (progn | |
4087 (setcdr (car ranges) (cdadr ranges)) | |
4088 (setcdr ranges (cddr ranges))))))) | |
4089 (setq ranges (cdr ranges))) | |
4090 out))) | |
4091 | |
4092 (defun gnus-remove-from-range (ranges list) | |
4093 "Return a list of ranges that has all articles from LIST removed from RANGES. | |
4094 Note: LIST has to be sorted over `<'." | |
4095 ;; !!! This function shouldn't look like this, but I've got a headache. | |
4096 (gnus-compress-sequence | |
4097 (gnus-sorted-complement | |
4098 (gnus-uncompress-range ranges) list))) | |
4099 | |
4100 (defun gnus-member-of-range (number ranges) | |
4101 (if (not (listp (cdr ranges))) | |
4102 (and (>= number (car ranges)) | |
4103 (<= number (cdr ranges))) | |
4104 (let ((not-stop t)) | |
4105 (while (and ranges | |
4106 (if (numberp (car ranges)) | |
4107 (>= number (car ranges)) | |
4108 (>= number (caar ranges))) | |
4109 not-stop) | |
4110 (if (if (numberp (car ranges)) | |
4111 (= number (car ranges)) | |
4112 (and (>= number (caar ranges)) | |
4113 (<= number (cdar ranges)))) | |
4114 (setq not-stop nil)) | |
4115 (setq ranges (cdr ranges))) | |
4116 (not not-stop)))) | |
4117 | |
4118 (defun gnus-range-length (range) | |
4119 "Return the length RANGE would have if uncompressed." | |
4120 (length (gnus-uncompress-range range))) | |
4121 | |
4122 (defun gnus-sublist-p (list sublist) | |
4123 "Test whether all elements in SUBLIST are members of LIST." | |
4124 (let ((sublistp t)) | |
4125 (while sublist | |
4126 (unless (memq (pop sublist) list) | |
4127 (setq sublistp nil | |
4128 sublist nil))) | |
4129 sublistp)) | |
4130 | |
4131 | |
4132 ;;; | |
4133 ;;; Gnus group mode | |
4134 ;;; | |
4135 | |
4136 (defvar gnus-group-mode-map nil) | |
4137 (put 'gnus-group-mode 'mode-class 'special) | |
4138 | |
4139 (unless gnus-group-mode-map | |
4140 (setq gnus-group-mode-map (make-keymap)) | |
4141 (suppress-keymap gnus-group-mode-map) | |
4142 | |
4143 (gnus-define-keys gnus-group-mode-map | |
4144 " " gnus-group-read-group | |
4145 "=" gnus-group-select-group | |
4146 "\r" gnus-group-select-group | |
4147 "\M-\r" gnus-group-quick-select-group | |
4148 "j" gnus-group-jump-to-group | |
4149 "n" gnus-group-next-unread-group | |
4150 "p" gnus-group-prev-unread-group | |
4151 "\177" gnus-group-prev-unread-group | |
4152 [delete] gnus-group-prev-unread-group | |
4153 "N" gnus-group-next-group | |
4154 "P" gnus-group-prev-group | |
4155 "\M-n" gnus-group-next-unread-group-same-level | |
4156 "\M-p" gnus-group-prev-unread-group-same-level | |
4157 "," gnus-group-best-unread-group | |
4158 "." gnus-group-first-unread-group | |
4159 "u" gnus-group-unsubscribe-current-group | |
4160 "U" gnus-group-unsubscribe-group | |
4161 "c" gnus-group-catchup-current | |
4162 "C" gnus-group-catchup-current-all | |
4163 "l" gnus-group-list-groups | |
4164 "L" gnus-group-list-all-groups | |
4165 "m" gnus-group-mail | |
4166 "g" gnus-group-get-new-news | |
4167 "\M-g" gnus-group-get-new-news-this-group | |
4168 "R" gnus-group-restart | |
4169 "r" gnus-group-read-init-file | |
4170 "B" gnus-group-browse-foreign-server | |
4171 "b" gnus-group-check-bogus-groups | |
4172 "F" gnus-find-new-newsgroups | |
4173 "\C-c\C-d" gnus-group-describe-group | |
4174 "\M-d" gnus-group-describe-all-groups | |
4175 "\C-c\C-a" gnus-group-apropos | |
4176 "\C-c\M-\C-a" gnus-group-description-apropos | |
4177 "a" gnus-group-post-news | |
4178 "\ek" gnus-group-edit-local-kill | |
4179 "\eK" gnus-group-edit-global-kill | |
4180 "\C-k" gnus-group-kill-group | |
4181 "\C-y" gnus-group-yank-group | |
4182 "\C-w" gnus-group-kill-region | |
4183 "\C-x\C-t" gnus-group-transpose-groups | |
4184 "\C-c\C-l" gnus-group-list-killed | |
4185 "\C-c\C-x" gnus-group-expire-articles | |
4186 "\C-c\M-\C-x" gnus-group-expire-all-groups | |
4187 "V" gnus-version | |
4188 "s" gnus-group-save-newsrc | |
4189 "z" gnus-group-suspend | |
4190 "Z" gnus-group-clear-dribble | |
4191 "q" gnus-group-exit | |
4192 "Q" gnus-group-quit | |
4193 "?" gnus-group-describe-briefly | |
4194 "\C-c\C-i" gnus-info-find-node | |
4195 "\M-e" gnus-group-edit-group-method | |
4196 "^" gnus-group-enter-server-mode | |
4197 gnus-mouse-2 gnus-mouse-pick-group | |
4198 "<" beginning-of-buffer | |
4199 ">" end-of-buffer | |
4200 "\C-c\C-b" gnus-bug | |
4201 "\C-c\C-s" gnus-group-sort-groups | |
4202 "t" gnus-topic-mode | |
4203 "\C-c\M-g" gnus-activate-all-groups | |
4204 "\M-&" gnus-group-universal-argument | |
4205 "#" gnus-group-mark-group | |
4206 "\M-#" gnus-group-unmark-group) | |
4207 | |
4208 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map) | |
4209 "m" gnus-group-mark-group | |
4210 "u" gnus-group-unmark-group | |
4211 "w" gnus-group-mark-region | |
4212 "m" gnus-group-mark-buffer | |
4213 "r" gnus-group-mark-regexp | |
4214 "U" gnus-group-unmark-all-groups) | |
4215 | |
4216 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map) | |
4217 "d" gnus-group-make-directory-group | |
4218 "h" gnus-group-make-help-group | |
4219 "a" gnus-group-make-archive-group | |
4220 "k" gnus-group-make-kiboze-group | |
4221 "m" gnus-group-make-group | |
4222 "E" gnus-group-edit-group | |
4223 "e" gnus-group-edit-group-method | |
4224 "p" gnus-group-edit-group-parameters | |
4225 "v" gnus-group-add-to-virtual | |
4226 "V" gnus-group-make-empty-virtual | |
4227 "D" gnus-group-enter-directory | |
4228 "f" gnus-group-make-doc-group | |
4229 "r" gnus-group-rename-group | |
4230 "\177" gnus-group-delete-group | |
4231 [delete] gnus-group-delete-group) | |
4232 | |
4233 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map) | |
4234 "b" gnus-group-brew-soup | |
4235 "w" gnus-soup-save-areas | |
4236 "s" gnus-soup-send-replies | |
4237 "p" gnus-soup-pack-packet | |
4238 "r" nnsoup-pack-replies) | |
4239 | |
4240 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map) | |
4241 "s" gnus-group-sort-groups | |
4242 "a" gnus-group-sort-groups-by-alphabet | |
4243 "u" gnus-group-sort-groups-by-unread | |
4244 "l" gnus-group-sort-groups-by-level | |
4245 "v" gnus-group-sort-groups-by-score | |
4246 "r" gnus-group-sort-groups-by-rank | |
4247 "m" gnus-group-sort-groups-by-method) | |
4248 | |
4249 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map) | |
4250 "k" gnus-group-list-killed | |
4251 "z" gnus-group-list-zombies | |
4252 "s" gnus-group-list-groups | |
4253 "u" gnus-group-list-all-groups | |
4254 "A" gnus-group-list-active | |
4255 "a" gnus-group-apropos | |
4256 "d" gnus-group-description-apropos | |
4257 "m" gnus-group-list-matching | |
4258 "M" gnus-group-list-all-matching | |
4259 "l" gnus-group-list-level) | |
4260 | |
4261 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map) | |
4262 "f" gnus-score-flush-cache) | |
4263 | |
4264 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map) | |
4265 "f" gnus-group-fetch-faq) | |
4266 | |
4267 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map) | |
4268 "l" gnus-group-set-current-level | |
4269 "t" gnus-group-unsubscribe-current-group | |
4270 "s" gnus-group-unsubscribe-group | |
4271 "k" gnus-group-kill-group | |
4272 "y" gnus-group-yank-group | |
4273 "w" gnus-group-kill-region | |
4274 "\C-k" gnus-group-kill-level | |
4275 "z" gnus-group-kill-all-zombies)) | |
4276 | |
4277 (defun gnus-group-mode () | |
4278 "Major mode for reading news. | |
4279 | |
4280 All normal editing commands are switched off. | |
4281 \\<gnus-group-mode-map> | |
4282 The group buffer lists (some of) the groups available. For instance, | |
4283 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]' | |
4284 lists all zombie groups. | |
4285 | |
4286 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe | |
4287 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'. | |
4288 | |
4289 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]'). | |
4290 | |
4291 The following commands are available: | |
4292 | |
4293 \\{gnus-group-mode-map}" | |
4294 (interactive) | |
4295 (when (and menu-bar-mode | |
4296 (gnus-visual-p 'group-menu 'menu)) | |
4297 (gnus-group-make-menu-bar)) | |
4298 (kill-all-local-variables) | |
4299 (gnus-simplify-mode-line) | |
4300 (setq major-mode 'gnus-group-mode) | |
4301 (setq mode-name "Group") | |
4302 (gnus-group-set-mode-line) | |
4303 (setq mode-line-process nil) | |
4304 (use-local-map gnus-group-mode-map) | |
4305 (buffer-disable-undo (current-buffer)) | |
4306 (setq truncate-lines t) | |
4307 (setq buffer-read-only t) | |
4308 (gnus-make-local-hook 'post-command-hook) | |
4309 (gnus-add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t) | |
4310 (run-hooks 'gnus-group-mode-hook)) | |
4311 | |
4312 (defun gnus-clear-inboxes-moved () | |
4313 (setq nnmail-moved-inboxes nil)) | |
4314 | |
4315 (defun gnus-mouse-pick-group (e) | |
4316 "Enter the group under the mouse pointer." | |
4317 (interactive "e") | |
4318 (mouse-set-point e) | |
4319 (gnus-group-read-group nil)) | |
4320 | |
4321 ;; Look at LEVEL and find out what the level is really supposed to be. | |
4322 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens | |
4323 ;; will depend on whether `gnus-group-use-permanent-levels' is used. | |
4324 (defun gnus-group-default-level (&optional level number-or-nil) | |
4325 (cond | |
4326 (gnus-group-use-permanent-levels | |
4327 (or (setq gnus-group-use-permanent-levels | |
4328 (or level (if (numberp gnus-group-use-permanent-levels) | |
4329 gnus-group-use-permanent-levels | |
4330 (or gnus-group-default-list-level | |
4331 gnus-level-subscribed)))) | |
4332 gnus-group-default-list-level gnus-level-subscribed)) | |
4333 (number-or-nil | |
4334 level) | |
4335 (t | |
4336 (or level gnus-group-default-list-level gnus-level-subscribed)))) | |
4337 | |
4338 ;;;###autoload | |
4339 (defun gnus-slave-no-server (&optional arg) | |
4340 "Read network news as a slave, without connecting to local server" | |
4341 (interactive "P") | |
4342 (gnus-no-server arg t)) | |
4343 | |
4344 ;;;###autoload | |
4345 (defun gnus-no-server (&optional arg slave) | |
4346 "Read network news. | |
4347 If ARG is a positive number, Gnus will use that as the | |
4348 startup level. If ARG is nil, Gnus will be started at level 2. | |
4349 If ARG is non-nil and not a positive number, Gnus will | |
4350 prompt the user for the name of an NNTP server to use. | |
4351 As opposed to `gnus', this command will not connect to the local server." | |
4352 (interactive "P") | |
4353 (let ((val (or arg (1- gnus-level-default-subscribed)))) | |
4354 (gnus val t slave) | |
4355 (make-local-variable 'gnus-group-use-permanent-levels) | |
4356 (setq gnus-group-use-permanent-levels val))) | |
4357 | |
4358 ;;;###autoload | |
4359 (defun gnus-slave (&optional arg) | |
4360 "Read news as a slave." | |
4361 (interactive "P") | |
4362 (gnus arg nil 'slave)) | |
4363 | |
4364 ;;;###autoload | |
4365 (defun gnus-other-frame (&optional arg) | |
4366 "Pop up a frame to read news." | |
4367 (interactive "P") | |
4368 (if (get-buffer gnus-group-buffer) | |
4369 (let ((pop-up-frames t)) | |
4370 (gnus arg)) | |
4371 (select-frame (make-frame)) | |
4372 (gnus arg))) | |
4373 | |
4374 ;;;###autoload | |
4375 (defun gnus (&optional arg dont-connect slave) | |
4376 "Read network news. | |
4377 If ARG is non-nil and a positive number, Gnus will use that as the | |
4378 startup level. If ARG is non-nil and not a positive number, Gnus will | |
4379 prompt the user for the name of an NNTP server to use." | |
4380 (interactive "P") | |
4381 | |
4382 (if (get-buffer gnus-group-buffer) | |
4383 (progn | |
4384 (switch-to-buffer gnus-group-buffer) | |
4385 (gnus-group-get-new-news)) | |
4386 | |
4387 (gnus-clear-system) | |
4388 (nnheader-init-server-buffer) | |
4389 (gnus-read-init-file) | |
4390 (setq gnus-slave slave) | |
4391 | |
4392 (gnus-group-setup-buffer) | |
4393 (let ((buffer-read-only nil)) | |
4394 (erase-buffer) | |
4395 (if (not gnus-inhibit-startup-message) | |
4396 (progn | |
4397 (gnus-group-startup-message) | |
4398 (sit-for 0)))) | |
4399 | |
4400 (let ((level (and (numberp arg) (> arg 0) arg)) | |
4401 did-connect) | |
4402 (unwind-protect | |
4403 (progn | |
4404 (or dont-connect | |
4405 (setq did-connect | |
4406 (gnus-start-news-server (and arg (not level)))))) | |
4407 (if (and (not dont-connect) | |
4408 (not did-connect)) | |
4409 (gnus-group-quit) | |
4410 (run-hooks 'gnus-startup-hook) | |
4411 ;; NNTP server is successfully open. | |
4412 | |
4413 ;; Find the current startup file name. | |
4414 (setq gnus-current-startup-file | |
4415 (gnus-make-newsrc-file gnus-startup-file)) | |
4416 | |
4417 ;; Read the dribble file. | |
4418 (when (or gnus-slave gnus-use-dribble-file) | |
4419 (gnus-dribble-read-file)) | |
4420 | |
4421 ;; Allow using GroupLens predictions. | |
4422 (when gnus-use-grouplens | |
4423 (bbb-login) | |
4424 (add-hook 'gnus-summary-mode-hook 'gnus-grouplens-mode)) | |
4425 | |
4426 (gnus-summary-make-display-table) | |
4427 ;; Do the actual startup. | |
4428 (gnus-setup-news nil level dont-connect) | |
4429 ;; Generate the group buffer. | |
4430 (gnus-group-list-groups level) | |
4431 (gnus-group-first-unread-group) | |
4432 (gnus-configure-windows 'group) | |
4433 (gnus-group-set-mode-line)))))) | |
4434 | |
4435 (defun gnus-unload () | |
4436 "Unload all Gnus features." | |
4437 (interactive) | |
4438 (or (boundp 'load-history) | |
4439 (error "Sorry, `gnus-unload' is not implemented in this Emacs version.")) | |
4440 (let ((history load-history) | |
4441 feature) | |
4442 (while history | |
4443 (and (string-match "^\\(gnus\\|nn\\)" (caar history)) | |
4444 (setq feature (cdr (assq 'provide (car history)))) | |
4445 (unload-feature feature 'force)) | |
4446 (setq history (cdr history))))) | |
4447 | |
4448 (defun gnus-compile () | |
4449 "Byte-compile the user-defined format specs." | |
4450 (interactive) | |
4451 (let ((entries gnus-format-specs) | |
4452 entry gnus-tmp-func) | |
4453 (save-excursion | |
4454 (gnus-message 7 "Compiling format specs...") | |
4455 | |
4456 (while entries | |
4457 (setq entry (pop entries)) | |
4458 (if (eq (car entry) 'version) | |
4459 (setq gnus-format-specs (delq entry gnus-format-specs)) | |
4460 (when (and (listp (caddr entry)) | |
4461 (not (eq 'byte-code (caaddr entry)))) | |
4462 (fset 'gnus-tmp-func | |
4463 `(lambda () ,(caddr entry))) | |
4464 (byte-compile 'gnus-tmp-func) | |
4465 (setcar (cddr entry) (gnus-byte-code 'gnus-tmp-func))))) | |
4466 | |
4467 (push (cons 'version emacs-version) gnus-format-specs) | |
4468 | |
4469 (gnus-message 7 "Compiling user specs...done")))) | |
4470 | |
4471 (defun gnus-indent-rigidly (start end arg) | |
4472 "Indent rigidly using only spaces and no tabs." | |
4473 (save-excursion | |
4474 (save-restriction | |
4475 (narrow-to-region start end) | |
4476 (indent-rigidly start end arg) | |
4477 (goto-char (point-min)) | |
4478 (while (search-forward "\t" nil t) | |
4479 (replace-match " " t t))))) | |
4480 | |
4481 (defun gnus-group-startup-message (&optional x y) | |
4482 "Insert startup message in current buffer." | |
4483 ;; Insert the message. | |
4484 (erase-buffer) | |
4485 (insert | |
4486 (format " %s | |
4487 _ ___ _ _ | |
4488 _ ___ __ ___ __ _ ___ | |
4489 __ _ ___ __ ___ | |
4490 _ ___ _ | |
4491 _ _ __ _ | |
4492 ___ __ _ | |
4493 __ _ | |
4494 _ _ _ | |
4495 _ _ _ | |
4496 _ _ _ | |
4497 __ ___ | |
4498 _ _ _ _ | |
4499 _ _ | |
4500 _ _ | |
4501 _ _ | |
4502 _ | |
4503 __ | |
4504 | |
4505 " | |
4506 "")) | |
4507 ;; And then hack it. | |
4508 (gnus-indent-rigidly (point-min) (point-max) | |
4509 (/ (max (- (window-width) (or x 46)) 0) 2)) | |
4510 (goto-char (point-min)) | |
4511 (forward-line 1) | |
4512 (let* ((pheight (count-lines (point-min) (point-max))) | |
4513 (wheight (window-height)) | |
4514 (rest (- wheight pheight))) | |
4515 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n))) | |
4516 ;; Fontify some. | |
4517 (goto-char (point-min)) | |
4518 (and (search-forward "Praxis" nil t) | |
4519 (gnus-put-text-property (match-beginning 0) (match-end 0) 'face 'bold)) | |
4520 (goto-char (point-min)) | |
4521 (let* ((mode-string (gnus-group-set-mode-line))) | |
4522 (setq mode-line-buffer-identification | |
4523 (list (concat gnus-version (substring (car mode-string) 4)))) | |
4524 (set-buffer-modified-p t))) | |
4525 | |
4526 (defun gnus-group-setup-buffer () | |
4527 (or (get-buffer gnus-group-buffer) | |
4528 (progn | |
4529 (switch-to-buffer gnus-group-buffer) | |
4530 (gnus-add-current-to-buffer-list) | |
4531 (gnus-group-mode) | |
4532 (and gnus-carpal (gnus-carpal-setup-buffer 'group))))) | |
4533 | |
4534 (defun gnus-group-list-groups (&optional level unread lowest) | |
4535 "List newsgroups with level LEVEL or lower that have unread articles. | |
4536 Default is all subscribed groups. | |
4537 If argument UNREAD is non-nil, groups with no unread articles are also | |
4538 listed." | |
4539 (interactive (list (if current-prefix-arg | |
4540 (prefix-numeric-value current-prefix-arg) | |
4541 (or | |
4542 (gnus-group-default-level nil t) | |
4543 gnus-group-default-list-level | |
4544 gnus-level-subscribed)))) | |
4545 (or level | |
4546 (setq level (car gnus-group-list-mode) | |
4547 unread (cdr gnus-group-list-mode))) | |
4548 (setq level (gnus-group-default-level level)) | |
4549 (gnus-group-setup-buffer) ;May call from out of group buffer | |
4550 (gnus-update-format-specifications) | |
4551 (let ((case-fold-search nil) | |
4552 (props (text-properties-at (gnus-point-at-bol))) | |
4553 (group (gnus-group-group-name))) | |
4554 (set-buffer gnus-group-buffer) | |
4555 (funcall gnus-group-prepare-function level unread lowest) | |
4556 (if (zerop (buffer-size)) | |
4557 (gnus-message 5 gnus-no-groups-message) | |
4558 (goto-char (point-max)) | |
4559 (when (or (not gnus-group-goto-next-group-function) | |
4560 (not (funcall gnus-group-goto-next-group-function | |
4561 group props))) | |
4562 (if (not group) | |
4563 ;; Go to the first group with unread articles. | |
4564 (gnus-group-search-forward t) | |
4565 ;; Find the right group to put point on. If the current group | |
4566 ;; has disappeared in the new listing, try to find the next | |
4567 ;; one. If no next one can be found, just leave point at the | |
4568 ;; first newsgroup in the buffer. | |
4569 (if (not (gnus-goto-char | |
4570 (text-property-any | |
4571 (point-min) (point-max) | |
4572 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))) | |
4573 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb)))) | |
4574 (while (and newsrc | |
4575 (not (gnus-goto-char | |
4576 (text-property-any | |
4577 (point-min) (point-max) 'gnus-group | |
4578 (gnus-intern-safe | |
4579 (caar newsrc) gnus-active-hashtb))))) | |
4580 (setq newsrc (cdr newsrc))) | |
4581 (or newsrc (progn (goto-char (point-max)) | |
4582 (forward-line -1))))))) | |
4583 ;; Adjust cursor point. | |
4584 (gnus-group-position-point)))) | |
4585 | |
4586 (defun gnus-group-list-level (level &optional all) | |
4587 "List groups on LEVEL. | |
4588 If ALL (the prefix), also list groups that have no unread articles." | |
4589 (interactive "nList groups on level: \nP") | |
4590 (gnus-group-list-groups level all level)) | |
4591 | |
4592 (defun gnus-group-prepare-flat (level &optional all lowest regexp) | |
4593 "List all newsgroups with unread articles of level LEVEL or lower. | |
4594 If ALL is non-nil, list groups that have no unread articles. | |
4595 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher. | |
4596 If REGEXP, only list groups matching REGEXP." | |
4597 (set-buffer gnus-group-buffer) | |
4598 (let ((buffer-read-only nil) | |
4599 (newsrc (cdr gnus-newsrc-alist)) | |
4600 (lowest (or lowest 1)) | |
4601 info clevel unread group params) | |
4602 (erase-buffer) | |
4603 (if (< lowest gnus-level-zombie) | |
4604 ;; List living groups. | |
4605 (while newsrc | |
4606 (setq info (car newsrc) | |
4607 group (gnus-info-group info) | |
4608 params (gnus-info-params info) | |
4609 newsrc (cdr newsrc) | |
4610 unread (car (gnus-gethash group gnus-newsrc-hashtb))) | |
4611 (and unread ; This group might be bogus | |
4612 (or (not regexp) | |
4613 (string-match regexp group)) | |
4614 (<= (setq clevel (gnus-info-level info)) level) | |
4615 (>= clevel lowest) | |
4616 (or all ; We list all groups? | |
4617 (if (eq unread t) ; Unactivated? | |
4618 gnus-group-list-inactive-groups ; We list unactivated | |
4619 (> unread 0)) ; We list groups with unread articles | |
4620 (and gnus-list-groups-with-ticked-articles | |
4621 (cdr (assq 'tick (gnus-info-marks info)))) | |
4622 ; And groups with tickeds | |
4623 ;; Check for permanent visibility. | |
4624 (and gnus-permanently-visible-groups | |
4625 (string-match gnus-permanently-visible-groups | |
4626 group)) | |
4627 (memq 'visible params) | |
4628 (cdr (assq 'visible params))) | |
4629 (gnus-group-insert-group-line | |
4630 group (gnus-info-level info) | |
4631 (gnus-info-marks info) unread (gnus-info-method info))))) | |
4632 | |
4633 ;; List dead groups. | |
4634 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie) | |
4635 (gnus-group-prepare-flat-list-dead | |
4636 (setq gnus-zombie-list (sort gnus-zombie-list 'string<)) | |
4637 gnus-level-zombie ?Z | |
4638 regexp)) | |
4639 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed) | |
4640 (gnus-group-prepare-flat-list-dead | |
4641 (setq gnus-killed-list (sort gnus-killed-list 'string<)) | |
4642 gnus-level-killed ?K regexp)) | |
4643 | |
4644 (gnus-group-set-mode-line) | |
4645 (setq gnus-group-list-mode (cons level all)) | |
4646 (run-hooks 'gnus-group-prepare-hook))) | |
4647 | |
4648 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp) | |
4649 ;; List zombies and killed lists somewhat faster, which was | |
4650 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does | |
4651 ;; this by ignoring the group format specification altogether. | |
4652 (let (group) | |
4653 (if regexp | |
4654 ;; This loop is used when listing groups that match some | |
4655 ;; regexp. | |
4656 (while groups | |
4657 (setq group (pop groups)) | |
4658 (when (string-match regexp group) | |
4659 (gnus-add-text-properties | |
4660 (point) (prog1 (1+ (point)) | |
4661 (insert " " mark " *: " group "\n")) | |
4662 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb) | |
4663 'gnus-unread t | |
4664 'gnus-level level)))) | |
4665 ;; This loop is used when listing all groups. | |
4666 (while groups | |
4667 (gnus-add-text-properties | |
4668 (point) (prog1 (1+ (point)) | |
4669 (insert " " mark " *: " | |
4670 (setq group (pop groups)) "\n")) | |
4671 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb) | |
4672 'gnus-unread t | |
4673 'gnus-level level)))))) | |
4674 | |
4675 (defmacro gnus-group-real-name (group) | |
4676 "Find the real name of a foreign newsgroup." | |
4677 `(let ((gname ,group)) | |
4678 (if (string-match ":[^:]+$" gname) | |
4679 (substring gname (1+ (match-beginning 0))) | |
4680 gname))) | |
4681 | |
4682 (defsubst gnus-server-add-address (method) | |
4683 (let ((method-name (symbol-name (car method)))) | |
4684 (if (and (memq 'address (assoc method-name gnus-valid-select-methods)) | |
4685 (not (assq (intern (concat method-name "-address")) method))) | |
4686 (append method (list (list (intern (concat method-name "-address")) | |
4687 (nth 1 method)))) | |
4688 method))) | |
4689 | |
4690 (defsubst gnus-server-get-method (group method) | |
4691 ;; Input either a server name, and extended server name, or a | |
4692 ;; select method, and return a select method. | |
4693 (cond ((stringp method) | |
4694 (gnus-server-to-method method)) | |
4695 ((equal method gnus-select-method) | |
4696 gnus-select-method) | |
4697 ((and (stringp (car method)) group) | |
4698 (gnus-server-extend-method group method)) | |
4699 ((and method (not group) | |
4700 (equal (cadr method) "")) | |
4701 method) | |
4702 (t | |
4703 (gnus-server-add-address method)))) | |
4704 | |
4705 (defun gnus-server-to-method (server) | |
4706 "Map virtual server names to select methods." | |
4707 (or | |
4708 ;; Is this a method, perhaps? | |
4709 (and server (listp server) server) | |
4710 ;; Perhaps this is the native server? | |
4711 (and (equal server "native") gnus-select-method) | |
4712 ;; It should be in the server alist. | |
4713 (cdr (assoc server gnus-server-alist)) | |
4714 ;; If not, we look through all the opened server | |
4715 ;; to see whether we can find it there. | |
4716 (let ((opened gnus-opened-servers)) | |
4717 (while (and opened | |
4718 (not (equal server (format "%s:%s" (caaar opened) | |
4719 (cadaar opened))))) | |
4720 (pop opened)) | |
4721 (caar opened)))) | |
4722 | |
4723 (defmacro gnus-method-equal (ss1 ss2) | |
4724 "Say whether two servers are equal." | |
4725 `(let ((s1 ,ss1) | |
4726 (s2 ,ss2)) | |
4727 (or (equal s1 s2) | |
4728 (and (= (length s1) (length s2)) | |
4729 (progn | |
4730 (while (and s1 (member (car s1) s2)) | |
4731 (setq s1 (cdr s1))) | |
4732 (null s1)))))) | |
4733 | |
4734 (defun gnus-server-equal (m1 m2) | |
4735 "Say whether two methods are equal." | |
4736 (let ((m1 (cond ((null m1) gnus-select-method) | |
4737 ((stringp m1) (gnus-server-to-method m1)) | |
4738 (t m1))) | |
4739 (m2 (cond ((null m2) gnus-select-method) | |
4740 ((stringp m2) (gnus-server-to-method m2)) | |
4741 (t m2)))) | |
4742 (gnus-method-equal m1 m2))) | |
4743 | |
4744 (defun gnus-servers-using-backend (backend) | |
4745 "Return a list of known servers using BACKEND." | |
4746 (let ((opened gnus-opened-servers) | |
4747 out) | |
4748 (while opened | |
4749 (when (eq backend (caaar opened)) | |
4750 (push (caar opened) out)) | |
4751 (pop opened)) | |
4752 out)) | |
4753 | |
4754 (defun gnus-group-prefixed-name (group method) | |
4755 "Return the whole name from GROUP and METHOD." | |
4756 (and (stringp method) (setq method (gnus-server-to-method method))) | |
4757 (concat (format "%s" (car method)) | |
4758 (if (and | |
4759 (or (assoc (format "%s" (car method)) | |
4760 (gnus-methods-using 'address)) | |
4761 (gnus-server-equal method gnus-message-archive-method)) | |
4762 (nth 1 method) | |
4763 (not (string= (nth 1 method) ""))) | |
4764 (concat "+" (nth 1 method))) | |
4765 ":" group)) | |
4766 | |
4767 (defun gnus-group-real-prefix (group) | |
4768 "Return the prefix of the current group name." | |
4769 (if (string-match "^[^:]+:" group) | |
4770 (substring group 0 (match-end 0)) | |
4771 "")) | |
4772 | |
4773 (defun gnus-group-method (group) | |
4774 "Return the server or method used for selecting GROUP." | |
4775 (let ((prefix (gnus-group-real-prefix group))) | |
4776 (if (equal prefix "") | |
4777 gnus-select-method | |
4778 (let ((servers gnus-opened-servers) | |
4779 (server "") | |
4780 backend possible found) | |
4781 (if (string-match "^[^\\+]+\\+" prefix) | |
4782 (setq backend (intern (substring prefix 0 (1- (match-end 0)))) | |
4783 server (substring prefix (match-end 0) (1- (length prefix)))) | |
4784 (setq backend (intern (substring prefix 0 (1- (length prefix)))))) | |
4785 (while servers | |
4786 (when (eq (caaar servers) backend) | |
4787 (setq possible (caar servers)) | |
4788 (when (equal (cadaar servers) server) | |
4789 (setq found (caar servers)))) | |
4790 (pop servers)) | |
4791 (or (car (rassoc found gnus-server-alist)) | |
4792 found | |
4793 (car (rassoc possible gnus-server-alist)) | |
4794 possible | |
4795 (list backend server)))))) | |
4796 | |
4797 (defsubst gnus-secondary-method-p (method) | |
4798 "Return whether METHOD is a secondary select method." | |
4799 (let ((methods gnus-secondary-select-methods) | |
4800 (gmethod (gnus-server-get-method nil method))) | |
4801 (while (and methods | |
4802 (not (equal (gnus-server-get-method nil (car methods)) | |
4803 gmethod))) | |
4804 (setq methods (cdr methods))) | |
4805 methods)) | |
4806 | |
4807 (defun gnus-group-foreign-p (group) | |
4808 "Say whether a group is foreign or not." | |
4809 (and (not (gnus-group-native-p group)) | |
4810 (not (gnus-group-secondary-p group)))) | |
4811 | |
4812 (defun gnus-group-native-p (group) | |
4813 "Say whether the group is native or not." | |
4814 (not (string-match ":" group))) | |
4815 | |
4816 (defun gnus-group-secondary-p (group) | |
4817 "Say whether the group is secondary or not." | |
4818 (gnus-secondary-method-p (gnus-find-method-for-group group))) | |
4819 | |
4820 (defun gnus-group-get-parameter (group &optional symbol) | |
4821 "Returns the group parameters for GROUP. | |
4822 If SYMBOL, return the value of that symbol in the group parameters." | |
4823 (let ((params (gnus-info-params (gnus-get-info group)))) | |
4824 (if symbol | |
4825 (gnus-group-parameter-value params symbol) | |
4826 params))) | |
4827 | |
4828 (defun gnus-group-parameter-value (params symbol) | |
4829 "Return the value of SYMBOL in group PARAMS." | |
4830 (or (car (memq symbol params)) ; It's either a simple symbol | |
4831 (cdr (assq symbol params)))) ; or a cons. | |
4832 | |
4833 (defun gnus-group-add-parameter (group param) | |
4834 "Add parameter PARAM to GROUP." | |
4835 (let ((info (gnus-get-info group))) | |
4836 (if (not info) | |
4837 () ; This is a dead group. We just ignore it. | |
4838 ;; Cons the new param to the old one and update. | |
4839 (gnus-group-set-info (cons param (gnus-info-params info)) | |
4840 group 'params)))) | |
4841 | |
4842 (defun gnus-group-set-parameter (group name value) | |
4843 "Set parameter NAME to VALUE in GROUP." | |
4844 (let ((info (gnus-get-info group))) | |
4845 (if (not info) | |
4846 () ; This is a dead group. We just ignore it. | |
4847 (let ((old-params (gnus-info-params info)) | |
4848 (new-params (list (cons name value)))) | |
4849 (while old-params | |
4850 (if (or (not (listp (car old-params))) | |
4851 (not (eq (caar old-params) name))) | |
4852 (setq new-params (append new-params (list (car old-params))))) | |
4853 (setq old-params (cdr old-params))) | |
4854 (gnus-group-set-info new-params group 'params))))) | |
4855 | |
4856 (defun gnus-group-add-score (group &optional score) | |
4857 "Add SCORE to the GROUP score. | |
4858 If SCORE is nil, add 1 to the score of GROUP." | |
4859 (let ((info (gnus-get-info group))) | |
4860 (when info | |
4861 (gnus-info-set-score info (+ (gnus-info-score info) (or score 1)))))) | |
4862 | |
4863 (defun gnus-summary-bubble-group () | |
4864 "Increase the score of the current group. | |
4865 This is a handy function to add to `gnus-summary-exit-hook' to | |
4866 increase the score of each group you read." | |
4867 (gnus-group-add-score gnus-newsgroup-name)) | |
4868 | |
4869 (defun gnus-group-set-info (info &optional method-only-group part) | |
4870 (let* ((entry (gnus-gethash | |
4871 (or method-only-group (gnus-info-group info)) | |
4872 gnus-newsrc-hashtb)) | |
4873 (part-info info) | |
4874 (info (if method-only-group (nth 2 entry) info)) | |
4875 method) | |
4876 (when method-only-group | |
4877 (unless entry | |
4878 (error "Trying to change non-existent group %s" method-only-group)) | |
4879 ;; We have received parts of the actual group info - either the | |
4880 ;; select method or the group parameters. We first check | |
4881 ;; whether we have to extend the info, and if so, do that. | |
4882 (let ((len (length info)) | |
4883 (total (if (eq part 'method) 5 6))) | |
4884 (when (< len total) | |
4885 (setcdr (nthcdr (1- len) info) | |
4886 (make-list (- total len) nil))) | |
4887 ;; Then we enter the new info. | |
4888 (setcar (nthcdr (1- total) info) part-info))) | |
4889 (unless entry | |
4890 ;; This is a new group, so we just create it. | |
4891 (save-excursion | |
4892 (set-buffer gnus-group-buffer) | |
4893 (setq method (gnus-info-method info)) | |
4894 (when (gnus-server-equal method "native") | |
4895 (setq method nil)) | |
4896 (save-excursion | |
4897 (set-buffer gnus-group-buffer) | |
4898 (if method | |
4899 ;; It's a foreign group... | |
4900 (gnus-group-make-group | |
4901 (gnus-group-real-name (gnus-info-group info)) | |
4902 (if (stringp method) method | |
4903 (prin1-to-string (car method))) | |
4904 (and (consp method) | |
4905 (nth 1 (gnus-info-method info)))) | |
4906 ;; It's a native group. | |
4907 (gnus-group-make-group (gnus-info-group info)))) | |
4908 (gnus-message 6 "Note: New group created") | |
4909 (setq entry | |
4910 (gnus-gethash (gnus-group-prefixed-name | |
4911 (gnus-group-real-name (gnus-info-group info)) | |
4912 (or (gnus-info-method info) gnus-select-method)) | |
4913 gnus-newsrc-hashtb)))) | |
4914 ;; Whether it was a new group or not, we now have the entry, so we | |
4915 ;; can do the update. | |
4916 (if entry | |
4917 (progn | |
4918 (setcar (nthcdr 2 entry) info) | |
4919 (when (and (not (eq (car entry) t)) | |
4920 (gnus-active (gnus-info-group info))) | |
4921 (setcar entry (length (gnus-list-of-unread-articles (car info)))))) | |
4922 (error "No such group: %s" (gnus-info-group info))))) | |
4923 | |
4924 (defun gnus-group-set-method-info (group select-method) | |
4925 (gnus-group-set-info select-method group 'method)) | |
4926 | |
4927 (defun gnus-group-set-params-info (group params) | |
4928 (gnus-group-set-info params group 'params)) | |
4929 | |
4930 (defun gnus-group-update-group-line () | |
4931 "Update the current line in the group buffer." | |
4932 (let* ((buffer-read-only nil) | |
4933 (group (gnus-group-group-name)) | |
4934 (entry (and group (gnus-gethash group gnus-newsrc-hashtb))) | |
4935 gnus-group-indentation) | |
4936 (when group | |
4937 (and entry | |
4938 (not (gnus-ephemeral-group-p group)) | |
4939 (gnus-dribble-enter | |
4940 (concat "(gnus-group-set-info '" | |
4941 (prin1-to-string (nth 2 entry)) ")"))) | |
4942 (setq gnus-group-indentation (gnus-group-group-indentation)) | |
4943 (gnus-delete-line) | |
4944 (gnus-group-insert-group-line-info group) | |
4945 (forward-line -1) | |
4946 (gnus-group-position-point)))) | |
4947 | |
4948 (defun gnus-group-insert-group-line-info (group) | |
4949 "Insert GROUP on the current line." | |
4950 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)) | |
4951 active info) | |
4952 (if entry | |
4953 (progn | |
4954 ;; (Un)subscribed group. | |
4955 (setq info (nth 2 entry)) | |
4956 (gnus-group-insert-group-line | |
4957 group (gnus-info-level info) (gnus-info-marks info) | |
4958 (or (car entry) t) (gnus-info-method info))) | |
4959 ;; This group is dead. | |
4960 (gnus-group-insert-group-line | |
4961 group | |
4962 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed) | |
4963 nil | |
4964 (if (setq active (gnus-active group)) | |
4965 (- (1+ (cdr active)) (car active)) 0) | |
4966 nil)))) | |
4967 | |
4968 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level | |
4969 gnus-tmp-marked number | |
4970 gnus-tmp-method) | |
4971 "Insert a group line in the group buffer." | |
4972 (let* ((gnus-tmp-active (gnus-active gnus-tmp-group)) | |
4973 (gnus-tmp-number-total | |
4974 (if gnus-tmp-active | |
4975 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active))) | |
4976 0)) | |
4977 (gnus-tmp-number-of-unread | |
4978 (if (numberp number) (int-to-string (max 0 number)) | |
4979 "*")) | |
4980 (gnus-tmp-number-of-read | |
4981 (if (numberp number) | |
4982 (int-to-string (max 0 (- gnus-tmp-number-total number))) | |
4983 "*")) | |
4984 (gnus-tmp-subscribed | |
4985 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? ) | |
4986 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U) | |
4987 ((= gnus-tmp-level gnus-level-zombie) ?Z) | |
4988 (t ?K))) | |
4989 (gnus-tmp-qualified-group (gnus-group-real-name gnus-tmp-group)) | |
4990 (gnus-tmp-newsgroup-description | |
4991 (if gnus-description-hashtb | |
4992 (or (gnus-gethash gnus-tmp-group gnus-description-hashtb) "") | |
4993 "")) | |
4994 (gnus-tmp-moderated | |
4995 (if (member gnus-tmp-group gnus-moderated-list) ?m ? )) | |
4996 (gnus-tmp-moderated-string | |
4997 (if (eq gnus-tmp-moderated ?m) "(m)" "")) | |
4998 (gnus-tmp-method | |
4999 (gnus-server-get-method gnus-tmp-group gnus-tmp-method)) | |
5000 (gnus-tmp-news-server (or (cadr gnus-tmp-method) "")) | |
5001 (gnus-tmp-news-method (or (car gnus-tmp-method) "")) | |
5002 (gnus-tmp-news-method-string | |
5003 (if gnus-tmp-method | |
5004 (format "(%s:%s)" (car gnus-tmp-method) | |
5005 (cadr gnus-tmp-method)) "")) | |
5006 (gnus-tmp-marked-mark | |
5007 (if (and (numberp number) | |
5008 (zerop number) | |
5009 (cdr (assq 'tick gnus-tmp-marked))) | |
5010 ?* ? )) | |
5011 (gnus-tmp-process-marked | |
5012 (if (member gnus-tmp-group gnus-group-marked) | |
5013 gnus-process-mark ? )) | |
5014 (gnus-tmp-grouplens | |
5015 (or (and gnus-use-grouplens | |
5016 (bbb-grouplens-group-p gnus-tmp-group)) | |
5017 "")) | |
5018 (buffer-read-only nil) | |
5019 header gnus-tmp-header) ; passed as parameter to user-funcs. | |
5020 (beginning-of-line) | |
5021 (gnus-add-text-properties | |
5022 (point) | |
5023 (prog1 (1+ (point)) | |
5024 ;; Insert the text. | |
5025 (eval gnus-group-line-format-spec)) | |
5026 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb) | |
5027 gnus-unread ,(if (numberp number) | |
5028 (string-to-int gnus-tmp-number-of-unread) | |
5029 t) | |
5030 gnus-marked ,gnus-tmp-marked-mark | |
5031 gnus-indentation ,gnus-group-indentation | |
5032 gnus-level ,gnus-tmp-level)) | |
5033 (when (inline (gnus-visual-p 'group-highlight 'highlight)) | |
5034 (forward-line -1) | |
5035 (run-hooks 'gnus-group-update-hook) | |
5036 (forward-line)) | |
5037 ;; Allow XEmacs to remove front-sticky text properties. | |
5038 (gnus-group-remove-excess-properties))) | |
5039 | |
5040 (defun gnus-group-update-group (group &optional visible-only) | |
5041 "Update all lines where GROUP appear. | |
5042 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't | |
5043 already." | |
5044 (save-excursion | |
5045 (set-buffer gnus-group-buffer) | |
5046 ;; The buffer may be narrowed. | |
5047 (save-restriction | |
5048 (widen) | |
5049 (let ((ident (gnus-intern-safe group gnus-active-hashtb)) | |
5050 (loc (point-min)) | |
5051 found buffer-read-only) | |
5052 ;; Enter the current status into the dribble buffer. | |
5053 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))) | |
5054 (if (and entry (not (gnus-ephemeral-group-p group))) | |
5055 (gnus-dribble-enter | |
5056 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry)) | |
5057 ")")))) | |
5058 ;; Find all group instances. If topics are in use, each group | |
5059 ;; may be listed in more than once. | |
5060 (while (setq loc (text-property-any | |
5061 loc (point-max) 'gnus-group ident)) | |
5062 (setq found t) | |
5063 (goto-char loc) | |
5064 (let ((gnus-group-indentation (gnus-group-group-indentation))) | |
5065 (gnus-delete-line) | |
5066 (gnus-group-insert-group-line-info group) | |
5067 (save-excursion | |
5068 (forward-line -1) | |
5069 (run-hooks 'gnus-group-update-group-hook))) | |
5070 (setq loc (1+ loc))) | |
5071 (unless (or found visible-only) | |
5072 ;; No such line in the buffer, find out where it's supposed to | |
5073 ;; go, and insert it there (or at the end of the buffer). | |
5074 (if gnus-goto-missing-group-function | |
5075 (funcall gnus-goto-missing-group-function group) | |
5076 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb)))) | |
5077 (while (and entry (car entry) | |
5078 (not | |
5079 (gnus-goto-char | |
5080 (text-property-any | |
5081 (point-min) (point-max) | |
5082 'gnus-group (gnus-intern-safe | |
5083 (caar entry) gnus-active-hashtb))))) | |
5084 (setq entry (cdr entry))) | |
5085 (or entry (goto-char (point-max))))) | |
5086 ;; Finally insert the line. | |
5087 (let ((gnus-group-indentation (gnus-group-group-indentation))) | |
5088 (gnus-group-insert-group-line-info group) | |
5089 (save-excursion | |
5090 (forward-line -1) | |
5091 (run-hooks 'gnus-group-update-group-hook)))) | |
5092 (gnus-group-set-mode-line))))) | |
5093 | |
5094 (defun gnus-group-set-mode-line () | |
5095 "Update the mode line in the group buffer." | |
5096 (when (memq 'group gnus-updated-mode-lines) | |
5097 ;; Yes, we want to keep this mode line updated. | |
5098 (save-excursion | |
5099 (set-buffer gnus-group-buffer) | |
5100 (let* ((gformat (or gnus-group-mode-line-format-spec | |
5101 (setq gnus-group-mode-line-format-spec | |
5102 (gnus-parse-format | |
5103 gnus-group-mode-line-format | |
5104 gnus-group-mode-line-format-alist)))) | |
5105 (gnus-tmp-news-server (cadr gnus-select-method)) | |
5106 (gnus-tmp-news-method (car gnus-select-method)) | |
5107 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":")) | |
5108 (max-len 60) | |
5109 gnus-tmp-header ;Dummy binding for user-defined formats | |
5110 ;; Get the resulting string. | |
5111 (modified | |
5112 (and gnus-dribble-buffer | |
5113 (buffer-name gnus-dribble-buffer) | |
5114 (buffer-modified-p gnus-dribble-buffer) | |
5115 (save-excursion | |
5116 (set-buffer gnus-dribble-buffer) | |
5117 (not (zerop (buffer-size)))))) | |
5118 (mode-string (eval gformat))) | |
5119 ;; Say whether the dribble buffer has been modified. | |
5120 (setq mode-line-modified | |
5121 (if modified "---*- " "----- ")) | |
5122 ;; If the line is too long, we chop it off. | |
5123 (when (> (length mode-string) max-len) | |
5124 (setq mode-string (substring mode-string 0 (- max-len 4)))) | |
5125 (prog1 | |
5126 (setq mode-line-buffer-identification | |
5127 (gnus-mode-line-buffer-identification | |
5128 (list mode-string))) | |
5129 (set-buffer-modified-p modified)))))) | |
5130 | |
5131 (defun gnus-group-group-name () | |
5132 "Get the name of the newsgroup on the current line." | |
5133 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group))) | |
5134 (and group (symbol-name group)))) | |
5135 | |
5136 (defun gnus-group-group-level () | |
5137 "Get the level of the newsgroup on the current line." | |
5138 (get-text-property (gnus-point-at-bol) 'gnus-level)) | |
5139 | |
5140 (defun gnus-group-group-indentation () | |
5141 "Get the indentation of the newsgroup on the current line." | |
5142 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation) | |
5143 (and gnus-group-indentation-function | |
5144 (funcall gnus-group-indentation-function)) | |
5145 "")) | |
5146 | |
5147 (defun gnus-group-group-unread () | |
5148 "Get the number of unread articles of the newsgroup on the current line." | |
5149 (get-text-property (gnus-point-at-bol) 'gnus-unread)) | |
5150 | |
5151 (defun gnus-group-search-forward (&optional backward all level first-too) | |
5152 "Find the next newsgroup with unread articles. | |
5153 If BACKWARD is non-nil, find the previous newsgroup instead. | |
5154 If ALL is non-nil, just find any newsgroup. | |
5155 If LEVEL is non-nil, find group with level LEVEL, or higher if no such | |
5156 group exists. | |
5157 If FIRST-TOO, the current line is also eligible as a target." | |
5158 (let ((way (if backward -1 1)) | |
5159 (low gnus-level-killed) | |
5160 (beg (point)) | |
5161 pos found lev) | |
5162 (if (and backward (progn (beginning-of-line)) (bobp)) | |
5163 nil | |
5164 (or first-too (forward-line way)) | |
5165 (while (and | |
5166 (not (eobp)) | |
5167 (not (setq | |
5168 found | |
5169 (and (or all | |
5170 (and | |
5171 (let ((unread | |
5172 (get-text-property (point) 'gnus-unread))) | |
5173 (and (numberp unread) (> unread 0))) | |
5174 (setq lev (get-text-property (point) | |
5175 'gnus-level)) | |
5176 (<= lev gnus-level-subscribed))) | |
5177 (or (not level) | |
5178 (and (setq lev (get-text-property (point) | |
5179 'gnus-level)) | |
5180 (or (= lev level) | |
5181 (and (< lev low) | |
5182 (< level lev) | |
5183 (progn | |
5184 (setq low lev) | |
5185 (setq pos (point)) | |
5186 nil)))))))) | |
5187 (zerop (forward-line way))))) | |
5188 (if found | |
5189 (progn (gnus-group-position-point) t) | |
5190 (goto-char (or pos beg)) | |
5191 (and pos t)))) | |
5192 | |
5193 ;;; Gnus group mode commands | |
5194 | |
5195 ;; Group marking. | |
5196 | |
5197 (defun gnus-group-mark-group (n &optional unmark no-advance) | |
5198 "Mark the current group." | |
5199 (interactive "p") | |
5200 (let ((buffer-read-only nil) | |
5201 group) | |
5202 (while (and (> n 0) | |
5203 (not (eobp))) | |
5204 (when (setq group (gnus-group-group-name)) | |
5205 ;; Update the mark. | |
5206 (beginning-of-line) | |
5207 (forward-char | |
5208 (or (cdr (assq 'process gnus-group-mark-positions)) 2)) | |
5209 (delete-char 1) | |
5210 (if unmark | |
5211 (progn | |
5212 (insert " ") | |
5213 (setq gnus-group-marked (delete group gnus-group-marked))) | |
5214 (insert "#") | |
5215 (setq gnus-group-marked | |
5216 (cons group (delete group gnus-group-marked))))) | |
5217 (or no-advance (gnus-group-next-group 1)) | |
5218 (decf n)) | |
5219 (gnus-summary-position-point) | |
5220 n)) | |
5221 | |
5222 (defun gnus-group-unmark-group (n) | |
5223 "Remove the mark from the current group." | |
5224 (interactive "p") | |
5225 (gnus-group-mark-group n 'unmark) | |
5226 (gnus-group-position-point)) | |
5227 | |
5228 (defun gnus-group-unmark-all-groups () | |
5229 "Unmark all groups." | |
5230 (interactive) | |
5231 (let ((groups gnus-group-marked)) | |
5232 (save-excursion | |
5233 (while groups | |
5234 (gnus-group-remove-mark (pop groups))))) | |
5235 (gnus-group-position-point)) | |
5236 | |
5237 (defun gnus-group-mark-region (unmark beg end) | |
5238 "Mark all groups between point and mark. | |
5239 If UNMARK, remove the mark instead." | |
5240 (interactive "P\nr") | |
5241 (let ((num (count-lines beg end))) | |
5242 (save-excursion | |
5243 (goto-char beg) | |
5244 (- num (gnus-group-mark-group num unmark))))) | |
5245 | |
5246 (defun gnus-group-mark-buffer (&optional unmark) | |
5247 "Mark all groups in the buffer. | |
5248 If UNMARK, remove the mark instead." | |
5249 (interactive "P") | |
5250 (gnus-group-mark-region unmark (point-min) (point-max))) | |
5251 | |
5252 (defun gnus-group-mark-regexp (regexp) | |
5253 "Mark all groups that match some regexp." | |
5254 (interactive "sMark (regexp): ") | |
5255 (let ((alist (cdr gnus-newsrc-alist)) | |
5256 group) | |
5257 (while alist | |
5258 (when (string-match regexp (setq group (gnus-info-group (pop alist)))) | |
5259 (gnus-group-set-mark group)))) | |
5260 (gnus-group-position-point)) | |
5261 | |
5262 (defun gnus-group-remove-mark (group) | |
5263 "Remove the process mark from GROUP and move point there. | |
5264 Return nil if the group isn't displayed." | |
5265 (if (gnus-group-goto-group group) | |
5266 (save-excursion | |
5267 (gnus-group-mark-group 1 'unmark t) | |
5268 t) | |
5269 (setq gnus-group-marked | |
5270 (delete group gnus-group-marked)) | |
5271 nil)) | |
5272 | |
5273 (defun gnus-group-set-mark (group) | |
5274 "Set the process mark on GROUP." | |
5275 (if (gnus-group-goto-group group) | |
5276 (save-excursion | |
5277 (gnus-group-mark-group 1 nil t)) | |
5278 (setq gnus-group-marked (cons group (delete group gnus-group-marked))))) | |
5279 | |
5280 (defun gnus-group-universal-argument (arg &optional groups func) | |
5281 "Perform any command on all groups accoring to the process/prefix convention." | |
5282 (interactive "P") | |
5283 (let ((groups (or groups (gnus-group-process-prefix arg))) | |
5284 group func) | |
5285 (if (eq (setq func (or func | |
5286 (key-binding | |
5287 (read-key-sequence | |
5288 (substitute-command-keys | |
5289 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]"))))) | |
5290 'undefined) | |
5291 (gnus-error 1 "Undefined key") | |
5292 (while groups | |
5293 (gnus-group-remove-mark (setq group (pop groups))) | |
5294 (command-execute func)))) | |
5295 (gnus-group-position-point)) | |
5296 | |
5297 (defun gnus-group-process-prefix (n) | |
5298 "Return a list of groups to work on. | |
5299 Take into consideration N (the prefix) and the list of marked groups." | |
5300 (cond | |
5301 (n | |
5302 (setq n (prefix-numeric-value n)) | |
5303 ;; There is a prefix, so we return a list of the N next | |
5304 ;; groups. | |
5305 (let ((way (if (< n 0) -1 1)) | |
5306 (n (abs n)) | |
5307 group groups) | |
5308 (save-excursion | |
5309 (while (and (> n 0) | |
5310 (setq group (gnus-group-group-name))) | |
5311 (setq groups (cons group groups)) | |
5312 (setq n (1- n)) | |
5313 (gnus-group-next-group way))) | |
5314 (nreverse groups))) | |
5315 ((and (boundp 'transient-mark-mode) | |
5316 transient-mark-mode | |
5317 (boundp 'mark-active) | |
5318 mark-active) | |
5319 ;; Work on the region between point and mark. | |
5320 (let ((max (max (point) (mark))) | |
5321 groups) | |
5322 (save-excursion | |
5323 (goto-char (min (point) (mark))) | |
5324 (while | |
5325 (and | |
5326 (push (gnus-group-group-name) groups) | |
5327 (zerop (gnus-group-next-group 1)) | |
5328 (< (point) max))) | |
5329 (nreverse groups)))) | |
5330 (gnus-group-marked | |
5331 ;; No prefix, but a list of marked articles. | |
5332 (reverse gnus-group-marked)) | |
5333 (t | |
5334 ;; Neither marked articles or a prefix, so we return the | |
5335 ;; current group. | |
5336 (let ((group (gnus-group-group-name))) | |
5337 (and group (list group)))))) | |
5338 | |
5339 ;; Selecting groups. | |
5340 | |
5341 (defun gnus-group-read-group (&optional all no-article group) | |
5342 "Read news in this newsgroup. | |
5343 If the prefix argument ALL is non-nil, already read articles become | |
5344 readable. IF ALL is a number, fetch this number of articles. If the | |
5345 optional argument NO-ARTICLE is non-nil, no article will be | |
5346 auto-selected upon group entry. If GROUP is non-nil, fetch that | |
5347 group." | |
5348 (interactive "P") | |
5349 (let ((group (or group (gnus-group-group-name))) | |
5350 number active marked entry) | |
5351 (or group (error "No group on current line")) | |
5352 (setq marked (nth 3 (nth 2 (setq entry (gnus-gethash | |
5353 group gnus-newsrc-hashtb))))) | |
5354 ;; This group might be a dead group. In that case we have to get | |
5355 ;; the number of unread articles from `gnus-active-hashtb'. | |
5356 (setq number | |
5357 (cond ((numberp all) all) | |
5358 (entry (car entry)) | |
5359 ((setq active (gnus-active group)) | |
5360 (- (1+ (cdr active)) (car active))))) | |
5361 (gnus-summary-read-group | |
5362 group (or all (and (numberp number) | |
5363 (zerop (+ number (length (cdr (assq 'tick marked))) | |
5364 (length (cdr (assq 'dormant marked))))))) | |
5365 no-article))) | |
5366 | |
5367 (defun gnus-group-select-group (&optional all) | |
5368 "Select this newsgroup. | |
5369 No article is selected automatically. | |
5370 If ALL is non-nil, already read articles become readable. | |
5371 If ALL is a number, fetch this number of articles." | |
5372 (interactive "P") | |
5373 (gnus-group-read-group all t)) | |
5374 | |
5375 (defun gnus-group-quick-select-group (&optional all) | |
5376 "Select the current group \"quickly\". | |
5377 This means that no highlighting or scoring will be performed." | |
5378 (interactive "P") | |
5379 (let (gnus-visual | |
5380 gnus-score-find-score-files-function | |
5381 gnus-apply-kill-hook | |
5382 gnus-summary-expunge-below) | |
5383 (gnus-group-read-group all t))) | |
5384 | |
5385 (defun gnus-group-visible-select-group (&optional all) | |
5386 "Select the current group without hiding any articles." | |
5387 (interactive "P") | |
5388 (let ((gnus-inhibit-limiting t)) | |
5389 (gnus-group-read-group all t))) | |
5390 | |
5391 ;;;###autoload | |
5392 (defun gnus-fetch-group (group) | |
5393 "Start Gnus if necessary and enter GROUP. | |
5394 Returns whether the fetching was successful or not." | |
5395 (interactive "sGroup name: ") | |
5396 (or (get-buffer gnus-group-buffer) | |
5397 (gnus)) | |
5398 (gnus-group-read-group nil nil group)) | |
5399 | |
5400 ;; Enter a group that is not in the group buffer. Non-nil is returned | |
5401 ;; if selection was successful. | |
5402 (defun gnus-group-read-ephemeral-group | |
5403 (group method &optional activate quit-config) | |
5404 (let ((group (if (gnus-group-foreign-p group) group | |
5405 (gnus-group-prefixed-name group method)))) | |
5406 (gnus-sethash | |
5407 group | |
5408 `(t nil (,group ,gnus-level-default-subscribed nil nil ,method | |
5409 ((quit-config . ,(if quit-config quit-config | |
5410 (cons (current-buffer) 'summary)))))) | |
5411 gnus-newsrc-hashtb) | |
5412 (set-buffer gnus-group-buffer) | |
5413 (or (gnus-check-server method) | |
5414 (error "Unable to contact server: %s" (gnus-status-message method))) | |
5415 (if activate (or (gnus-request-group group) | |
5416 (error "Couldn't request group"))) | |
5417 (condition-case () | |
5418 (gnus-group-read-group t t group) | |
5419 (error nil) | |
5420 (quit nil)))) | |
5421 | |
5422 (defun gnus-group-jump-to-group (group) | |
5423 "Jump to newsgroup GROUP." | |
5424 (interactive | |
5425 (list (completing-read | |
5426 "Group: " gnus-active-hashtb nil | |
5427 (gnus-read-active-file-p) | |
5428 nil | |
5429 'gnus-group-history))) | |
5430 | |
5431 (when (equal group "") | |
5432 (error "Empty group name")) | |
5433 | |
5434 (when (string-match "[\000-\032]" group) | |
5435 (error "Control characters in group: %s" group)) | |
5436 | |
5437 (let ((b (text-property-any | |
5438 (point-min) (point-max) | |
5439 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))) | |
5440 (unless (gnus-ephemeral-group-p group) | |
5441 (if b | |
5442 ;; Either go to the line in the group buffer... | |
5443 (goto-char b) | |
5444 ;; ... or insert the line. | |
5445 (or | |
5446 (gnus-active group) | |
5447 (gnus-activate-group group) | |
5448 (error "%s error: %s" group (gnus-status-message group))) | |
5449 | |
5450 (gnus-group-update-group group) | |
5451 (goto-char (text-property-any | |
5452 (point-min) (point-max) | |
5453 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))) | |
5454 ;; Adjust cursor point. | |
5455 (gnus-group-position-point))) | |
5456 | |
5457 (defun gnus-group-goto-group (group) | |
5458 "Goto to newsgroup GROUP." | |
5459 (when group | |
5460 (let ((b (text-property-any (point-min) (point-max) | |
5461 'gnus-group (gnus-intern-safe | |
5462 group gnus-active-hashtb)))) | |
5463 (and b (goto-char b))))) | |
5464 | |
5465 (defun gnus-group-next-group (n) | |
5466 "Go to next N'th newsgroup. | |
5467 If N is negative, search backward instead. | |
5468 Returns the difference between N and the number of skips actually | |
5469 done." | |
5470 (interactive "p") | |
5471 (gnus-group-next-unread-group n t)) | |
5472 | |
5473 (defun gnus-group-next-unread-group (n &optional all level) | |
5474 "Go to next N'th unread newsgroup. | |
5475 If N is negative, search backward instead. | |
5476 If ALL is non-nil, choose any newsgroup, unread or not. | |
5477 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no | |
5478 such group can be found, the next group with a level higher than | |
5479 LEVEL. | |
5480 Returns the difference between N and the number of skips actually | |
5481 made." | |
5482 (interactive "p") | |
5483 (let ((backward (< n 0)) | |
5484 (n (abs n))) | |
5485 (while (and (> n 0) | |
5486 (gnus-group-search-forward | |
5487 backward (or (not gnus-group-goto-unread) all) level)) | |
5488 (setq n (1- n))) | |
5489 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread") | |
5490 (if level " on this level or higher" ""))) | |
5491 n)) | |
5492 | |
5493 (defun gnus-group-prev-group (n) | |
5494 "Go to previous N'th newsgroup. | |
5495 Returns the difference between N and the number of skips actually | |
5496 done." | |
5497 (interactive "p") | |
5498 (gnus-group-next-unread-group (- n) t)) | |
5499 | |
5500 (defun gnus-group-prev-unread-group (n) | |
5501 "Go to previous N'th unread newsgroup. | |
5502 Returns the difference between N and the number of skips actually | |
5503 done." | |
5504 (interactive "p") | |
5505 (gnus-group-next-unread-group (- n))) | |
5506 | |
5507 (defun gnus-group-next-unread-group-same-level (n) | |
5508 "Go to next N'th unread newsgroup on the same level. | |
5509 If N is negative, search backward instead. | |
5510 Returns the difference between N and the number of skips actually | |
5511 done." | |
5512 (interactive "p") | |
5513 (gnus-group-next-unread-group n t (gnus-group-group-level)) | |
5514 (gnus-group-position-point)) | |
5515 | |
5516 (defun gnus-group-prev-unread-group-same-level (n) | |
5517 "Go to next N'th unread newsgroup on the same level. | |
5518 Returns the difference between N and the number of skips actually | |
5519 done." | |
5520 (interactive "p") | |
5521 (gnus-group-next-unread-group (- n) t (gnus-group-group-level)) | |
5522 (gnus-group-position-point)) | |
5523 | |
5524 (defun gnus-group-best-unread-group (&optional exclude-group) | |
5525 "Go to the group with the highest level. | |
5526 If EXCLUDE-GROUP, do not go to that group." | |
5527 (interactive) | |
5528 (goto-char (point-min)) | |
5529 (let ((best 100000) | |
5530 unread best-point) | |
5531 (while (not (eobp)) | |
5532 (setq unread (get-text-property (point) 'gnus-unread)) | |
5533 (if (and (numberp unread) (> unread 0)) | |
5534 (progn | |
5535 (if (and (get-text-property (point) 'gnus-level) | |
5536 (< (get-text-property (point) 'gnus-level) best) | |
5537 (or (not exclude-group) | |
5538 (not (equal exclude-group (gnus-group-group-name))))) | |
5539 (progn | |
5540 (setq best (get-text-property (point) 'gnus-level)) | |
5541 (setq best-point (point)))))) | |
5542 (forward-line 1)) | |
5543 (if best-point (goto-char best-point)) | |
5544 (gnus-summary-position-point) | |
5545 (and best-point (gnus-group-group-name)))) | |
5546 | |
5547 (defun gnus-group-first-unread-group () | |
5548 "Go to the first group with unread articles." | |
5549 (interactive) | |
5550 (prog1 | |
5551 (let ((opoint (point)) | |
5552 unread) | |
5553 (goto-char (point-min)) | |
5554 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active. | |
5555 (and (numberp unread) ; Not a topic. | |
5556 (not (zerop unread))) ; Has unread articles. | |
5557 (zerop (gnus-group-next-unread-group 1))) ; Next unread group. | |
5558 (point) ; Success. | |
5559 (goto-char opoint) | |
5560 nil)) ; Not success. | |
5561 (gnus-group-position-point))) | |
5562 | |
5563 (defun gnus-group-enter-server-mode () | |
5564 "Jump to the server buffer." | |
5565 (interactive) | |
5566 (gnus-enter-server-buffer)) | |
5567 | |
5568 (defun gnus-group-make-group (name &optional method address) | |
5569 "Add a new newsgroup. | |
5570 The user will be prompted for a NAME, for a select METHOD, and an | |
5571 ADDRESS." | |
5572 (interactive | |
5573 (cons | |
5574 (read-string "Group name: ") | |
5575 (let ((method | |
5576 (completing-read | |
5577 "Method: " (append gnus-valid-select-methods gnus-server-alist) | |
5578 nil t nil 'gnus-method-history))) | |
5579 (cond ((assoc method gnus-valid-select-methods) | |
5580 (list method | |
5581 (if (memq 'prompt-address | |
5582 (assoc method gnus-valid-select-methods)) | |
5583 (read-string "Address: ") | |
5584 ""))) | |
5585 ((assoc method gnus-server-alist) | |
5586 (list method)) | |
5587 (t | |
5588 (list method "")))))) | |
5589 | |
5590 (let* ((meth (and method (if address (list (intern method) address) | |
5591 method))) | |
5592 (nname (if method (gnus-group-prefixed-name name meth) name)) | |
5593 backend info) | |
5594 (when (gnus-gethash nname gnus-newsrc-hashtb) | |
5595 (error "Group %s already exists" nname)) | |
5596 ;; Subscribe to the new group. | |
5597 (gnus-group-change-level | |
5598 (setq info (list t nname gnus-level-default-subscribed nil nil meth)) | |
5599 gnus-level-default-subscribed gnus-level-killed | |
5600 (and (gnus-group-group-name) | |
5601 (gnus-gethash (gnus-group-group-name) | |
5602 gnus-newsrc-hashtb)) | |
5603 t) | |
5604 ;; Make it active. | |
5605 (gnus-set-active nname (cons 1 0)) | |
5606 (or (gnus-ephemeral-group-p name) | |
5607 (gnus-dribble-enter | |
5608 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")"))) | |
5609 ;; Insert the line. | |
5610 (gnus-group-insert-group-line-info nname) | |
5611 (forward-line -1) | |
5612 (gnus-group-position-point) | |
5613 | |
5614 ;; Load the backend and try to make the backend create | |
5615 ;; the group as well. | |
5616 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method | |
5617 nil meth)))) | |
5618 gnus-valid-select-methods) | |
5619 (require backend)) | |
5620 (gnus-check-server meth) | |
5621 (and (gnus-check-backend-function 'request-create-group nname) | |
5622 (gnus-request-create-group nname)) | |
5623 t)) | |
5624 | |
5625 (defun gnus-group-delete-group (group &optional force) | |
5626 "Delete the current group. Only meaningful with mail groups. | |
5627 If FORCE (the prefix) is non-nil, all the articles in the group will | |
5628 be deleted. This is \"deleted\" as in \"removed forever from the face | |
5629 of the Earth\". There is no undo. The user will be prompted before | |
5630 doing the deletion." | |
5631 (interactive | |
5632 (list (gnus-group-group-name) | |
5633 current-prefix-arg)) | |
5634 (or group (error "No group to rename")) | |
5635 (or (gnus-check-backend-function 'request-delete-group group) | |
5636 (error "This backend does not support group deletion")) | |
5637 (prog1 | |
5638 (if (not (gnus-yes-or-no-p | |
5639 (format | |
5640 "Do you really want to delete %s%s? " | |
5641 group (if force " and all its contents" "")))) | |
5642 () ; Whew! | |
5643 (gnus-message 6 "Deleting group %s..." group) | |
5644 (if (not (gnus-request-delete-group group force)) | |
5645 (gnus-error 3 "Couldn't delete group %s" group) | |
5646 (gnus-message 6 "Deleting group %s...done" group) | |
5647 (gnus-group-goto-group group) | |
5648 (gnus-group-kill-group 1 t) | |
5649 (gnus-sethash group nil gnus-active-hashtb) | |
5650 t)) | |
5651 (gnus-group-position-point))) | |
5652 | |
5653 (defun gnus-group-rename-group (group new-name) | |
5654 (interactive | |
5655 (list | |
5656 (gnus-group-group-name) | |
5657 (progn | |
5658 (or (gnus-check-backend-function | |
5659 'request-rename-group (gnus-group-group-name)) | |
5660 (error "This backend does not support renaming groups")) | |
5661 (read-string "New group name: ")))) | |
5662 | |
5663 (or (gnus-check-backend-function 'request-rename-group group) | |
5664 (error "This backend does not support renaming groups")) | |
5665 | |
5666 (or group (error "No group to rename")) | |
5667 (and (string-match "^[ \t]*$" new-name) | |
5668 (error "Not a valid group name")) | |
5669 | |
5670 ;; We find the proper prefixed name. | |
5671 (setq new-name | |
5672 (gnus-group-prefixed-name | |
5673 (gnus-group-real-name new-name) | |
5674 (gnus-info-method (gnus-get-info group)))) | |
5675 | |
5676 (gnus-message 6 "Renaming group %s to %s..." group new-name) | |
5677 (prog1 | |
5678 (if (not (gnus-request-rename-group group new-name)) | |
5679 (gnus-error 3 "Couldn't rename group %s to %s" group new-name) | |
5680 ;; We rename the group internally by killing it... | |
5681 (gnus-group-goto-group group) | |
5682 (gnus-group-kill-group) | |
5683 ;; ... changing its name ... | |
5684 (setcar (cdar gnus-list-of-killed-groups) new-name) | |
5685 ;; ... and then yanking it. Magic! | |
5686 (gnus-group-yank-group) | |
5687 (gnus-set-active new-name (gnus-active group)) | |
5688 (gnus-message 6 "Renaming group %s to %s...done" group new-name) | |
5689 new-name) | |
5690 (gnus-group-position-point))) | |
5691 | |
5692 (defun gnus-group-edit-group (group &optional part) | |
5693 "Edit the group on the current line." | |
5694 (interactive (list (gnus-group-group-name))) | |
5695 (let* ((part (or part 'info)) | |
5696 (done-func `(lambda () | |
5697 "Exit editing mode and update the information." | |
5698 (interactive) | |
5699 (gnus-group-edit-group-done ',part ,group))) | |
5700 (winconf (current-window-configuration)) | |
5701 info) | |
5702 (or group (error "No group on current line")) | |
5703 (or (setq info (gnus-get-info group)) | |
5704 (error "Killed group; can't be edited")) | |
5705 (set-buffer (get-buffer-create gnus-group-edit-buffer)) | |
5706 (gnus-configure-windows 'edit-group) | |
5707 (gnus-add-current-to-buffer-list) | |
5708 (emacs-lisp-mode) | |
5709 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>. | |
5710 (use-local-map (copy-keymap emacs-lisp-mode-map)) | |
5711 (local-set-key "\C-c\C-c" done-func) | |
5712 (make-local-variable 'gnus-prev-winconf) | |
5713 (setq gnus-prev-winconf winconf) | |
5714 (erase-buffer) | |
5715 (insert | |
5716 (cond | |
5717 ((eq part 'method) | |
5718 ";; Type `C-c C-c' after editing the select method.\n\n") | |
5719 ((eq part 'params) | |
5720 ";; Type `C-c C-c' after editing the group parameters.\n\n") | |
5721 ((eq part 'info) | |
5722 ";; Type `C-c C-c' after editing the group info.\n\n"))) | |
5723 (insert | |
5724 (pp-to-string | |
5725 (cond ((eq part 'method) | |
5726 (or (gnus-info-method info) "native")) | |
5727 ((eq part 'params) | |
5728 (gnus-info-params info)) | |
5729 (t info))) | |
5730 "\n"))) | |
5731 | |
5732 (defun gnus-group-edit-group-method (group) | |
5733 "Edit the select method of GROUP." | |
5734 (interactive (list (gnus-group-group-name))) | |
5735 (gnus-group-edit-group group 'method)) | |
5736 | |
5737 (defun gnus-group-edit-group-parameters (group) | |
5738 "Edit the group parameters of GROUP." | |
5739 (interactive (list (gnus-group-group-name))) | |
5740 (gnus-group-edit-group group 'params)) | |
5741 | |
5742 (defun gnus-group-edit-group-done (part group) | |
5743 "Get info from buffer, update variables and jump to the group buffer." | |
5744 (set-buffer (get-buffer-create gnus-group-edit-buffer)) | |
5745 (goto-char (point-min)) | |
5746 (let* ((form (read (current-buffer))) | |
5747 (winconf gnus-prev-winconf) | |
5748 (method (cond ((eq part 'info) (nth 4 form)) | |
5749 ((eq part 'method) form) | |
5750 (t nil))) | |
5751 (info (cond ((eq part 'info) form) | |
5752 ((eq part 'method) (gnus-get-info group)) | |
5753 (t nil))) | |
5754 (new-group (if info | |
5755 (if (or (not method) | |
5756 (gnus-server-equal | |
5757 gnus-select-method method)) | |
5758 (gnus-group-real-name (car info)) | |
5759 (gnus-group-prefixed-name | |
5760 (gnus-group-real-name (car info)) method)) | |
5761 nil))) | |
5762 (when (and new-group | |
5763 (not (equal new-group group))) | |
5764 (when (gnus-group-goto-group group) | |
5765 (gnus-group-kill-group 1)) | |
5766 (gnus-activate-group new-group)) | |
5767 ;; Set the info. | |
5768 (if (and info new-group) | |
5769 (progn | |
5770 (setq info (gnus-copy-sequence info)) | |
5771 (setcar info new-group) | |
5772 (unless (gnus-server-equal method "native") | |
5773 (unless (nthcdr 3 info) | |
5774 (nconc info (list nil nil))) | |
5775 (unless (nthcdr 4 info) | |
5776 (nconc info (list nil))) | |
5777 (gnus-info-set-method info method)) | |
5778 (gnus-group-set-info info)) | |
5779 (gnus-group-set-info form (or new-group group) part)) | |
5780 (kill-buffer (current-buffer)) | |
5781 (and winconf (set-window-configuration winconf)) | |
5782 (set-buffer gnus-group-buffer) | |
5783 (gnus-group-update-group (or new-group group)) | |
5784 (gnus-group-position-point))) | |
5785 | |
5786 (defun gnus-group-make-help-group () | |
5787 "Create the Gnus documentation group." | |
5788 (interactive) | |
5789 (let ((path load-path) | |
5790 (name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help"))) | |
5791 file dir) | |
5792 (and (gnus-gethash name gnus-newsrc-hashtb) | |
5793 (error "Documentation group already exists")) | |
5794 (while path | |
5795 (setq dir (file-name-as-directory (expand-file-name (pop path))) | |
5796 file nil) | |
5797 (when (or (file-exists-p (setq file (concat dir "gnus-tut.txt"))) | |
5798 (file-exists-p | |
5799 (setq file (concat (file-name-directory | |
5800 (directory-file-name dir)) | |
5801 "etc/gnus-tut.txt")))) | |
5802 (setq path nil))) | |
5803 (if (not file) | |
5804 (gnus-message 1 "Couldn't find doc group") | |
5805 (gnus-group-make-group | |
5806 (gnus-group-real-name name) | |
5807 (list 'nndoc "gnus-help" | |
5808 (list 'nndoc-address file) | |
5809 (list 'nndoc-article-type 'mbox))))) | |
5810 (gnus-group-position-point)) | |
5811 | |
5812 (defun gnus-group-make-doc-group (file type) | |
5813 "Create a group that uses a single file as the source." | |
5814 (interactive | |
5815 (list (read-file-name "File name: ") | |
5816 (and current-prefix-arg 'ask))) | |
5817 (when (eq type 'ask) | |
5818 (let ((err "") | |
5819 char found) | |
5820 (while (not found) | |
5821 (message | |
5822 "%sFile type (mbox, babyl, digest, forward, mmfd, guess) [mbdfag]: " | |
5823 err) | |
5824 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox) | |
5825 ((= char ?b) 'babyl) | |
5826 ((= char ?d) 'digest) | |
5827 ((= char ?f) 'forward) | |
5828 ((= char ?a) 'mmfd) | |
5829 (t (setq err (format "%c unknown. " char)) | |
5830 nil)))) | |
5831 (setq type found))) | |
5832 (let* ((file (expand-file-name file)) | |
5833 (name (gnus-generate-new-group-name | |
5834 (gnus-group-prefixed-name | |
5835 (file-name-nondirectory file) '(nndoc ""))))) | |
5836 (gnus-group-make-group | |
5837 (gnus-group-real-name name) | |
5838 (list 'nndoc (file-name-nondirectory file) | |
5839 (list 'nndoc-address file) | |
5840 (list 'nndoc-article-type (or type 'guess)))))) | |
5841 | |
5842 (defun gnus-group-make-archive-group (&optional all) | |
5843 "Create the (ding) Gnus archive group of the most recent articles. | |
5844 Given a prefix, create a full group." | |
5845 (interactive "P") | |
5846 (let ((group (gnus-group-prefixed-name | |
5847 (if all "ding.archives" "ding.recent") '(nndir "")))) | |
5848 (and (gnus-gethash group gnus-newsrc-hashtb) | |
5849 (error "Archive group already exists")) | |
5850 (gnus-group-make-group | |
5851 (gnus-group-real-name group) | |
5852 (list 'nndir (if all "hpc" "edu") | |
5853 (list 'nndir-directory | |
5854 (if all gnus-group-archive-directory | |
5855 gnus-group-recent-archive-directory)))))) | |
5856 | |
5857 (defun gnus-group-make-directory-group (dir) | |
5858 "Create an nndir group. | |
5859 The user will be prompted for a directory. The contents of this | |
5860 directory will be used as a newsgroup. The directory should contain | |
5861 mail messages or news articles in files that have numeric names." | |
5862 (interactive | |
5863 (list (read-file-name "Create group from directory: "))) | |
5864 (or (file-exists-p dir) (error "No such directory")) | |
5865 (or (file-directory-p dir) (error "Not a directory")) | |
5866 (let ((ext "") | |
5867 (i 0) | |
5868 group) | |
5869 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb)) | |
5870 (setq group | |
5871 (gnus-group-prefixed-name | |
5872 (concat (file-name-as-directory (directory-file-name dir)) | |
5873 ext) | |
5874 '(nndir ""))) | |
5875 (setq ext (format "<%d>" (setq i (1+ i))))) | |
5876 (gnus-group-make-group | |
5877 (gnus-group-real-name group) | |
5878 (list 'nndir group (list 'nndir-directory dir))))) | |
5879 | |
5880 (defun gnus-group-make-kiboze-group (group address scores) | |
5881 "Create an nnkiboze group. | |
5882 The user will be prompted for a name, a regexp to match groups, and | |
5883 score file entries for articles to include in the group." | |
5884 (interactive | |
5885 (list | |
5886 (read-string "nnkiboze group name: ") | |
5887 (read-string "Source groups (regexp): ") | |
5888 (let ((headers (mapcar (lambda (group) (list group)) | |
5889 '("subject" "from" "number" "date" "message-id" | |
5890 "references" "chars" "lines" "xref" | |
5891 "followup" "all" "body" "head"))) | |
5892 scores header regexp regexps) | |
5893 (while (not (equal "" (setq header (completing-read | |
5894 "Match on header: " headers nil t)))) | |
5895 (setq regexps nil) | |
5896 (while (not (equal "" (setq regexp (read-string | |
5897 (format "Match on %s (string): " | |
5898 header))))) | |
5899 (setq regexps (cons (list regexp nil nil 'r) regexps))) | |
5900 (setq scores (cons (cons header regexps) scores))) | |
5901 scores))) | |
5902 (gnus-group-make-group group "nnkiboze" address) | |
5903 (nnheader-temp-write (gnus-score-file-name (concat "nnkiboze:" group)) | |
5904 (let (emacs-lisp-mode-hook) | |
5905 (pp scores (current-buffer))))) | |
5906 | |
5907 (defun gnus-group-add-to-virtual (n vgroup) | |
5908 "Add the current group to a virtual group." | |
5909 (interactive | |
5910 (list current-prefix-arg | |
5911 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t | |
5912 "nnvirtual:"))) | |
5913 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual) | |
5914 (error "%s is not an nnvirtual group" vgroup)) | |
5915 (let* ((groups (gnus-group-process-prefix n)) | |
5916 (method (gnus-info-method (gnus-get-info vgroup)))) | |
5917 (setcar (cdr method) | |
5918 (concat | |
5919 (nth 1 method) "\\|" | |
5920 (mapconcat | |
5921 (lambda (s) | |
5922 (gnus-group-remove-mark s) | |
5923 (concat "\\(^" (regexp-quote s) "$\\)")) | |
5924 groups "\\|")))) | |
5925 (gnus-group-position-point)) | |
5926 | |
5927 (defun gnus-group-make-empty-virtual (group) | |
5928 "Create a new, fresh, empty virtual group." | |
5929 (interactive "sCreate new, empty virtual group: ") | |
5930 (let* ((method (list 'nnvirtual "^$")) | |
5931 (pgroup (gnus-group-prefixed-name group method))) | |
5932 ;; Check whether it exists already. | |
5933 (and (gnus-gethash pgroup gnus-newsrc-hashtb) | |
5934 (error "Group %s already exists." pgroup)) | |
5935 ;; Subscribe the new group after the group on the current line. | |
5936 (gnus-subscribe-group pgroup (gnus-group-group-name) method) | |
5937 (gnus-group-update-group pgroup) | |
5938 (forward-line -1) | |
5939 (gnus-group-position-point))) | |
5940 | |
5941 (defun gnus-group-enter-directory (dir) | |
5942 "Enter an ephemeral nneething group." | |
5943 (interactive "DDirectory to read: ") | |
5944 (let* ((method (list 'nneething dir)) | |
5945 (leaf (gnus-group-prefixed-name | |
5946 (file-name-nondirectory (directory-file-name dir)) | |
5947 method)) | |
5948 (name (gnus-generate-new-group-name leaf))) | |
5949 (let ((nneething-read-only t)) | |
5950 (or (gnus-group-read-ephemeral-group | |
5951 name method t | |
5952 (cons (current-buffer) (if (eq major-mode 'gnus-summary-mode) | |
5953 'summary 'group))) | |
5954 (error "Couldn't enter %s" dir))))) | |
5955 | |
5956 ;; Group sorting commands | |
5957 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>. | |
5958 | |
5959 (defun gnus-group-sort-groups (func &optional reverse) | |
5960 "Sort the group buffer according to FUNC. | |
5961 If REVERSE, reverse the sorting order." | |
5962 (interactive (list gnus-group-sort-function | |
5963 current-prefix-arg)) | |
5964 (let ((func (cond | |
5965 ((not (listp func)) func) | |
5966 ((null func) func) | |
5967 ((= 1 (length func)) (car func)) | |
5968 (t `(lambda (t1 t2) | |
5969 ,(gnus-make-sort-function | |
5970 (reverse func))))))) | |
5971 ;; We peel off the dummy group from the alist. | |
5972 (when func | |
5973 (when (equal (car (gnus-info-group gnus-newsrc-alist)) "dummy.group") | |
5974 (pop gnus-newsrc-alist)) | |
5975 ;; Do the sorting. | |
5976 (setq gnus-newsrc-alist | |
5977 (sort gnus-newsrc-alist func)) | |
5978 (when reverse | |
5979 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))) | |
5980 ;; Regenerate the hash table. | |
5981 (gnus-make-hashtable-from-newsrc-alist) | |
5982 (gnus-group-list-groups)))) | |
5983 | |
5984 (defun gnus-group-sort-groups-by-alphabet (&optional reverse) | |
5985 "Sort the group buffer alphabetically by group name. | |
5986 If REVERSE, sort in reverse order." | |
5987 (interactive "P") | |
5988 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse)) | |
5989 | |
5990 (defun gnus-group-sort-groups-by-unread (&optional reverse) | |
5991 "Sort the group buffer by number of unread articles. | |
5992 If REVERSE, sort in reverse order." | |
5993 (interactive "P") | |
5994 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse)) | |
5995 | |
5996 (defun gnus-group-sort-groups-by-level (&optional reverse) | |
5997 "Sort the group buffer by group level. | |
5998 If REVERSE, sort in reverse order." | |
5999 (interactive "P") | |
6000 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse)) | |
6001 | |
6002 (defun gnus-group-sort-groups-by-score (&optional reverse) | |
6003 "Sort the group buffer by group score. | |
6004 If REVERSE, sort in reverse order." | |
6005 (interactive "P") | |
6006 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse)) | |
6007 | |
6008 (defun gnus-group-sort-groups-by-rank (&optional reverse) | |
6009 "Sort the group buffer by group rank. | |
6010 If REVERSE, sort in reverse order." | |
6011 (interactive "P") | |
6012 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse)) | |
6013 | |
6014 (defun gnus-group-sort-groups-by-method (&optional reverse) | |
6015 "Sort the group buffer alphabetically by backend name. | |
6016 If REVERSE, sort in reverse order." | |
6017 (interactive "P") | |
6018 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse)) | |
6019 | |
6020 (defun gnus-group-sort-by-alphabet (info1 info2) | |
6021 "Sort alphabetically." | |
6022 (string< (gnus-info-group info1) (gnus-info-group info2))) | |
6023 | |
6024 (defun gnus-group-sort-by-unread (info1 info2) | |
6025 "Sort by number of unread articles." | |
6026 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb))) | |
6027 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb)))) | |
6028 (< (or (and (numberp n1) n1) 0) | |
6029 (or (and (numberp n2) n2) 0)))) | |
6030 | |
6031 (defun gnus-group-sort-by-level (info1 info2) | |
6032 "Sort by level." | |
6033 (< (gnus-info-level info1) (gnus-info-level info2))) | |
6034 | |
6035 (defun gnus-group-sort-by-method (info1 info2) | |
6036 "Sort alphabetically by backend name." | |
6037 (string< (symbol-name (car (gnus-find-method-for-group | |
6038 (gnus-info-group info1) info1))) | |
6039 (symbol-name (car (gnus-find-method-for-group | |
6040 (gnus-info-group info2) info2))))) | |
6041 | |
6042 (defun gnus-group-sort-by-score (info1 info2) | |
6043 "Sort by group score." | |
6044 (< (gnus-info-score info1) (gnus-info-score info2))) | |
6045 | |
6046 (defun gnus-group-sort-by-rank (info1 info2) | |
6047 "Sort by level and score." | |
6048 (let ((level1 (gnus-info-level info1)) | |
6049 (level2 (gnus-info-level info2))) | |
6050 (or (< level1 level2) | |
6051 (and (= level1 level2) | |
6052 (> (gnus-info-score info1) (gnus-info-score info2)))))) | |
6053 | |
6054 ;; Group catching up. | |
6055 | |
6056 (defun gnus-group-clear-data (n) | |
6057 "Clear all marks and read ranges from the current group." | |
6058 (interactive "P") | |
6059 (let ((groups (gnus-group-process-prefix n)) | |
6060 group info) | |
6061 (while (setq group (pop groups)) | |
6062 (setq info (gnus-get-info group)) | |
6063 (gnus-info-set-read info nil) | |
6064 (when (gnus-info-marks info) | |
6065 (gnus-info-set-marks info nil)) | |
6066 (gnus-get-unread-articles-in-group info (gnus-active group) t) | |
6067 (when (gnus-group-goto-group group) | |
6068 (gnus-group-remove-mark group) | |
6069 (gnus-group-update-group-line))))) | |
6070 | |
6071 (defun gnus-group-catchup-current (&optional n all) | |
6072 "Mark all articles not marked as unread in current newsgroup as read. | |
6073 If prefix argument N is numeric, the ARG next newsgroups will be | |
6074 caught up. If ALL is non-nil, marked articles will also be marked as | |
6075 read. Cross references (Xref: header) of articles are ignored. | |
6076 The difference between N and actual number of newsgroups that were | |
6077 caught up is returned." | |
6078 (interactive "P") | |
6079 (unless (gnus-group-group-name) | |
6080 (error "No group on the current line")) | |
6081 (if (not (or (not gnus-interactive-catchup) ;Without confirmation? | |
6082 gnus-expert-user | |
6083 (gnus-y-or-n-p | |
6084 (if all | |
6085 "Do you really want to mark all articles as read? " | |
6086 "Mark all unread articles as read? ")))) | |
6087 n | |
6088 (let ((groups (gnus-group-process-prefix n)) | |
6089 (ret 0)) | |
6090 (while groups | |
6091 ;; Virtual groups have to be given special treatment. | |
6092 (let ((method (gnus-find-method-for-group (car groups)))) | |
6093 (if (eq 'nnvirtual (car method)) | |
6094 (nnvirtual-catchup-group | |
6095 (gnus-group-real-name (car groups)) (nth 1 method) all))) | |
6096 (gnus-group-remove-mark (car groups)) | |
6097 (if (>= (gnus-group-group-level) gnus-level-zombie) | |
6098 (gnus-message 2 "Dead groups can't be caught up") | |
6099 (if (prog1 | |
6100 (gnus-group-goto-group (car groups)) | |
6101 (gnus-group-catchup (car groups) all)) | |
6102 (gnus-group-update-group-line) | |
6103 (setq ret (1+ ret)))) | |
6104 (setq groups (cdr groups))) | |
6105 (gnus-group-next-unread-group 1) | |
6106 ret))) | |
6107 | |
6108 (defun gnus-group-catchup-current-all (&optional n) | |
6109 "Mark all articles in current newsgroup as read. | |
6110 Cross references (Xref: header) of articles are ignored." | |
6111 (interactive "P") | |
6112 (gnus-group-catchup-current n 'all)) | |
6113 | |
6114 (defun gnus-group-catchup (group &optional all) | |
6115 "Mark all articles in GROUP as read. | |
6116 If ALL is non-nil, all articles are marked as read. | |
6117 The return value is the number of articles that were marked as read, | |
6118 or nil if no action could be taken." | |
6119 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb)) | |
6120 (num (car entry))) | |
6121 ;; Do the updating only if the newsgroup isn't killed. | |
6122 (if (not (numberp (car entry))) | |
6123 (gnus-message 1 "Can't catch up; non-active group") | |
6124 ;; Do auto-expirable marks if that's required. | |
6125 (when (gnus-group-auto-expirable-p group) | |
6126 (gnus-add-marked-articles | |
6127 group 'expire (gnus-list-of-unread-articles group)) | |
6128 (when all | |
6129 (let ((marks (nth 3 (nth 2 entry)))) | |
6130 (gnus-add-marked-articles | |
6131 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))) | |
6132 (gnus-add-marked-articles | |
6133 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))))) | |
6134 (when entry | |
6135 (gnus-update-read-articles group nil) | |
6136 ;; Also nix out the lists of marks and dormants. | |
6137 (when all | |
6138 (gnus-add-marked-articles group 'tick nil nil 'force) | |
6139 (gnus-add-marked-articles group 'dormant nil nil 'force)) | |
6140 (run-hooks 'gnus-group-catchup-group-hook) | |
6141 num)))) | |
6142 | |
6143 (defun gnus-group-expire-articles (&optional n) | |
6144 "Expire all expirable articles in the current newsgroup." | |
6145 (interactive "P") | |
6146 (let ((groups (gnus-group-process-prefix n)) | |
6147 group) | |
6148 (unless groups | |
6149 (error "No groups to expire")) | |
6150 (while (setq group (pop groups)) | |
6151 (gnus-group-remove-mark group) | |
6152 (when (gnus-check-backend-function 'request-expire-articles group) | |
6153 (gnus-message 6 "Expiring articles in %s..." group) | |
6154 (let* ((info (gnus-get-info group)) | |
6155 (expirable (if (gnus-group-total-expirable-p group) | |
6156 (cons nil (gnus-list-of-read-articles group)) | |
6157 (assq 'expire (gnus-info-marks info)))) | |
6158 (expiry-wait (gnus-group-get-parameter group 'expiry-wait))) | |
6159 (when expirable | |
6160 (setcdr | |
6161 expirable | |
6162 (gnus-compress-sequence | |
6163 (if expiry-wait | |
6164 ;; We set the expiry variables to the groupp | |
6165 ;; parameter. | |
6166 (let ((nnmail-expiry-wait-function nil) | |
6167 (nnmail-expiry-wait expiry-wait)) | |
6168 (gnus-request-expire-articles | |
6169 (gnus-uncompress-sequence (cdr expirable)) group)) | |
6170 ;; Just expire using the normal expiry values. | |
6171 (gnus-request-expire-articles | |
6172 (gnus-uncompress-sequence (cdr expirable)) group)))) | |
6173 (gnus-close-group group)) | |
6174 (gnus-message 6 "Expiring articles in %s...done" group))) | |
6175 (gnus-group-position-point)))) | |
6176 | |
6177 (defun gnus-group-expire-all-groups () | |
6178 "Expire all expirable articles in all newsgroups." | |
6179 (interactive) | |
6180 (save-excursion | |
6181 (gnus-message 5 "Expiring...") | |
6182 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info)) | |
6183 (cdr gnus-newsrc-alist)))) | |
6184 (gnus-group-expire-articles nil))) | |
6185 (gnus-group-position-point) | |
6186 (gnus-message 5 "Expiring...done")) | |
6187 | |
6188 (defun gnus-group-set-current-level (n level) | |
6189 "Set the level of the next N groups to LEVEL." | |
6190 (interactive | |
6191 (list | |
6192 current-prefix-arg | |
6193 (string-to-int | |
6194 (let ((s (read-string | |
6195 (format "Level (default %s): " | |
6196 (or (gnus-group-group-level) | |
6197 gnus-level-default-subscribed))))) | |
6198 (if (string-match "^\\s-*$" s) | |
6199 (int-to-string (or (gnus-group-group-level) | |
6200 gnus-level-default-subscribed)) | |
6201 s))))) | |
6202 (or (and (>= level 1) (<= level gnus-level-killed)) | |
6203 (error "Illegal level: %d" level)) | |
6204 (let ((groups (gnus-group-process-prefix n)) | |
6205 group) | |
6206 (while (setq group (pop groups)) | |
6207 (gnus-group-remove-mark group) | |
6208 (gnus-message 6 "Changed level of %s from %d to %d" | |
6209 group (or (gnus-group-group-level) gnus-level-killed) | |
6210 level) | |
6211 (gnus-group-change-level | |
6212 group level (or (gnus-group-group-level) gnus-level-killed)) | |
6213 (gnus-group-update-group-line))) | |
6214 (gnus-group-position-point)) | |
6215 | |
6216 (defun gnus-group-unsubscribe-current-group (&optional n) | |
6217 "Toggle subscription of the current group. | |
6218 If given numerical prefix, toggle the N next groups." | |
6219 (interactive "P") | |
6220 (let ((groups (gnus-group-process-prefix n)) | |
6221 group) | |
6222 (while groups | |
6223 (setq group (car groups) | |
6224 groups (cdr groups)) | |
6225 (gnus-group-remove-mark group) | |
6226 (gnus-group-unsubscribe-group | |
6227 group (if (<= (gnus-group-group-level) gnus-level-subscribed) | |
6228 gnus-level-default-unsubscribed | |
6229 gnus-level-default-subscribed) t) | |
6230 (gnus-group-update-group-line)) | |
6231 (gnus-group-next-group 1))) | |
6232 | |
6233 (defun gnus-group-unsubscribe-group (group &optional level silent) | |
6234 "Toggle subscription to GROUP. | |
6235 Killed newsgroups are subscribed. If SILENT, don't try to update the | |
6236 group line." | |
6237 (interactive | |
6238 (list (completing-read | |
6239 "Group: " gnus-active-hashtb nil | |
6240 (gnus-read-active-file-p) | |
6241 nil | |
6242 'gnus-group-history))) | |
6243 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb))) | |
6244 (cond | |
6245 ((string-match "^[ \t]$" group) | |
6246 (error "Empty group name")) | |
6247 (newsrc | |
6248 ;; Toggle subscription flag. | |
6249 (gnus-group-change-level | |
6250 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc)) | |
6251 gnus-level-subscribed) | |
6252 (1+ gnus-level-subscribed) | |
6253 gnus-level-default-subscribed))) | |
6254 (unless silent | |
6255 (gnus-group-update-group group))) | |
6256 ((and (stringp group) | |
6257 (or (not (gnus-read-active-file-p)) | |
6258 (gnus-active group))) | |
6259 ;; Add new newsgroup. | |
6260 (gnus-group-change-level | |
6261 group | |
6262 (if level level gnus-level-default-subscribed) | |
6263 (or (and (member group gnus-zombie-list) | |
6264 gnus-level-zombie) | |
6265 gnus-level-killed) | |
6266 (and (gnus-group-group-name) | |
6267 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb))) | |
6268 (unless silent | |
6269 (gnus-group-update-group group))) | |
6270 (t (error "No such newsgroup: %s" group))) | |
6271 (gnus-group-position-point))) | |
6272 | |
6273 (defun gnus-group-transpose-groups (n) | |
6274 "Move the current newsgroup up N places. | |
6275 If given a negative prefix, move down instead. The difference between | |
6276 N and the number of steps taken is returned." | |
6277 (interactive "p") | |
6278 (or (gnus-group-group-name) | |
6279 (error "No group on current line")) | |
6280 (gnus-group-kill-group 1) | |
6281 (prog1 | |
6282 (forward-line (- n)) | |
6283 (gnus-group-yank-group) | |
6284 (gnus-group-position-point))) | |
6285 | |
6286 (defun gnus-group-kill-all-zombies () | |
6287 "Kill all zombie newsgroups." | |
6288 (interactive) | |
6289 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list)) | |
6290 (setq gnus-zombie-list nil) | |
6291 (gnus-group-list-groups)) | |
6292 | |
6293 (defun gnus-group-kill-region (begin end) | |
6294 "Kill newsgroups in current region (excluding current point). | |
6295 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]." | |
6296 (interactive "r") | |
6297 (let ((lines | |
6298 ;; Count lines. | |
6299 (save-excursion | |
6300 (count-lines | |
6301 (progn | |
6302 (goto-char begin) | |
6303 (beginning-of-line) | |
6304 (point)) | |
6305 (progn | |
6306 (goto-char end) | |
6307 (beginning-of-line) | |
6308 (point)))))) | |
6309 (goto-char begin) | |
6310 (beginning-of-line) ;Important when LINES < 1 | |
6311 (gnus-group-kill-group lines))) | |
6312 | |
6313 (defun gnus-group-kill-group (&optional n discard) | |
6314 "Kill the next N groups. | |
6315 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]. | |
6316 However, only groups that were alive can be yanked; already killed | |
6317 groups or zombie groups can't be yanked. | |
6318 The return value is the name of the group that was killed, or a list | |
6319 of groups killed." | |
6320 (interactive "P") | |
6321 (let ((buffer-read-only nil) | |
6322 (groups (gnus-group-process-prefix n)) | |
6323 group entry level out) | |
6324 (if (< (length groups) 10) | |
6325 ;; This is faster when there are few groups. | |
6326 (while groups | |
6327 (push (setq group (pop groups)) out) | |
6328 (gnus-group-remove-mark group) | |
6329 (setq level (gnus-group-group-level)) | |
6330 (gnus-delete-line) | |
6331 (when (and (not discard) | |
6332 (setq entry (gnus-gethash group gnus-newsrc-hashtb))) | |
6333 (push (cons (car entry) (nth 2 entry)) | |
6334 gnus-list-of-killed-groups)) | |
6335 (gnus-group-change-level | |
6336 (if entry entry group) gnus-level-killed (if entry nil level))) | |
6337 ;; If there are lots and lots of groups to be killed, we use | |
6338 ;; this thing instead. | |
6339 (let (entry) | |
6340 (setq groups (nreverse groups)) | |
6341 (while groups | |
6342 (gnus-group-remove-mark (setq group (pop groups))) | |
6343 (gnus-delete-line) | |
6344 (push group gnus-killed-list) | |
6345 (setq gnus-newsrc-alist | |
6346 (delq (assoc group gnus-newsrc-alist) | |
6347 gnus-newsrc-alist)) | |
6348 (when gnus-group-change-level-function | |
6349 (funcall gnus-group-change-level-function group 9 3)) | |
6350 (cond | |
6351 ((setq entry (gnus-gethash group gnus-newsrc-hashtb)) | |
6352 (push (cons (car entry) (nth 2 entry)) | |
6353 gnus-list-of-killed-groups) | |
6354 (setcdr (cdr entry) (cdddr entry))) | |
6355 ((member group gnus-zombie-list) | |
6356 (setq gnus-zombie-list (delete group gnus-zombie-list))))) | |
6357 (gnus-make-hashtable-from-newsrc-alist))) | |
6358 | |
6359 (gnus-group-position-point) | |
6360 (if (< (length out) 2) (car out) (nreverse out)))) | |
6361 | |
6362 (defun gnus-group-yank-group (&optional arg) | |
6363 "Yank the last newsgroups killed with \\[gnus-group-kill-group], | |
6364 inserting it before the current newsgroup. The numeric ARG specifies | |
6365 how many newsgroups are to be yanked. The name of the newsgroup yanked | |
6366 is returned, or (if several groups are yanked) a list of yanked groups | |
6367 is returned." | |
6368 (interactive "p") | |
6369 (setq arg (or arg 1)) | |
6370 (let (info group prev out) | |
6371 (while (>= (decf arg) 0) | |
6372 (if (not (setq info (pop gnus-list-of-killed-groups))) | |
6373 (error "No more newsgroups to yank")) | |
6374 (push (setq group (nth 1 info)) out) | |
6375 ;; Find which newsgroup to insert this one before - search | |
6376 ;; backward until something suitable is found. If there are no | |
6377 ;; other newsgroups in this buffer, just make this newsgroup the | |
6378 ;; first newsgroup. | |
6379 (setq prev (gnus-group-group-name)) | |
6380 (gnus-group-change-level | |
6381 info (gnus-info-level (cdr info)) gnus-level-killed | |
6382 (and prev (gnus-gethash prev gnus-newsrc-hashtb)) | |
6383 t) | |
6384 (gnus-group-insert-group-line-info group)) | |
6385 (forward-line -1) | |
6386 (gnus-group-position-point) | |
6387 (if (< (length out) 2) (car out) (nreverse out)))) | |
6388 | |
6389 (defun gnus-group-kill-level (level) | |
6390 "Kill all groups that is on a certain LEVEL." | |
6391 (interactive "nKill all groups on level: ") | |
6392 (cond | |
6393 ((= level gnus-level-zombie) | |
6394 (setq gnus-killed-list | |
6395 (nconc gnus-zombie-list gnus-killed-list)) | |
6396 (setq gnus-zombie-list nil)) | |
6397 ((and (< level gnus-level-zombie) | |
6398 (> level 0) | |
6399 (or gnus-expert-user | |
6400 (gnus-yes-or-no-p | |
6401 (format | |
6402 "Do you really want to kill all groups on level %d? " | |
6403 level)))) | |
6404 (let* ((prev gnus-newsrc-alist) | |
6405 (alist (cdr prev))) | |
6406 (while alist | |
6407 (if (= (gnus-info-level level) level) | |
6408 (setcdr prev (cdr alist)) | |
6409 (setq prev alist)) | |
6410 (setq alist (cdr alist))) | |
6411 (gnus-make-hashtable-from-newsrc-alist) | |
6412 (gnus-group-list-groups))) | |
6413 (t | |
6414 (error "Can't kill; illegal level: %d" level)))) | |
6415 | |
6416 (defun gnus-group-list-all-groups (&optional arg) | |
6417 "List all newsgroups with level ARG or lower. | |
6418 Default is gnus-level-unsubscribed, which lists all subscribed and most | |
6419 unsubscribed groups." | |
6420 (interactive "P") | |
6421 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t)) | |
6422 | |
6423 ;; Redefine this to list ALL killed groups if prefix arg used. | |
6424 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom). | |
6425 (defun gnus-group-list-killed (&optional arg) | |
6426 "List all killed newsgroups in the group buffer. | |
6427 If ARG is non-nil, list ALL killed groups known to Gnus. This may | |
6428 entail asking the server for the groups." | |
6429 (interactive "P") | |
6430 ;; Find all possible killed newsgroups if arg. | |
6431 (when arg | |
6432 (gnus-get-killed-groups)) | |
6433 (if (not gnus-killed-list) | |
6434 (gnus-message 6 "No killed groups") | |
6435 (let (gnus-group-list-mode) | |
6436 (funcall gnus-group-prepare-function | |
6437 gnus-level-killed t gnus-level-killed)) | |
6438 (goto-char (point-min))) | |
6439 (gnus-group-position-point)) | |
6440 | |
6441 (defun gnus-group-list-zombies () | |
6442 "List all zombie newsgroups in the group buffer." | |
6443 (interactive) | |
6444 (if (not gnus-zombie-list) | |
6445 (gnus-message 6 "No zombie groups") | |
6446 (let (gnus-group-list-mode) | |
6447 (funcall gnus-group-prepare-function | |
6448 gnus-level-zombie t gnus-level-zombie)) | |
6449 (goto-char (point-min))) | |
6450 (gnus-group-position-point)) | |
6451 | |
6452 (defun gnus-group-list-active () | |
6453 "List all groups that are available from the server(s)." | |
6454 (interactive) | |
6455 ;; First we make sure that we have really read the active file. | |
6456 (unless (gnus-read-active-file-p) | |
6457 (let ((gnus-read-active-file t)) | |
6458 (gnus-read-active-file))) | |
6459 ;; Find all groups and sort them. | |
6460 (let ((groups | |
6461 (sort | |
6462 (let (list) | |
6463 (mapatoms | |
6464 (lambda (sym) | |
6465 (and (boundp sym) | |
6466 (symbol-value sym) | |
6467 (setq list (cons (symbol-name sym) list)))) | |
6468 gnus-active-hashtb) | |
6469 list) | |
6470 'string<)) | |
6471 (buffer-read-only nil)) | |
6472 (erase-buffer) | |
6473 (while groups | |
6474 (gnus-group-insert-group-line-info (pop groups))) | |
6475 (goto-char (point-min)))) | |
6476 | |
6477 (defun gnus-activate-all-groups (level) | |
6478 "Activate absolutely all groups." | |
6479 (interactive (list 7)) | |
6480 (let ((gnus-activate-level level) | |
6481 (gnus-activate-foreign-newsgroups level)) | |
6482 (gnus-group-get-new-news))) | |
6483 | |
6484 (defun gnus-group-get-new-news (&optional arg) | |
6485 "Get newly arrived articles. | |
6486 If ARG is a number, it specifies which levels you are interested in | |
6487 re-scanning. If ARG is non-nil and not a number, this will force | |
6488 \"hard\" re-reading of the active files from all servers." | |
6489 (interactive "P") | |
6490 (run-hooks 'gnus-get-new-news-hook) | |
6491 ;; We might read in new NoCeM messages here. | |
6492 (when (and gnus-use-nocem | |
6493 (null arg)) | |
6494 (gnus-nocem-scan-groups)) | |
6495 ;; If ARG is not a number, then we read the active file. | |
6496 (when (and arg (not (numberp arg))) | |
6497 (let ((gnus-read-active-file t)) | |
6498 (gnus-read-active-file)) | |
6499 (setq arg nil)) | |
6500 | |
6501 (setq arg (gnus-group-default-level arg t)) | |
6502 (if (and gnus-read-active-file (not arg)) | |
6503 (progn | |
6504 (gnus-read-active-file) | |
6505 (gnus-get-unread-articles arg)) | |
6506 (let ((gnus-read-active-file (if arg nil gnus-read-active-file))) | |
6507 (gnus-get-unread-articles arg))) | |
6508 (run-hooks 'gnus-after-getting-new-news-hook) | |
6509 (gnus-group-list-groups)) | |
6510 | |
6511 (defun gnus-group-get-new-news-this-group (&optional n) | |
6512 "Check for newly arrived news in the current group (and the N-1 next groups). | |
6513 The difference between N and the number of newsgroup checked is returned. | |
6514 If N is negative, this group and the N-1 previous groups will be checked." | |
6515 (interactive "P") | |
6516 (let* ((groups (gnus-group-process-prefix n)) | |
6517 (ret (if (numberp n) (- n (length groups)) 0)) | |
6518 (beg (unless n (point))) | |
6519 group) | |
6520 (while (setq group (pop groups)) | |
6521 (gnus-group-remove-mark group) | |
6522 (if (gnus-activate-group group 'scan) | |
6523 (progn | |
6524 (gnus-get-unread-articles-in-group | |
6525 (gnus-get-info group) (gnus-active group) t) | |
6526 (unless (gnus-virtual-group-p group) | |
6527 (gnus-close-group group)) | |
6528 (gnus-group-update-group group)) | |
6529 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))) | |
6530 (when beg (goto-char beg)) | |
6531 (when gnus-goto-next-group-when-activating | |
6532 (gnus-group-next-unread-group 1 t)) | |
6533 (gnus-summary-position-point) | |
6534 ret)) | |
6535 | |
6536 (defun gnus-group-fetch-faq (group &optional faq-dir) | |
6537 "Fetch the FAQ for the current group." | |
6538 (interactive | |
6539 (list | |
6540 (and (gnus-group-group-name) | |
6541 (gnus-group-real-name (gnus-group-group-name))) | |
6542 (cond (current-prefix-arg | |
6543 (completing-read | |
6544 "Faq dir: " (and (listp gnus-group-faq-directory) | |
6545 (mapcar (lambda (file) (list file)) | |
6546 gnus-group-faq-directory))))))) | |
6547 (or faq-dir | |
6548 (setq faq-dir (if (listp gnus-group-faq-directory) | |
6549 (car gnus-group-faq-directory) | |
6550 gnus-group-faq-directory))) | |
6551 (or group (error "No group name given")) | |
6552 (let ((file (concat (file-name-as-directory faq-dir) | |
6553 (gnus-group-real-name group)))) | |
6554 (if (not (file-exists-p file)) | |
6555 (error "No such file: %s" file) | |
6556 (find-file file)))) | |
6557 | |
6558 (defun gnus-group-describe-group (force &optional group) | |
6559 "Display a description of the current newsgroup." | |
6560 (interactive (list current-prefix-arg (gnus-group-group-name))) | |
6561 (when (and force | |
6562 gnus-description-hashtb) | |
6563 (gnus-sethash group nil gnus-description-hashtb)) | |
6564 (let ((method (gnus-find-method-for-group group)) | |
6565 desc) | |
6566 (or group (error "No group name given")) | |
6567 (and (or (and gnus-description-hashtb | |
6568 ;; We check whether this group's method has been | |
6569 ;; queried for a description file. | |
6570 (gnus-gethash | |
6571 (gnus-group-prefixed-name "" method) | |
6572 gnus-description-hashtb)) | |
6573 (setq desc (gnus-group-get-description group)) | |
6574 (gnus-read-descriptions-file method)) | |
6575 (gnus-message 1 | |
6576 (or desc (gnus-gethash group gnus-description-hashtb) | |
6577 "No description available"))))) | |
6578 | |
6579 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>. | |
6580 (defun gnus-group-describe-all-groups (&optional force) | |
6581 "Pop up a buffer with descriptions of all newsgroups." | |
6582 (interactive "P") | |
6583 (and force (setq gnus-description-hashtb nil)) | |
6584 (if (not (or gnus-description-hashtb | |
6585 (gnus-read-all-descriptions-files))) | |
6586 (error "Couldn't request descriptions file")) | |
6587 (let ((buffer-read-only nil) | |
6588 b) | |
6589 (erase-buffer) | |
6590 (mapatoms | |
6591 (lambda (group) | |
6592 (setq b (point)) | |
6593 (insert (format " *: %-20s %s\n" (symbol-name group) | |
6594 (symbol-value group))) | |
6595 (gnus-add-text-properties | |
6596 b (1+ b) (list 'gnus-group group | |
6597 'gnus-unread t 'gnus-marked nil | |
6598 'gnus-level (1+ gnus-level-subscribed)))) | |
6599 gnus-description-hashtb) | |
6600 (goto-char (point-min)) | |
6601 (gnus-group-position-point))) | |
6602 | |
6603 ;; Suggested by by Daniel Quinlan <quinlan@best.com>. | |
6604 (defun gnus-group-apropos (regexp &optional search-description) | |
6605 "List all newsgroups that have names that match a regexp." | |
6606 (interactive "sGnus apropos (regexp): ") | |
6607 (let ((prev "") | |
6608 (obuf (current-buffer)) | |
6609 groups des) | |
6610 ;; Go through all newsgroups that are known to Gnus. | |
6611 (mapatoms | |
6612 (lambda (group) | |
6613 (and (symbol-name group) | |
6614 (string-match regexp (symbol-name group)) | |
6615 (setq groups (cons (symbol-name group) groups)))) | |
6616 gnus-active-hashtb) | |
6617 ;; Also go through all descriptions that are known to Gnus. | |
6618 (when search-description | |
6619 (mapatoms | |
6620 (lambda (group) | |
6621 (and (string-match regexp (symbol-value group)) | |
6622 (gnus-active (symbol-name group)) | |
6623 (setq groups (cons (symbol-name group) groups)))) | |
6624 gnus-description-hashtb)) | |
6625 (if (not groups) | |
6626 (gnus-message 3 "No groups matched \"%s\"." regexp) | |
6627 ;; Print out all the groups. | |
6628 (save-excursion | |
6629 (pop-to-buffer "*Gnus Help*") | |
6630 (buffer-disable-undo (current-buffer)) | |
6631 (erase-buffer) | |
6632 (setq groups (sort groups 'string<)) | |
6633 (while groups | |
6634 ;; Groups may be entered twice into the list of groups. | |
6635 (if (not (string= (car groups) prev)) | |
6636 (progn | |
6637 (insert (setq prev (car groups)) "\n") | |
6638 (if (and gnus-description-hashtb | |
6639 (setq des (gnus-gethash (car groups) | |
6640 gnus-description-hashtb))) | |
6641 (insert " " des "\n")))) | |
6642 (setq groups (cdr groups))) | |
6643 (goto-char (point-min)))) | |
6644 (pop-to-buffer obuf))) | |
6645 | |
6646 (defun gnus-group-description-apropos (regexp) | |
6647 "List all newsgroups that have names or descriptions that match a regexp." | |
6648 (interactive "sGnus description apropos (regexp): ") | |
6649 (if (not (or gnus-description-hashtb | |
6650 (gnus-read-all-descriptions-files))) | |
6651 (error "Couldn't request descriptions file")) | |
6652 (gnus-group-apropos regexp t)) | |
6653 | |
6654 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>. | |
6655 (defun gnus-group-list-matching (level regexp &optional all lowest) | |
6656 "List all groups with unread articles that match REGEXP. | |
6657 If the prefix LEVEL is non-nil, it should be a number that says which | |
6658 level to cut off listing groups. | |
6659 If ALL, also list groups with no unread articles. | |
6660 If LOWEST, don't list groups with level lower than LOWEST. | |
6661 | |
6662 This command may read the active file." | |
6663 (interactive "P\nsList newsgroups matching: ") | |
6664 ;; First make sure active file has been read. | |
6665 (when (and level | |
6666 (> (prefix-numeric-value level) gnus-level-killed)) | |
6667 (gnus-get-killed-groups)) | |
6668 (gnus-group-prepare-flat (or level gnus-level-subscribed) | |
6669 all (or lowest 1) regexp) | |
6670 (goto-char (point-min)) | |
6671 (gnus-group-position-point)) | |
6672 | |
6673 (defun gnus-group-list-all-matching (level regexp &optional lowest) | |
6674 "List all groups that match REGEXP. | |
6675 If the prefix LEVEL is non-nil, it should be a number that says which | |
6676 level to cut off listing groups. | |
6677 If LOWEST, don't list groups with level lower than LOWEST." | |
6678 (interactive "P\nsList newsgroups matching: ") | |
6679 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest)) | |
6680 | |
6681 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. | |
6682 (defun gnus-group-save-newsrc (&optional force) | |
6683 "Save the Gnus startup files. | |
6684 If FORCE, force saving whether it is necessary or not." | |
6685 (interactive "P") | |
6686 (gnus-save-newsrc-file force)) | |
6687 | |
6688 (defun gnus-group-restart (&optional arg) | |
6689 "Force Gnus to read the .newsrc file." | |
6690 (interactive "P") | |
6691 (when (gnus-yes-or-no-p | |
6692 (format "Are you sure you want to read %s? " | |
6693 gnus-current-startup-file)) | |
6694 (gnus-save-newsrc-file) | |
6695 (gnus-setup-news 'force) | |
6696 (gnus-group-list-groups arg))) | |
6697 | |
6698 (defun gnus-group-read-init-file () | |
6699 "Read the Gnus elisp init file." | |
6700 (interactive) | |
6701 (gnus-read-init-file)) | |
6702 | |
6703 (defun gnus-group-check-bogus-groups (&optional silent) | |
6704 "Check bogus newsgroups. | |
6705 If given a prefix, don't ask for confirmation before removing a bogus | |
6706 group." | |
6707 (interactive "P") | |
6708 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user))) | |
6709 (gnus-group-list-groups)) | |
6710 | |
6711 (defun gnus-group-edit-global-kill (&optional article group) | |
6712 "Edit the global kill file. | |
6713 If GROUP, edit that local kill file instead." | |
6714 (interactive "P") | |
6715 (setq gnus-current-kill-article article) | |
6716 (gnus-kill-file-edit-file group) | |
6717 (gnus-message | |
6718 6 | |
6719 (substitute-command-keys | |
6720 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)" | |
6721 (if group "local" "global"))))) | |
6722 | |
6723 (defun gnus-group-edit-local-kill (article group) | |
6724 "Edit a local kill file." | |
6725 (interactive (list nil (gnus-group-group-name))) | |
6726 (gnus-group-edit-global-kill article group)) | |
6727 | |
6728 (defun gnus-group-force-update () | |
6729 "Update `.newsrc' file." | |
6730 (interactive) | |
6731 (gnus-save-newsrc-file)) | |
6732 | |
6733 (defun gnus-group-suspend () | |
6734 "Suspend the current Gnus session. | |
6735 In fact, cleanup buffers except for group mode buffer. | |
6736 The hook gnus-suspend-gnus-hook is called before actually suspending." | |
6737 (interactive) | |
6738 (run-hooks 'gnus-suspend-gnus-hook) | |
6739 ;; Kill Gnus buffers except for group mode buffer. | |
6740 (let* ((group-buf (get-buffer gnus-group-buffer)) | |
6741 ;; Do this on a separate list in case the user does a ^G before we finish | |
6742 (gnus-buffer-list | |
6743 (delete group-buf (delete gnus-dribble-buffer | |
6744 (append gnus-buffer-list nil))))) | |
6745 (while gnus-buffer-list | |
6746 (gnus-kill-buffer (pop gnus-buffer-list))) | |
6747 (gnus-kill-gnus-frames) | |
6748 (when group-buf | |
6749 (setq gnus-buffer-list (list group-buf)) | |
6750 (bury-buffer group-buf) | |
6751 (delete-windows-on group-buf t)))) | |
6752 | |
6753 (defun gnus-group-clear-dribble () | |
6754 "Clear all information from the dribble buffer." | |
6755 (interactive) | |
6756 (gnus-dribble-clear) | |
6757 (gnus-message 7 "Cleared dribble buffer")) | |
6758 | |
6759 (defun gnus-group-exit () | |
6760 "Quit reading news after updating .newsrc.eld and .newsrc. | |
6761 The hook `gnus-exit-gnus-hook' is called before actually exiting." | |
6762 (interactive) | |
6763 (when | |
6764 (or noninteractive ;For gnus-batch-kill | |
6765 (not gnus-interactive-exit) ;Without confirmation | |
6766 gnus-expert-user | |
6767 (gnus-y-or-n-p "Are you sure you want to quit reading news? ")) | |
6768 (run-hooks 'gnus-exit-gnus-hook) | |
6769 ;; Offer to save data from non-quitted summary buffers. | |
6770 (gnus-offer-save-summaries) | |
6771 ;; Save the newsrc file(s). | |
6772 (gnus-save-newsrc-file) | |
6773 ;; Kill-em-all. | |
6774 (gnus-close-backends) | |
6775 ;; Reset everything. | |
6776 (gnus-clear-system) | |
6777 ;; Allow the user to do things after cleaning up. | |
6778 (run-hooks 'gnus-after-exiting-gnus-hook))) | |
6779 | |
6780 (defun gnus-close-backends () | |
6781 ;; Send a close request to all backends that support such a request. | |
6782 (let ((methods gnus-valid-select-methods) | |
6783 func) | |
6784 (while methods | |
6785 (if (fboundp (setq func (intern (concat (caar methods) | |
6786 "-request-close")))) | |
6787 (funcall func)) | |
6788 (setq methods (cdr methods))))) | |
6789 | |
6790 (defun gnus-group-quit () | |
6791 "Quit reading news without updating .newsrc.eld or .newsrc. | |
6792 The hook `gnus-exit-gnus-hook' is called before actually exiting." | |
6793 (interactive) | |
6794 (when (or noninteractive ;For gnus-batch-kill | |
6795 (zerop (buffer-size)) | |
6796 (not (gnus-server-opened gnus-select-method)) | |
6797 gnus-expert-user | |
6798 (not gnus-current-startup-file) | |
6799 (gnus-yes-or-no-p | |
6800 (format "Quit reading news without saving %s? " | |
6801 (file-name-nondirectory gnus-current-startup-file)))) | |
6802 (run-hooks 'gnus-exit-gnus-hook) | |
6803 (if gnus-use-full-window | |
6804 (delete-other-windows) | |
6805 (gnus-remove-some-windows)) | |
6806 (gnus-dribble-save) | |
6807 (gnus-close-backends) | |
6808 (gnus-clear-system) | |
6809 ;; Allow the user to do things after cleaning up. | |
6810 (run-hooks 'gnus-after-exiting-gnus-hook))) | |
6811 | |
6812 (defun gnus-offer-save-summaries () | |
6813 "Offer to save all active summary buffers." | |
6814 (save-excursion | |
6815 (let ((buflist (buffer-list)) | |
6816 buffers bufname) | |
6817 ;; Go through all buffers and find all summaries. | |
6818 (while buflist | |
6819 (and (setq bufname (buffer-name (car buflist))) | |
6820 (string-match "Summary" bufname) | |
6821 (save-excursion | |
6822 (set-buffer bufname) | |
6823 ;; We check that this is, indeed, a summary buffer. | |
6824 (and (eq major-mode 'gnus-summary-mode) | |
6825 ;; Also make sure this isn't bogus. | |
6826 gnus-newsgroup-prepared)) | |
6827 (push bufname buffers)) | |
6828 (setq buflist (cdr buflist))) | |
6829 ;; Go through all these summary buffers and offer to save them. | |
6830 (when buffers | |
6831 (map-y-or-n-p | |
6832 "Update summary buffer %s? " | |
6833 (lambda (buf) (set-buffer buf) (gnus-summary-exit)) | |
6834 buffers))))) | |
6835 | |
6836 (defun gnus-group-describe-briefly () | |
6837 "Give a one line description of the group mode commands." | |
6838 (interactive) | |
6839 (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"))) | |
6840 | |
6841 (defun gnus-group-browse-foreign-server (method) | |
6842 "Browse a foreign news server. | |
6843 If called interactively, this function will ask for a select method | |
6844 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where). | |
6845 If not, METHOD should be a list where the first element is the method | |
6846 and the second element is the address." | |
6847 (interactive | |
6848 (list (let ((how (completing-read | |
6849 "Which backend: " | |
6850 (append gnus-valid-select-methods gnus-server-alist) | |
6851 nil t (cons "nntp" 0) 'gnus-method-history))) | |
6852 ;; We either got a backend name or a virtual server name. | |
6853 ;; If the first, we also need an address. | |
6854 (if (assoc how gnus-valid-select-methods) | |
6855 (list (intern how) | |
6856 ;; Suggested by mapjph@bath.ac.uk. | |
6857 (completing-read | |
6858 "Address: " | |
6859 (mapcar (lambda (server) (list server)) | |
6860 gnus-secondary-servers))) | |
6861 ;; We got a server name, so we find the method. | |
6862 (gnus-server-to-method how))))) | |
6863 (gnus-browse-foreign-server method)) | |
6864 | |
6865 | |
6866 ;;; | |
6867 ;;; Gnus summary mode | |
6868 ;;; | |
6869 | |
6870 (defvar gnus-summary-mode-map nil) | |
6871 | |
6872 (put 'gnus-summary-mode 'mode-class 'special) | |
6873 | |
6874 (unless gnus-summary-mode-map | |
6875 (setq gnus-summary-mode-map (make-keymap)) | |
6876 (suppress-keymap gnus-summary-mode-map) | |
6877 | |
6878 ;; Non-orthogonal keys | |
6879 | |
6880 (gnus-define-keys gnus-summary-mode-map | |
6881 " " gnus-summary-next-page | |
6882 "\177" gnus-summary-prev-page | |
6883 [delete] gnus-summary-prev-page | |
6884 "\r" gnus-summary-scroll-up | |
6885 "n" gnus-summary-next-unread-article | |
6886 "p" gnus-summary-prev-unread-article | |
6887 "N" gnus-summary-next-article | |
6888 "P" gnus-summary-prev-article | |
6889 "\M-\C-n" gnus-summary-next-same-subject | |
6890 "\M-\C-p" gnus-summary-prev-same-subject | |
6891 "\M-n" gnus-summary-next-unread-subject | |
6892 "\M-p" gnus-summary-prev-unread-subject | |
6893 "." gnus-summary-first-unread-article | |
6894 "," gnus-summary-best-unread-article | |
6895 "\M-s" gnus-summary-search-article-forward | |
6896 "\M-r" gnus-summary-search-article-backward | |
6897 "<" gnus-summary-beginning-of-article | |
6898 ">" gnus-summary-end-of-article | |
6899 "j" gnus-summary-goto-article | |
6900 "^" gnus-summary-refer-parent-article | |
6901 "\M-^" gnus-summary-refer-article | |
6902 "u" gnus-summary-tick-article-forward | |
6903 "!" gnus-summary-tick-article-forward | |
6904 "U" gnus-summary-tick-article-backward | |
6905 "d" gnus-summary-mark-as-read-forward | |
6906 "D" gnus-summary-mark-as-read-backward | |
6907 "E" gnus-summary-mark-as-expirable | |
6908 "\M-u" gnus-summary-clear-mark-forward | |
6909 "\M-U" gnus-summary-clear-mark-backward | |
6910 "k" gnus-summary-kill-same-subject-and-select | |
6911 "\C-k" gnus-summary-kill-same-subject | |
6912 "\M-\C-k" gnus-summary-kill-thread | |
6913 "\M-\C-l" gnus-summary-lower-thread | |
6914 "e" gnus-summary-edit-article | |
6915 "#" gnus-summary-mark-as-processable | |
6916 "\M-#" gnus-summary-unmark-as-processable | |
6917 "\M-\C-t" gnus-summary-toggle-threads | |
6918 "\M-\C-s" gnus-summary-show-thread | |
6919 "\M-\C-h" gnus-summary-hide-thread | |
6920 "\M-\C-f" gnus-summary-next-thread | |
6921 "\M-\C-b" gnus-summary-prev-thread | |
6922 "\M-\C-u" gnus-summary-up-thread | |
6923 "\M-\C-d" gnus-summary-down-thread | |
6924 "&" gnus-summary-execute-command | |
6925 "c" gnus-summary-catchup-and-exit | |
6926 "\C-w" gnus-summary-mark-region-as-read | |
6927 "\C-t" gnus-summary-toggle-truncation | |
6928 "?" gnus-summary-mark-as-dormant | |
6929 "\C-c\M-\C-s" gnus-summary-limit-include-expunged | |
6930 "\C-c\C-s\C-n" gnus-summary-sort-by-number | |
6931 "\C-c\C-s\C-a" gnus-summary-sort-by-author | |
6932 "\C-c\C-s\C-s" gnus-summary-sort-by-subject | |
6933 "\C-c\C-s\C-d" gnus-summary-sort-by-date | |
6934 "\C-c\C-s\C-i" gnus-summary-sort-by-score | |
6935 "=" gnus-summary-expand-window | |
6936 "\C-x\C-s" gnus-summary-reselect-current-group | |
6937 "\M-g" gnus-summary-rescan-group | |
6938 "w" gnus-summary-stop-page-breaking | |
6939 "\C-c\C-r" gnus-summary-caesar-message | |
6940 "\M-t" gnus-summary-toggle-mime | |
6941 "f" gnus-summary-followup | |
6942 "F" gnus-summary-followup-with-original | |
6943 "C" gnus-summary-cancel-article | |
6944 "r" gnus-summary-reply | |
6945 "R" gnus-summary-reply-with-original | |
6946 "\C-c\C-f" gnus-summary-mail-forward | |
6947 "o" gnus-summary-save-article | |
6948 "\C-o" gnus-summary-save-article-mail | |
6949 "|" gnus-summary-pipe-output | |
6950 "\M-k" gnus-summary-edit-local-kill | |
6951 "\M-K" gnus-summary-edit-global-kill | |
6952 "V" gnus-version | |
6953 "\C-c\C-d" gnus-summary-describe-group | |
6954 "q" gnus-summary-exit | |
6955 "Q" gnus-summary-exit-no-update | |
6956 "\C-c\C-i" gnus-info-find-node | |
6957 gnus-mouse-2 gnus-mouse-pick-article | |
6958 "m" gnus-summary-mail-other-window | |
6959 "a" gnus-summary-post-news | |
6960 "x" gnus-summary-limit-to-unread | |
6961 "s" gnus-summary-isearch-article | |
6962 "t" gnus-article-hide-headers | |
6963 "g" gnus-summary-show-article | |
6964 "l" gnus-summary-goto-last-article | |
6965 "\C-c\C-v\C-v" gnus-uu-decode-uu-view | |
6966 "\C-d" gnus-summary-enter-digest-group | |
6967 "\C-c\C-b" gnus-bug | |
6968 "*" gnus-cache-enter-article | |
6969 "\M-*" gnus-cache-remove-article | |
6970 "\M-&" gnus-summary-universal-argument | |
6971 "\C-l" gnus-recenter | |
6972 "I" gnus-summary-increase-score | |
6973 "L" gnus-summary-lower-score | |
6974 | |
6975 "V" gnus-summary-score-map | |
6976 "X" gnus-uu-extract-map | |
6977 "S" gnus-summary-send-map) | |
6978 | |
6979 ;; Sort of orthogonal keymap | |
6980 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map) | |
6981 "t" gnus-summary-tick-article-forward | |
6982 "!" gnus-summary-tick-article-forward | |
6983 "d" gnus-summary-mark-as-read-forward | |
6984 "r" gnus-summary-mark-as-read-forward | |
6985 "c" gnus-summary-clear-mark-forward | |
6986 " " gnus-summary-clear-mark-forward | |
6987 "e" gnus-summary-mark-as-expirable | |
6988 "x" gnus-summary-mark-as-expirable | |
6989 "?" gnus-summary-mark-as-dormant | |
6990 "b" gnus-summary-set-bookmark | |
6991 "B" gnus-summary-remove-bookmark | |
6992 "#" gnus-summary-mark-as-processable | |
6993 "\M-#" gnus-summary-unmark-as-processable | |
6994 "S" gnus-summary-limit-include-expunged | |
6995 "C" gnus-summary-catchup | |
6996 "H" gnus-summary-catchup-to-here | |
6997 "\C-c" gnus-summary-catchup-all | |
6998 "k" gnus-summary-kill-same-subject-and-select | |
6999 "K" gnus-summary-kill-same-subject | |
7000 "P" gnus-uu-mark-map) | |
7001 | |
7002 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mode-map) | |
7003 "c" gnus-summary-clear-above | |
7004 "u" gnus-summary-tick-above | |
7005 "m" gnus-summary-mark-above | |
7006 "k" gnus-summary-kill-below) | |
7007 | |
7008 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map) | |
7009 "/" gnus-summary-limit-to-subject | |
7010 "n" gnus-summary-limit-to-articles | |
7011 "w" gnus-summary-pop-limit | |
7012 "s" gnus-summary-limit-to-subject | |
7013 "a" gnus-summary-limit-to-author | |
7014 "u" gnus-summary-limit-to-unread | |
7015 "m" gnus-summary-limit-to-marks | |
7016 "v" gnus-summary-limit-to-score | |
7017 "D" gnus-summary-limit-include-dormant | |
7018 "d" gnus-summary-limit-exclude-dormant | |
7019 ;; "t" gnus-summary-limit-exclude-thread | |
7020 "E" gnus-summary-limit-include-expunged | |
7021 "c" gnus-summary-limit-exclude-childless-dormant | |
7022 "C" gnus-summary-limit-mark-excluded-as-read) | |
7023 | |
7024 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map) | |
7025 "n" gnus-summary-next-unread-article | |
7026 "p" gnus-summary-prev-unread-article | |
7027 "N" gnus-summary-next-article | |
7028 "P" gnus-summary-prev-article | |
7029 "\C-n" gnus-summary-next-same-subject | |
7030 "\C-p" gnus-summary-prev-same-subject | |
7031 "\M-n" gnus-summary-next-unread-subject | |
7032 "\M-p" gnus-summary-prev-unread-subject | |
7033 "f" gnus-summary-first-unread-article | |
7034 "b" gnus-summary-best-unread-article | |
7035 "j" gnus-summary-goto-article | |
7036 "g" gnus-summary-goto-subject | |
7037 "l" gnus-summary-goto-last-article | |
7038 "p" gnus-summary-pop-article) | |
7039 | |
7040 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map) | |
7041 "k" gnus-summary-kill-thread | |
7042 "l" gnus-summary-lower-thread | |
7043 "i" gnus-summary-raise-thread | |
7044 "T" gnus-summary-toggle-threads | |
7045 "t" gnus-summary-rethread-current | |
7046 "^" gnus-summary-reparent-thread | |
7047 "s" gnus-summary-show-thread | |
7048 "S" gnus-summary-show-all-threads | |
7049 "h" gnus-summary-hide-thread | |
7050 "H" gnus-summary-hide-all-threads | |
7051 "n" gnus-summary-next-thread | |
7052 "p" gnus-summary-prev-thread | |
7053 "u" gnus-summary-up-thread | |
7054 "o" gnus-summary-top-thread | |
7055 "d" gnus-summary-down-thread | |
7056 "#" gnus-uu-mark-thread | |
7057 "\M-#" gnus-uu-unmark-thread) | |
7058 | |
7059 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map) | |
7060 "c" gnus-summary-catchup-and-exit | |
7061 "C" gnus-summary-catchup-all-and-exit | |
7062 "E" gnus-summary-exit-no-update | |
7063 "Q" gnus-summary-exit | |
7064 "Z" gnus-summary-exit | |
7065 "n" gnus-summary-catchup-and-goto-next-group | |
7066 "R" gnus-summary-reselect-current-group | |
7067 "G" gnus-summary-rescan-group | |
7068 "N" gnus-summary-next-group | |
7069 "P" gnus-summary-prev-group) | |
7070 | |
7071 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map) | |
7072 " " gnus-summary-next-page | |
7073 "n" gnus-summary-next-page | |
7074 "\177" gnus-summary-prev-page | |
7075 [delete] gnus-summary-prev-page | |
7076 "p" gnus-summary-prev-page | |
7077 "\r" gnus-summary-scroll-up | |
7078 "<" gnus-summary-beginning-of-article | |
7079 ">" gnus-summary-end-of-article | |
7080 "b" gnus-summary-beginning-of-article | |
7081 "e" gnus-summary-end-of-article | |
7082 "^" gnus-summary-refer-parent-article | |
7083 "r" gnus-summary-refer-parent-article | |
7084 "R" gnus-summary-refer-references | |
7085 "g" gnus-summary-show-article | |
7086 "s" gnus-summary-isearch-article) | |
7087 | |
7088 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map) | |
7089 "b" gnus-article-add-buttons | |
7090 "B" gnus-article-add-buttons-to-head | |
7091 "o" gnus-article-treat-overstrike | |
7092 ;; "w" gnus-article-word-wrap | |
7093 "w" gnus-article-fill-cited-article | |
7094 "c" gnus-article-remove-cr | |
7095 "L" gnus-article-remove-trailing-blank-lines | |
7096 "q" gnus-article-de-quoted-unreadable | |
7097 "f" gnus-article-display-x-face | |
7098 "l" gnus-summary-stop-page-breaking | |
7099 "r" gnus-summary-caesar-message | |
7100 "t" gnus-article-hide-headers | |
7101 "v" gnus-summary-verbose-headers | |
7102 "m" gnus-summary-toggle-mime) | |
7103 | |
7104 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map) | |
7105 "a" gnus-article-hide | |
7106 "h" gnus-article-hide-headers | |
7107 "b" gnus-article-hide-boring-headers | |
7108 "s" gnus-article-hide-signature | |
7109 "c" gnus-article-hide-citation | |
7110 "p" gnus-article-hide-pgp | |
7111 "\C-c" gnus-article-hide-citation-maybe) | |
7112 | |
7113 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map) | |
7114 "a" gnus-article-highlight | |
7115 "h" gnus-article-highlight-headers | |
7116 "c" gnus-article-highlight-citation | |
7117 "s" gnus-article-highlight-signature) | |
7118 | |
7119 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map) | |
7120 "z" gnus-article-date-ut | |
7121 "u" gnus-article-date-ut | |
7122 "l" gnus-article-date-local | |
7123 "e" gnus-article-date-lapsed | |
7124 "o" gnus-article-date-original) | |
7125 | |
7126 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map) | |
7127 "v" gnus-version | |
7128 "f" gnus-summary-fetch-faq | |
7129 "d" gnus-summary-describe-group | |
7130 "h" gnus-summary-describe-briefly | |
7131 "i" gnus-info-find-node) | |
7132 | |
7133 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map) | |
7134 "e" gnus-summary-expire-articles | |
7135 "\M-\C-e" gnus-summary-expire-articles-now | |
7136 "\177" gnus-summary-delete-article | |
7137 [delete] gnus-summary-delete-article | |
7138 "m" gnus-summary-move-article | |
7139 "r" gnus-summary-respool-article | |
7140 "w" gnus-summary-edit-article | |
7141 "c" gnus-summary-copy-article | |
7142 "B" gnus-summary-crosspost-article | |
7143 "q" gnus-summary-respool-query | |
7144 "i" gnus-summary-import-article) | |
7145 | |
7146 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map) | |
7147 "o" gnus-summary-save-article | |
7148 "m" gnus-summary-save-article-mail | |
7149 "r" gnus-summary-save-article-rmail | |
7150 "f" gnus-summary-save-article-file | |
7151 "b" gnus-summary-save-article-body-file | |
7152 "h" gnus-summary-save-article-folder | |
7153 "v" gnus-summary-save-article-vm | |
7154 "p" gnus-summary-pipe-output | |
7155 "s" gnus-soup-add-article) | |
7156 ) | |
7157 | |
7158 | |
7159 | |
7160 (defun gnus-summary-mode (&optional group) | |
7161 "Major mode for reading articles. | |
7162 | |
7163 All normal editing commands are switched off. | |
7164 \\<gnus-summary-mode-map> | |
7165 Each line in this buffer represents one article. To read an | |
7166 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards | |
7167 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]', | |
7168 respectively. | |
7169 | |
7170 You can also post articles and send mail from this buffer. To | |
7171 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author | |
7172 of an article, type `\\[gnus-summary-reply]'. | |
7173 | |
7174 There are approx. one gazillion commands you can execute in this | |
7175 buffer; read the info pages for more information (`\\[gnus-info-find-node]'). | |
7176 | |
7177 The following commands are available: | |
7178 | |
7179 \\{gnus-summary-mode-map}" | |
7180 (interactive) | |
7181 (when (and menu-bar-mode | |
7182 (gnus-visual-p 'summary-menu 'menu)) | |
7183 (gnus-summary-make-menu-bar)) | |
7184 (kill-all-local-variables) | |
7185 (gnus-summary-make-local-variables) | |
7186 (gnus-make-thread-indent-array) | |
7187 (gnus-simplify-mode-line) | |
7188 (setq major-mode 'gnus-summary-mode) | |
7189 (setq mode-name "Summary") | |
7190 (make-local-variable 'minor-mode-alist) | |
7191 (use-local-map gnus-summary-mode-map) | |
7192 (buffer-disable-undo (current-buffer)) | |
7193 (setq buffer-read-only t) ;Disable modification | |
7194 (setq truncate-lines t) | |
7195 (setq selective-display t) | |
7196 (setq selective-display-ellipses t) ;Display `...' | |
7197 (setq buffer-display-table gnus-summary-display-table) | |
7198 (setq gnus-newsgroup-name group) | |
7199 (make-local-variable 'gnus-summary-line-format) | |
7200 (make-local-variable 'gnus-summary-line-format-spec) | |
7201 (make-local-variable 'gnus-summary-mark-positions) | |
7202 (run-hooks 'gnus-summary-mode-hook)) | |
7203 | |
7204 (defun gnus-summary-make-local-variables () | |
7205 "Make all the local summary buffer variables." | |
7206 (let ((locals gnus-summary-local-variables) | |
7207 global local) | |
7208 (while (setq local (pop locals)) | |
7209 (if (consp local) | |
7210 (progn | |
7211 (if (eq (cdr local) 'global) | |
7212 ;; Copy the global value of the variable. | |
7213 (setq global (symbol-value (car local))) | |
7214 ;; Use the value from the list. | |
7215 (setq global (eval (cdr local)))) | |
7216 (make-local-variable (car local)) | |
7217 (set (car local) global)) | |
7218 ;; Simple nil-valued local variable. | |
7219 (make-local-variable local) | |
7220 (set local nil))))) | |
7221 | |
7222 (defun gnus-summary-make-display-table () | |
7223 ;; Change the display table. Odd characters have a tendency to mess | |
7224 ;; up nicely formatted displays - we make all possible glyphs | |
7225 ;; display only a single character. | |
7226 | |
7227 ;; We start from the standard display table, if any. | |
7228 (setq gnus-summary-display-table | |
7229 (or (copy-sequence standard-display-table) | |
7230 (make-display-table))) | |
7231 ;; Nix out all the control chars... | |
7232 (let ((i 32)) | |
7233 (while (>= (setq i (1- i)) 0) | |
7234 (aset gnus-summary-display-table i [??]))) | |
7235 ;; ... but not newline and cr, of course. (cr is necessary for the | |
7236 ;; selective display). | |
7237 (aset gnus-summary-display-table ?\n nil) | |
7238 (aset gnus-summary-display-table ?\r nil) | |
7239 ;; We nix out any glyphs over 126 that are not set already. | |
7240 (let ((i 256)) | |
7241 (while (>= (setq i (1- i)) 127) | |
7242 ;; Only modify if the entry is nil. | |
7243 (or (aref gnus-summary-display-table i) | |
7244 (aset gnus-summary-display-table i [??]))))) | |
7245 | |
7246 (defun gnus-summary-clear-local-variables () | |
7247 (let ((locals gnus-summary-local-variables)) | |
7248 (while locals | |
7249 (if (consp (car locals)) | |
7250 (and (vectorp (caar locals)) | |
7251 (set (caar locals) nil)) | |
7252 (and (vectorp (car locals)) | |
7253 (set (car locals) nil))) | |
7254 (setq locals (cdr locals))))) | |
7255 | |
7256 ;; Summary data functions. | |
7257 | |
7258 (defmacro gnus-data-number (data) | |
7259 `(car ,data)) | |
7260 | |
7261 (defmacro gnus-data-set-number (data number) | |
7262 `(setcar ,data ,number)) | |
7263 | |
7264 (defmacro gnus-data-mark (data) | |
7265 `(nth 1 ,data)) | |
7266 | |
7267 (defmacro gnus-data-set-mark (data mark) | |
7268 `(setcar (nthcdr 1 ,data) ,mark)) | |
7269 | |
7270 (defmacro gnus-data-pos (data) | |
7271 `(nth 2 ,data)) | |
7272 | |
7273 (defmacro gnus-data-set-pos (data pos) | |
7274 `(setcar (nthcdr 2 ,data) ,pos)) | |
7275 | |
7276 (defmacro gnus-data-header (data) | |
7277 `(nth 3 ,data)) | |
7278 | |
7279 (defmacro gnus-data-level (data) | |
7280 `(nth 4 ,data)) | |
7281 | |
7282 (defmacro gnus-data-unread-p (data) | |
7283 `(= (nth 1 ,data) gnus-unread-mark)) | |
7284 | |
7285 (defmacro gnus-data-pseudo-p (data) | |
7286 `(consp (nth 3 ,data))) | |
7287 | |
7288 (defmacro gnus-data-find (number) | |
7289 `(assq ,number gnus-newsgroup-data)) | |
7290 | |
7291 (defmacro gnus-data-find-list (number &optional data) | |
7292 `(let ((bdata ,(or data 'gnus-newsgroup-data))) | |
7293 (memq (assq ,number bdata) | |
7294 bdata))) | |
7295 | |
7296 (defmacro gnus-data-make (number mark pos header level) | |
7297 `(list ,number ,mark ,pos ,header ,level)) | |
7298 | |
7299 (defun gnus-data-enter (after-article number mark pos header level offset) | |
7300 (let ((data (gnus-data-find-list after-article))) | |
7301 (or data (error "No such article: %d" after-article)) | |
7302 (setcdr data (cons (gnus-data-make number mark pos header level) | |
7303 (cdr data))) | |
7304 (setq gnus-newsgroup-data-reverse nil) | |
7305 (gnus-data-update-list (cddr data) offset))) | |
7306 | |
7307 (defun gnus-data-enter-list (after-article list &optional offset) | |
7308 (when list | |
7309 (let ((data (and after-article (gnus-data-find-list after-article))) | |
7310 (ilist list)) | |
7311 (or data (not after-article) (error "No such article: %d" after-article)) | |
7312 ;; Find the last element in the list to be spliced into the main | |
7313 ;; list. | |
7314 (while (cdr list) | |
7315 (setq list (cdr list))) | |
7316 (if (not data) | |
7317 (progn | |
7318 (setcdr list gnus-newsgroup-data) | |
7319 (setq gnus-newsgroup-data ilist) | |
7320 (and offset (gnus-data-update-list (cdr list) offset))) | |
7321 (setcdr list (cdr data)) | |
7322 (setcdr data ilist) | |
7323 (and offset (gnus-data-update-list (cdr data) offset))) | |
7324 (setq gnus-newsgroup-data-reverse nil)))) | |
7325 | |
7326 (defun gnus-data-remove (article &optional offset) | |
7327 (let ((data gnus-newsgroup-data)) | |
7328 (if (= (gnus-data-number (car data)) article) | |
7329 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data) | |
7330 gnus-newsgroup-data-reverse nil) | |
7331 (while (cdr data) | |
7332 (and (= (gnus-data-number (cadr data)) article) | |
7333 (progn | |
7334 (setcdr data (cddr data)) | |
7335 (and offset (gnus-data-update-list (cdr data) offset)) | |
7336 (setq data nil | |
7337 gnus-newsgroup-data-reverse nil))) | |
7338 (setq data (cdr data)))))) | |
7339 | |
7340 (defmacro gnus-data-list (backward) | |
7341 `(if ,backward | |
7342 (or gnus-newsgroup-data-reverse | |
7343 (setq gnus-newsgroup-data-reverse | |
7344 (reverse gnus-newsgroup-data))) | |
7345 gnus-newsgroup-data)) | |
7346 | |
7347 (defun gnus-data-update-list (data offset) | |
7348 "Add OFFSET to the POS of all data entries in DATA." | |
7349 (while data | |
7350 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data)))) | |
7351 (setq data (cdr data)))) | |
7352 | |
7353 (defun gnus-data-compute-positions () | |
7354 "Compute the positions of all articles." | |
7355 (let ((data gnus-newsgroup-data) | |
7356 pos) | |
7357 (while data | |
7358 (when (setq pos (text-property-any | |
7359 (point-min) (point-max) | |
7360 'gnus-number (gnus-data-number (car data)))) | |
7361 (gnus-data-set-pos (car data) (+ pos 3))) | |
7362 (setq data (cdr data))))) | |
7363 | |
7364 (defun gnus-summary-article-pseudo-p (article) | |
7365 "Say whether this article is a pseudo article or not." | |
7366 (not (vectorp (gnus-data-header (gnus-data-find article))))) | |
7367 | |
7368 (defun gnus-article-parent-p (number) | |
7369 "Say whether this article is a parent or not." | |
7370 (let ((data (gnus-data-find-list number))) | |
7371 (and (cdr data) ; There has to be an article after... | |
7372 (< (gnus-data-level (car data)) ; And it has to have a higher level. | |
7373 (gnus-data-level (nth 1 data)))))) | |
7374 | |
7375 (defun gnus-article-children (number) | |
7376 "Return a list of all children to NUMBER." | |
7377 (let* ((data (gnus-data-find-list number)) | |
7378 (level (gnus-data-level (car data))) | |
7379 children) | |
7380 (setq data (cdr data)) | |
7381 (while (and data | |
7382 (= (gnus-data-level (car data)) (1+ level))) | |
7383 (push (gnus-data-number (car data)) children) | |
7384 (setq data (cdr data))) | |
7385 children)) | |
7386 | |
7387 (defmacro gnus-summary-skip-intangible () | |
7388 "If the current article is intangible, then jump to a different article." | |
7389 '(let ((to (get-text-property (point) 'gnus-intangible))) | |
7390 (and to (gnus-summary-goto-subject to)))) | |
7391 | |
7392 (defmacro gnus-summary-article-intangible-p () | |
7393 "Say whether this article is intangible or not." | |
7394 '(get-text-property (point) 'gnus-intangible)) | |
7395 | |
7396 ;; Some summary mode macros. | |
7397 | |
7398 (defmacro gnus-summary-article-number () | |
7399 "The article number of the article on the current line. | |
7400 If there isn's an article number here, then we return the current | |
7401 article number." | |
7402 '(progn | |
7403 (gnus-summary-skip-intangible) | |
7404 (or (get-text-property (point) 'gnus-number) | |
7405 (gnus-summary-last-subject)))) | |
7406 | |
7407 (defmacro gnus-summary-article-header (&optional number) | |
7408 `(gnus-data-header (gnus-data-find | |
7409 ,(or number '(gnus-summary-article-number))))) | |
7410 | |
7411 (defmacro gnus-summary-thread-level (&optional number) | |
7412 `(if (and (eq gnus-summary-make-false-root 'dummy) | |
7413 (get-text-property (point) 'gnus-intangible)) | |
7414 0 | |
7415 (gnus-data-level (gnus-data-find | |
7416 ,(or number '(gnus-summary-article-number)))))) | |
7417 | |
7418 (defmacro gnus-summary-article-mark (&optional number) | |
7419 `(gnus-data-mark (gnus-data-find | |
7420 ,(or number '(gnus-summary-article-number))))) | |
7421 | |
7422 (defmacro gnus-summary-article-pos (&optional number) | |
7423 `(gnus-data-pos (gnus-data-find | |
7424 ,(or number '(gnus-summary-article-number))))) | |
7425 | |
7426 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject) | |
7427 (defmacro gnus-summary-article-subject (&optional number) | |
7428 "Return current subject string or nil if nothing." | |
7429 `(let ((headers | |
7430 ,(if number | |
7431 `(gnus-data-header (assq ,number gnus-newsgroup-data)) | |
7432 '(gnus-data-header (assq (gnus-summary-article-number) | |
7433 gnus-newsgroup-data))))) | |
7434 (and headers | |
7435 (vectorp headers) | |
7436 (mail-header-subject headers)))) | |
7437 | |
7438 (defmacro gnus-summary-article-score (&optional number) | |
7439 "Return current article score." | |
7440 `(or (cdr (assq ,(or number '(gnus-summary-article-number)) | |
7441 gnus-newsgroup-scored)) | |
7442 gnus-summary-default-score 0)) | |
7443 | |
7444 (defun gnus-summary-article-children (&optional number) | |
7445 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number)))) | |
7446 (level (gnus-data-level (car data))) | |
7447 l children) | |
7448 (while (and (setq data (cdr data)) | |
7449 (> (setq l (gnus-data-level (car data))) level)) | |
7450 (and (= (1+ level) l) | |
7451 (setq children (cons (gnus-data-number (car data)) | |
7452 children)))) | |
7453 (nreverse children))) | |
7454 | |
7455 (defun gnus-summary-article-parent (&optional number) | |
7456 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number)) | |
7457 (gnus-data-list t))) | |
7458 (level (gnus-data-level (car data)))) | |
7459 (if (zerop level) | |
7460 () ; This is a root. | |
7461 ;; We search until we find an article with a level less than | |
7462 ;; this one. That function has to be the parent. | |
7463 (while (and (setq data (cdr data)) | |
7464 (not (< (gnus-data-level (car data)) level)))) | |
7465 (and data (gnus-data-number (car data)))))) | |
7466 | |
7467 (defun gnus-unread-mark-p (mark) | |
7468 "Say whether MARK is the unread mark." | |
7469 (= mark gnus-unread-mark)) | |
7470 | |
7471 (defun gnus-read-mark-p (mark) | |
7472 "Say whether MARK is one of the marks that mark as read. | |
7473 This is all marks except unread, ticked, dormant, and expirable." | |
7474 (not (or (= mark gnus-unread-mark) | |
7475 (= mark gnus-ticked-mark) | |
7476 (= mark gnus-dormant-mark) | |
7477 (= mark gnus-expirable-mark)))) | |
7478 | |
7479 ;; Saving hidden threads. | |
7480 | |
7481 (put 'gnus-save-hidden-threads 'lisp-indent-function 0) | |
7482 (put 'gnus-save-hidden-threads 'lisp-indent-hook 0) | |
7483 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body)) | |
7484 | |
7485 (defmacro gnus-save-hidden-threads (&rest forms) | |
7486 "Save hidden threads, eval FORMS, and restore the hidden threads." | |
7487 (let ((config (make-symbol "config"))) | |
7488 `(let ((,config (gnus-hidden-threads-configuration))) | |
7489 (unwind-protect | |
7490 (progn | |
7491 ,@forms) | |
7492 (gnus-restore-hidden-threads-configuration ,config))))) | |
7493 | |
7494 (defun gnus-hidden-threads-configuration () | |
7495 "Return the current hidden threads configuration." | |
7496 (save-excursion | |
7497 (let (config) | |
7498 (goto-char (point-min)) | |
7499 (while (search-forward "\r" nil t) | |
7500 (push (1- (point)) config)) | |
7501 config))) | |
7502 | |
7503 (defun gnus-restore-hidden-threads-configuration (config) | |
7504 "Restore hidden threads configuration from CONFIG." | |
7505 (let (point buffer-read-only) | |
7506 (while (setq point (pop config)) | |
7507 (when (and (< point (point-max)) | |
7508 (goto-char point) | |
7509 (= (following-char) ?\n)) | |
7510 (subst-char-in-region point (1+ point) ?\n ?\r))))) | |
7511 | |
7512 ;; Various summary mode internalish functions. | |
7513 | |
7514 (defun gnus-mouse-pick-article (e) | |
7515 (interactive "e") | |
7516 (mouse-set-point e) | |
7517 (gnus-summary-next-page nil t)) | |
7518 | |
7519 (defun gnus-summary-setup-buffer (group) | |
7520 "Initialize summary buffer." | |
7521 (let ((buffer (concat "*Summary " group "*"))) | |
7522 (if (get-buffer buffer) | |
7523 (progn | |
7524 (set-buffer buffer) | |
7525 (setq gnus-summary-buffer (current-buffer)) | |
7526 (not gnus-newsgroup-prepared)) | |
7527 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu> | |
7528 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer))) | |
7529 (gnus-add-current-to-buffer-list) | |
7530 (gnus-summary-mode group) | |
7531 (when gnus-carpal | |
7532 (gnus-carpal-setup-buffer 'summary)) | |
7533 (unless gnus-single-article-buffer | |
7534 (make-local-variable 'gnus-article-buffer) | |
7535 (make-local-variable 'gnus-article-current) | |
7536 (make-local-variable 'gnus-original-article-buffer)) | |
7537 (setq gnus-newsgroup-name group) | |
7538 t))) | |
7539 | |
7540 (defun gnus-set-global-variables () | |
7541 ;; Set the global equivalents of the summary buffer-local variables | |
7542 ;; to the latest values they had. These reflect the summary buffer | |
7543 ;; that was in action when the last article was fetched. | |
7544 (when (eq major-mode 'gnus-summary-mode) | |
7545 (setq gnus-summary-buffer (current-buffer)) | |
7546 (let ((name gnus-newsgroup-name) | |
7547 (marked gnus-newsgroup-marked) | |
7548 (unread gnus-newsgroup-unreads) | |
7549 (headers gnus-current-headers) | |
7550 (data gnus-newsgroup-data) | |
7551 (summary gnus-summary-buffer) | |
7552 (article-buffer gnus-article-buffer) | |
7553 (original gnus-original-article-buffer) | |
7554 (gac gnus-article-current) | |
7555 (score-file gnus-current-score-file)) | |
7556 (save-excursion | |
7557 (set-buffer gnus-group-buffer) | |
7558 (setq gnus-newsgroup-name name) | |
7559 (setq gnus-newsgroup-marked marked) | |
7560 (setq gnus-newsgroup-unreads unread) | |
7561 (setq gnus-current-headers headers) | |
7562 (setq gnus-newsgroup-data data) | |
7563 (setq gnus-article-current gac) | |
7564 (setq gnus-summary-buffer summary) | |
7565 (setq gnus-article-buffer article-buffer) | |
7566 (setq gnus-original-article-buffer original) | |
7567 (setq gnus-current-score-file score-file))))) | |
7568 | |
7569 (defun gnus-summary-last-article-p (&optional article) | |
7570 "Return whether ARTICLE is the last article in the buffer." | |
7571 (if (not (setq article (or article (gnus-summary-article-number)))) | |
7572 t ; All non-existant numbers are the last article. :-) | |
7573 (not (cdr (gnus-data-find-list article))))) | |
7574 | |
7575 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number) | |
7576 "Insert a dummy root in the summary buffer." | |
7577 (beginning-of-line) | |
7578 (gnus-add-text-properties | |
7579 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point)) | |
7580 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number))) | |
7581 | |
7582 (defun gnus-make-thread-indent-array () | |
7583 (let ((n 200)) | |
7584 (unless (and gnus-thread-indent-array | |
7585 (= gnus-thread-indent-level gnus-thread-indent-array-level)) | |
7586 (setq gnus-thread-indent-array (make-vector 201 "") | |
7587 gnus-thread-indent-array-level gnus-thread-indent-level) | |
7588 (while (>= n 0) | |
7589 (aset gnus-thread-indent-array n | |
7590 (make-string (* n gnus-thread-indent-level) ? )) | |
7591 (setq n (1- n)))))) | |
7592 | |
7593 (defun gnus-summary-insert-line | |
7594 (gnus-tmp-header gnus-tmp-level gnus-tmp-current gnus-tmp-unread | |
7595 gnus-tmp-replied gnus-tmp-expirable gnus-tmp-subject-or-nil | |
7596 &optional gnus-tmp-dummy gnus-tmp-score gnus-tmp-process) | |
7597 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level)) | |
7598 (gnus-tmp-lines (mail-header-lines gnus-tmp-header)) | |
7599 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0)) | |
7600 (gnus-tmp-score-char | |
7601 (if (or (null gnus-summary-default-score) | |
7602 (<= (abs (- gnus-tmp-score gnus-summary-default-score)) | |
7603 gnus-summary-zcore-fuzz)) ? | |
7604 (if (< gnus-tmp-score gnus-summary-default-score) | |
7605 gnus-score-below-mark gnus-score-over-mark))) | |
7606 (gnus-tmp-replied (cond (gnus-tmp-process gnus-process-mark) | |
7607 ((memq gnus-tmp-current gnus-newsgroup-cached) | |
7608 gnus-cached-mark) | |
7609 (gnus-tmp-replied gnus-replied-mark) | |
7610 ((memq gnus-tmp-current gnus-newsgroup-saved) | |
7611 gnus-saved-mark) | |
7612 (t gnus-unread-mark))) | |
7613 (gnus-tmp-from (mail-header-from gnus-tmp-header)) | |
7614 (gnus-tmp-name | |
7615 (cond | |
7616 ((string-match "(.+)" gnus-tmp-from) | |
7617 (substring gnus-tmp-from | |
7618 (1+ (match-beginning 0)) (1- (match-end 0)))) | |
7619 ((string-match "<[^>]+> *$" gnus-tmp-from) | |
7620 (let ((beg (match-beginning 0))) | |
7621 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from) | |
7622 (substring gnus-tmp-from (1+ (match-beginning 0)) | |
7623 (1- (match-end 0)))) | |
7624 (substring gnus-tmp-from 0 beg)))) | |
7625 (t gnus-tmp-from))) | |
7626 (gnus-tmp-subject (mail-header-subject gnus-tmp-header)) | |
7627 (gnus-tmp-number (mail-header-number gnus-tmp-header)) | |
7628 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[)) | |
7629 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\])) | |
7630 (buffer-read-only nil)) | |
7631 (when (string= gnus-tmp-name "") | |
7632 (setq gnus-tmp-name gnus-tmp-from)) | |
7633 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0)) | |
7634 (gnus-put-text-property | |
7635 (point) | |
7636 (progn (eval gnus-summary-line-format-spec) (point)) | |
7637 'gnus-number gnus-tmp-number) | |
7638 (when (gnus-visual-p 'summary-highlight 'highlight) | |
7639 (forward-line -1) | |
7640 (run-hooks 'gnus-summary-update-hook) | |
7641 (forward-line 1)))) | |
7642 | |
7643 (defun gnus-summary-update-line (&optional dont-update) | |
7644 ;; Update summary line after change. | |
7645 (when (and gnus-summary-default-score | |
7646 (not gnus-summary-inhibit-highlight)) | |
7647 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion. | |
7648 (article (gnus-summary-article-number)) | |
7649 (score (gnus-summary-article-score article))) | |
7650 (unless dont-update | |
7651 (if (and gnus-summary-mark-below | |
7652 (< (gnus-summary-article-score) | |
7653 gnus-summary-mark-below)) | |
7654 ;; This article has a low score, so we mark it as read. | |
7655 (when (memq article gnus-newsgroup-unreads) | |
7656 (gnus-summary-mark-article-as-read gnus-low-score-mark)) | |
7657 (when (eq (gnus-summary-article-mark) gnus-low-score-mark) | |
7658 ;; This article was previously marked as read on account | |
7659 ;; of a low score, but now it has risen, so we mark it as | |
7660 ;; unread. | |
7661 (gnus-summary-mark-article-as-unread gnus-unread-mark))) | |
7662 (gnus-summary-update-mark | |
7663 (if (or (null gnus-summary-default-score) | |
7664 (<= (abs (- score gnus-summary-default-score)) | |
7665 gnus-summary-zcore-fuzz)) ? | |
7666 (if (< score gnus-summary-default-score) | |
7667 gnus-score-below-mark gnus-score-over-mark)) 'score)) | |
7668 ;; Do visual highlighting. | |
7669 (when (gnus-visual-p 'summary-highlight 'highlight) | |
7670 (run-hooks 'gnus-summary-update-hook))))) | |
7671 | |
7672 (defvar gnus-tmp-new-adopts nil) | |
7673 | |
7674 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char) | |
7675 ;; Sum up all elements (and sub-elements) in a list. | |
7676 (let* ((number | |
7677 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>. | |
7678 (cond | |
7679 ((and (consp thread) (cdr thread)) | |
7680 (apply | |
7681 '+ 1 (mapcar | |
7682 'gnus-summary-number-of-articles-in-thread (cdr thread)))) | |
7683 ((null thread) | |
7684 1) | |
7685 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit) | |
7686 1) | |
7687 (t 0)))) | |
7688 (when (and level (zerop level) gnus-tmp-new-adopts) | |
7689 (incf number | |
7690 (apply '+ (mapcar | |
7691 'gnus-summary-number-of-articles-in-thread | |
7692 gnus-tmp-new-adopts)))) | |
7693 (if char | |
7694 (if (> number 1) gnus-not-empty-thread-mark | |
7695 gnus-empty-thread-mark) | |
7696 number))) | |
7697 | |
7698 (defun gnus-summary-set-local-parameters (group) | |
7699 "Go through the local params of GROUP and set all variable specs in that list." | |
7700 (let ((params (gnus-info-params (gnus-get-info group))) | |
7701 elem) | |
7702 (while params | |
7703 (setq elem (car params) | |
7704 params (cdr params)) | |
7705 (and (consp elem) ; Has to be a cons. | |
7706 (consp (cdr elem)) ; The cdr has to be a list. | |
7707 (symbolp (car elem)) ; Has to be a symbol in there. | |
7708 (not (memq (car elem) | |
7709 '(quit-config to-address to-list to-group))) | |
7710 (progn ; So we set it. | |
7711 (make-local-variable (car elem)) | |
7712 (set (car elem) (eval (nth 1 elem)))))))) | |
7713 | |
7714 (defun gnus-summary-read-group (group &optional show-all no-article | |
7715 kill-buffer no-display) | |
7716 "Start reading news in newsgroup GROUP. | |
7717 If SHOW-ALL is non-nil, already read articles are also listed. | |
7718 If NO-ARTICLE is non-nil, no article is selected initially. | |
7719 If NO-DISPLAY, don't generate a summary buffer." | |
7720 (gnus-message 5 "Retrieving newsgroup: %s..." group) | |
7721 (let* ((new-group (gnus-summary-setup-buffer group)) | |
7722 (quit-config (gnus-group-quit-config group)) | |
7723 (did-select (and new-group (gnus-select-newsgroup group show-all)))) | |
7724 (cond | |
7725 ;; This summary buffer exists already, so we just select it. | |
7726 ((not new-group) | |
7727 (gnus-set-global-variables) | |
7728 (when kill-buffer | |
7729 (gnus-kill-or-deaden-summary kill-buffer)) | |
7730 (gnus-configure-windows 'summary 'force) | |
7731 (gnus-set-mode-line 'summary) | |
7732 (gnus-summary-position-point) | |
7733 (message "") | |
7734 t) | |
7735 ;; We couldn't select this group. | |
7736 ((null did-select) | |
7737 (when (and (eq major-mode 'gnus-summary-mode) | |
7738 (not (equal (current-buffer) kill-buffer))) | |
7739 (kill-buffer (current-buffer)) | |
7740 (if (not quit-config) | |
7741 (progn | |
7742 (set-buffer gnus-group-buffer) | |
7743 (gnus-group-jump-to-group group) | |
7744 (gnus-group-next-unread-group 1)) | |
7745 (if (not (buffer-name (car quit-config))) | |
7746 (gnus-configure-windows 'group 'force) | |
7747 (set-buffer (car quit-config)) | |
7748 (and (eq major-mode 'gnus-summary-mode) | |
7749 (gnus-set-global-variables)) | |
7750 (gnus-configure-windows (cdr quit-config))))) | |
7751 (gnus-message 3 "Can't select group") | |
7752 nil) | |
7753 ;; The user did a `C-g' while prompting for number of articles, | |
7754 ;; so we exit this group. | |
7755 ((eq did-select 'quit) | |
7756 (and (eq major-mode 'gnus-summary-mode) | |
7757 (not (equal (current-buffer) kill-buffer)) | |
7758 (kill-buffer (current-buffer))) | |
7759 (when kill-buffer | |
7760 (gnus-kill-or-deaden-summary kill-buffer)) | |
7761 (if (not quit-config) | |
7762 (progn | |
7763 (set-buffer gnus-group-buffer) | |
7764 (gnus-group-jump-to-group group) | |
7765 (gnus-group-next-unread-group 1) | |
7766 (gnus-configure-windows 'group 'force)) | |
7767 (if (not (buffer-name (car quit-config))) | |
7768 (gnus-configure-windows 'group 'force) | |
7769 (set-buffer (car quit-config)) | |
7770 (and (eq major-mode 'gnus-summary-mode) | |
7771 (gnus-set-global-variables)) | |
7772 (gnus-configure-windows (cdr quit-config)))) | |
7773 ;; Finally signal the quit. | |
7774 (signal 'quit nil)) | |
7775 ;; The group was successfully selected. | |
7776 (t | |
7777 (gnus-set-global-variables) | |
7778 ;; Save the active value in effect when the group was entered. | |
7779 (setq gnus-newsgroup-active | |
7780 (gnus-copy-sequence | |
7781 (gnus-active gnus-newsgroup-name))) | |
7782 ;; You can change the summary buffer in some way with this hook. | |
7783 (run-hooks 'gnus-select-group-hook) | |
7784 ;; Set any local variables in the group parameters. | |
7785 (gnus-summary-set-local-parameters gnus-newsgroup-name) | |
7786 (gnus-update-format-specifications) | |
7787 ;; Do score processing. | |
7788 (when gnus-use-scoring | |
7789 (gnus-possibly-score-headers)) | |
7790 ;; Check whether to fill in the gaps in the threads. | |
7791 (when gnus-build-sparse-threads | |
7792 (gnus-build-sparse-threads)) | |
7793 ;; Find the initial limit. | |
7794 (if gnus-show-threads | |
7795 (if show-all | |
7796 (let ((gnus-newsgroup-dormant nil)) | |
7797 (gnus-summary-initial-limit show-all)) | |
7798 (gnus-summary-initial-limit show-all)) | |
7799 (setq gnus-newsgroup-limit | |
7800 (mapcar | |
7801 (lambda (header) (mail-header-number header)) | |
7802 gnus-newsgroup-headers))) | |
7803 ;; Generate the summary buffer. | |
7804 (unless no-display | |
7805 (gnus-summary-prepare)) | |
7806 (when gnus-use-trees | |
7807 (gnus-tree-open group) | |
7808 (setq gnus-summary-highlight-line-function | |
7809 'gnus-tree-highlight-article)) | |
7810 ;; If the summary buffer is empty, but there are some low-scored | |
7811 ;; articles or some excluded dormants, we include these in the | |
7812 ;; buffer. | |
7813 (when (and (zerop (buffer-size)) | |
7814 (not no-display)) | |
7815 (cond (gnus-newsgroup-dormant | |
7816 (gnus-summary-limit-include-dormant)) | |
7817 ((and gnus-newsgroup-scored show-all) | |
7818 (gnus-summary-limit-include-expunged)))) | |
7819 ;; Function `gnus-apply-kill-file' must be called in this hook. | |
7820 (run-hooks 'gnus-apply-kill-hook) | |
7821 (if (and (zerop (buffer-size)) | |
7822 (not no-display)) | |
7823 (progn | |
7824 ;; This newsgroup is empty. | |
7825 (gnus-summary-catchup-and-exit nil t) ;Without confirmations. | |
7826 (gnus-message 6 "No unread news") | |
7827 (when kill-buffer | |
7828 (gnus-kill-or-deaden-summary kill-buffer)) | |
7829 ;; Return nil from this function. | |
7830 nil) | |
7831 ;; Hide conversation thread subtrees. We cannot do this in | |
7832 ;; gnus-summary-prepare-hook since kill processing may not | |
7833 ;; work with hidden articles. | |
7834 (and gnus-show-threads | |
7835 gnus-thread-hide-subtree | |
7836 (gnus-summary-hide-all-threads)) | |
7837 ;; Show first unread article if requested. | |
7838 (if (and (not no-article) | |
7839 (not no-display) | |
7840 gnus-newsgroup-unreads | |
7841 gnus-auto-select-first) | |
7842 (unless (if (eq gnus-auto-select-first 'best) | |
7843 (gnus-summary-best-unread-article) | |
7844 (gnus-summary-first-unread-article)) | |
7845 (gnus-configure-windows 'summary)) | |
7846 ;; Don't select any articles, just move point to the first | |
7847 ;; article in the group. | |
7848 (goto-char (point-min)) | |
7849 (gnus-summary-position-point) | |
7850 (gnus-set-mode-line 'summary) | |
7851 (gnus-configure-windows 'summary 'force)) | |
7852 ;; If we are in async mode, we send some info to the backend. | |
7853 (when gnus-newsgroup-async | |
7854 (gnus-request-asynchronous gnus-newsgroup-name gnus-newsgroup-data)) | |
7855 (when kill-buffer | |
7856 (gnus-kill-or-deaden-summary kill-buffer)) | |
7857 (when (get-buffer-window gnus-group-buffer t) | |
7858 ;; Gotta use windows, because recenter does wierd stuff if | |
7859 ;; the current buffer ain't the displayed window. | |
7860 (let ((owin (selected-window))) | |
7861 (select-window (get-buffer-window gnus-group-buffer t)) | |
7862 (when (gnus-group-goto-group group) | |
7863 (recenter)) | |
7864 (select-window owin)))) | |
7865 ;; Mark this buffer as "prepared". | |
7866 (setq gnus-newsgroup-prepared t) | |
7867 t)))) | |
7868 | |
7869 (defun gnus-summary-prepare () | |
7870 "Generate the summary buffer." | |
7871 (let ((buffer-read-only nil)) | |
7872 (erase-buffer) | |
7873 (setq gnus-newsgroup-data nil | |
7874 gnus-newsgroup-data-reverse nil) | |
7875 (run-hooks 'gnus-summary-generate-hook) | |
7876 ;; Generate the buffer, either with threads or without. | |
7877 (when gnus-newsgroup-headers | |
7878 (gnus-summary-prepare-threads | |
7879 (if gnus-show-threads | |
7880 (gnus-sort-gathered-threads | |
7881 (funcall gnus-summary-thread-gathering-function | |
7882 (gnus-sort-threads | |
7883 (gnus-cut-threads (gnus-make-threads))))) | |
7884 ;; Unthreaded display. | |
7885 (gnus-sort-articles gnus-newsgroup-headers)))) | |
7886 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data)) | |
7887 ;; Call hooks for modifying summary buffer. | |
7888 (goto-char (point-min)) | |
7889 (run-hooks 'gnus-summary-prepare-hook))) | |
7890 | |
7891 (defun gnus-gather-threads-by-subject (threads) | |
7892 "Gather threads by looking at Subject headers." | |
7893 (if (not gnus-summary-make-false-root) | |
7894 threads | |
7895 (let ((hashtb (gnus-make-hashtable 1023)) | |
7896 (prev threads) | |
7897 (result threads) | |
7898 subject hthread whole-subject) | |
7899 (while threads | |
7900 (setq whole-subject (mail-header-subject (caar threads))) | |
7901 (setq subject | |
7902 (cond | |
7903 ;; Truncate the subject. | |
7904 ((numberp gnus-summary-gather-subject-limit) | |
7905 (setq subject (gnus-simplify-subject-re whole-subject)) | |
7906 (if (> (length subject) gnus-summary-gather-subject-limit) | |
7907 (substring subject 0 gnus-summary-gather-subject-limit) | |
7908 subject)) | |
7909 ;; Fuzzily simplify it. | |
7910 ((eq 'fuzzy gnus-summary-gather-subject-limit) | |
7911 (gnus-simplify-subject-fuzzy whole-subject)) | |
7912 ;; Just remove the leading "Re:". | |
7913 (t | |
7914 (gnus-simplify-subject-re whole-subject)))) | |
7915 | |
7916 (if (and gnus-summary-gather-exclude-subject | |
7917 (string-match gnus-summary-gather-exclude-subject | |
7918 subject)) | |
7919 () ; We don't want to do anything with this article. | |
7920 ;; We simplify the subject before looking it up in the | |
7921 ;; hash table. | |
7922 | |
7923 (if (setq hthread (gnus-gethash subject hashtb)) | |
7924 (progn | |
7925 ;; We enter a dummy root into the thread, if we | |
7926 ;; haven't done that already. | |
7927 (unless (stringp (caar hthread)) | |
7928 (setcar hthread (list whole-subject (car hthread)))) | |
7929 ;; We add this new gathered thread to this gathered | |
7930 ;; thread. | |
7931 (setcdr (car hthread) | |
7932 (nconc (cdar hthread) (list (car threads)))) | |
7933 ;; Remove it from the list of threads. | |
7934 (setcdr prev (cdr threads)) | |
7935 (setq threads prev)) | |
7936 ;; Enter this thread into the hash table. | |
7937 (gnus-sethash subject threads hashtb))) | |
7938 (setq prev threads) | |
7939 (setq threads (cdr threads))) | |
7940 result))) | |
7941 | |
7942 (defun gnus-gather-threads-by-references (threads) | |
7943 "Gather threads by looking at References headers." | |
7944 (let ((idhashtb (gnus-make-hashtable 1023)) | |
7945 (thhashtb (gnus-make-hashtable 1023)) | |
7946 (prev threads) | |
7947 (result threads) | |
7948 ids references id gthread gid entered) | |
7949 (while threads | |
7950 (when (setq references (mail-header-references (caar threads))) | |
7951 (setq id (mail-header-id (caar threads))) | |
7952 (setq ids (gnus-split-references references)) | |
7953 (setq entered nil) | |
7954 (while ids | |
7955 (if (not (setq gid (gnus-gethash (car ids) idhashtb))) | |
7956 (progn | |
7957 (gnus-sethash (car ids) id idhashtb) | |
7958 (gnus-sethash id threads thhashtb)) | |
7959 (setq gthread (gnus-gethash gid thhashtb)) | |
7960 (unless entered | |
7961 ;; We enter a dummy root into the thread, if we | |
7962 ;; haven't done that already. | |
7963 (unless (stringp (caar gthread)) | |
7964 (setcar gthread (list (mail-header-subject (caar gthread)) | |
7965 (car gthread)))) | |
7966 ;; We add this new gathered thread to this gathered | |
7967 ;; thread. | |
7968 (setcdr (car gthread) | |
7969 (nconc (cdar gthread) (list (car threads))))) | |
7970 ;; Add it into the thread hash table. | |
7971 (gnus-sethash id gthread thhashtb) | |
7972 (setq entered t) | |
7973 ;; Remove it from the list of threads. | |
7974 (setcdr prev (cdr threads)) | |
7975 (setq threads prev)) | |
7976 (setq ids (cdr ids)))) | |
7977 (setq prev threads) | |
7978 (setq threads (cdr threads))) | |
7979 result)) | |
7980 | |
7981 (defun gnus-sort-gathered-threads (threads) | |
7982 "Sort subtreads inside each gathered thread by article number." | |
7983 (let ((result threads)) | |
7984 (while threads | |
7985 (when (stringp (caar threads)) | |
7986 (setcdr (car threads) | |
7987 (sort (cdar threads) 'gnus-thread-sort-by-number))) | |
7988 (setq threads (cdr threads))) | |
7989 result)) | |
7990 | |
7991 (defun gnus-make-threads () | |
7992 "Go through the dependency hashtb and find the roots. Return all threads." | |
7993 (let (threads) | |
7994 (mapatoms | |
7995 (lambda (refs) | |
7996 (unless (car (symbol-value refs)) | |
7997 ;; These threads do not refer back to any other articles, | |
7998 ;; so they're roots. | |
7999 (setq threads (append (cdr (symbol-value refs)) threads)))) | |
8000 gnus-newsgroup-dependencies) | |
8001 threads)) | |
8002 | |
8003 (defun gnus-build-sparse-threads () | |
8004 (let ((headers gnus-newsgroup-headers) | |
8005 (deps gnus-newsgroup-dependencies) | |
8006 header references generation relations | |
8007 cthread subject child end pthread relation) | |
8008 ;; First we create an alist of generations/relations, where | |
8009 ;; generations is how much we trust the ralation, and the relation | |
8010 ;; is parent/child. | |
8011 (gnus-message 7 "Making sparse threads...") | |
8012 (save-excursion | |
8013 (nnheader-set-temp-buffer " *gnus sparse threads*") | |
8014 (while (setq header (pop headers)) | |
8015 (when (and (setq references (mail-header-references header)) | |
8016 (not (string= references ""))) | |
8017 (insert references) | |
8018 (setq child (mail-header-id header) | |
8019 subject (mail-header-subject header)) | |
8020 (setq generation 0) | |
8021 (while (search-backward ">" nil t) | |
8022 (setq end (1+ (point))) | |
8023 (when (search-backward "<" nil t) | |
8024 (push (list (incf generation) | |
8025 child (setq child (buffer-substring (point) end)) | |
8026 subject) | |
8027 relations))) | |
8028 (push (list (1+ generation) child nil subject) relations) | |
8029 (erase-buffer))) | |
8030 (kill-buffer (current-buffer))) | |
8031 ;; Sort over trustworthiness. | |
8032 (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2))))) | |
8033 (while (setq relation (pop relations)) | |
8034 (when (if (boundp (setq cthread (intern (cadr relation) deps))) | |
8035 (unless (car (symbol-value cthread)) | |
8036 ;; Make this article the parent of these threads. | |
8037 (setcar (symbol-value cthread) | |
8038 (vector gnus-reffed-article-number | |
8039 (cadddr relation) | |
8040 "" "" | |
8041 (cadr relation) | |
8042 (or (caddr relation) "") 0 0 ""))) | |
8043 (set cthread (list (vector gnus-reffed-article-number | |
8044 (cadddr relation) | |
8045 "" "" (cadr relation) | |
8046 (or (caddr relation) "") 0 0 "")))) | |
8047 (push gnus-reffed-article-number gnus-newsgroup-limit) | |
8048 (push gnus-reffed-article-number gnus-newsgroup-sparse) | |
8049 (push (cons gnus-reffed-article-number gnus-sparse-mark) | |
8050 gnus-newsgroup-reads) | |
8051 (decf gnus-reffed-article-number) | |
8052 ;; Make this new thread the child of its parent. | |
8053 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps))) | |
8054 (setcdr (symbol-value pthread) | |
8055 (nconc (cdr (symbol-value pthread)) | |
8056 (list (symbol-value cthread)))) | |
8057 (set pthread (list nil (symbol-value cthread)))))) | |
8058 (gnus-message 7 "Making sparse threads...done"))) | |
8059 | |
8060 (defun gnus-build-old-threads () | |
8061 ;; Look at all the articles that refer back to old articles, and | |
8062 ;; fetch the headers for the articles that aren't there. This will | |
8063 ;; build complete threads - if the roots haven't been expired by the | |
8064 ;; server, that is. | |
8065 (let (id heads) | |
8066 (mapatoms | |
8067 (lambda (refs) | |
8068 (when (not (car (symbol-value refs))) | |
8069 (setq heads (cdr (symbol-value refs))) | |
8070 (while heads | |
8071 (if (memq (mail-header-number (caar heads)) | |
8072 gnus-newsgroup-dormant) | |
8073 (setq heads (cdr heads)) | |
8074 (setq id (symbol-name refs)) | |
8075 (while (and (setq id (gnus-build-get-header id)) | |
8076 (not (car (gnus-gethash | |
8077 id gnus-newsgroup-dependencies))))) | |
8078 (setq heads nil))))) | |
8079 gnus-newsgroup-dependencies))) | |
8080 | |
8081 (defun gnus-build-get-header (id) | |
8082 ;; Look through the buffer of NOV lines and find the header to | |
8083 ;; ID. Enter this line into the dependencies hash table, and return | |
8084 ;; the id of the parent article (if any). | |
8085 (let ((deps gnus-newsgroup-dependencies) | |
8086 found header) | |
8087 (prog1 | |
8088 (save-excursion | |
8089 (set-buffer nntp-server-buffer) | |
8090 (goto-char (point-min)) | |
8091 (while (and (not found) (search-forward id nil t)) | |
8092 (beginning-of-line) | |
8093 (setq found (looking-at | |
8094 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s" | |
8095 (regexp-quote id)))) | |
8096 (or found (beginning-of-line 2))) | |
8097 (when found | |
8098 (beginning-of-line) | |
8099 (and | |
8100 (setq header (gnus-nov-parse-line | |
8101 (read (current-buffer)) deps)) | |
8102 (gnus-parent-id (mail-header-references header))))) | |
8103 (when header | |
8104 (let ((number (mail-header-number header))) | |
8105 (push number gnus-newsgroup-limit) | |
8106 (push header gnus-newsgroup-headers) | |
8107 (if (memq number gnus-newsgroup-unselected) | |
8108 (progn | |
8109 (push number gnus-newsgroup-unreads) | |
8110 (setq gnus-newsgroup-unselected | |
8111 (delq number gnus-newsgroup-unselected))) | |
8112 (push number gnus-newsgroup-ancient))))))) | |
8113 | |
8114 (defun gnus-summary-update-article (article &optional iheader) | |
8115 "Update ARTICLE in the summary buffer." | |
8116 (set-buffer gnus-summary-buffer) | |
8117 (let* ((header (or iheader (gnus-summary-article-header article))) | |
8118 (id (mail-header-id header)) | |
8119 (data (gnus-data-find article)) | |
8120 (thread (gnus-id-to-thread id)) | |
8121 (references (mail-header-references header)) | |
8122 (parent | |
8123 (gnus-id-to-thread | |
8124 (or (gnus-parent-id | |
8125 (if (and references | |
8126 (not (equal "" references))) | |
8127 references)) | |
8128 "none"))) | |
8129 (buffer-read-only nil) | |
8130 (old (car thread)) | |
8131 (number (mail-header-number header)) | |
8132 pos) | |
8133 (when thread | |
8134 ;; !!! Should this be in or not? | |
8135 (unless iheader | |
8136 (setcar thread nil)) | |
8137 (when parent | |
8138 (delq thread parent)) | |
8139 (if (gnus-summary-insert-subject id header iheader) | |
8140 ;; Set the (possibly) new article number in the data structure. | |
8141 (gnus-data-set-number data (gnus-id-to-article id)) | |
8142 (setcar thread old) | |
8143 nil)))) | |
8144 | |
8145 (defun gnus-rebuild-thread (id) | |
8146 "Rebuild the thread containing ID." | |
8147 (let ((buffer-read-only nil) | |
8148 current thread data) | |
8149 (if (not gnus-show-threads) | |
8150 (setq thread (list (car (gnus-id-to-thread id)))) | |
8151 ;; Get the thread this article is part of. | |
8152 (setq thread (gnus-remove-thread id))) | |
8153 (setq current (save-excursion | |
8154 (and (zerop (forward-line -1)) | |
8155 (gnus-summary-article-number)))) | |
8156 ;; If this is a gathered thread, we have to go some re-gathering. | |
8157 (when (stringp (car thread)) | |
8158 (let ((subject (car thread)) | |
8159 roots thr) | |
8160 (setq thread (cdr thread)) | |
8161 (while thread | |
8162 (unless (memq (setq thr (gnus-id-to-thread | |
8163 (gnus-root-id | |
8164 (mail-header-id (caar thread))))) | |
8165 roots) | |
8166 (push thr roots)) | |
8167 (setq thread (cdr thread))) | |
8168 ;; We now have all (unique) roots. | |
8169 (if (= (length roots) 1) | |
8170 ;; All the loose roots are now one solid root. | |
8171 (setq thread (car roots)) | |
8172 (setq thread (cons subject (gnus-sort-threads roots)))))) | |
8173 (let (threads) | |
8174 ;; We then insert this thread into the summary buffer. | |
8175 (let (gnus-newsgroup-data gnus-newsgroup-threads) | |
8176 (gnus-summary-prepare-threads (gnus-cut-threads (list thread))) | |
8177 (setq data (nreverse gnus-newsgroup-data)) | |
8178 (setq threads gnus-newsgroup-threads)) | |
8179 ;; We splice the new data into the data structure. | |
8180 (gnus-data-enter-list current data) | |
8181 (gnus-data-compute-positions) | |
8182 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads))))) | |
8183 | |
8184 (defun gnus-number-to-header (number) | |
8185 "Return the header for article NUMBER." | |
8186 (let ((headers gnus-newsgroup-headers)) | |
8187 (while (and headers | |
8188 (not (= number (mail-header-number (car headers))))) | |
8189 (pop headers)) | |
8190 (when headers | |
8191 (car headers)))) | |
8192 | |
8193 (defun gnus-id-to-thread (id) | |
8194 "Return the (sub-)thread where ID appears." | |
8195 (gnus-gethash id gnus-newsgroup-dependencies)) | |
8196 | |
8197 (defun gnus-id-to-article (id) | |
8198 "Return the article number of ID." | |
8199 (let ((thread (gnus-id-to-thread id))) | |
8200 (when (and thread | |
8201 (car thread)) | |
8202 (mail-header-number (car thread))))) | |
8203 | |
8204 (defun gnus-id-to-header (id) | |
8205 "Return the article headers of ID." | |
8206 (car (gnus-id-to-thread id))) | |
8207 | |
8208 (defun gnus-article-displayed-root-p (article) | |
8209 "Say whether ARTICLE is a root(ish) article." | |
8210 (let ((level (gnus-summary-thread-level article)) | |
8211 (refs (mail-header-references (gnus-summary-article-header article))) | |
8212 particle) | |
8213 (cond | |
8214 ((null level) nil) | |
8215 ((zerop level) t) | |
8216 ((null refs) t) | |
8217 ((null (gnus-parent-id refs)) t) | |
8218 ((and (= 1 level) | |
8219 (null (setq particle (gnus-id-to-article | |
8220 (gnus-parent-id refs)))) | |
8221 (null (gnus-summary-thread-level particle))))))) | |
8222 | |
8223 (defun gnus-root-id (id) | |
8224 "Return the id of the root of the thread where ID appears." | |
8225 (let (last-id prev) | |
8226 (while (and id (setq prev (car (gnus-gethash | |
8227 id gnus-newsgroup-dependencies)))) | |
8228 (setq last-id id | |
8229 id (gnus-parent-id (mail-header-references prev)))) | |
8230 last-id)) | |
8231 | |
8232 (defun gnus-remove-thread (id &optional dont-remove) | |
8233 "Remove the thread that has ID in it." | |
8234 (let ((dep gnus-newsgroup-dependencies) | |
8235 headers thread last-id) | |
8236 ;; First go up in this thread until we find the root. | |
8237 (setq last-id (gnus-root-id id)) | |
8238 (setq headers (list (car (gnus-id-to-thread last-id)) | |
8239 (caadr (gnus-id-to-thread last-id)))) | |
8240 ;; We have now found the real root of this thread. It might have | |
8241 ;; been gathered into some loose thread, so we have to search | |
8242 ;; through the threads to find the thread we wanted. | |
8243 (let ((threads gnus-newsgroup-threads) | |
8244 sub) | |
8245 (while threads | |
8246 (setq sub (car threads)) | |
8247 (if (stringp (car sub)) | |
8248 ;; This is a gathered threads, so we look at the roots | |
8249 ;; below it to find whether this article in in this | |
8250 ;; gathered root. | |
8251 (progn | |
8252 (setq sub (cdr sub)) | |
8253 (while sub | |
8254 (when (member (caar sub) headers) | |
8255 (setq thread (car threads) | |
8256 threads nil | |
8257 sub nil)) | |
8258 (setq sub (cdr sub)))) | |
8259 ;; It's an ordinary thread, so we check it. | |
8260 (when (eq (car sub) (car headers)) | |
8261 (setq thread sub | |
8262 threads nil))) | |
8263 (setq threads (cdr threads))) | |
8264 ;; If this article is in no thread, then it's a root. | |
8265 (if thread | |
8266 (unless dont-remove | |
8267 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads))) | |
8268 (setq thread (gnus-gethash last-id dep))) | |
8269 (when thread | |
8270 (prog1 | |
8271 thread ; We return this thread. | |
8272 (unless dont-remove | |
8273 (if (stringp (car thread)) | |
8274 (progn | |
8275 ;; If we use dummy roots, then we have to remove the | |
8276 ;; dummy root as well. | |
8277 (when (eq gnus-summary-make-false-root 'dummy) | |
8278 ;; Uhm. | |
8279 ) | |
8280 (setq thread (cdr thread)) | |
8281 (while thread | |
8282 (gnus-remove-thread-1 (car thread)) | |
8283 (setq thread (cdr thread)))) | |
8284 (gnus-remove-thread-1 thread)))))))) | |
8285 | |
8286 (defun gnus-remove-thread-1 (thread) | |
8287 "Remove the thread THREAD recursively." | |
8288 (let ((number (mail-header-number (car thread))) | |
8289 pos) | |
8290 (when (setq pos (text-property-any | |
8291 (point-min) (point-max) 'gnus-number number)) | |
8292 (goto-char pos) | |
8293 (gnus-delete-line) | |
8294 (gnus-data-remove number)) | |
8295 (setq thread (cdr thread)) | |
8296 (while thread | |
8297 (gnus-remove-thread-1 (pop thread))))) | |
8298 | |
8299 (defun gnus-sort-threads (threads) | |
8300 "Sort THREADS." | |
8301 (if (not gnus-thread-sort-functions) | |
8302 threads | |
8303 (let ((func (if (= 1 (length gnus-thread-sort-functions)) | |
8304 (car gnus-thread-sort-functions) | |
8305 `(lambda (t1 t2) | |
8306 ,(gnus-make-sort-function | |
8307 (reverse gnus-thread-sort-functions)))))) | |
8308 (gnus-message 7 "Sorting threads...") | |
8309 (prog1 | |
8310 (sort threads func) | |
8311 (gnus-message 7 "Sorting threads...done"))))) | |
8312 | |
8313 (defun gnus-sort-articles (articles) | |
8314 "Sort ARTICLES." | |
8315 (when gnus-article-sort-functions | |
8316 (let ((func (if (= 1 (length gnus-article-sort-functions)) | |
8317 (car gnus-article-sort-functions) | |
8318 `(lambda (t1 t2) | |
8319 ,(gnus-make-sort-function | |
8320 (reverse gnus-article-sort-functions)))))) | |
8321 (gnus-message 7 "Sorting articles...") | |
8322 (prog1 | |
8323 (setq gnus-newsgroup-headers (sort articles func)) | |
8324 (gnus-message 7 "Sorting articles...done"))))) | |
8325 | |
8326 (defun gnus-make-sort-function (funs) | |
8327 "Return a composite sort condition based on the functions in FUNC." | |
8328 (if (cdr funs) | |
8329 `(or (,(car funs) t1 t2) | |
8330 (and (not (,(car funs) t2 t1)) | |
8331 ,(gnus-make-sort-function (cdr funs)))) | |
8332 `(,(car funs) t1 t2))) | |
8333 | |
8334 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>. | |
8335 (defmacro gnus-thread-header (thread) | |
8336 ;; Return header of first article in THREAD. | |
8337 ;; Note that THREAD must never, ever be anything else than a variable - | |
8338 ;; using some other form will lead to serious barfage. | |
8339 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread))) | |
8340 ;; (8% speedup to gnus-summary-prepare, just for fun :-) | |
8341 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ; | |
8342 (vector thread) 2)) | |
8343 | |
8344 (defsubst gnus-article-sort-by-number (h1 h2) | |
8345 "Sort articles by article number." | |
8346 (< (mail-header-number h1) | |
8347 (mail-header-number h2))) | |
8348 | |
8349 (defun gnus-thread-sort-by-number (h1 h2) | |
8350 "Sort threads by root article number." | |
8351 (gnus-article-sort-by-number | |
8352 (gnus-thread-header h1) (gnus-thread-header h2))) | |
8353 | |
8354 (defsubst gnus-article-sort-by-author (h1 h2) | |
8355 "Sort articles by root author." | |
8356 (string-lessp | |
8357 (let ((extract (funcall | |
8358 gnus-extract-address-components | |
8359 (mail-header-from h1)))) | |
8360 (or (car extract) (cdr extract))) | |
8361 (let ((extract (funcall | |
8362 gnus-extract-address-components | |
8363 (mail-header-from h2)))) | |
8364 (or (car extract) (cdr extract))))) | |
8365 | |
8366 (defun gnus-thread-sort-by-author (h1 h2) | |
8367 "Sort threads by root author." | |
8368 (gnus-article-sort-by-author | |
8369 (gnus-thread-header h1) (gnus-thread-header h2))) | |
8370 | |
8371 (defsubst gnus-article-sort-by-subject (h1 h2) | |
8372 "Sort articles by root subject." | |
8373 (string-lessp | |
8374 (downcase (gnus-simplify-subject-re (mail-header-subject h1))) | |
8375 (downcase (gnus-simplify-subject-re (mail-header-subject h2))))) | |
8376 | |
8377 (defun gnus-thread-sort-by-subject (h1 h2) | |
8378 "Sort threads by root subject." | |
8379 (gnus-article-sort-by-subject | |
8380 (gnus-thread-header h1) (gnus-thread-header h2))) | |
8381 | |
8382 (defsubst gnus-article-sort-by-date (h1 h2) | |
8383 "Sort articles by root article date." | |
8384 (string-lessp | |
8385 (inline (gnus-sortable-date (mail-header-date h1))) | |
8386 (inline (gnus-sortable-date (mail-header-date h2))))) | |
8387 | |
8388 (defun gnus-thread-sort-by-date (h1 h2) | |
8389 "Sort threads by root article date." | |
8390 (gnus-article-sort-by-date | |
8391 (gnus-thread-header h1) (gnus-thread-header h2))) | |
8392 | |
8393 (defsubst gnus-article-sort-by-score (h1 h2) | |
8394 "Sort articles by root article score. | |
8395 Unscored articles will be counted as having a score of zero." | |
8396 (> (or (cdr (assq (mail-header-number h1) | |
8397 gnus-newsgroup-scored)) | |
8398 gnus-summary-default-score 0) | |
8399 (or (cdr (assq (mail-header-number h2) | |
8400 gnus-newsgroup-scored)) | |
8401 gnus-summary-default-score 0))) | |
8402 | |
8403 (defun gnus-thread-sort-by-score (h1 h2) | |
8404 "Sort threads by root article score." | |
8405 (gnus-article-sort-by-score | |
8406 (gnus-thread-header h1) (gnus-thread-header h2))) | |
8407 | |
8408 (defun gnus-thread-sort-by-total-score (h1 h2) | |
8409 "Sort threads by the sum of all scores in the thread. | |
8410 Unscored articles will be counted as having a score of zero." | |
8411 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2))) | |
8412 | |
8413 (defun gnus-thread-total-score (thread) | |
8414 ;; This function find the total score of THREAD. | |
8415 (cond ((null thread) | |
8416 0) | |
8417 ((consp thread) | |
8418 (if (stringp (car thread)) | |
8419 (apply gnus-thread-score-function 0 | |
8420 (mapcar 'gnus-thread-total-score-1 (cdr thread))) | |
8421 (gnus-thread-total-score-1 thread))) | |
8422 (t | |
8423 (gnus-thread-total-score-1 (list thread))))) | |
8424 | |
8425 (defun gnus-thread-total-score-1 (root) | |
8426 ;; This function find the total score of the thread below ROOT. | |
8427 (setq root (car root)) | |
8428 (apply gnus-thread-score-function | |
8429 (or (cdr (assq (mail-header-number root) gnus-newsgroup-scored)) | |
8430 gnus-summary-default-score 0) | |
8431 (mapcar 'gnus-thread-total-score | |
8432 (cdr (gnus-gethash (mail-header-id root) | |
8433 gnus-newsgroup-dependencies))))) | |
8434 | |
8435 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>. | |
8436 (defvar gnus-tmp-prev-subject nil) | |
8437 (defvar gnus-tmp-false-parent nil) | |
8438 (defvar gnus-tmp-root-expunged nil) | |
8439 (defvar gnus-tmp-dummy-line nil) | |
8440 | |
8441 (defun gnus-summary-prepare-threads (threads) | |
8442 "Prepare summary buffer from THREADS and indentation LEVEL. | |
8443 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])' | |
8444 or a straight list of headers." | |
8445 (gnus-message 7 "Generating summary...") | |
8446 | |
8447 (setq gnus-newsgroup-threads threads) | |
8448 (beginning-of-line) | |
8449 | |
8450 (let ((gnus-tmp-level 0) | |
8451 (default-score (or gnus-summary-default-score 0)) | |
8452 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight)) | |
8453 thread number subject stack state gnus-tmp-gathered beg-match | |
8454 new-roots gnus-tmp-new-adopts thread-end | |
8455 gnus-tmp-header gnus-tmp-unread | |
8456 gnus-tmp-replied gnus-tmp-subject-or-nil | |
8457 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score | |
8458 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name | |
8459 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket) | |
8460 | |
8461 (setq gnus-tmp-prev-subject nil) | |
8462 | |
8463 (if (vectorp (car threads)) | |
8464 ;; If this is a straight (sic) list of headers, then a | |
8465 ;; threaded summary display isn't required, so we just create | |
8466 ;; an unthreaded one. | |
8467 (gnus-summary-prepare-unthreaded threads) | |
8468 | |
8469 ;; Do the threaded display. | |
8470 | |
8471 (while (or threads stack gnus-tmp-new-adopts new-roots) | |
8472 | |
8473 (if (and (= gnus-tmp-level 0) | |
8474 (not (setq gnus-tmp-dummy-line nil)) | |
8475 (or (not stack) | |
8476 (= (caar stack) 0)) | |
8477 (not gnus-tmp-false-parent) | |
8478 (or gnus-tmp-new-adopts new-roots)) | |
8479 (if gnus-tmp-new-adopts | |
8480 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1) | |
8481 thread (list (car gnus-tmp-new-adopts)) | |
8482 gnus-tmp-header (caar thread) | |
8483 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts)) | |
8484 (if new-roots | |
8485 (setq thread (list (car new-roots)) | |
8486 gnus-tmp-header (caar thread) | |
8487 new-roots (cdr new-roots)))) | |
8488 | |
8489 (if threads | |
8490 ;; If there are some threads, we do them before the | |
8491 ;; threads on the stack. | |
8492 (setq thread threads | |
8493 gnus-tmp-header (caar thread)) | |
8494 ;; There were no current threads, so we pop something off | |
8495 ;; the stack. | |
8496 (setq state (car stack) | |
8497 gnus-tmp-level (car state) | |
8498 thread (cdr state) | |
8499 stack (cdr stack) | |
8500 gnus-tmp-header (caar thread)))) | |
8501 | |
8502 (setq gnus-tmp-false-parent nil) | |
8503 (setq gnus-tmp-root-expunged nil) | |
8504 (setq thread-end nil) | |
8505 | |
8506 (if (stringp gnus-tmp-header) | |
8507 ;; The header is a dummy root. | |
8508 (cond | |
8509 ((eq gnus-summary-make-false-root 'adopt) | |
8510 ;; We let the first article adopt the rest. | |
8511 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts | |
8512 (cddar thread))) | |
8513 (setq gnus-tmp-gathered | |
8514 (nconc (mapcar | |
8515 (lambda (h) (mail-header-number (car h))) | |
8516 (cddar thread)) | |
8517 gnus-tmp-gathered)) | |
8518 (setq thread (cons (list (caar thread) | |
8519 (cadar thread)) | |
8520 (cdr thread))) | |
8521 (setq gnus-tmp-level -1 | |
8522 gnus-tmp-false-parent t)) | |
8523 ((eq gnus-summary-make-false-root 'empty) | |
8524 ;; We print adopted articles with empty subject fields. | |
8525 (setq gnus-tmp-gathered | |
8526 (nconc (mapcar | |
8527 (lambda (h) (mail-header-number (car h))) | |
8528 (cddar thread)) | |
8529 gnus-tmp-gathered)) | |
8530 (setq gnus-tmp-level -1)) | |
8531 ((eq gnus-summary-make-false-root 'dummy) | |
8532 ;; We remember that we probably want to output a dummy | |
8533 ;; root. | |
8534 (setq gnus-tmp-dummy-line gnus-tmp-header) | |
8535 (setq gnus-tmp-prev-subject gnus-tmp-header)) | |
8536 (t | |
8537 ;; We do not make a root for the gathered | |
8538 ;; sub-threads at all. | |
8539 (setq gnus-tmp-level -1))) | |
8540 | |
8541 (setq number (mail-header-number gnus-tmp-header) | |
8542 subject (mail-header-subject gnus-tmp-header)) | |
8543 | |
8544 (cond | |
8545 ;; If the thread has changed subject, we might want to make | |
8546 ;; this subthread into a root. | |
8547 ((and (null gnus-thread-ignore-subject) | |
8548 (not (zerop gnus-tmp-level)) | |
8549 gnus-tmp-prev-subject | |
8550 (not (inline | |
8551 (gnus-subject-equal gnus-tmp-prev-subject subject)))) | |
8552 (setq new-roots (nconc new-roots (list (car thread))) | |
8553 thread-end t | |
8554 gnus-tmp-header nil)) | |
8555 ;; If the article lies outside the current limit, | |
8556 ;; then we do not display it. | |
8557 ((and (not (memq number gnus-newsgroup-limit)) | |
8558 (not gnus-tmp-dummy-line)) | |
8559 (setq gnus-tmp-gathered | |
8560 (nconc (mapcar | |
8561 (lambda (h) (mail-header-number (car h))) | |
8562 (cdar thread)) | |
8563 gnus-tmp-gathered)) | |
8564 (setq gnus-tmp-new-adopts (if (cdar thread) | |
8565 (append gnus-tmp-new-adopts | |
8566 (cdar thread)) | |
8567 gnus-tmp-new-adopts) | |
8568 thread-end t | |
8569 gnus-tmp-header nil) | |
8570 (when (zerop gnus-tmp-level) | |
8571 (setq gnus-tmp-root-expunged t))) | |
8572 ;; Perhaps this article is to be marked as read? | |
8573 ((and gnus-summary-mark-below | |
8574 (< (or (cdr (assq number gnus-newsgroup-scored)) | |
8575 default-score) | |
8576 gnus-summary-mark-below) | |
8577 ;; Don't touch sparse articles. | |
8578 (not (memq number gnus-newsgroup-sparse)) | |
8579 (not (memq number gnus-newsgroup-ancient))) | |
8580 (setq gnus-newsgroup-unreads | |
8581 (delq number gnus-newsgroup-unreads)) | |
8582 (if gnus-newsgroup-auto-expire | |
8583 (push number gnus-newsgroup-expirable) | |
8584 (push (cons number gnus-low-score-mark) | |
8585 gnus-newsgroup-reads)))) | |
8586 | |
8587 (when gnus-tmp-header | |
8588 ;; We may have an old dummy line to output before this | |
8589 ;; article. | |
8590 (when gnus-tmp-dummy-line | |
8591 (gnus-summary-insert-dummy-line | |
8592 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header)) | |
8593 (setq gnus-tmp-dummy-line nil)) | |
8594 | |
8595 ;; Compute the mark. | |
8596 (setq | |
8597 gnus-tmp-unread | |
8598 (cond | |
8599 ((memq number gnus-newsgroup-unreads) gnus-unread-mark) | |
8600 ((memq number gnus-newsgroup-marked) gnus-ticked-mark) | |
8601 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark) | |
8602 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark) | |
8603 (t (or (cdr (assq number gnus-newsgroup-reads)) | |
8604 gnus-ancient-mark)))) | |
8605 | |
8606 (push (gnus-data-make number gnus-tmp-unread (1+ (point)) | |
8607 gnus-tmp-header gnus-tmp-level) | |
8608 gnus-newsgroup-data) | |
8609 | |
8610 ;; Actually insert the line. | |
8611 (setq | |
8612 gnus-tmp-subject-or-nil | |
8613 (cond | |
8614 ((and gnus-thread-ignore-subject | |
8615 gnus-tmp-prev-subject | |
8616 (not (inline (gnus-subject-equal | |
8617 gnus-tmp-prev-subject subject)))) | |
8618 subject) | |
8619 ((zerop gnus-tmp-level) | |
8620 (if (and (eq gnus-summary-make-false-root 'empty) | |
8621 (memq number gnus-tmp-gathered) | |
8622 gnus-tmp-prev-subject | |
8623 (inline (gnus-subject-equal | |
8624 gnus-tmp-prev-subject subject))) | |
8625 gnus-summary-same-subject | |
8626 subject)) | |
8627 (t gnus-summary-same-subject))) | |
8628 (if (and (eq gnus-summary-make-false-root 'adopt) | |
8629 (= gnus-tmp-level 1) | |
8630 (memq number gnus-tmp-gathered)) | |
8631 (setq gnus-tmp-opening-bracket ?\< | |
8632 gnus-tmp-closing-bracket ?\>) | |
8633 (setq gnus-tmp-opening-bracket ?\[ | |
8634 gnus-tmp-closing-bracket ?\])) | |
8635 (setq | |
8636 gnus-tmp-indentation | |
8637 (aref gnus-thread-indent-array gnus-tmp-level) | |
8638 gnus-tmp-lines (mail-header-lines gnus-tmp-header) | |
8639 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored)) | |
8640 gnus-summary-default-score 0) | |
8641 gnus-tmp-score-char | |
8642 (if (or (null gnus-summary-default-score) | |
8643 (<= (abs (- gnus-tmp-score gnus-summary-default-score)) | |
8644 gnus-summary-zcore-fuzz)) ? | |
8645 (if (< gnus-tmp-score gnus-summary-default-score) | |
8646 gnus-score-below-mark gnus-score-over-mark)) | |
8647 gnus-tmp-replied | |
8648 (cond ((memq number gnus-newsgroup-processable) | |
8649 gnus-process-mark) | |
8650 ((memq number gnus-newsgroup-cached) | |
8651 gnus-cached-mark) | |
8652 ((memq number gnus-newsgroup-replied) | |
8653 gnus-replied-mark) | |
8654 ((memq number gnus-newsgroup-saved) | |
8655 gnus-saved-mark) | |
8656 (t gnus-unread-mark)) | |
8657 gnus-tmp-from (mail-header-from gnus-tmp-header) | |
8658 gnus-tmp-name | |
8659 (cond | |
8660 ((string-match "(.+)" gnus-tmp-from) | |
8661 (substring gnus-tmp-from | |
8662 (1+ (match-beginning 0)) (1- (match-end 0)))) | |
8663 ((string-match "<[^>]+> *$" gnus-tmp-from) | |
8664 (setq beg-match (match-beginning 0)) | |
8665 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from) | |
8666 (substring gnus-tmp-from (1+ (match-beginning 0)) | |
8667 (1- (match-end 0)))) | |
8668 (substring gnus-tmp-from 0 beg-match))) | |
8669 (t gnus-tmp-from))) | |
8670 (when (string= gnus-tmp-name "") | |
8671 (setq gnus-tmp-name gnus-tmp-from)) | |
8672 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0)) | |
8673 (gnus-put-text-property | |
8674 (point) | |
8675 (progn (eval gnus-summary-line-format-spec) (point)) | |
8676 'gnus-number number) | |
8677 (when gnus-visual-p | |
8678 (forward-line -1) | |
8679 (run-hooks 'gnus-summary-update-hook) | |
8680 (forward-line 1)) | |
8681 | |
8682 (setq gnus-tmp-prev-subject subject))) | |
8683 | |
8684 (when (nth 1 thread) | |
8685 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack)) | |
8686 (incf gnus-tmp-level) | |
8687 (setq threads (if thread-end nil (cdar thread))) | |
8688 (unless threads | |
8689 (setq gnus-tmp-level 0))))) | |
8690 (gnus-message 7 "Generating summary...done")) | |
8691 | |
8692 (defun gnus-summary-prepare-unthreaded (headers) | |
8693 "Generate an unthreaded summary buffer based on HEADERS." | |
8694 (let (header number mark) | |
8695 | |
8696 (while headers | |
8697 ;; We may have to root out some bad articles... | |
8698 (when (memq (setq number (mail-header-number | |
8699 (setq header (pop headers)))) | |
8700 gnus-newsgroup-limit) | |
8701 ;; Mark article as read when it has a low score. | |
8702 (when (and gnus-summary-mark-below | |
8703 (< (or (cdr (assq number gnus-newsgroup-scored)) | |
8704 gnus-summary-default-score 0) | |
8705 gnus-summary-mark-below) | |
8706 (not (memq number gnus-newsgroup-ancient))) | |
8707 (setq gnus-newsgroup-unreads | |
8708 (delq number gnus-newsgroup-unreads)) | |
8709 (if gnus-newsgroup-auto-expire | |
8710 (push number gnus-newsgroup-expirable) | |
8711 (push (cons number gnus-low-score-mark) | |
8712 gnus-newsgroup-reads))) | |
8713 | |
8714 (setq mark | |
8715 (cond | |
8716 ((memq number gnus-newsgroup-marked) gnus-ticked-mark) | |
8717 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark) | |
8718 ((memq number gnus-newsgroup-unreads) gnus-unread-mark) | |
8719 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark) | |
8720 (t (or (cdr (assq number gnus-newsgroup-reads)) | |
8721 gnus-ancient-mark)))) | |
8722 (setq gnus-newsgroup-data | |
8723 (cons (gnus-data-make number mark (1+ (point)) header 0) | |
8724 gnus-newsgroup-data)) | |
8725 (gnus-summary-insert-line | |
8726 header 0 nil mark (memq number gnus-newsgroup-replied) | |
8727 (memq number gnus-newsgroup-expirable) | |
8728 (mail-header-subject header) nil | |
8729 (cdr (assq number gnus-newsgroup-scored)) | |
8730 (memq number gnus-newsgroup-processable)))))) | |
8731 | |
8732 (defun gnus-select-newsgroup (group &optional read-all) | |
8733 "Select newsgroup GROUP. | |
8734 If READ-ALL is non-nil, all articles in the group are selected." | |
8735 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb)) | |
8736 (info (nth 2 entry)) | |
8737 articles fetched-articles cached) | |
8738 | |
8739 (or (gnus-check-server | |
8740 (setq gnus-current-select-method (gnus-find-method-for-group group))) | |
8741 (error "Couldn't open server")) | |
8742 | |
8743 (or (and entry (not (eq (car entry) t))) ; Either it's active... | |
8744 (gnus-activate-group group) ; Or we can activate it... | |
8745 (progn ; Or we bug out. | |
8746 (when (equal major-mode 'gnus-summary-mode) | |
8747 (kill-buffer (current-buffer))) | |
8748 (error "Couldn't request group %s: %s" | |
8749 group (gnus-status-message group)))) | |
8750 | |
8751 (unless (gnus-request-group group t) | |
8752 (when (equal major-mode 'gnus-summary-mode) | |
8753 (kill-buffer (current-buffer))) | |
8754 (error "Couldn't request group %s: %s" | |
8755 group (gnus-status-message group))) | |
8756 | |
8757 (setq gnus-newsgroup-name group) | |
8758 (setq gnus-newsgroup-unselected nil) | |
8759 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group)) | |
8760 | |
8761 (and gnus-asynchronous | |
8762 (gnus-check-backend-function | |
8763 'request-asynchronous gnus-newsgroup-name) | |
8764 (setq gnus-newsgroup-async | |
8765 (gnus-request-asynchronous gnus-newsgroup-name))) | |
8766 | |
8767 ;; Adjust and set lists of article marks. | |
8768 (when info | |
8769 (gnus-adjust-marked-articles info)) | |
8770 | |
8771 ;; Kludge to avoid having cached articles nixed out in virtual groups. | |
8772 (when (gnus-virtual-group-p group) | |
8773 (setq cached gnus-newsgroup-cached)) | |
8774 | |
8775 (setq gnus-newsgroup-unreads | |
8776 (gnus-set-difference | |
8777 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked) | |
8778 gnus-newsgroup-dormant)) | |
8779 | |
8780 (setq gnus-newsgroup-processable nil) | |
8781 | |
8782 (setq articles (gnus-articles-to-read group read-all)) | |
8783 | |
8784 (cond | |
8785 ((null articles) | |
8786 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display") | |
8787 'quit) | |
8788 ((eq articles 0) nil) | |
8789 (t | |
8790 ;; Init the dependencies hash table. | |
8791 (setq gnus-newsgroup-dependencies | |
8792 (gnus-make-hashtable (length articles))) | |
8793 ;; Retrieve the headers and read them in. | |
8794 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name) | |
8795 (setq gnus-newsgroup-headers | |
8796 (if (eq 'nov | |
8797 (setq gnus-headers-retrieved-by | |
8798 (gnus-retrieve-headers | |
8799 articles gnus-newsgroup-name | |
8800 ;; We might want to fetch old headers, but | |
8801 ;; not if there is only 1 article. | |
8802 (and gnus-fetch-old-headers | |
8803 (or (and | |
8804 (not (eq gnus-fetch-old-headers 'some)) | |
8805 (not (numberp gnus-fetch-old-headers))) | |
8806 (> (length articles) 1)))))) | |
8807 (gnus-get-newsgroup-headers-xover articles) | |
8808 (gnus-get-newsgroup-headers))) | |
8809 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name) | |
8810 | |
8811 ;; Kludge to avoid having cached articles nixed out in virtual groups. | |
8812 (when cached | |
8813 (setq gnus-newsgroup-cached cached)) | |
8814 | |
8815 ;; Set the initial limit. | |
8816 (setq gnus-newsgroup-limit (copy-sequence articles)) | |
8817 ;; Remove canceled articles from the list of unread articles. | |
8818 (setq gnus-newsgroup-unreads | |
8819 (gnus-set-sorted-intersection | |
8820 gnus-newsgroup-unreads | |
8821 (setq fetched-articles | |
8822 (mapcar (lambda (headers) (mail-header-number headers)) | |
8823 gnus-newsgroup-headers)))) | |
8824 ;; Removed marked articles that do not exist. | |
8825 (gnus-update-missing-marks | |
8826 (gnus-sorted-complement fetched-articles articles)) | |
8827 ;; We might want to build some more threads first. | |
8828 (and gnus-fetch-old-headers | |
8829 (eq gnus-headers-retrieved-by 'nov) | |
8830 (gnus-build-old-threads)) | |
8831 ;; Check whether auto-expire is to be done in this group. | |
8832 (setq gnus-newsgroup-auto-expire | |
8833 (gnus-group-auto-expirable-p group)) | |
8834 ;; Set up the article buffer now, if necessary. | |
8835 (unless gnus-single-article-buffer | |
8836 (gnus-article-setup-buffer)) | |
8837 ;; First and last article in this newsgroup. | |
8838 (when gnus-newsgroup-headers | |
8839 (setq gnus-newsgroup-begin | |
8840 (mail-header-number (car gnus-newsgroup-headers)) | |
8841 gnus-newsgroup-end | |
8842 (mail-header-number | |
8843 (gnus-last-element gnus-newsgroup-headers)))) | |
8844 (setq gnus-reffed-article-number -1) | |
8845 ;; GROUP is successfully selected. | |
8846 (or gnus-newsgroup-headers t))))) | |
8847 | |
8848 (defun gnus-articles-to-read (group read-all) | |
8849 ;; Find out what articles the user wants to read. | |
8850 (let* ((articles | |
8851 ;; Select all articles if `read-all' is non-nil, or if there | |
8852 ;; are no unread articles. | |
8853 (if (or read-all | |
8854 (and (zerop (length gnus-newsgroup-marked)) | |
8855 (zerop (length gnus-newsgroup-unreads)))) | |
8856 (gnus-uncompress-range (gnus-active group)) | |
8857 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked | |
8858 (copy-sequence gnus-newsgroup-unreads)) | |
8859 '<))) | |
8860 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles)) | |
8861 (scored (length scored-list)) | |
8862 (number (length articles)) | |
8863 (marked (+ (length gnus-newsgroup-marked) | |
8864 (length gnus-newsgroup-dormant))) | |
8865 (select | |
8866 (cond | |
8867 ((numberp read-all) | |
8868 read-all) | |
8869 (t | |
8870 (condition-case () | |
8871 (cond | |
8872 ((and (or (<= scored marked) (= scored number)) | |
8873 (numberp gnus-large-newsgroup) | |
8874 (> number gnus-large-newsgroup)) | |
8875 (let ((input | |
8876 (read-string | |
8877 (format | |
8878 "How many articles from %s (default %d): " | |
8879 gnus-newsgroup-name number)))) | |
8880 (if (string-match "^[ \t]*$" input) number input))) | |
8881 ((and (> scored marked) (< scored number) | |
8882 (> (- scored number) 20)) | |
8883 (let ((input | |
8884 (read-string | |
8885 (format "%s %s (%d scored, %d total): " | |
8886 "How many articles from" | |
8887 group scored number)))) | |
8888 (if (string-match "^[ \t]*$" input) | |
8889 number input))) | |
8890 (t number)) | |
8891 (quit nil)))))) | |
8892 (setq select (if (stringp select) (string-to-number select) select)) | |
8893 (if (or (null select) (zerop select)) | |
8894 select | |
8895 (if (and (not (zerop scored)) (<= (abs select) scored)) | |
8896 (progn | |
8897 (setq articles (sort scored-list '<)) | |
8898 (setq number (length articles))) | |
8899 (setq articles (copy-sequence articles))) | |
8900 | |
8901 (if (< (abs select) number) | |
8902 (if (< select 0) | |
8903 ;; Select the N oldest articles. | |
8904 (setcdr (nthcdr (1- (abs select)) articles) nil) | |
8905 ;; Select the N most recent articles. | |
8906 (setq articles (nthcdr (- number select) articles)))) | |
8907 (setq gnus-newsgroup-unselected | |
8908 (gnus-sorted-intersection | |
8909 gnus-newsgroup-unreads | |
8910 (gnus-sorted-complement gnus-newsgroup-unreads articles))) | |
8911 articles))) | |
8912 | |
8913 (defun gnus-killed-articles (killed articles) | |
8914 (let (out) | |
8915 (while articles | |
8916 (if (inline (gnus-member-of-range (car articles) killed)) | |
8917 (setq out (cons (car articles) out))) | |
8918 (setq articles (cdr articles))) | |
8919 out)) | |
8920 | |
8921 (defun gnus-uncompress-marks (marks) | |
8922 "Uncompress the mark ranges in MARKS." | |
8923 (let ((uncompressed '(score bookmark)) | |
8924 out) | |
8925 (while marks | |
8926 (if (memq (caar marks) uncompressed) | |
8927 (push (car marks) out) | |
8928 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out)) | |
8929 (setq marks (cdr marks))) | |
8930 out)) | |
8931 | |
8932 (defun gnus-adjust-marked-articles (info) | |
8933 "Set all article lists and remove all marks that are no longer legal." | |
8934 (let* ((marked-lists (gnus-info-marks info)) | |
8935 (active (gnus-active (gnus-info-group info))) | |
8936 (min (car active)) | |
8937 (max (cdr active)) | |
8938 (types gnus-article-mark-lists) | |
8939 (uncompressed '(score bookmark)) | |
8940 marks var articles article mark) | |
8941 | |
8942 (while marked-lists | |
8943 (setq marks (pop marked-lists)) | |
8944 (set (setq var (intern (format "gnus-newsgroup-%s" | |
8945 (car (rassq (setq mark (car marks)) | |
8946 types))))) | |
8947 (if (memq (car marks) uncompressed) (cdr marks) | |
8948 (gnus-uncompress-range (cdr marks)))) | |
8949 | |
8950 (setq articles (symbol-value var)) | |
8951 | |
8952 ;; All articles have to be subsets of the active articles. | |
8953 (cond | |
8954 ;; Adjust "simple" lists. | |
8955 ((memq mark '(tick dormant expirable reply killed save)) | |
8956 (while articles | |
8957 (when (or (< (setq article (pop articles)) min) (> article max)) | |
8958 (set var (delq article (symbol-value var)))))) | |
8959 ;; Adjust assocs. | |
8960 ((memq mark '(score bookmark)) | |
8961 (while articles | |
8962 (when (or (not (consp (setq article (pop articles)))) | |
8963 (< (car article) min) | |
8964 (> (car article) max)) | |
8965 (set var (delq article (symbol-value var)))))))))) | |
8966 | |
8967 (defun gnus-update-missing-marks (missing) | |
8968 "Go through the list of MISSING articles and remove them mark lists." | |
8969 (when missing | |
8970 (let ((types gnus-article-mark-lists) | |
8971 var m) | |
8972 ;; Go through all types. | |
8973 (while types | |
8974 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types))))) | |
8975 (when (symbol-value var) | |
8976 ;; This list has articles. So we delete all missing articles | |
8977 ;; from it. | |
8978 (setq m missing) | |
8979 (while m | |
8980 (set var (delq (pop m) (symbol-value var))))))))) | |
8981 | |
8982 (defun gnus-update-marks () | |
8983 "Enter the various lists of marked articles into the newsgroup info list." | |
8984 (let ((types gnus-article-mark-lists) | |
8985 (info (gnus-get-info gnus-newsgroup-name)) | |
8986 (uncompressed '(score bookmark killed)) | |
8987 type list newmarked symbol) | |
8988 (when info | |
8989 ;; Add all marks lists that are non-nil to the list of marks lists. | |
8990 (while types | |
8991 (setq type (pop types)) | |
8992 (when (setq list (symbol-value | |
8993 (setq symbol | |
8994 (intern (format "gnus-newsgroup-%s" | |
8995 (car type)))))) | |
8996 (push (cons (cdr type) | |
8997 (if (memq (cdr type) uncompressed) list | |
8998 (gnus-compress-sequence | |
8999 (set symbol (sort list '<)) t))) | |
9000 newmarked))) | |
9001 | |
9002 ;; Enter these new marks into the info of the group. | |
9003 (if (nthcdr 3 info) | |
9004 (setcar (nthcdr 3 info) newmarked) | |
9005 ;; Add the marks lists to the end of the info. | |
9006 (when newmarked | |
9007 (setcdr (nthcdr 2 info) (list newmarked)))) | |
9008 | |
9009 ;; Cut off the end of the info if there's nothing else there. | |
9010 (let ((i 5)) | |
9011 (while (and (> i 2) | |
9012 (not (nth i info))) | |
9013 (when (nthcdr (decf i) info) | |
9014 (setcdr (nthcdr i info) nil))))))) | |
9015 | |
9016 (defun gnus-add-marked-articles (group type articles &optional info force) | |
9017 ;; Add ARTICLES of TYPE to the info of GROUP. | |
9018 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't | |
9019 ;; add, but replace marked articles of TYPE with ARTICLES. | |
9020 (let ((info (or info (gnus-get-info group))) | |
9021 (uncompressed '(score bookmark killed)) | |
9022 marked m) | |
9023 (or (not info) | |
9024 (and (not (setq marked (nthcdr 3 info))) | |
9025 (or (null articles) | |
9026 (setcdr (nthcdr 2 info) | |
9027 (list (list (cons type (gnus-compress-sequence | |
9028 articles t))))))) | |
9029 (and (not (setq m (assq type (car marked)))) | |
9030 (or (null articles) | |
9031 (setcar marked | |
9032 (cons (cons type (gnus-compress-sequence articles t) ) | |
9033 (car marked))))) | |
9034 (if force | |
9035 (if (null articles) | |
9036 (setcar (nthcdr 3 info) | |
9037 (delq (assq type (car marked)) (car marked))) | |
9038 (setcdr m (gnus-compress-sequence articles t))) | |
9039 (setcdr m (gnus-compress-sequence | |
9040 (sort (nconc (gnus-uncompress-range (cdr m)) | |
9041 (copy-sequence articles)) '<) t)))))) | |
9042 | |
9043 (defun gnus-set-mode-line (where) | |
9044 "This function sets the mode line of the article or summary buffers. | |
9045 If WHERE is `summary', the summary mode line format will be used." | |
9046 ;; Is this mode line one we keep updated? | |
9047 (when (memq where gnus-updated-mode-lines) | |
9048 (let (mode-string) | |
9049 (save-excursion | |
9050 ;; We evaluate this in the summary buffer since these | |
9051 ;; variables are buffer-local to that buffer. | |
9052 (set-buffer gnus-summary-buffer) | |
9053 ;; We bind all these variables that are used in the `eval' form | |
9054 ;; below. | |
9055 (let* ((mformat (symbol-value | |
9056 (intern | |
9057 (format "gnus-%s-mode-line-format-spec" where)))) | |
9058 (gnus-tmp-group-name gnus-newsgroup-name) | |
9059 (gnus-tmp-article-number (or gnus-current-article 0)) | |
9060 (gnus-tmp-unread gnus-newsgroup-unreads) | |
9061 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads)) | |
9062 (gnus-tmp-unselected (length gnus-newsgroup-unselected)) | |
9063 (gnus-tmp-unread-and-unselected | |
9064 (cond ((and (zerop gnus-tmp-unread-and-unticked) | |
9065 (zerop gnus-tmp-unselected)) "") | |
9066 ((zerop gnus-tmp-unselected) | |
9067 (format "{%d more}" gnus-tmp-unread-and-unticked)) | |
9068 (t (format "{%d(+%d) more}" | |
9069 gnus-tmp-unread-and-unticked | |
9070 gnus-tmp-unselected)))) | |
9071 (gnus-tmp-subject | |
9072 (if (and gnus-current-headers | |
9073 (vectorp gnus-current-headers)) | |
9074 (gnus-mode-string-quote | |
9075 (mail-header-subject gnus-current-headers)) "")) | |
9076 max-len | |
9077 gnus-tmp-header);; passed as argument to any user-format-funcs | |
9078 (setq mode-string (eval mformat)) | |
9079 (setq max-len (max 4 (if gnus-mode-non-string-length | |
9080 (- (window-width) | |
9081 gnus-mode-non-string-length) | |
9082 (length mode-string)))) | |
9083 ;; We might have to chop a bit of the string off... | |
9084 (when (> (length mode-string) max-len) | |
9085 (setq mode-string | |
9086 (concat (gnus-truncate-string mode-string (- max-len 3)) | |
9087 "..."))) | |
9088 ;; Pad the mode string a bit. | |
9089 (setq mode-string (format (format "%%-%ds" max-len) mode-string)))) | |
9090 ;; Update the mode line. | |
9091 (setq mode-line-buffer-identification | |
9092 (gnus-mode-line-buffer-identification | |
9093 (list mode-string))) | |
9094 (set-buffer-modified-p t)))) | |
9095 | |
9096 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads) | |
9097 "Go through the HEADERS list and add all Xrefs to a hash table. | |
9098 The resulting hash table is returned, or nil if no Xrefs were found." | |
9099 (let* ((virtual (gnus-virtual-group-p from-newsgroup)) | |
9100 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup))) | |
9101 (xref-hashtb (make-vector 63 0)) | |
9102 start group entry number xrefs header) | |
9103 (while headers | |
9104 (setq header (pop headers)) | |
9105 (when (and (setq xrefs (mail-header-xref header)) | |
9106 (not (memq (setq number (mail-header-number header)) | |
9107 unreads))) | |
9108 (setq start 0) | |
9109 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start) | |
9110 (setq start (match-end 0)) | |
9111 (setq group (if prefix | |
9112 (concat prefix (substring xrefs (match-beginning 1) | |
9113 (match-end 1))) | |
9114 (substring xrefs (match-beginning 1) (match-end 1)))) | |
9115 (setq number | |
9116 (string-to-int (substring xrefs (match-beginning 2) | |
9117 (match-end 2)))) | |
9118 (if (setq entry (gnus-gethash group xref-hashtb)) | |
9119 (setcdr entry (cons number (cdr entry))) | |
9120 (gnus-sethash group (cons number nil) xref-hashtb))))) | |
9121 (and start xref-hashtb))) | |
9122 | |
9123 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads) | |
9124 "Look through all the headers and mark the Xrefs as read." | |
9125 (let ((virtual (gnus-virtual-group-p from-newsgroup)) | |
9126 name entry info xref-hashtb idlist method nth4) | |
9127 (save-excursion | |
9128 (set-buffer gnus-group-buffer) | |
9129 (when (setq xref-hashtb | |
9130 (gnus-create-xref-hashtb from-newsgroup headers unreads)) | |
9131 (mapatoms | |
9132 (lambda (group) | |
9133 (unless (string= from-newsgroup (setq name (symbol-name group))) | |
9134 (setq idlist (symbol-value group)) | |
9135 ;; Dead groups are not updated. | |
9136 (and (prog1 | |
9137 (setq entry (gnus-gethash name gnus-newsrc-hashtb) | |
9138 info (nth 2 entry)) | |
9139 (if (stringp (setq nth4 (gnus-info-method info))) | |
9140 (setq nth4 (gnus-server-to-method nth4)))) | |
9141 ;; Only do the xrefs if the group has the same | |
9142 ;; select method as the group we have just read. | |
9143 (or (gnus-methods-equal-p | |
9144 nth4 (gnus-find-method-for-group from-newsgroup)) | |
9145 virtual | |
9146 (equal nth4 (setq method (gnus-find-method-for-group | |
9147 from-newsgroup))) | |
9148 (and (equal (car nth4) (car method)) | |
9149 (equal (nth 1 nth4) (nth 1 method)))) | |
9150 gnus-use-cross-reference | |
9151 (or (not (eq gnus-use-cross-reference t)) | |
9152 virtual | |
9153 ;; Only do cross-references on subscribed | |
9154 ;; groups, if that is what is wanted. | |
9155 (<= (gnus-info-level info) gnus-level-subscribed)) | |
9156 (gnus-group-make-articles-read name idlist)))) | |
9157 xref-hashtb))))) | |
9158 | |
9159 (defun gnus-group-make-articles-read (group articles) | |
9160 (let* ((num 0) | |
9161 (entry (gnus-gethash group gnus-newsrc-hashtb)) | |
9162 (info (nth 2 entry)) | |
9163 (active (gnus-active group)) | |
9164 range) | |
9165 ;; First peel off all illegal article numbers. | |
9166 (if active | |
9167 (let ((ids articles) | |
9168 id first) | |
9169 (while ids | |
9170 (setq id (car ids)) | |
9171 (if (and first (> id (cdr active))) | |
9172 (progn | |
9173 ;; We'll end up in this situation in one particular | |
9174 ;; obscure situation. If you re-scan a group and get | |
9175 ;; a new article that is cross-posted to a different | |
9176 ;; group that has not been re-scanned, you might get | |
9177 ;; crossposted article that has a higher number than | |
9178 ;; Gnus believes possible. So we re-activate this | |
9179 ;; group as well. This might mean doing the | |
9180 ;; crossposting thingy will *increase* the number | |
9181 ;; of articles in some groups. Tsk, tsk. | |
9182 (setq active (or (gnus-activate-group group) active)))) | |
9183 (if (or (> id (cdr active)) | |
9184 (< id (car active))) | |
9185 (setq articles (delq id articles))) | |
9186 (setq ids (cdr ids))))) | |
9187 ;; If the read list is nil, we init it. | |
9188 (and active | |
9189 (null (gnus-info-read info)) | |
9190 (> (car active) 1) | |
9191 (gnus-info-set-read info (cons 1 (1- (car active))))) | |
9192 ;; Then we add the read articles to the range. | |
9193 (gnus-info-set-read | |
9194 info | |
9195 (setq range | |
9196 (gnus-add-to-range | |
9197 (gnus-info-read info) (setq articles (sort articles '<))))) | |
9198 ;; Then we have to re-compute how many unread | |
9199 ;; articles there are in this group. | |
9200 (if active | |
9201 (progn | |
9202 (cond | |
9203 ((not range) | |
9204 (setq num (- (1+ (cdr active)) (car active)))) | |
9205 ((not (listp (cdr range))) | |
9206 (setq num (- (cdr active) (- (1+ (cdr range)) | |
9207 (car range))))) | |
9208 (t | |
9209 (while range | |
9210 (if (numberp (car range)) | |
9211 (setq num (1+ num)) | |
9212 (setq num (+ num (- (1+ (cdar range)) (caar range))))) | |
9213 (setq range (cdr range))) | |
9214 (setq num (- (cdr active) num)))) | |
9215 ;; Update the number of unread articles. | |
9216 (setcar entry num) | |
9217 ;; Update the group buffer. | |
9218 (gnus-group-update-group group t))))) | |
9219 | |
9220 (defun gnus-methods-equal-p (m1 m2) | |
9221 (let ((m1 (or m1 gnus-select-method)) | |
9222 (m2 (or m2 gnus-select-method))) | |
9223 (or (equal m1 m2) | |
9224 (and (eq (car m1) (car m2)) | |
9225 (or (not (memq 'address (assoc (symbol-name (car m1)) | |
9226 gnus-valid-select-methods))) | |
9227 (equal (nth 1 m1) (nth 1 m2))))))) | |
9228 | |
9229 (defsubst gnus-header-value () | |
9230 (buffer-substring (match-end 0) (gnus-point-at-eol))) | |
9231 | |
9232 (defvar gnus-newsgroup-none-id 0) | |
9233 | |
9234 (defun gnus-get-newsgroup-headers (&optional dependencies force-new) | |
9235 (let ((cur nntp-server-buffer) | |
9236 (dependencies | |
9237 (or dependencies | |
9238 (save-excursion (set-buffer gnus-summary-buffer) | |
9239 gnus-newsgroup-dependencies))) | |
9240 headers id id-dep ref-dep end ref) | |
9241 (save-excursion | |
9242 (set-buffer nntp-server-buffer) | |
9243 (run-hooks 'gnus-parse-headers-hook) | |
9244 (let ((case-fold-search t) | |
9245 in-reply-to header p lines) | |
9246 (goto-char (point-min)) | |
9247 ;; Search to the beginning of the next header. Error messages | |
9248 ;; do not begin with 2 or 3. | |
9249 (while (re-search-forward "^[23][0-9]+ " nil t) | |
9250 (setq id nil | |
9251 ref nil) | |
9252 ;; This implementation of this function, with nine | |
9253 ;; search-forwards instead of the one re-search-forward and | |
9254 ;; a case (which basically was the old function) is actually | |
9255 ;; about twice as fast, even though it looks messier. You | |
9256 ;; can't have everything, I guess. Speed and elegance | |
9257 ;; doesn't always go hand in hand. | |
9258 (setq | |
9259 header | |
9260 (vector | |
9261 ;; Number. | |
9262 (prog1 | |
9263 (read cur) | |
9264 (end-of-line) | |
9265 (setq p (point)) | |
9266 (narrow-to-region (point) | |
9267 (or (and (search-forward "\n.\n" nil t) | |
9268 (- (point) 2)) | |
9269 (point)))) | |
9270 ;; Subject. | |
9271 (progn | |
9272 (goto-char p) | |
9273 (if (search-forward "\nsubject: " nil t) | |
9274 (gnus-header-value) "(none)")) | |
9275 ;; From. | |
9276 (progn | |
9277 (goto-char p) | |
9278 (if (search-forward "\nfrom: " nil t) | |
9279 (gnus-header-value) "(nobody)")) | |
9280 ;; Date. | |
9281 (progn | |
9282 (goto-char p) | |
9283 (if (search-forward "\ndate: " nil t) | |
9284 (gnus-header-value) "")) | |
9285 ;; Message-ID. | |
9286 (progn | |
9287 (goto-char p) | |
9288 (if (search-forward "\nmessage-id: " nil t) | |
9289 (setq id (gnus-header-value)) | |
9290 ;; If there was no message-id, we just fake one to make | |
9291 ;; subsequent routines simpler. | |
9292 (setq id (concat "none+" | |
9293 (int-to-string | |
9294 (setq gnus-newsgroup-none-id | |
9295 (1+ gnus-newsgroup-none-id))))))) | |
9296 ;; References. | |
9297 (progn | |
9298 (goto-char p) | |
9299 (if (search-forward "\nreferences: " nil t) | |
9300 (progn | |
9301 (setq end (point)) | |
9302 (prog1 | |
9303 (gnus-header-value) | |
9304 (setq ref | |
9305 (buffer-substring | |
9306 (progn | |
9307 (end-of-line) | |
9308 (search-backward ">" end t) | |
9309 (1+ (point))) | |
9310 (progn | |
9311 (search-backward "<" end t) | |
9312 (point)))))) | |
9313 ;; Get the references from the in-reply-to header if there | |
9314 ;; were no references and the in-reply-to header looks | |
9315 ;; promising. | |
9316 (if (and (search-forward "\nin-reply-to: " nil t) | |
9317 (setq in-reply-to (gnus-header-value)) | |
9318 (string-match "<[^>]+>" in-reply-to)) | |
9319 (setq ref (substring in-reply-to (match-beginning 0) | |
9320 (match-end 0))) | |
9321 (setq ref "")))) | |
9322 ;; Chars. | |
9323 0 | |
9324 ;; Lines. | |
9325 (progn | |
9326 (goto-char p) | |
9327 (if (search-forward "\nlines: " nil t) | |
9328 (if (numberp (setq lines (read cur))) | |
9329 lines 0) | |
9330 0)) | |
9331 ;; Xref. | |
9332 (progn | |
9333 (goto-char p) | |
9334 (and (search-forward "\nxref: " nil t) | |
9335 (gnus-header-value))))) | |
9336 ;; We do the threading while we read the headers. The | |
9337 ;; message-id and the last reference are both entered into | |
9338 ;; the same hash table. Some tippy-toeing around has to be | |
9339 ;; done in case an article has arrived before the article | |
9340 ;; which it refers to. | |
9341 (if (boundp (setq id-dep (intern id dependencies))) | |
9342 (if (and (car (symbol-value id-dep)) | |
9343 (not force-new)) | |
9344 ;; An article with this Message-ID has already | |
9345 ;; been seen, so we ignore this one, except we add | |
9346 ;; any additional Xrefs (in case the two articles | |
9347 ;; came from different servers). | |
9348 (progn | |
9349 (mail-header-set-xref | |
9350 (car (symbol-value id-dep)) | |
9351 (concat (or (mail-header-xref | |
9352 (car (symbol-value id-dep))) "") | |
9353 (or (mail-header-xref header) ""))) | |
9354 (setq header nil)) | |
9355 (setcar (symbol-value id-dep) header)) | |
9356 (set id-dep (list header))) | |
9357 (when header | |
9358 (if (boundp (setq ref-dep (intern ref dependencies))) | |
9359 (setcdr (symbol-value ref-dep) | |
9360 (nconc (cdr (symbol-value ref-dep)) | |
9361 (list (symbol-value id-dep)))) | |
9362 (set ref-dep (list nil (symbol-value id-dep)))) | |
9363 (setq headers (cons header headers))) | |
9364 (goto-char (point-max)) | |
9365 (widen)) | |
9366 (nreverse headers))))) | |
9367 | |
9368 ;; The following macros and functions were written by Felix Lee | |
9369 ;; <flee@cse.psu.edu>. | |
9370 | |
9371 (defmacro gnus-nov-read-integer () | |
9372 '(prog1 | |
9373 (if (= (following-char) ?\t) | |
9374 0 | |
9375 (let ((num (condition-case nil (read buffer) (error nil)))) | |
9376 (if (numberp num) num 0))) | |
9377 (or (eobp) (forward-char 1)))) | |
9378 | |
9379 (defmacro gnus-nov-skip-field () | |
9380 '(search-forward "\t" eol 'move)) | |
9381 | |
9382 (defmacro gnus-nov-field () | |
9383 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol))) | |
9384 | |
9385 ;; Goes through the xover lines and returns a list of vectors | |
9386 (defun gnus-get-newsgroup-headers-xover (sequence &optional | |
9387 force-new dependencies) | |
9388 "Parse the news overview data in the server buffer, and return a | |
9389 list of headers that match SEQUENCE (see `nntp-retrieve-headers')." | |
9390 ;; Get the Xref when the users reads the articles since most/some | |
9391 ;; NNTP servers do not include Xrefs when using XOVER. | |
9392 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs)) | |
9393 (let ((cur nntp-server-buffer) | |
9394 (dependencies (or dependencies gnus-newsgroup-dependencies)) | |
9395 number headers header) | |
9396 (save-excursion | |
9397 (set-buffer nntp-server-buffer) | |
9398 ;; Allow the user to mangle the headers before parsing them. | |
9399 (run-hooks 'gnus-parse-headers-hook) | |
9400 (goto-char (point-min)) | |
9401 (while (and sequence (not (eobp))) | |
9402 (setq number (read cur)) | |
9403 (while (and sequence (< (car sequence) number)) | |
9404 (setq sequence (cdr sequence))) | |
9405 (and sequence | |
9406 (eq number (car sequence)) | |
9407 (progn | |
9408 (setq sequence (cdr sequence)) | |
9409 (if (setq header | |
9410 (inline (gnus-nov-parse-line | |
9411 number dependencies force-new))) | |
9412 (setq headers (cons header headers))))) | |
9413 (forward-line 1)) | |
9414 (setq headers (nreverse headers))) | |
9415 headers)) | |
9416 | |
9417 ;; This function has to be called with point after the article number | |
9418 ;; on the beginning of the line. | |
9419 (defun gnus-nov-parse-line (number dependencies &optional force-new) | |
9420 (let ((none 0) | |
9421 (eol (gnus-point-at-eol)) | |
9422 (buffer (current-buffer)) | |
9423 header ref id id-dep ref-dep) | |
9424 | |
9425 ;; overview: [num subject from date id refs chars lines misc] | |
9426 (narrow-to-region (point) eol) | |
9427 (or (eobp) (forward-char)) | |
9428 | |
9429 (condition-case nil | |
9430 (setq header | |
9431 (vector | |
9432 number ; number | |
9433 (gnus-nov-field) ; subject | |
9434 (gnus-nov-field) ; from | |
9435 (gnus-nov-field) ; date | |
9436 (setq id (or (gnus-nov-field) | |
9437 (concat "none+" | |
9438 (int-to-string | |
9439 (setq none (1+ none)))))) ; id | |
9440 (progn | |
9441 (save-excursion | |
9442 (let ((beg (point))) | |
9443 (search-forward "\t" eol) | |
9444 (if (search-backward ">" beg t) | |
9445 (setq ref | |
9446 (buffer-substring | |
9447 (1+ (point)) | |
9448 (search-backward "<" beg t))) | |
9449 (setq ref nil)))) | |
9450 (gnus-nov-field)) ; refs | |
9451 (gnus-nov-read-integer) ; chars | |
9452 (gnus-nov-read-integer) ; lines | |
9453 (if (= (following-char) ?\n) | |
9454 nil | |
9455 (gnus-nov-field)) ; misc | |
9456 )) | |
9457 (error (progn | |
9458 (gnus-error 4 "Strange nov line") | |
9459 (setq header nil) | |
9460 (goto-char eol)))) | |
9461 | |
9462 (widen) | |
9463 | |
9464 ;; We build the thread tree. | |
9465 (when header | |
9466 (if (boundp (setq id-dep (intern id dependencies))) | |
9467 (if (and (car (symbol-value id-dep)) | |
9468 (not force-new)) | |
9469 ;; An article with this Message-ID has already been seen, | |
9470 ;; so we ignore this one, except we add any additional | |
9471 ;; Xrefs (in case the two articles came from different | |
9472 ;; servers. | |
9473 (progn | |
9474 (mail-header-set-xref | |
9475 (car (symbol-value id-dep)) | |
9476 (concat (or (mail-header-xref | |
9477 (car (symbol-value id-dep))) "") | |
9478 (or (mail-header-xref header) ""))) | |
9479 (setq header nil)) | |
9480 (setcar (symbol-value id-dep) header)) | |
9481 (set id-dep (list header)))) | |
9482 (when header | |
9483 (if (boundp (setq ref-dep (intern (or ref "none") dependencies))) | |
9484 (setcdr (symbol-value ref-dep) | |
9485 (nconc (cdr (symbol-value ref-dep)) | |
9486 (list (symbol-value id-dep)))) | |
9487 (set ref-dep (list nil (symbol-value id-dep))))) | |
9488 header)) | |
9489 | |
9490 (defun gnus-article-get-xrefs () | |
9491 "Fill in the Xref value in `gnus-current-headers', if necessary. | |
9492 This is meant to be called in `gnus-article-internal-prepare-hook'." | |
9493 (let ((headers (save-excursion (set-buffer gnus-summary-buffer) | |
9494 gnus-current-headers))) | |
9495 (or (not gnus-use-cross-reference) | |
9496 (not headers) | |
9497 (and (mail-header-xref headers) | |
9498 (not (string= (mail-header-xref headers) ""))) | |
9499 (let ((case-fold-search t) | |
9500 xref) | |
9501 (save-restriction | |
9502 (nnheader-narrow-to-headers) | |
9503 (goto-char (point-min)) | |
9504 (if (or (and (eq (downcase (following-char)) ?x) | |
9505 (looking-at "Xref:")) | |
9506 (search-forward "\nXref:" nil t)) | |
9507 (progn | |
9508 (goto-char (1+ (match-end 0))) | |
9509 (setq xref (buffer-substring (point) | |
9510 (progn (end-of-line) (point)))) | |
9511 (mail-header-set-xref headers xref)))))))) | |
9512 | |
9513 (defun gnus-summary-insert-subject (id &optional old-header use-old-header) | |
9514 "Find article ID and insert the summary line for that article." | |
9515 (let ((header (if (and old-header use-old-header) | |
9516 old-header (gnus-read-header id))) | |
9517 (number (and (numberp id) id)) | |
9518 pos) | |
9519 (when header | |
9520 ;; Rebuild the thread that this article is part of and go to the | |
9521 ;; article we have fetched. | |
9522 (when (and (not gnus-show-threads) | |
9523 old-header) | |
9524 (when (setq pos (text-property-any | |
9525 (point-min) (point-max) 'gnus-number | |
9526 (mail-header-number old-header))) | |
9527 (goto-char pos) | |
9528 (gnus-delete-line) | |
9529 (gnus-data-remove (mail-header-number old-header)))) | |
9530 (when old-header | |
9531 (mail-header-set-number header (mail-header-number old-header))) | |
9532 (setq gnus-newsgroup-sparse | |
9533 (delq (setq number (mail-header-number header)) | |
9534 gnus-newsgroup-sparse)) | |
9535 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient)) | |
9536 (gnus-rebuild-thread (mail-header-id header)) | |
9537 (gnus-summary-goto-subject number nil t)) | |
9538 (when (and (numberp number) | |
9539 (> number 0)) | |
9540 ;; We have to update the boundaries even if we can't fetch the | |
9541 ;; article if ID is a number -- so that the next `P' or `N' | |
9542 ;; command will fetch the previous (or next) article even | |
9543 ;; if the one we tried to fetch this time has been canceled. | |
9544 (and (> number gnus-newsgroup-end) | |
9545 (setq gnus-newsgroup-end number)) | |
9546 (and (< number gnus-newsgroup-begin) | |
9547 (setq gnus-newsgroup-begin number)) | |
9548 (setq gnus-newsgroup-unselected | |
9549 (delq number gnus-newsgroup-unselected))) | |
9550 ;; Report back a success? | |
9551 (and header (mail-header-number header)))) | |
9552 | |
9553 (defun gnus-summary-work-articles (n) | |
9554 "Return a list of articles to be worked upon. The prefix argument, | |
9555 the list of process marked articles, and the current article will be | |
9556 taken into consideration." | |
9557 (cond | |
9558 (n | |
9559 ;; A numerical prefix has been given. | |
9560 (let ((backward (< n 0)) | |
9561 (n (abs (prefix-numeric-value n))) | |
9562 articles article) | |
9563 (save-excursion | |
9564 (while | |
9565 (and (> n 0) | |
9566 (push (setq article (gnus-summary-article-number)) | |
9567 articles) | |
9568 (if backward | |
9569 (gnus-summary-find-prev nil article) | |
9570 (gnus-summary-find-next nil article))) | |
9571 (decf n))) | |
9572 (nreverse articles))) | |
9573 ((and (boundp 'transient-mark-mode) | |
9574 transient-mark-mode | |
9575 mark-active) | |
9576 ;; Work on the region between point and mark. | |
9577 (let ((max (max (point) (mark))) | |
9578 articles article) | |
9579 (save-excursion | |
9580 (goto-char (min (point) (mark))) | |
9581 (while | |
9582 (and | |
9583 (push (setq article (gnus-summary-article-number)) articles) | |
9584 (gnus-summary-find-next nil article) | |
9585 (< (point) max))) | |
9586 (nreverse articles)))) | |
9587 (gnus-newsgroup-processable | |
9588 ;; There are process-marked articles present. | |
9589 (reverse gnus-newsgroup-processable)) | |
9590 (t | |
9591 ;; Just return the current article. | |
9592 (list (gnus-summary-article-number))))) | |
9593 | |
9594 (defun gnus-summary-search-group (&optional backward use-level) | |
9595 "Search for next unread newsgroup. | |
9596 If optional argument BACKWARD is non-nil, search backward instead." | |
9597 (save-excursion | |
9598 (set-buffer gnus-group-buffer) | |
9599 (if (gnus-group-search-forward | |
9600 backward nil (if use-level (gnus-group-group-level) nil)) | |
9601 (gnus-group-group-name)))) | |
9602 | |
9603 (defun gnus-summary-best-group (&optional exclude-group) | |
9604 "Find the name of the best unread group. | |
9605 If EXCLUDE-GROUP, do not go to this group." | |
9606 (save-excursion | |
9607 (set-buffer gnus-group-buffer) | |
9608 (save-excursion | |
9609 (gnus-group-best-unread-group exclude-group)))) | |
9610 | |
9611 (defun gnus-summary-find-next (&optional unread article backward) | |
9612 (if backward (gnus-summary-find-prev) | |
9613 (let* ((dummy (gnus-summary-article-intangible-p)) | |
9614 (article (or article (gnus-summary-article-number))) | |
9615 (arts (gnus-data-find-list article)) | |
9616 result) | |
9617 (when (and (not dummy) | |
9618 (or (not gnus-summary-check-current) | |
9619 (not unread) | |
9620 (not (gnus-data-unread-p (car arts))))) | |
9621 (setq arts (cdr arts))) | |
9622 (when (setq result | |
9623 (if unread | |
9624 (progn | |
9625 (while arts | |
9626 (when (gnus-data-unread-p (car arts)) | |
9627 (setq result (car arts) | |
9628 arts nil)) | |
9629 (setq arts (cdr arts))) | |
9630 result) | |
9631 (car arts))) | |
9632 (goto-char (gnus-data-pos result)) | |
9633 (gnus-data-number result))))) | |
9634 | |
9635 (defun gnus-summary-find-prev (&optional unread article) | |
9636 (let* ((eobp (eobp)) | |
9637 (article (or article (gnus-summary-article-number))) | |
9638 (arts (gnus-data-find-list article (gnus-data-list 'rev))) | |
9639 result) | |
9640 (when (and (not eobp) | |
9641 (or (not gnus-summary-check-current) | |
9642 (not unread) | |
9643 (not (gnus-data-unread-p (car arts))))) | |
9644 (setq arts (cdr arts))) | |
9645 (if (setq result | |
9646 (if unread | |
9647 (progn | |
9648 (while arts | |
9649 (and (gnus-data-unread-p (car arts)) | |
9650 (setq result (car arts) | |
9651 arts nil)) | |
9652 (setq arts (cdr arts))) | |
9653 result) | |
9654 (car arts))) | |
9655 (progn | |
9656 (goto-char (gnus-data-pos result)) | |
9657 (gnus-data-number result))))) | |
9658 | |
9659 (defun gnus-summary-find-subject (subject &optional unread backward article) | |
9660 (let* ((simp-subject (gnus-simplify-subject-fully subject)) | |
9661 (article (or article (gnus-summary-article-number))) | |
9662 (articles (gnus-data-list backward)) | |
9663 (arts (gnus-data-find-list article articles)) | |
9664 result) | |
9665 (when (or (not gnus-summary-check-current) | |
9666 (not unread) | |
9667 (not (gnus-data-unread-p (car arts)))) | |
9668 (setq arts (cdr arts))) | |
9669 (while arts | |
9670 (and (or (not unread) | |
9671 (gnus-data-unread-p (car arts))) | |
9672 (vectorp (gnus-data-header (car arts))) | |
9673 (gnus-subject-equal | |
9674 simp-subject (mail-header-subject (gnus-data-header (car arts))) t) | |
9675 (setq result (car arts) | |
9676 arts nil)) | |
9677 (setq arts (cdr arts))) | |
9678 (and result | |
9679 (goto-char (gnus-data-pos result)) | |
9680 (gnus-data-number result)))) | |
9681 | |
9682 (defun gnus-summary-search-forward (&optional unread subject backward) | |
9683 "Search forward for an article. | |
9684 If UNREAD, look for unread articles. If SUBJECT, look for | |
9685 articles with that subject. If BACKWARD, search backward instead." | |
9686 (cond (subject (gnus-summary-find-subject subject unread backward)) | |
9687 (backward (gnus-summary-find-prev unread)) | |
9688 (t (gnus-summary-find-next unread)))) | |
9689 | |
9690 (defun gnus-recenter (&optional n) | |
9691 "Center point in window and redisplay frame. | |
9692 Also do horizontal recentering." | |
9693 (interactive "P") | |
9694 (when (and gnus-auto-center-summary | |
9695 (not (eq gnus-auto-center-summary 'vertical))) | |
9696 (gnus-horizontal-recenter)) | |
9697 (recenter n)) | |
9698 | |
9699 (defun gnus-summary-recenter () | |
9700 "Center point in the summary window. | |
9701 If `gnus-auto-center-summary' is nil, or the article buffer isn't | |
9702 displayed, no centering will be performed." | |
9703 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle). | |
9704 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu. | |
9705 (let* ((top (cond ((< (window-height) 4) 0) | |
9706 ((< (window-height) 7) 1) | |
9707 (t 2))) | |
9708 (height (1- (window-height))) | |
9709 (bottom (save-excursion (goto-char (point-max)) | |
9710 (forward-line (- height)) | |
9711 (point))) | |
9712 (window (get-buffer-window (current-buffer)))) | |
9713 ;; The user has to want it. | |
9714 (when gnus-auto-center-summary | |
9715 (when (get-buffer-window gnus-article-buffer) | |
9716 ;; Only do recentering when the article buffer is displayed, | |
9717 ;; Set the window start to either `bottom', which is the biggest | |
9718 ;; possible valid number, or the second line from the top, | |
9719 ;; whichever is the least. | |
9720 (set-window-start | |
9721 window (min bottom (save-excursion | |
9722 (forward-line (- top)) (point))))) | |
9723 ;; Do horizontal recentering while we're at it. | |
9724 (when (and (get-buffer-window (current-buffer) t) | |
9725 (not (eq gnus-auto-center-summary 'vertical))) | |
9726 (let ((selected (selected-window))) | |
9727 (select-window (get-buffer-window (current-buffer) t)) | |
9728 (gnus-summary-position-point) | |
9729 (gnus-horizontal-recenter) | |
9730 (select-window selected)))))) | |
9731 | |
9732 (defun gnus-horizontal-recenter () | |
9733 "Recenter the current buffer horizontally." | |
9734 (if (< (current-column) (/ (window-width) 2)) | |
9735 (set-window-hscroll (get-buffer-window (current-buffer) t) 0) | |
9736 (let* ((orig (point)) | |
9737 (end (window-end (get-buffer-window (current-buffer) t))) | |
9738 (max 0)) | |
9739 ;; Find the longest line currently displayed in the window. | |
9740 (goto-char (window-start)) | |
9741 (while (and (not (eobp)) | |
9742 (< (point) end)) | |
9743 (end-of-line) | |
9744 (setq max (max max (current-column))) | |
9745 (forward-line 1)) | |
9746 (goto-char orig) | |
9747 ;; Scroll horizontally to center (sort of) the point. | |
9748 (if (> max (window-width)) | |
9749 (set-window-hscroll | |
9750 (get-buffer-window (current-buffer) t) | |
9751 (min (- (current-column) (/ (window-width) 3)) | |
9752 (+ 2 (- max (window-width))))) | |
9753 (set-window-hscroll (get-buffer-window (current-buffer) t) 0)) | |
9754 max))) | |
9755 | |
9756 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>. | |
9757 (defun gnus-short-group-name (group &optional levels) | |
9758 "Collapse GROUP name LEVELS." | |
9759 (let* ((name "") | |
9760 (foreign "") | |
9761 (depth 0) | |
9762 (skip 1) | |
9763 (levels (or levels | |
9764 (progn | |
9765 (while (string-match "\\." group skip) | |
9766 (setq skip (match-end 0) | |
9767 depth (+ depth 1))) | |
9768 depth)))) | |
9769 (if (string-match ":" group) | |
9770 (setq foreign (substring group 0 (match-end 0)) | |
9771 group (substring group (match-end 0)))) | |
9772 (while group | |
9773 (if (and (string-match "\\." group) | |
9774 (> levels (- gnus-group-uncollapsed-levels 1))) | |
9775 (setq name (concat name (substring group 0 1)) | |
9776 group (substring group (match-end 0)) | |
9777 levels (- levels 1) | |
9778 name (concat name ".")) | |
9779 (setq name (concat foreign name group) | |
9780 group nil))) | |
9781 name)) | |
9782 | |
9783 (defun gnus-summary-jump-to-group (newsgroup) | |
9784 "Move point to NEWSGROUP in group mode buffer." | |
9785 ;; Keep update point of group mode buffer if visible. | |
9786 (if (eq (current-buffer) (get-buffer gnus-group-buffer)) | |
9787 (save-window-excursion | |
9788 ;; Take care of tree window mode. | |
9789 (if (get-buffer-window gnus-group-buffer) | |
9790 (pop-to-buffer gnus-group-buffer)) | |
9791 (gnus-group-jump-to-group newsgroup)) | |
9792 (save-excursion | |
9793 ;; Take care of tree window mode. | |
9794 (if (get-buffer-window gnus-group-buffer) | |
9795 (pop-to-buffer gnus-group-buffer) | |
9796 (set-buffer gnus-group-buffer)) | |
9797 (gnus-group-jump-to-group newsgroup)))) | |
9798 | |
9799 ;; This function returns a list of article numbers based on the | |
9800 ;; difference between the ranges of read articles in this group and | |
9801 ;; the range of active articles. | |
9802 (defun gnus-list-of-unread-articles (group) | |
9803 (let* ((read (gnus-info-read (gnus-get-info group))) | |
9804 (active (gnus-active group)) | |
9805 (last (cdr active)) | |
9806 first nlast unread) | |
9807 ;; If none are read, then all are unread. | |
9808 (if (not read) | |
9809 (setq first (car active)) | |
9810 ;; If the range of read articles is a single range, then the | |
9811 ;; first unread article is the article after the last read | |
9812 ;; article. Sounds logical, doesn't it? | |
9813 (if (not (listp (cdr read))) | |
9814 (setq first (1+ (cdr read))) | |
9815 ;; `read' is a list of ranges. | |
9816 (if (/= (setq nlast (or (and (numberp (car read)) (car read)) | |
9817 (caar read))) 1) | |
9818 (setq first 1)) | |
9819 (while read | |
9820 (if first | |
9821 (while (< first nlast) | |
9822 (setq unread (cons first unread)) | |
9823 (setq first (1+ first)))) | |
9824 (setq first (1+ (if (atom (car read)) (car read) (cdar read)))) | |
9825 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read))) | |
9826 (setq read (cdr read))))) | |
9827 ;; And add the last unread articles. | |
9828 (while (<= first last) | |
9829 (setq unread (cons first unread)) | |
9830 (setq first (1+ first))) | |
9831 ;; Return the list of unread articles. | |
9832 (nreverse unread))) | |
9833 | |
9834 (defun gnus-list-of-read-articles (group) | |
9835 "Return a list of unread, unticked and non-dormant articles." | |
9836 (let* ((info (gnus-get-info group)) | |
9837 (marked (gnus-info-marks info)) | |
9838 (active (gnus-active group))) | |
9839 (and info active | |
9840 (gnus-set-difference | |
9841 (gnus-sorted-complement | |
9842 (gnus-uncompress-range active) | |
9843 (gnus-list-of-unread-articles group)) | |
9844 (append | |
9845 (gnus-uncompress-range (cdr (assq 'dormant marked))) | |
9846 (gnus-uncompress-range (cdr (assq 'tick marked)))))))) | |
9847 | |
9848 ;; Various summary commands | |
9849 | |
9850 (defun gnus-summary-universal-argument (arg) | |
9851 "Perform any operation on all articles that are process/prefixed." | |
9852 (interactive "P") | |
9853 (gnus-set-global-variables) | |
9854 (let ((articles (gnus-summary-work-articles arg)) | |
9855 func article) | |
9856 (if (eq | |
9857 (setq | |
9858 func | |
9859 (key-binding | |
9860 (read-key-sequence | |
9861 (substitute-command-keys | |
9862 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]" | |
9863 )))) | |
9864 'undefined) | |
9865 (gnus-error 1 "Undefined key") | |
9866 (save-excursion | |
9867 (while articles | |
9868 (gnus-summary-goto-subject (setq article (pop articles))) | |
9869 (command-execute func) | |
9870 (gnus-summary-remove-process-mark article))))) | |
9871 (gnus-summary-position-point)) | |
9872 | |
9873 (defun gnus-summary-toggle-truncation (&optional arg) | |
9874 "Toggle truncation of summary lines. | |
9875 With arg, turn line truncation on iff arg is positive." | |
9876 (interactive "P") | |
9877 (setq truncate-lines | |
9878 (if (null arg) (not truncate-lines) | |
9879 (> (prefix-numeric-value arg) 0))) | |
9880 (redraw-display)) | |
9881 | |
9882 (defun gnus-summary-reselect-current-group (&optional all rescan) | |
9883 "Exit and then reselect the current newsgroup. | |
9884 The prefix argument ALL means to select all articles." | |
9885 (interactive "P") | |
9886 (gnus-set-global-variables) | |
9887 (when (gnus-ephemeral-group-p gnus-newsgroup-name) | |
9888 (error "Ephemeral groups can't be reselected")) | |
9889 (let ((current-subject (gnus-summary-article-number)) | |
9890 (group gnus-newsgroup-name)) | |
9891 (setq gnus-newsgroup-begin nil) | |
9892 (gnus-summary-exit) | |
9893 ;; We have to adjust the point of group mode buffer because the | |
9894 ;; current point was moved to the next unread newsgroup by | |
9895 ;; exiting. | |
9896 (gnus-summary-jump-to-group group) | |
9897 (when rescan | |
9898 (save-excursion | |
9899 (gnus-group-get-new-news-this-group 1))) | |
9900 (gnus-group-read-group all t) | |
9901 (gnus-summary-goto-subject current-subject nil t))) | |
9902 | |
9903 (defun gnus-summary-rescan-group (&optional all) | |
9904 "Exit the newsgroup, ask for new articles, and select the newsgroup." | |
9905 (interactive "P") | |
9906 (gnus-summary-reselect-current-group all t)) | |
9907 | |
9908 (defun gnus-summary-update-info () | |
9909 (let* ((group gnus-newsgroup-name)) | |
9910 (when gnus-newsgroup-kill-headers | |
9911 (setq gnus-newsgroup-killed | |
9912 (gnus-compress-sequence | |
9913 (nconc | |
9914 (gnus-set-sorted-intersection | |
9915 (gnus-uncompress-range gnus-newsgroup-killed) | |
9916 (setq gnus-newsgroup-unselected | |
9917 (sort gnus-newsgroup-unselected '<))) | |
9918 (setq gnus-newsgroup-unreads | |
9919 (sort gnus-newsgroup-unreads '<))) t))) | |
9920 (unless (listp (cdr gnus-newsgroup-killed)) | |
9921 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed))) | |
9922 (let ((headers gnus-newsgroup-headers)) | |
9923 (run-hooks 'gnus-exit-group-hook) | |
9924 (unless gnus-save-score | |
9925 (setq gnus-newsgroup-scored nil)) | |
9926 ;; Set the new ranges of read articles. | |
9927 (gnus-update-read-articles | |
9928 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected)) | |
9929 ;; Set the current article marks. | |
9930 (gnus-update-marks) | |
9931 ;; Do the cross-ref thing. | |
9932 (when gnus-use-cross-reference | |
9933 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads)) | |
9934 ;; Do adaptive scoring, and possibly save score files. | |
9935 (when gnus-newsgroup-adaptive | |
9936 (gnus-score-adaptive)) | |
9937 (when gnus-use-scoring | |
9938 (gnus-score-save)) | |
9939 ;; Do not switch windows but change the buffer to work. | |
9940 (set-buffer gnus-group-buffer) | |
9941 (or (gnus-ephemeral-group-p gnus-newsgroup-name) | |
9942 (gnus-group-update-group group))))) | |
9943 | |
9944 (defun gnus-summary-exit (&optional temporary) | |
9945 "Exit reading current newsgroup, and then return to group selection mode. | |
9946 gnus-exit-group-hook is called with no arguments if that value is non-nil." | |
9947 (interactive) | |
9948 (gnus-set-global-variables) | |
9949 (gnus-kill-save-kill-buffer) | |
9950 (let* ((group gnus-newsgroup-name) | |
9951 (quit-config (gnus-group-quit-config gnus-newsgroup-name)) | |
9952 (mode major-mode) | |
9953 (buf (current-buffer))) | |
9954 (run-hooks 'gnus-summary-prepare-exit-hook) | |
9955 ;; If we have several article buffers, we kill them at exit. | |
9956 (unless gnus-single-article-buffer | |
9957 (gnus-kill-buffer gnus-original-article-buffer) | |
9958 (setq gnus-article-current nil)) | |
9959 (when gnus-use-cache | |
9960 (gnus-cache-possibly-remove-articles) | |
9961 (gnus-cache-save-buffers)) | |
9962 (when gnus-use-trees | |
9963 (gnus-tree-close group)) | |
9964 ;; Make all changes in this group permanent. | |
9965 (unless quit-config | |
9966 (gnus-summary-update-info)) | |
9967 (gnus-close-group group) | |
9968 ;; Make sure where I was, and go to next newsgroup. | |
9969 (set-buffer gnus-group-buffer) | |
9970 (unless quit-config | |
9971 (gnus-group-jump-to-group group)) | |
9972 (run-hooks 'gnus-summary-exit-hook) | |
9973 (unless quit-config | |
9974 (gnus-group-next-unread-group 1)) | |
9975 (if temporary | |
9976 nil ;Nothing to do. | |
9977 ;; If we have several article buffers, we kill them at exit. | |
9978 (unless gnus-single-article-buffer | |
9979 (gnus-kill-buffer gnus-article-buffer) | |
9980 (gnus-kill-buffer gnus-original-article-buffer) | |
9981 (setq gnus-article-current nil)) | |
9982 (set-buffer buf) | |
9983 (if (not gnus-kill-summary-on-exit) | |
9984 (gnus-deaden-summary) | |
9985 ;; We set all buffer-local variables to nil. It is unclear why | |
9986 ;; this is needed, but if we don't, buffer-local variables are | |
9987 ;; not garbage-collected, it seems. This would the lead to en | |
9988 ;; ever-growing Emacs. | |
9989 (gnus-summary-clear-local-variables) | |
9990 (when (get-buffer gnus-article-buffer) | |
9991 (bury-buffer gnus-article-buffer)) | |
9992 ;; We clear the global counterparts of the buffer-local | |
9993 ;; variables as well, just to be on the safe side. | |
9994 (gnus-configure-windows 'group 'force) | |
9995 (gnus-summary-clear-local-variables) | |
9996 ;; Return to group mode buffer. | |
9997 (if (eq mode 'gnus-summary-mode) | |
9998 (gnus-kill-buffer buf))) | |
9999 (setq gnus-current-select-method gnus-select-method) | |
10000 (pop-to-buffer gnus-group-buffer) | |
10001 ;; Clear the current group name. | |
10002 (if (not quit-config) | |
10003 (progn | |
10004 (gnus-group-jump-to-group group) | |
10005 (gnus-group-next-unread-group 1) | |
10006 (gnus-configure-windows 'group 'force)) | |
10007 (if (not (buffer-name (car quit-config))) | |
10008 (gnus-configure-windows 'group 'force) | |
10009 (set-buffer (car quit-config)) | |
10010 (and (eq major-mode 'gnus-summary-mode) | |
10011 (gnus-set-global-variables)) | |
10012 (gnus-configure-windows (cdr quit-config)))) | |
10013 (unless quit-config | |
10014 (setq gnus-newsgroup-name nil))))) | |
10015 | |
10016 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update) | |
10017 (defun gnus-summary-exit-no-update (&optional no-questions) | |
10018 "Quit reading current newsgroup without updating read article info." | |
10019 (interactive) | |
10020 (gnus-set-global-variables) | |
10021 (let* ((group gnus-newsgroup-name) | |
10022 (quit-config (gnus-group-quit-config group))) | |
10023 (when (or no-questions | |
10024 gnus-expert-user | |
10025 (gnus-y-or-n-p "Do you really wanna quit reading this group? ")) | |
10026 ;; If we have several article buffers, we kill them at exit. | |
10027 (unless gnus-single-article-buffer | |
10028 (gnus-kill-buffer gnus-article-buffer) | |
10029 (gnus-kill-buffer gnus-original-article-buffer) | |
10030 (setq gnus-article-current nil)) | |
10031 (if (not gnus-kill-summary-on-exit) | |
10032 (gnus-deaden-summary) | |
10033 (gnus-close-group group) | |
10034 (gnus-summary-clear-local-variables) | |
10035 (set-buffer gnus-group-buffer) | |
10036 (gnus-summary-clear-local-variables) | |
10037 (when (get-buffer gnus-summary-buffer) | |
10038 (kill-buffer gnus-summary-buffer))) | |
10039 (unless gnus-single-article-buffer | |
10040 (setq gnus-article-current nil)) | |
10041 (when gnus-use-trees | |
10042 (gnus-tree-close group)) | |
10043 (when (get-buffer gnus-article-buffer) | |
10044 (bury-buffer gnus-article-buffer)) | |
10045 ;; Return to the group buffer. | |
10046 (gnus-configure-windows 'group 'force) | |
10047 ;; Clear the current group name. | |
10048 (setq gnus-newsgroup-name nil) | |
10049 (when (equal (gnus-group-group-name) group) | |
10050 (gnus-group-next-unread-group 1)) | |
10051 (when quit-config | |
10052 (if (not (buffer-name (car quit-config))) | |
10053 (gnus-configure-windows 'group 'force) | |
10054 (set-buffer (car quit-config)) | |
10055 (when (eq major-mode 'gnus-summary-mode) | |
10056 (gnus-set-global-variables)) | |
10057 (gnus-configure-windows (cdr quit-config))))))) | |
10058 | |
10059 ;;; Dead summaries. | |
10060 | |
10061 (defvar gnus-dead-summary-mode-map nil) | |
10062 | |
10063 (if gnus-dead-summary-mode-map | |
10064 nil | |
10065 (setq gnus-dead-summary-mode-map (make-keymap)) | |
10066 (suppress-keymap gnus-dead-summary-mode-map) | |
10067 (substitute-key-definition | |
10068 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map) | |
10069 (let ((keys '("\C-d" "\r" "\177"))) | |
10070 (while keys | |
10071 (define-key gnus-dead-summary-mode-map | |
10072 (pop keys) 'gnus-summary-wake-up-the-dead)))) | |
10073 | |
10074 (defvar gnus-dead-summary-mode nil | |
10075 "Minor mode for Gnus summary buffers.") | |
10076 | |
10077 (defun gnus-dead-summary-mode (&optional arg) | |
10078 "Minor mode for Gnus summary buffers." | |
10079 (interactive "P") | |
10080 (when (eq major-mode 'gnus-summary-mode) | |
10081 (make-local-variable 'gnus-dead-summary-mode) | |
10082 (setq gnus-dead-summary-mode | |
10083 (if (null arg) (not gnus-dead-summary-mode) | |
10084 (> (prefix-numeric-value arg) 0))) | |
10085 (when gnus-dead-summary-mode | |
10086 (unless (assq 'gnus-dead-summary-mode minor-mode-alist) | |
10087 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist)) | |
10088 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist) | |
10089 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map) | |
10090 minor-mode-map-alist))))) | |
10091 | |
10092 (defun gnus-deaden-summary () | |
10093 "Make the current summary buffer into a dead summary buffer." | |
10094 ;; Kill any previous dead summary buffer. | |
10095 (when (and gnus-dead-summary | |
10096 (buffer-name gnus-dead-summary)) | |
10097 (save-excursion | |
10098 (set-buffer gnus-dead-summary) | |
10099 (when gnus-dead-summary-mode | |
10100 (kill-buffer (current-buffer))))) | |
10101 ;; Make this the current dead summary. | |
10102 (setq gnus-dead-summary (current-buffer)) | |
10103 (gnus-dead-summary-mode 1) | |
10104 (let ((name (buffer-name))) | |
10105 (when (string-match "Summary" name) | |
10106 (rename-buffer | |
10107 (concat (substring name 0 (match-beginning 0)) "Dead " | |
10108 (substring name (match-beginning 0))) t)))) | |
10109 | |
10110 (defun gnus-kill-or-deaden-summary (buffer) | |
10111 "Kill or deaden the summary BUFFER." | |
10112 (when (and (buffer-name buffer) | |
10113 (not gnus-single-article-buffer)) | |
10114 (save-excursion | |
10115 (set-buffer buffer) | |
10116 (gnus-kill-buffer gnus-article-buffer) | |
10117 (gnus-kill-buffer gnus-original-article-buffer))) | |
10118 (cond (gnus-kill-summary-on-exit | |
10119 (when (and gnus-use-trees | |
10120 (and (get-buffer buffer) | |
10121 (buffer-name (get-buffer buffer)))) | |
10122 (save-excursion | |
10123 (set-buffer (get-buffer buffer)) | |
10124 (gnus-tree-close gnus-newsgroup-name))) | |
10125 (gnus-kill-buffer buffer)) | |
10126 ((and (get-buffer buffer) | |
10127 (buffer-name (get-buffer buffer))) | |
10128 (save-excursion | |
10129 (set-buffer buffer) | |
10130 (gnus-deaden-summary))))) | |
10131 | |
10132 (defun gnus-summary-wake-up-the-dead (&rest args) | |
10133 "Wake up the dead summary buffer." | |
10134 (interactive) | |
10135 (gnus-dead-summary-mode -1) | |
10136 (let ((name (buffer-name))) | |
10137 (when (string-match "Dead " name) | |
10138 (rename-buffer | |
10139 (concat (substring name 0 (match-beginning 0)) | |
10140 (substring name (match-end 0))) t))) | |
10141 (gnus-message 3 "This dead summary is now alive again")) | |
10142 | |
10143 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>. | |
10144 (defun gnus-summary-fetch-faq (&optional faq-dir) | |
10145 "Fetch the FAQ for the current group. | |
10146 If FAQ-DIR (the prefix), prompt for a directory to search for the faq | |
10147 in." | |
10148 (interactive | |
10149 (list | |
10150 (if current-prefix-arg | |
10151 (completing-read | |
10152 "Faq dir: " (and (listp gnus-group-faq-directory) | |
10153 gnus-group-faq-directory))))) | |
10154 (let (gnus-faq-buffer) | |
10155 (and (setq gnus-faq-buffer | |
10156 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir)) | |
10157 (gnus-configure-windows 'summary-faq)))) | |
10158 | |
10159 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>. | |
10160 (defun gnus-summary-describe-group (&optional force) | |
10161 "Describe the current newsgroup." | |
10162 (interactive "P") | |
10163 (gnus-group-describe-group force gnus-newsgroup-name)) | |
10164 | |
10165 (defun gnus-summary-describe-briefly () | |
10166 "Describe summary mode commands briefly." | |
10167 (interactive) | |
10168 (gnus-message 6 | |
10169 (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"))) | |
10170 | |
10171 ;; Walking around group mode buffer from summary mode. | |
10172 | |
10173 (defun gnus-summary-next-group (&optional no-article target-group backward) | |
10174 "Exit current newsgroup and then select next unread newsgroup. | |
10175 If prefix argument NO-ARTICLE is non-nil, no article is selected | |
10176 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to | |
10177 previous group instead." | |
10178 (interactive "P") | |
10179 (gnus-set-global-variables) | |
10180 (let ((current-group gnus-newsgroup-name) | |
10181 (current-buffer (current-buffer)) | |
10182 entered) | |
10183 ;; First we semi-exit this group to update Xrefs and all variables. | |
10184 ;; We can't do a real exit, because the window conf must remain | |
10185 ;; the same in case the user is prompted for info, and we don't | |
10186 ;; want the window conf to change before that... | |
10187 (gnus-summary-exit t) | |
10188 (while (not entered) | |
10189 ;; Then we find what group we are supposed to enter. | |
10190 (set-buffer gnus-group-buffer) | |
10191 (gnus-group-jump-to-group current-group) | |
10192 (setq target-group | |
10193 (or target-group | |
10194 (if (eq gnus-keep-same-level 'best) | |
10195 (gnus-summary-best-group gnus-newsgroup-name) | |
10196 (gnus-summary-search-group backward gnus-keep-same-level)))) | |
10197 (if (not target-group) | |
10198 ;; There are no further groups, so we return to the group | |
10199 ;; buffer. | |
10200 (progn | |
10201 (gnus-message 5 "Returning to the group buffer") | |
10202 (setq entered t) | |
10203 (set-buffer current-buffer) | |
10204 (gnus-summary-exit)) | |
10205 ;; We try to enter the target group. | |
10206 (gnus-group-jump-to-group target-group) | |
10207 (let ((unreads (gnus-group-group-unread))) | |
10208 (if (and (or (eq t unreads) | |
10209 (and unreads (not (zerop unreads)))) | |
10210 (gnus-summary-read-group | |
10211 target-group nil no-article current-buffer)) | |
10212 (setq entered t) | |
10213 (setq current-group target-group | |
10214 target-group nil))))))) | |
10215 | |
10216 (defun gnus-summary-prev-group (&optional no-article) | |
10217 "Exit current newsgroup and then select previous unread newsgroup. | |
10218 If prefix argument NO-ARTICLE is non-nil, no article is selected initially." | |
10219 (interactive "P") | |
10220 (gnus-summary-next-group no-article nil t)) | |
10221 | |
10222 ;; Walking around summary lines. | |
10223 | |
10224 (defun gnus-summary-first-subject (&optional unread) | |
10225 "Go to the first unread subject. | |
10226 If UNREAD is non-nil, go to the first unread article. | |
10227 Returns the article selected or nil if there are no unread articles." | |
10228 (interactive "P") | |
10229 (prog1 | |
10230 (cond | |
10231 ;; Empty summary. | |
10232 ((null gnus-newsgroup-data) | |
10233 (gnus-message 3 "No articles in the group") | |
10234 nil) | |
10235 ;; Pick the first article. | |
10236 ((not unread) | |
10237 (goto-char (gnus-data-pos (car gnus-newsgroup-data))) | |
10238 (gnus-data-number (car gnus-newsgroup-data))) | |
10239 ;; No unread articles. | |
10240 ((null gnus-newsgroup-unreads) | |
10241 (gnus-message 3 "No more unread articles") | |
10242 nil) | |
10243 ;; Find the first unread article. | |
10244 (t | |
10245 (let ((data gnus-newsgroup-data)) | |
10246 (while (and data | |
10247 (not (gnus-data-unread-p (car data)))) | |
10248 (setq data (cdr data))) | |
10249 (if data | |
10250 (progn | |
10251 (goto-char (gnus-data-pos (car data))) | |
10252 (gnus-data-number (car data))))))) | |
10253 (gnus-summary-position-point))) | |
10254 | |
10255 (defun gnus-summary-next-subject (n &optional unread dont-display) | |
10256 "Go to next N'th summary line. | |
10257 If N is negative, go to the previous N'th subject line. | |
10258 If UNREAD is non-nil, only unread articles are selected. | |
10259 The difference between N and the actual number of steps taken is | |
10260 returned." | |
10261 (interactive "p") | |
10262 (let ((backward (< n 0)) | |
10263 (n (abs n))) | |
10264 (while (and (> n 0) | |
10265 (if backward | |
10266 (gnus-summary-find-prev unread) | |
10267 (gnus-summary-find-next unread))) | |
10268 (setq n (1- n))) | |
10269 (if (/= 0 n) (gnus-message 7 "No more%s articles" | |
10270 (if unread " unread" ""))) | |
10271 (unless dont-display | |
10272 (gnus-summary-recenter) | |
10273 (gnus-summary-position-point)) | |
10274 n)) | |
10275 | |
10276 (defun gnus-summary-next-unread-subject (n) | |
10277 "Go to next N'th unread summary line." | |
10278 (interactive "p") | |
10279 (gnus-summary-next-subject n t)) | |
10280 | |
10281 (defun gnus-summary-prev-subject (n &optional unread) | |
10282 "Go to previous N'th summary line. | |
10283 If optional argument UNREAD is non-nil, only unread article is selected." | |
10284 (interactive "p") | |
10285 (gnus-summary-next-subject (- n) unread)) | |
10286 | |
10287 (defun gnus-summary-prev-unread-subject (n) | |
10288 "Go to previous N'th unread summary line." | |
10289 (interactive "p") | |
10290 (gnus-summary-next-subject (- n) t)) | |
10291 | |
10292 (defun gnus-summary-goto-subject (article &optional force silent) | |
10293 "Go the subject line of ARTICLE. | |
10294 If FORCE, also allow jumping to articles not currently shown." | |
10295 (let ((b (point)) | |
10296 (data (gnus-data-find article))) | |
10297 ;; We read in the article if we have to. | |
10298 (and (not data) | |
10299 force | |
10300 (gnus-summary-insert-subject article (and (vectorp force) force) t) | |
10301 (setq data (gnus-data-find article))) | |
10302 (goto-char b) | |
10303 (if (not data) | |
10304 (progn | |
10305 (unless silent | |
10306 (gnus-message 3 "Can't find article %d" article)) | |
10307 nil) | |
10308 (goto-char (gnus-data-pos data)) | |
10309 article))) | |
10310 | |
10311 ;; Walking around summary lines with displaying articles. | |
10312 | |
10313 (defun gnus-summary-expand-window (&optional arg) | |
10314 "Make the summary buffer take up the entire Emacs frame. | |
10315 Given a prefix, will force an `article' buffer configuration." | |
10316 (interactive "P") | |
10317 (gnus-set-global-variables) | |
10318 (if arg | |
10319 (gnus-configure-windows 'article 'force) | |
10320 (gnus-configure-windows 'summary 'force))) | |
10321 | |
10322 (defun gnus-summary-display-article (article &optional all-header) | |
10323 "Display ARTICLE in article buffer." | |
10324 (gnus-set-global-variables) | |
10325 (if (null article) | |
10326 nil | |
10327 (prog1 | |
10328 (if gnus-summary-display-article-function | |
10329 (funcall gnus-summary-display-article-function article all-header) | |
10330 (gnus-article-prepare article all-header)) | |
10331 (run-hooks 'gnus-select-article-hook) | |
10332 (unless (zerop gnus-current-article) | |
10333 (gnus-summary-goto-subject gnus-current-article)) | |
10334 (gnus-summary-recenter) | |
10335 (when gnus-use-trees | |
10336 (gnus-possibly-generate-tree article) | |
10337 (gnus-highlight-selected-tree article)) | |
10338 ;; Successfully display article. | |
10339 (gnus-article-set-window-start | |
10340 (cdr (assq article gnus-newsgroup-bookmarks)))))) | |
10341 | |
10342 (defun gnus-summary-select-article (&optional all-headers force pseudo article) | |
10343 "Select the current article. | |
10344 If ALL-HEADERS is non-nil, show all header fields. If FORCE is | |
10345 non-nil, the article will be re-fetched even if it already present in | |
10346 the article buffer. If PSEUDO is non-nil, pseudo-articles will also | |
10347 be displayed." | |
10348 ;; Make sure we are in the summary buffer to work around bbdb bug. | |
10349 (unless (eq major-mode 'gnus-summary-mode) | |
10350 (set-buffer gnus-summary-buffer)) | |
10351 (let ((article (or article (gnus-summary-article-number))) | |
10352 (all-headers (not (not all-headers))) ;Must be T or NIL. | |
10353 gnus-summary-display-article-function | |
10354 did) | |
10355 (and (not pseudo) | |
10356 (gnus-summary-article-pseudo-p article) | |
10357 (error "This is a pseudo-article.")) | |
10358 (prog1 | |
10359 (save-excursion | |
10360 (set-buffer gnus-summary-buffer) | |
10361 (if (or (and gnus-single-article-buffer | |
10362 (or (null gnus-current-article) | |
10363 (null gnus-article-current) | |
10364 (null (get-buffer gnus-article-buffer)) | |
10365 (not (eq article (cdr gnus-article-current))) | |
10366 (not (equal (car gnus-article-current) | |
10367 gnus-newsgroup-name)))) | |
10368 (and (not gnus-single-article-buffer) | |
10369 (or (null gnus-current-article) | |
10370 (not (eq gnus-current-article article)))) | |
10371 force) | |
10372 ;; The requested article is different from the current article. | |
10373 (prog1 | |
10374 (gnus-summary-display-article article all-headers) | |
10375 (setq did article)) | |
10376 (if (or all-headers gnus-show-all-headers) | |
10377 (gnus-article-show-all-headers)) | |
10378 'old)) | |
10379 (if did | |
10380 (gnus-article-set-window-start | |
10381 (cdr (assq article gnus-newsgroup-bookmarks))))))) | |
10382 | |
10383 (defun gnus-summary-set-current-mark (&optional current-mark) | |
10384 "Obsolete function." | |
10385 nil) | |
10386 | |
10387 (defun gnus-summary-next-article (&optional unread subject backward push) | |
10388 "Select the next article. | |
10389 If UNREAD, only unread articles are selected. | |
10390 If SUBJECT, only articles with SUBJECT are selected. | |
10391 If BACKWARD, the previous article is selected instead of the next." | |
10392 (interactive "P") | |
10393 (gnus-set-global-variables) | |
10394 (cond | |
10395 ;; Is there such an article? | |
10396 ((and (gnus-summary-search-forward unread subject backward) | |
10397 (or (gnus-summary-display-article (gnus-summary-article-number)) | |
10398 (eq (gnus-summary-article-mark) gnus-canceled-mark))) | |
10399 (gnus-summary-position-point)) | |
10400 ;; If not, we try the first unread, if that is wanted. | |
10401 ((and subject | |
10402 gnus-auto-select-same | |
10403 (or (gnus-summary-first-unread-article) | |
10404 (eq (gnus-summary-article-mark) gnus-canceled-mark))) | |
10405 (gnus-summary-position-point) | |
10406 (gnus-message 6 "Wrapped")) | |
10407 ;; Try to get next/previous article not displayed in this group. | |
10408 ((and gnus-auto-extend-newsgroup | |
10409 (not unread) (not subject)) | |
10410 (gnus-summary-goto-article | |
10411 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end)) | |
10412 nil t)) | |
10413 ;; Go to next/previous group. | |
10414 (t | |
10415 (or (gnus-ephemeral-group-p gnus-newsgroup-name) | |
10416 (gnus-summary-jump-to-group gnus-newsgroup-name)) | |
10417 (let ((cmd last-command-char) | |
10418 (group | |
10419 (if (eq gnus-keep-same-level 'best) | |
10420 (gnus-summary-best-group gnus-newsgroup-name) | |
10421 (gnus-summary-search-group backward gnus-keep-same-level)))) | |
10422 ;; For some reason, the group window gets selected. We change | |
10423 ;; it back. | |
10424 (select-window (get-buffer-window (current-buffer))) | |
10425 ;; Select next unread newsgroup automagically. | |
10426 (cond | |
10427 ((or (not gnus-auto-select-next) | |
10428 (not cmd)) | |
10429 (gnus-message 7 "No more%s articles" (if unread " unread" ""))) | |
10430 ((or (eq gnus-auto-select-next 'quietly) | |
10431 (and (eq gnus-auto-select-next 'slightly-quietly) | |
10432 push) | |
10433 (and (eq gnus-auto-select-next 'almost-quietly) | |
10434 (gnus-summary-last-article-p))) | |
10435 ;; Select quietly. | |
10436 (if (gnus-ephemeral-group-p gnus-newsgroup-name) | |
10437 (gnus-summary-exit) | |
10438 (gnus-message 7 "No more%s articles (%s)..." | |
10439 (if unread " unread" "") | |
10440 (if group (concat "selecting " group) | |
10441 "exiting")) | |
10442 (gnus-summary-next-group nil group backward))) | |
10443 (t | |
10444 (gnus-summary-walk-group-buffer | |
10445 gnus-newsgroup-name cmd unread backward))))))) | |
10446 | |
10447 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward) | |
10448 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1)) | |
10449 (?\C-p (gnus-group-prev-unread-group 1)))) | |
10450 keve key group ended) | |
10451 (save-excursion | |
10452 (set-buffer gnus-group-buffer) | |
10453 (gnus-summary-jump-to-group from-group) | |
10454 (setq group | |
10455 (if (eq gnus-keep-same-level 'best) | |
10456 (gnus-summary-best-group gnus-newsgroup-name) | |
10457 (gnus-summary-search-group backward gnus-keep-same-level)))) | |
10458 (while (not ended) | |
10459 (gnus-message | |
10460 5 "No more%s articles%s" (if unread " unread" "") | |
10461 (if (and group | |
10462 (not (gnus-ephemeral-group-p gnus-newsgroup-name))) | |
10463 (format " (Type %s for %s [%s])" | |
10464 (single-key-description cmd) group | |
10465 (car (gnus-gethash group gnus-newsrc-hashtb))) | |
10466 (format " (Type %s to exit %s)" | |
10467 (single-key-description cmd) | |
10468 gnus-newsgroup-name))) | |
10469 ;; Confirm auto selection. | |
10470 (setq key (car (setq keve (gnus-read-event-char)))) | |
10471 (setq ended t) | |
10472 (cond | |
10473 ((assq key keystrokes) | |
10474 (let ((obuf (current-buffer))) | |
10475 (switch-to-buffer gnus-group-buffer) | |
10476 (and group | |
10477 (gnus-group-jump-to-group group)) | |
10478 (eval (cadr (assq key keystrokes))) | |
10479 (setq group (gnus-group-group-name)) | |
10480 (switch-to-buffer obuf)) | |
10481 (setq ended nil)) | |
10482 ((equal key cmd) | |
10483 (if (or (not group) | |
10484 (gnus-ephemeral-group-p gnus-newsgroup-name)) | |
10485 (gnus-summary-exit) | |
10486 (gnus-summary-next-group nil group backward))) | |
10487 (t | |
10488 (push (cdr keve) unread-command-events)))))) | |
10489 | |
10490 (defun gnus-read-event-char () | |
10491 "Get the next event." | |
10492 (let ((event (read-event))) | |
10493 (cons (and (numberp event) event) event))) | |
10494 | |
10495 (defun gnus-summary-next-unread-article () | |
10496 "Select unread article after current one." | |
10497 (interactive) | |
10498 (gnus-summary-next-article t (and gnus-auto-select-same | |
10499 (gnus-summary-article-subject)))) | |
10500 | |
10501 (defun gnus-summary-prev-article (&optional unread subject) | |
10502 "Select the article after the current one. | |
10503 If UNREAD is non-nil, only unread articles are selected." | |
10504 (interactive "P") | |
10505 (gnus-summary-next-article unread subject t)) | |
10506 | |
10507 (defun gnus-summary-prev-unread-article () | |
10508 "Select unred article before current one." | |
10509 (interactive) | |
10510 (gnus-summary-prev-article t (and gnus-auto-select-same | |
10511 (gnus-summary-article-subject)))) | |
10512 | |
10513 (defun gnus-summary-next-page (&optional lines circular) | |
10514 "Show next page of the selected article. | |
10515 If at the end of the current article, select the next article. | |
10516 LINES says how many lines should be scrolled up. | |
10517 | |
10518 If CIRCULAR is non-nil, go to the start of the article instead of | |
10519 selecting the next article when reaching the end of the current | |
10520 article." | |
10521 (interactive "P") | |
10522 (setq gnus-summary-buffer (current-buffer)) | |
10523 (gnus-set-global-variables) | |
10524 (let ((article (gnus-summary-article-number)) | |
10525 (endp nil)) | |
10526 (gnus-configure-windows 'article) | |
10527 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark) | |
10528 (if (and (eq gnus-summary-goto-unread 'never) | |
10529 (not (gnus-summary-last-article-p article))) | |
10530 (gnus-summary-next-article) | |
10531 (gnus-summary-next-unread-article)) | |
10532 (if (or (null gnus-current-article) | |
10533 (null gnus-article-current) | |
10534 (/= article (cdr gnus-article-current)) | |
10535 (not (equal (car gnus-article-current) gnus-newsgroup-name))) | |
10536 ;; Selected subject is different from current article's. | |
10537 (gnus-summary-display-article article) | |
10538 (gnus-eval-in-buffer-window gnus-article-buffer | |
10539 (setq endp (gnus-article-next-page lines))) | |
10540 (if endp | |
10541 (cond (circular | |
10542 (gnus-summary-beginning-of-article)) | |
10543 (lines | |
10544 (gnus-message 3 "End of message")) | |
10545 ((null lines) | |
10546 (if (and (eq gnus-summary-goto-unread 'never) | |
10547 (not (gnus-summary-last-article-p article))) | |
10548 (gnus-summary-next-article) | |
10549 (gnus-summary-next-unread-article))))))) | |
10550 (gnus-summary-recenter) | |
10551 (gnus-summary-position-point))) | |
10552 | |
10553 (defun gnus-summary-prev-page (&optional lines) | |
10554 "Show previous page of selected article. | |
10555 Argument LINES specifies lines to be scrolled down." | |
10556 (interactive "P") | |
10557 (gnus-set-global-variables) | |
10558 (let ((article (gnus-summary-article-number))) | |
10559 (gnus-configure-windows 'article) | |
10560 (if (or (null gnus-current-article) | |
10561 (null gnus-article-current) | |
10562 (/= article (cdr gnus-article-current)) | |
10563 (not (equal (car gnus-article-current) gnus-newsgroup-name))) | |
10564 ;; Selected subject is different from current article's. | |
10565 (gnus-summary-display-article article) | |
10566 (gnus-summary-recenter) | |
10567 (gnus-eval-in-buffer-window gnus-article-buffer | |
10568 (gnus-article-prev-page lines)))) | |
10569 (gnus-summary-position-point)) | |
10570 | |
10571 (defun gnus-summary-scroll-up (lines) | |
10572 "Scroll up (or down) one line current article. | |
10573 Argument LINES specifies lines to be scrolled up (or down if negative)." | |
10574 (interactive "p") | |
10575 (gnus-set-global-variables) | |
10576 (gnus-configure-windows 'article) | |
10577 (gnus-summary-show-thread) | |
10578 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old) | |
10579 (gnus-eval-in-buffer-window gnus-article-buffer | |
10580 (cond ((> lines 0) | |
10581 (if (gnus-article-next-page lines) | |
10582 (gnus-message 3 "End of message"))) | |
10583 ((< lines 0) | |
10584 (gnus-article-prev-page (- lines)))))) | |
10585 (gnus-summary-recenter) | |
10586 (gnus-summary-position-point)) | |
10587 | |
10588 (defun gnus-summary-next-same-subject () | |
10589 "Select next article which has the same subject as current one." | |
10590 (interactive) | |
10591 (gnus-set-global-variables) | |
10592 (gnus-summary-next-article nil (gnus-summary-article-subject))) | |
10593 | |
10594 (defun gnus-summary-prev-same-subject () | |
10595 "Select previous article which has the same subject as current one." | |
10596 (interactive) | |
10597 (gnus-set-global-variables) | |
10598 (gnus-summary-prev-article nil (gnus-summary-article-subject))) | |
10599 | |
10600 (defun gnus-summary-next-unread-same-subject () | |
10601 "Select next unread article which has the same subject as current one." | |
10602 (interactive) | |
10603 (gnus-set-global-variables) | |
10604 (gnus-summary-next-article t (gnus-summary-article-subject))) | |
10605 | |
10606 (defun gnus-summary-prev-unread-same-subject () | |
10607 "Select previous unread article which has the same subject as current one." | |
10608 (interactive) | |
10609 (gnus-set-global-variables) | |
10610 (gnus-summary-prev-article t (gnus-summary-article-subject))) | |
10611 | |
10612 (defun gnus-summary-first-unread-article () | |
10613 "Select the first unread article. | |
10614 Return nil if there are no unread articles." | |
10615 (interactive) | |
10616 (gnus-set-global-variables) | |
10617 (prog1 | |
10618 (if (gnus-summary-first-subject t) | |
10619 (progn | |
10620 (gnus-summary-show-thread) | |
10621 (gnus-summary-first-subject t) | |
10622 (gnus-summary-display-article (gnus-summary-article-number)))) | |
10623 (gnus-summary-position-point))) | |
10624 | |
10625 (defun gnus-summary-best-unread-article () | |
10626 "Select the unread article with the highest score." | |
10627 (interactive) | |
10628 (gnus-set-global-variables) | |
10629 (let ((best -1000000) | |
10630 (data gnus-newsgroup-data) | |
10631 article score) | |
10632 (while data | |
10633 (and (gnus-data-unread-p (car data)) | |
10634 (> (setq score | |
10635 (gnus-summary-article-score (gnus-data-number (car data)))) | |
10636 best) | |
10637 (setq best score | |
10638 article (gnus-data-number (car data)))) | |
10639 (setq data (cdr data))) | |
10640 (prog1 | |
10641 (if article | |
10642 (gnus-summary-goto-article article) | |
10643 (error "No unread articles")) | |
10644 (gnus-summary-position-point)))) | |
10645 | |
10646 (defun gnus-summary-last-subject () | |
10647 "Go to the last displayed subject line in the group." | |
10648 (let ((article (gnus-data-number (car (gnus-data-list t))))) | |
10649 (when article | |
10650 (gnus-summary-goto-subject article)))) | |
10651 | |
10652 (defun gnus-summary-goto-article (article &optional all-headers force) | |
10653 "Fetch ARTICLE and display it if it exists. | |
10654 If ALL-HEADERS is non-nil, no header lines are hidden." | |
10655 (interactive | |
10656 (list | |
10657 (string-to-int | |
10658 (completing-read | |
10659 "Article number: " | |
10660 (mapcar (lambda (number) (list (int-to-string number))) | |
10661 gnus-newsgroup-limit))) | |
10662 current-prefix-arg | |
10663 t)) | |
10664 (prog1 | |
10665 (if (gnus-summary-goto-subject article force) | |
10666 (gnus-summary-display-article article all-headers) | |
10667 (gnus-message 4 "Couldn't go to article %s" article) nil) | |
10668 (gnus-summary-position-point))) | |
10669 | |
10670 (defun gnus-summary-goto-last-article () | |
10671 "Go to the previously read article." | |
10672 (interactive) | |
10673 (prog1 | |
10674 (and gnus-last-article | |
10675 (gnus-summary-goto-article gnus-last-article)) | |
10676 (gnus-summary-position-point))) | |
10677 | |
10678 (defun gnus-summary-pop-article (number) | |
10679 "Pop one article off the history and go to the previous. | |
10680 NUMBER articles will be popped off." | |
10681 (interactive "p") | |
10682 (let (to) | |
10683 (setq gnus-newsgroup-history | |
10684 (cdr (setq to (nthcdr number gnus-newsgroup-history)))) | |
10685 (if to | |
10686 (gnus-summary-goto-article (car to)) | |
10687 (error "Article history empty"))) | |
10688 (gnus-summary-position-point)) | |
10689 | |
10690 ;; Summary commands and functions for limiting the summary buffer. | |
10691 | |
10692 (defun gnus-summary-limit-to-articles (n) | |
10693 "Limit the summary buffer to the next N articles. | |
10694 If not given a prefix, use the process marked articles instead." | |
10695 (interactive "P") | |
10696 (gnus-set-global-variables) | |
10697 (prog1 | |
10698 (let ((articles (gnus-summary-work-articles n))) | |
10699 (setq gnus-newsgroup-processable nil) | |
10700 (gnus-summary-limit articles)) | |
10701 (gnus-summary-position-point))) | |
10702 | |
10703 (defun gnus-summary-pop-limit (&optional total) | |
10704 "Restore the previous limit. | |
10705 If given a prefix, remove all limits." | |
10706 (interactive "P") | |
10707 (gnus-set-global-variables) | |
10708 (when total | |
10709 (setq gnus-newsgroup-limits | |
10710 (list (mapcar (lambda (h) (mail-header-number h)) | |
10711 gnus-newsgroup-headers)))) | |
10712 (unless gnus-newsgroup-limits | |
10713 (error "No limit to pop")) | |
10714 (prog1 | |
10715 (gnus-summary-limit nil 'pop) | |
10716 (gnus-summary-position-point))) | |
10717 | |
10718 (defun gnus-summary-limit-to-subject (subject &optional header) | |
10719 "Limit the summary buffer to articles that have subjects that match a regexp." | |
10720 (interactive "sRegexp: ") | |
10721 (unless header | |
10722 (setq header "subject")) | |
10723 (when (not (equal "" subject)) | |
10724 (prog1 | |
10725 (let ((articles (gnus-summary-find-matching | |
10726 (or header "subject") subject 'all))) | |
10727 (or articles (error "Found no matches for \"%s\"" subject)) | |
10728 (gnus-summary-limit articles)) | |
10729 (gnus-summary-position-point)))) | |
10730 | |
10731 (defun gnus-summary-limit-to-author (from) | |
10732 "Limit the summary buffer to articles that have authors that match a regexp." | |
10733 (interactive "sRegexp: ") | |
10734 (gnus-summary-limit-to-subject from "from")) | |
10735 | |
10736 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread) | |
10737 (make-obsolete | |
10738 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread) | |
10739 | |
10740 (defun gnus-summary-limit-to-unread (&optional all) | |
10741 "Limit the summary buffer to articles that are not marked as read. | |
10742 If ALL is non-nil, limit strictly to unread articles." | |
10743 (interactive "P") | |
10744 (if all | |
10745 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark)) | |
10746 (gnus-summary-limit-to-marks | |
10747 ;; Concat all the marks that say that an article is read and have | |
10748 ;; those removed. | |
10749 (list gnus-del-mark gnus-read-mark gnus-ancient-mark | |
10750 gnus-killed-mark gnus-kill-file-mark | |
10751 gnus-low-score-mark gnus-expirable-mark | |
10752 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark) | |
10753 'reverse))) | |
10754 | |
10755 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks) | |
10756 (make-obsolete 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks) | |
10757 | |
10758 (defun gnus-summary-limit-to-marks (marks &optional reverse) | |
10759 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\"). | |
10760 If REVERSE, limit the summary buffer to articles that are not marked | |
10761 with MARKS. MARKS can either be a string of marks or a list of marks. | |
10762 Returns how many articles were removed." | |
10763 (interactive "sMarks: ") | |
10764 (gnus-set-global-variables) | |
10765 (prog1 | |
10766 (let ((data gnus-newsgroup-data) | |
10767 (marks (if (listp marks) marks | |
10768 (append marks nil))) ; Transform to list. | |
10769 articles) | |
10770 (while data | |
10771 (and (if reverse (not (memq (gnus-data-mark (car data)) marks)) | |
10772 (memq (gnus-data-mark (car data)) marks)) | |
10773 (setq articles (cons (gnus-data-number (car data)) articles))) | |
10774 (setq data (cdr data))) | |
10775 (gnus-summary-limit articles)) | |
10776 (gnus-summary-position-point))) | |
10777 | |
10778 (defun gnus-summary-limit-to-score (&optional score) | |
10779 "Limit to articles with score at or above SCORE." | |
10780 (interactive "P") | |
10781 (gnus-set-global-variables) | |
10782 (setq score (if score | |
10783 (prefix-numeric-value score) | |
10784 (or gnus-summary-default-score 0))) | |
10785 (let ((data gnus-newsgroup-data) | |
10786 articles) | |
10787 (while data | |
10788 (when (>= (gnus-summary-article-score (gnus-data-number (car data))) | |
10789 score) | |
10790 (push (gnus-data-number (car data)) articles)) | |
10791 (setq data (cdr data))) | |
10792 (prog1 | |
10793 (gnus-summary-limit articles) | |
10794 (gnus-summary-position-point)))) | |
10795 | |
10796 (defun gnus-summary-limit-include-dormant () | |
10797 "Display all the hidden articles that are marked as dormant." | |
10798 (interactive) | |
10799 (gnus-set-global-variables) | |
10800 (or gnus-newsgroup-dormant | |
10801 (error "There are no dormant articles in this group")) | |
10802 (prog1 | |
10803 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit)) | |
10804 (gnus-summary-position-point))) | |
10805 | |
10806 (defun gnus-summary-limit-exclude-dormant () | |
10807 "Hide all dormant articles." | |
10808 (interactive) | |
10809 (gnus-set-global-variables) | |
10810 (prog1 | |
10811 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse) | |
10812 (gnus-summary-position-point))) | |
10813 | |
10814 (defun gnus-summary-limit-exclude-childless-dormant () | |
10815 "Hide all dormant articles that have no children." | |
10816 (interactive) | |
10817 (gnus-set-global-variables) | |
10818 (let ((data (gnus-data-list t)) | |
10819 articles d children) | |
10820 ;; Find all articles that are either not dormant or have | |
10821 ;; children. | |
10822 (while (setq d (pop data)) | |
10823 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark)) | |
10824 (and (setq children | |
10825 (gnus-article-children (gnus-data-number d))) | |
10826 (let (found) | |
10827 (while children | |
10828 (when (memq (car children) articles) | |
10829 (setq children nil | |
10830 found t)) | |
10831 (pop children)) | |
10832 found))) | |
10833 (push (gnus-data-number d) articles))) | |
10834 ;; Do the limiting. | |
10835 (prog1 | |
10836 (gnus-summary-limit articles) | |
10837 (gnus-summary-position-point)))) | |
10838 | |
10839 (defun gnus-summary-limit-mark-excluded-as-read (&optional all) | |
10840 "Mark all unread excluded articles as read. | |
10841 If ALL, mark even excluded ticked and dormants as read." | |
10842 (interactive "P") | |
10843 (let ((articles (gnus-sorted-complement | |
10844 (sort | |
10845 (mapcar (lambda (h) (mail-header-number h)) | |
10846 gnus-newsgroup-headers) | |
10847 '<) | |
10848 (sort gnus-newsgroup-limit '<))) | |
10849 article) | |
10850 (setq gnus-newsgroup-unreads nil) | |
10851 (if all | |
10852 (setq gnus-newsgroup-dormant nil | |
10853 gnus-newsgroup-marked nil | |
10854 gnus-newsgroup-reads | |
10855 (nconc | |
10856 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles) | |
10857 gnus-newsgroup-reads)) | |
10858 (while (setq article (pop articles)) | |
10859 (unless (or (memq article gnus-newsgroup-dormant) | |
10860 (memq article gnus-newsgroup-marked)) | |
10861 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads)))))) | |
10862 | |
10863 (defun gnus-summary-limit (articles &optional pop) | |
10864 (if pop | |
10865 ;; We pop the previous limit off the stack and use that. | |
10866 (setq articles (car gnus-newsgroup-limits) | |
10867 gnus-newsgroup-limits (cdr gnus-newsgroup-limits)) | |
10868 ;; We use the new limit, so we push the old limit on the stack. | |
10869 (setq gnus-newsgroup-limits | |
10870 (cons gnus-newsgroup-limit gnus-newsgroup-limits))) | |
10871 ;; Set the limit. | |
10872 (setq gnus-newsgroup-limit articles) | |
10873 (let ((total (length gnus-newsgroup-data)) | |
10874 (data (gnus-data-find-list (gnus-summary-article-number))) | |
10875 found) | |
10876 ;; This will do all the work of generating the new summary buffer | |
10877 ;; according to the new limit. | |
10878 (gnus-summary-prepare) | |
10879 ;; Hide any threads, possibly. | |
10880 (and gnus-show-threads | |
10881 gnus-thread-hide-subtree | |
10882 (gnus-summary-hide-all-threads)) | |
10883 ;; Try to return to the article you were at, or one in the | |
10884 ;; neighborhood. | |
10885 (if data | |
10886 ;; We try to find some article after the current one. | |
10887 (while data | |
10888 (and (gnus-summary-goto-subject | |
10889 (gnus-data-number (car data)) nil t) | |
10890 (setq data nil | |
10891 found t)) | |
10892 (setq data (cdr data)))) | |
10893 (or found | |
10894 ;; If there is no data, that means that we were after the last | |
10895 ;; article. The same goes when we can't find any articles | |
10896 ;; after the current one. | |
10897 (progn | |
10898 (goto-char (point-max)) | |
10899 (gnus-summary-find-prev))) | |
10900 ;; We return how many articles were removed from the summary | |
10901 ;; buffer as a result of the new limit. | |
10902 (- total (length gnus-newsgroup-data)))) | |
10903 | |
10904 (defsubst gnus-invisible-cut-children (threads) | |
10905 (let ((num 0)) | |
10906 (while threads | |
10907 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit) | |
10908 (incf num)) | |
10909 (pop threads)) | |
10910 (< num 2))) | |
10911 | |
10912 (defsubst gnus-cut-thread (thread) | |
10913 "Go forwards in the thread until we find an article that we want to display." | |
10914 (when (or (eq gnus-fetch-old-headers 'some) | |
10915 (eq gnus-build-sparse-threads 'some) | |
10916 (eq gnus-build-sparse-threads 'more)) | |
10917 ;; Deal with old-fetched headers and sparse threads. | |
10918 (while (and | |
10919 thread | |
10920 (or | |
10921 (memq (mail-header-number (car thread)) gnus-newsgroup-sparse) | |
10922 (memq (mail-header-number (car thread)) gnus-newsgroup-ancient)) | |
10923 (or (<= (length (cdr thread)) 1) | |
10924 (gnus-invisible-cut-children (cdr thread)))) | |
10925 (setq thread (cadr thread)))) | |
10926 thread) | |
10927 | |
10928 (defun gnus-cut-threads (threads) | |
10929 "Cut off all uninteresting articles from the beginning of threads." | |
10930 (when (or (eq gnus-fetch-old-headers 'some) | |
10931 (eq gnus-build-sparse-threads 'some) | |
10932 (eq gnus-build-sparse-threads 'more)) | |
10933 (let ((th threads)) | |
10934 (while th | |
10935 (setcar th (gnus-cut-thread (car th))) | |
10936 (setq th (cdr th))))) | |
10937 ;; Remove nixed out threads. | |
10938 (delq nil threads)) | |
10939 | |
10940 (defun gnus-summary-initial-limit (&optional show-if-empty) | |
10941 "Figure out what the initial limit is supposed to be on group entry. | |
10942 This entails weeding out unwanted dormants, low-scored articles, | |
10943 fetch-old-headers verbiage, and so on." | |
10944 ;; Most groups have nothing to remove. | |
10945 (if (or gnus-inhibit-limiting | |
10946 (and (null gnus-newsgroup-dormant) | |
10947 (not (eq gnus-fetch-old-headers 'some)) | |
10948 (null gnus-summary-expunge-below) | |
10949 (not (eq gnus-build-sparse-threads 'some)) | |
10950 (not (eq gnus-build-sparse-threads 'more)) | |
10951 (null gnus-thread-expunge-below) | |
10952 (not gnus-use-nocem))) | |
10953 () ; Do nothing. | |
10954 (push gnus-newsgroup-limit gnus-newsgroup-limits) | |
10955 (setq gnus-newsgroup-limit nil) | |
10956 (mapatoms | |
10957 (lambda (node) | |
10958 (unless (car (symbol-value node)) | |
10959 ;; These threads have no parents -- they are roots. | |
10960 (let ((nodes (cdr (symbol-value node))) | |
10961 thread) | |
10962 (while nodes | |
10963 (if (and gnus-thread-expunge-below | |
10964 (< (gnus-thread-total-score (car nodes)) | |
10965 gnus-thread-expunge-below)) | |
10966 (gnus-expunge-thread (pop nodes)) | |
10967 (setq thread (pop nodes)) | |
10968 (gnus-summary-limit-children thread)))))) | |
10969 gnus-newsgroup-dependencies) | |
10970 ;; If this limitation resulted in an empty group, we might | |
10971 ;; pop the previous limit and use it instead. | |
10972 (when (and (not gnus-newsgroup-limit) | |
10973 show-if-empty) | |
10974 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits))) | |
10975 gnus-newsgroup-limit)) | |
10976 | |
10977 (defun gnus-summary-limit-children (thread) | |
10978 "Return 1 if this subthread is visible and 0 if it is not." | |
10979 ;; First we get the number of visible children to this thread. This | |
10980 ;; is done by recursing down the thread using this function, so this | |
10981 ;; will really go down to a leaf article first, before slowly | |
10982 ;; working its way up towards the root. | |
10983 (when thread | |
10984 (let ((children | |
10985 (if (cdr thread) | |
10986 (apply '+ (mapcar 'gnus-summary-limit-children | |
10987 (cdr thread))) | |
10988 0)) | |
10989 (number (mail-header-number (car thread))) | |
10990 score) | |
10991 (if (or | |
10992 ;; If this article is dormant and has absolutely no visible | |
10993 ;; children, then this article isn't visible. | |
10994 (and (memq number gnus-newsgroup-dormant) | |
10995 (= children 0)) | |
10996 ;; If this is "fetch-old-headered" and there is only one | |
10997 ;; visible child (or less), then we don't want this article. | |
10998 (and (eq gnus-fetch-old-headers 'some) | |
10999 (memq number gnus-newsgroup-ancient) | |
11000 (zerop children)) | |
11001 ;; If this is a sparsely inserted article with no children, | |
11002 ;; we don't want it. | |
11003 (and (eq gnus-build-sparse-threads 'some) | |
11004 (memq number gnus-newsgroup-sparse) | |
11005 (zerop children)) | |
11006 ;; If we use expunging, and this article is really | |
11007 ;; low-scored, then we don't want this article. | |
11008 (when (and gnus-summary-expunge-below | |
11009 (< (setq score | |
11010 (or (cdr (assq number gnus-newsgroup-scored)) | |
11011 gnus-summary-default-score)) | |
11012 gnus-summary-expunge-below)) | |
11013 ;; We increase the expunge-tally here, but that has | |
11014 ;; nothing to do with the limits, really. | |
11015 (incf gnus-newsgroup-expunged-tally) | |
11016 ;; We also mark as read here, if that's wanted. | |
11017 (when (and gnus-summary-mark-below | |
11018 (< score gnus-summary-mark-below)) | |
11019 (setq gnus-newsgroup-unreads | |
11020 (delq number gnus-newsgroup-unreads)) | |
11021 (if gnus-newsgroup-auto-expire | |
11022 (push number gnus-newsgroup-expirable) | |
11023 (push (cons number gnus-low-score-mark) | |
11024 gnus-newsgroup-reads))) | |
11025 t) | |
11026 (and gnus-use-nocem | |
11027 (gnus-nocem-unwanted-article-p (mail-header-id (car thread))))) | |
11028 ;; Nope, invisible article. | |
11029 0 | |
11030 ;; Ok, this article is to be visible, so we add it to the limit | |
11031 ;; and return 1. | |
11032 (setq gnus-newsgroup-limit (cons number gnus-newsgroup-limit)) | |
11033 1)))) | |
11034 | |
11035 (defun gnus-expunge-thread (thread) | |
11036 "Mark all articles in THREAD as read." | |
11037 (let* ((number (mail-header-number (car thread)))) | |
11038 (incf gnus-newsgroup-expunged-tally) | |
11039 ;; We also mark as read here, if that's wanted. | |
11040 (setq gnus-newsgroup-unreads | |
11041 (delq number gnus-newsgroup-unreads)) | |
11042 (if gnus-newsgroup-auto-expire | |
11043 (push number gnus-newsgroup-expirable) | |
11044 (push (cons number gnus-low-score-mark) | |
11045 gnus-newsgroup-reads))) | |
11046 ;; Go recursively through all subthreads. | |
11047 (mapcar 'gnus-expunge-thread (cdr thread))) | |
11048 | |
11049 ;; Summary article oriented commands | |
11050 | |
11051 (defun gnus-summary-refer-parent-article (n) | |
11052 "Refer parent article N times. | |
11053 The difference between N and the number of articles fetched is returned." | |
11054 (interactive "p") | |
11055 (gnus-set-global-variables) | |
11056 (while | |
11057 (and | |
11058 (> n 0) | |
11059 (let* ((header (gnus-summary-article-header)) | |
11060 (ref | |
11061 ;; If we try to find the parent of the currently | |
11062 ;; displayed article, then we take a look at the actual | |
11063 ;; References header, since this is slightly more | |
11064 ;; reliable than the References field we got from the | |
11065 ;; server. | |
11066 (if (and (eq (mail-header-number header) | |
11067 (cdr gnus-article-current)) | |
11068 (equal gnus-newsgroup-name | |
11069 (car gnus-article-current))) | |
11070 (save-excursion | |
11071 (set-buffer gnus-original-article-buffer) | |
11072 (nnheader-narrow-to-headers) | |
11073 (prog1 | |
11074 (message-fetch-field "references") | |
11075 (widen))) | |
11076 ;; It's not the current article, so we take a bet on | |
11077 ;; the value we got from the server. | |
11078 (mail-header-references header)))) | |
11079 (if (setq ref (or ref (mail-header-references header))) | |
11080 (or (gnus-summary-refer-article (gnus-parent-id ref)) | |
11081 (gnus-message 1 "Couldn't find parent")) | |
11082 (gnus-message 1 "No references in article %d" | |
11083 (gnus-summary-article-number)) | |
11084 nil))) | |
11085 (setq n (1- n))) | |
11086 (gnus-summary-position-point) | |
11087 n) | |
11088 | |
11089 (defun gnus-summary-refer-references () | |
11090 "Fetch all articles mentioned in the References header. | |
11091 Return how many articles were fetched." | |
11092 (interactive) | |
11093 (gnus-set-global-variables) | |
11094 (let ((ref (mail-header-references (gnus-summary-article-header))) | |
11095 (current (gnus-summary-article-number)) | |
11096 (n 0)) | |
11097 ;; For each Message-ID in the References header... | |
11098 (while (string-match "<[^>]*>" ref) | |
11099 (incf n) | |
11100 ;; ... fetch that article. | |
11101 (gnus-summary-refer-article | |
11102 (prog1 (match-string 0 ref) | |
11103 (setq ref (substring ref (match-end 0)))))) | |
11104 (gnus-summary-goto-subject current) | |
11105 (gnus-summary-position-point) | |
11106 n)) | |
11107 | |
11108 (defun gnus-summary-refer-article (message-id) | |
11109 "Fetch an article specified by MESSAGE-ID." | |
11110 (interactive "sMessage-ID: ") | |
11111 (when (and (stringp message-id) | |
11112 (not (zerop (length message-id)))) | |
11113 ;; Construct the correct Message-ID if necessary. | |
11114 ;; Suggested by tale@pawl.rpi.edu. | |
11115 (unless (string-match "^<" message-id) | |
11116 (setq message-id (concat "<" message-id))) | |
11117 (unless (string-match ">$" message-id) | |
11118 (setq message-id (concat message-id ">"))) | |
11119 (let* ((header (gnus-id-to-header message-id)) | |
11120 (sparse (and header | |
11121 (memq (mail-header-number header) | |
11122 gnus-newsgroup-sparse)))) | |
11123 (if header | |
11124 (prog1 | |
11125 ;; The article is present in the buffer, to we just go to it. | |
11126 (gnus-summary-goto-article | |
11127 (mail-header-number header) nil header) | |
11128 (when sparse | |
11129 (gnus-summary-update-article (mail-header-number header)))) | |
11130 ;; We fetch the article | |
11131 (let ((gnus-override-method | |
11132 (and (gnus-news-group-p gnus-newsgroup-name) | |
11133 gnus-refer-article-method)) | |
11134 number) | |
11135 ;; Start the special refer-article method, if necessary. | |
11136 (when (and gnus-refer-article-method | |
11137 (gnus-news-group-p gnus-newsgroup-name)) | |
11138 (gnus-check-server gnus-refer-article-method)) | |
11139 ;; Fetch the header, and display the article. | |
11140 (if (setq number (gnus-summary-insert-subject message-id)) | |
11141 (gnus-summary-select-article nil nil nil number) | |
11142 (gnus-message 3 "Couldn't fetch article %s" message-id))))))) | |
11143 | |
11144 (defun gnus-summary-enter-digest-group (&optional force) | |
11145 "Enter a digest group based on the current article." | |
11146 (interactive "P") | |
11147 (gnus-set-global-variables) | |
11148 (gnus-summary-select-article) | |
11149 (let ((name (format "%s-%d" | |
11150 (gnus-group-prefixed-name | |
11151 gnus-newsgroup-name (list 'nndoc "")) | |
11152 gnus-current-article)) | |
11153 (ogroup gnus-newsgroup-name) | |
11154 (case-fold-search t) | |
11155 (buf (current-buffer)) | |
11156 dig) | |
11157 (save-excursion | |
11158 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*")) | |
11159 (insert-buffer-substring gnus-original-article-buffer) | |
11160 (narrow-to-region | |
11161 (goto-char (point-min)) | |
11162 (or (search-forward "\n\n" nil t) (point))) | |
11163 (goto-char (point-min)) | |
11164 (delete-matching-lines "^\\(Path\\):\\|^From ") | |
11165 (widen)) | |
11166 (unwind-protect | |
11167 (if (gnus-group-read-ephemeral-group | |
11168 name `(nndoc ,name (nndoc-address | |
11169 ,(get-buffer dig)) | |
11170 (nndoc-article-type ,(if force 'digest 'guess))) t) | |
11171 ;; Make all postings to this group go to the parent group. | |
11172 (nconc (gnus-info-params (gnus-get-info name)) | |
11173 (list (cons 'to-group ogroup))) | |
11174 ;; Couldn't select this doc group. | |
11175 (switch-to-buffer buf) | |
11176 (gnus-set-global-variables) | |
11177 (gnus-configure-windows 'summary) | |
11178 (gnus-message 3 "Article couldn't be entered?")) | |
11179 (kill-buffer dig)))) | |
11180 | |
11181 (defun gnus-summary-isearch-article (&optional regexp-p) | |
11182 "Do incremental search forward on the current article. | |
11183 If REGEXP-P (the prefix) is non-nil, do regexp isearch." | |
11184 (interactive "P") | |
11185 (gnus-set-global-variables) | |
11186 (gnus-summary-select-article) | |
11187 (gnus-configure-windows 'article) | |
11188 (gnus-eval-in-buffer-window gnus-article-buffer | |
11189 (goto-char (point-min)) | |
11190 (isearch-forward regexp-p))) | |
11191 | |
11192 (defun gnus-summary-search-article-forward (regexp &optional backward) | |
11193 "Search for an article containing REGEXP forward. | |
11194 If BACKWARD, search backward instead." | |
11195 (interactive | |
11196 (list (read-string | |
11197 (format "Search article %s (regexp%s): " | |
11198 (if current-prefix-arg "backward" "forward") | |
11199 (if gnus-last-search-regexp | |
11200 (concat ", default " gnus-last-search-regexp) | |
11201 ""))) | |
11202 current-prefix-arg)) | |
11203 (gnus-set-global-variables) | |
11204 (if (string-equal regexp "") | |
11205 (setq regexp (or gnus-last-search-regexp "")) | |
11206 (setq gnus-last-search-regexp regexp)) | |
11207 (unless (gnus-summary-search-article regexp backward) | |
11208 (error "Search failed: \"%s\"" regexp))) | |
11209 | |
11210 (defun gnus-summary-search-article-backward (regexp) | |
11211 "Search for an article containing REGEXP backward." | |
11212 (interactive | |
11213 (list (read-string | |
11214 (format "Search article backward (regexp%s): " | |
11215 (if gnus-last-search-regexp | |
11216 (concat ", default " gnus-last-search-regexp) | |
11217 ""))))) | |
11218 (gnus-summary-search-article-forward regexp 'backward)) | |
11219 | |
11220 (defun gnus-summary-search-article (regexp &optional backward) | |
11221 "Search for an article containing REGEXP. | |
11222 Optional argument BACKWARD means do search for backward. | |
11223 `gnus-select-article-hook' is not called during the search." | |
11224 (let ((gnus-select-article-hook nil) ;Disable hook. | |
11225 (gnus-article-display-hook nil) | |
11226 (gnus-mark-article-hook nil) ;Inhibit marking as read. | |
11227 (re-search | |
11228 (if backward | |
11229 're-search-backward 're-search-forward)) | |
11230 (sum (current-buffer)) | |
11231 (found nil)) | |
11232 (gnus-save-hidden-threads | |
11233 (gnus-summary-select-article) | |
11234 (set-buffer gnus-article-buffer) | |
11235 (when backward | |
11236 (forward-line -1)) | |
11237 (while (not found) | |
11238 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current)) | |
11239 (if (if backward | |
11240 (re-search-backward regexp nil t) | |
11241 (re-search-forward regexp nil t)) | |
11242 ;; We found the regexp. | |
11243 (progn | |
11244 (setq found 'found) | |
11245 (beginning-of-line) | |
11246 (set-window-start | |
11247 (get-buffer-window (current-buffer)) | |
11248 (point)) | |
11249 (forward-line 1) | |
11250 (set-buffer sum)) | |
11251 ;; We didn't find it, so we go to the next article. | |
11252 (set-buffer sum) | |
11253 (if (not (if backward (gnus-summary-find-prev) | |
11254 (gnus-summary-find-next))) | |
11255 ;; No more articles. | |
11256 (setq found t) | |
11257 ;; Select the next article and adjust point. | |
11258 (gnus-summary-select-article) | |
11259 (set-buffer gnus-article-buffer) | |
11260 (widen) | |
11261 (goto-char (if backward (point-max) (point-min)))))) | |
11262 (gnus-message 7 "")) | |
11263 ;; Return whether we found the regexp. | |
11264 (when (eq found 'found) | |
11265 (gnus-summary-show-thread) | |
11266 (gnus-summary-goto-subject gnus-current-article) | |
11267 (gnus-summary-position-point) | |
11268 t))) | |
11269 | |
11270 (defun gnus-summary-find-matching (header regexp &optional backward unread | |
11271 not-case-fold) | |
11272 "Return a list of all articles that match REGEXP on HEADER. | |
11273 The search stars on the current article and goes forwards unless | |
11274 BACKWARD is non-nil. If BACKWARD is `all', do all articles. | |
11275 If UNREAD is non-nil, only unread articles will | |
11276 be taken into consideration. If NOT-CASE-FOLD, case won't be folded | |
11277 in the comparisons." | |
11278 (let ((data (if (eq backward 'all) gnus-newsgroup-data | |
11279 (gnus-data-find-list | |
11280 (gnus-summary-article-number) (gnus-data-list backward)))) | |
11281 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h))) | |
11282 (case-fold-search (not not-case-fold)) | |
11283 articles d) | |
11284 (or (fboundp (intern (concat "mail-header-" header))) | |
11285 (error "%s is not a valid header" header)) | |
11286 (while data | |
11287 (setq d (car data)) | |
11288 (and (or (not unread) ; We want all articles... | |
11289 (gnus-data-unread-p d)) ; Or just unreads. | |
11290 (vectorp (gnus-data-header d)) ; It's not a pseudo. | |
11291 (string-match regexp (funcall func (gnus-data-header d))) ; Match. | |
11292 (setq articles (cons (gnus-data-number d) articles))) ; Success! | |
11293 (setq data (cdr data))) | |
11294 (nreverse articles))) | |
11295 | |
11296 (defun gnus-summary-execute-command (header regexp command &optional backward) | |
11297 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND. | |
11298 If HEADER is an empty string (or nil), the match is done on the entire | |
11299 article. If BACKWARD (the prefix) is non-nil, search backward instead." | |
11300 (interactive | |
11301 (list (let ((completion-ignore-case t)) | |
11302 (completing-read | |
11303 "Header name: " | |
11304 (mapcar (lambda (string) (list string)) | |
11305 '("Number" "Subject" "From" "Lines" "Date" | |
11306 "Message-ID" "Xref" "References" "Body")) | |
11307 nil 'require-match)) | |
11308 (read-string "Regexp: ") | |
11309 (read-key-sequence "Command: ") | |
11310 current-prefix-arg)) | |
11311 (when (equal header "Body") | |
11312 (setq header "")) | |
11313 (gnus-set-global-variables) | |
11314 ;; Hidden thread subtrees must be searched as well. | |
11315 (gnus-summary-show-all-threads) | |
11316 ;; We don't want to change current point nor window configuration. | |
11317 (save-excursion | |
11318 (save-window-excursion | |
11319 (gnus-message 6 "Executing %s..." (key-description command)) | |
11320 ;; We'd like to execute COMMAND interactively so as to give arguments. | |
11321 (gnus-execute header regexp | |
11322 `(lambda () (call-interactively ',(key-binding command))) | |
11323 backward) | |
11324 (gnus-message 6 "Executing %s...done" (key-description command))))) | |
11325 | |
11326 (defun gnus-summary-beginning-of-article () | |
11327 "Scroll the article back to the beginning." | |
11328 (interactive) | |
11329 (gnus-set-global-variables) | |
11330 (gnus-summary-select-article) | |
11331 (gnus-configure-windows 'article) | |
11332 (gnus-eval-in-buffer-window gnus-article-buffer | |
11333 (widen) | |
11334 (goto-char (point-min)) | |
11335 (and gnus-break-pages (gnus-narrow-to-page)))) | |
11336 | |
11337 (defun gnus-summary-end-of-article () | |
11338 "Scroll to the end of the article." | |
11339 (interactive) | |
11340 (gnus-set-global-variables) | |
11341 (gnus-summary-select-article) | |
11342 (gnus-configure-windows 'article) | |
11343 (gnus-eval-in-buffer-window gnus-article-buffer | |
11344 (widen) | |
11345 (goto-char (point-max)) | |
11346 (recenter -3) | |
11347 (and gnus-break-pages (gnus-narrow-to-page)))) | |
11348 | |
11349 (defun gnus-summary-show-article (&optional arg) | |
11350 "Force re-fetching of the current article. | |
11351 If ARG (the prefix) is non-nil, show the raw article without any | |
11352 article massaging functions being run." | |
11353 (interactive "P") | |
11354 (gnus-set-global-variables) | |
11355 (if (not arg) | |
11356 ;; Select the article the normal way. | |
11357 (gnus-summary-select-article nil 'force) | |
11358 ;; Bind the article treatment functions to nil. | |
11359 (let ((gnus-have-all-headers t) | |
11360 gnus-article-display-hook | |
11361 gnus-article-prepare-hook | |
11362 gnus-break-pages | |
11363 gnus-visual) | |
11364 (gnus-summary-select-article nil 'force))) | |
11365 (gnus-summary-goto-subject gnus-current-article) | |
11366 ; (gnus-configure-windows 'article) | |
11367 (gnus-summary-position-point)) | |
11368 | |
11369 (defun gnus-summary-verbose-headers (&optional arg) | |
11370 "Toggle permanent full header display. | |
11371 If ARG is a positive number, turn header display on. | |
11372 If ARG is a negative number, turn header display off." | |
11373 (interactive "P") | |
11374 (gnus-set-global-variables) | |
11375 (gnus-summary-toggle-header arg) | |
11376 (setq gnus-show-all-headers | |
11377 (cond ((or (not (numberp arg)) | |
11378 (zerop arg)) | |
11379 (not gnus-show-all-headers)) | |
11380 ((natnump arg) | |
11381 t)))) | |
11382 | |
11383 (defun gnus-summary-toggle-header (&optional arg) | |
11384 "Show the headers if they are hidden, or hide them if they are shown. | |
11385 If ARG is a positive number, show the entire header. | |
11386 If ARG is a negative number, hide the unwanted header lines." | |
11387 (interactive "P") | |
11388 (gnus-set-global-variables) | |
11389 (save-excursion | |
11390 (set-buffer gnus-article-buffer) | |
11391 (let* ((buffer-read-only nil) | |
11392 (inhibit-point-motion-hooks t) | |
11393 (hidden (text-property-any | |
11394 (goto-char (point-min)) (search-forward "\n\n") | |
11395 'invisible t)) | |
11396 e) | |
11397 (goto-char (point-min)) | |
11398 (when (search-forward "\n\n" nil t) | |
11399 (delete-region (point-min) (1- (point)))) | |
11400 (goto-char (point-min)) | |
11401 (save-excursion | |
11402 (set-buffer gnus-original-article-buffer) | |
11403 (goto-char (point-min)) | |
11404 (setq e (1- (or (search-forward "\n\n" nil t) (point-max))))) | |
11405 (insert-buffer-substring gnus-original-article-buffer 1 e) | |
11406 (let ((gnus-inhibit-hiding t)) | |
11407 (run-hooks 'gnus-article-display-hook)) | |
11408 (if (or (not hidden) (and (numberp arg) (< arg 0))) | |
11409 (gnus-article-hide-headers))))) | |
11410 | |
11411 (defun gnus-summary-show-all-headers () | |
11412 "Make all header lines visible." | |
11413 (interactive) | |
11414 (gnus-set-global-variables) | |
11415 (gnus-article-show-all-headers)) | |
11416 | |
11417 (defun gnus-summary-toggle-mime (&optional arg) | |
11418 "Toggle MIME processing. | |
11419 If ARG is a positive number, turn MIME processing on." | |
11420 (interactive "P") | |
11421 (gnus-set-global-variables) | |
11422 (setq gnus-show-mime | |
11423 (if (null arg) (not gnus-show-mime) | |
11424 (> (prefix-numeric-value arg) 0))) | |
11425 (gnus-summary-select-article t 'force)) | |
11426 | |
11427 (defun gnus-summary-caesar-message (&optional arg) | |
11428 "Caesar rotate the current article by 13. | |
11429 The numerical prefix specifies how manu places to rotate each letter | |
11430 forward." | |
11431 (interactive "P") | |
11432 (gnus-set-global-variables) | |
11433 (gnus-summary-select-article) | |
11434 (let ((mail-header-separator "")) | |
11435 (gnus-eval-in-buffer-window gnus-article-buffer | |
11436 (save-restriction | |
11437 (widen) | |
11438 (let ((start (window-start)) | |
11439 buffer-read-only) | |
11440 (message-caesar-buffer-body arg) | |
11441 (set-window-start (get-buffer-window (current-buffer)) start)))))) | |
11442 | |
11443 (defun gnus-summary-stop-page-breaking () | |
11444 "Stop page breaking in the current article." | |
11445 (interactive) | |
11446 (gnus-set-global-variables) | |
11447 (gnus-summary-select-article) | |
11448 (gnus-eval-in-buffer-window gnus-article-buffer | |
11449 (widen))) | |
11450 | |
11451 (defun gnus-summary-move-article (&optional n to-newsgroup select-method action) | |
11452 "Move the current article to a different newsgroup. | |
11453 If N is a positive number, move the N next articles. | |
11454 If N is a negative number, move the N previous articles. | |
11455 If N is nil and any articles have been marked with the process mark, | |
11456 move those articles instead. | |
11457 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to. | |
11458 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but | |
11459 re-spool using this method. | |
11460 | |
11461 For this function to work, both the current newsgroup and the | |
11462 newsgroup that you want to move to have to support the `request-move' | |
11463 and `request-accept' functions." | |
11464 (interactive "P") | |
11465 (unless action (setq action 'move)) | |
11466 (gnus-set-global-variables) | |
11467 ;; Check whether the source group supports the required functions. | |
11468 (cond ((and (eq action 'move) | |
11469 (not (gnus-check-backend-function | |
11470 'request-move-article gnus-newsgroup-name))) | |
11471 (error "The current group does not support article moving")) | |
11472 ((and (eq action 'crosspost) | |
11473 (not (gnus-check-backend-function | |
11474 'request-replace-article gnus-newsgroup-name))) | |
11475 (error "The current group does not support article editing"))) | |
11476 (let ((articles (gnus-summary-work-articles n)) | |
11477 (prefix (gnus-group-real-prefix gnus-newsgroup-name)) | |
11478 (names '((move "Move" "Moving") | |
11479 (copy "Copy" "Copying") | |
11480 (crosspost "Crosspost" "Crossposting"))) | |
11481 (copy-buf (save-excursion | |
11482 (nnheader-set-temp-buffer " *copy article*"))) | |
11483 art-group to-method new-xref article to-groups) | |
11484 (unless (assq action names) | |
11485 (error "Unknown action %s" action)) | |
11486 ;; Read the newsgroup name. | |
11487 (when (and (not to-newsgroup) | |
11488 (not select-method)) | |
11489 (setq to-newsgroup | |
11490 (gnus-read-move-group-name | |
11491 (cadr (assq action names)) | |
11492 (symbol-value (intern (format "gnus-current-%s-group" action))) | |
11493 articles prefix)) | |
11494 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup)) | |
11495 (setq to-method (or select-method | |
11496 (gnus-group-name-to-method to-newsgroup))) | |
11497 ;; Check the method we are to move this article to... | |
11498 (or (gnus-check-backend-function 'request-accept-article (car to-method)) | |
11499 (error "%s does not support article copying" (car to-method))) | |
11500 (or (gnus-check-server to-method) | |
11501 (error "Can't open server %s" (car to-method))) | |
11502 (gnus-message 6 "%s to %s: %s..." | |
11503 (caddr (assq action names)) | |
11504 (or (car select-method) to-newsgroup) articles) | |
11505 (while articles | |
11506 (setq article (pop articles)) | |
11507 (setq | |
11508 art-group | |
11509 (cond | |
11510 ;; Move the article. | |
11511 ((eq action 'move) | |
11512 (gnus-request-move-article | |
11513 article ; Article to move | |
11514 gnus-newsgroup-name ; From newsgrouo | |
11515 (nth 1 (gnus-find-method-for-group | |
11516 gnus-newsgroup-name)) ; Server | |
11517 (list 'gnus-request-accept-article | |
11518 to-newsgroup (list 'quote select-method) | |
11519 (not articles)) ; Accept form | |
11520 (not articles))) ; Only save nov last time | |
11521 ;; Copy the article. | |
11522 ((eq action 'copy) | |
11523 (save-excursion | |
11524 (set-buffer copy-buf) | |
11525 (gnus-request-article-this-buffer article gnus-newsgroup-name) | |
11526 (gnus-request-accept-article | |
11527 to-newsgroup select-method (not articles)))) | |
11528 ;; Crosspost the article. | |
11529 ((eq action 'crosspost) | |
11530 (let ((xref (mail-header-xref (gnus-summary-article-header article)))) | |
11531 (setq new-xref (concat gnus-newsgroup-name ":" article)) | |
11532 (if (and xref (not (string= xref ""))) | |
11533 (progn | |
11534 (when (string-match "^Xref: " xref) | |
11535 (setq xref (substring xref (match-end 0)))) | |
11536 (setq new-xref (concat xref " " new-xref))) | |
11537 (setq new-xref (concat (system-name) " " new-xref))) | |
11538 (save-excursion | |
11539 (set-buffer copy-buf) | |
11540 (gnus-request-article-this-buffer article gnus-newsgroup-name) | |
11541 (nnheader-replace-header "xref" new-xref) | |
11542 (gnus-request-accept-article | |
11543 to-newsgroup select-method (not articles))))))) | |
11544 (if (not art-group) | |
11545 (gnus-message 1 "Couldn't %s article %s" | |
11546 (cadr (assq action names)) article) | |
11547 (let* ((entry | |
11548 (or | |
11549 (gnus-gethash (car art-group) gnus-newsrc-hashtb) | |
11550 (gnus-gethash | |
11551 (gnus-group-prefixed-name | |
11552 (car art-group) | |
11553 (or select-method | |
11554 (gnus-find-method-for-group to-newsgroup))) | |
11555 gnus-newsrc-hashtb))) | |
11556 (info (nth 2 entry)) | |
11557 (to-group (gnus-info-group info))) | |
11558 ;; Update the group that has been moved to. | |
11559 (when (and info | |
11560 (memq action '(move copy))) | |
11561 (unless (member to-group to-groups) | |
11562 (push to-group to-groups)) | |
11563 | |
11564 (unless (memq article gnus-newsgroup-unreads) | |
11565 (gnus-info-set-read | |
11566 info (gnus-add-to-range (gnus-info-read info) | |
11567 (list (cdr art-group))))) | |
11568 | |
11569 ;; Copy any marks over to the new group. | |
11570 (let ((marks gnus-article-mark-lists) | |
11571 (to-article (cdr art-group))) | |
11572 | |
11573 ;; See whether the article is to be put in the cache. | |
11574 (when gnus-use-cache | |
11575 (gnus-cache-possibly-enter-article | |
11576 to-group to-article | |
11577 (let ((header (copy-sequence | |
11578 (gnus-summary-article-header article)))) | |
11579 (mail-header-set-number header to-article) | |
11580 header) | |
11581 (memq article gnus-newsgroup-marked) | |
11582 (memq article gnus-newsgroup-dormant) | |
11583 (memq article gnus-newsgroup-unreads))) | |
11584 | |
11585 (while marks | |
11586 (when (memq article (symbol-value | |
11587 (intern (format "gnus-newsgroup-%s" | |
11588 (caar marks))))) | |
11589 ;; If the other group is the same as this group, | |
11590 ;; then we have to add the mark to the list. | |
11591 (when (equal to-group gnus-newsgroup-name) | |
11592 (set (intern (format "gnus-newsgroup-%s" (caar marks))) | |
11593 (cons to-article | |
11594 (symbol-value | |
11595 (intern (format "gnus-newsgroup-%s" | |
11596 (caar marks))))))) | |
11597 ;; Copy mark to other group. | |
11598 (gnus-add-marked-articles | |
11599 to-group (cdar marks) (list to-article) info)) | |
11600 (setq marks (cdr marks))))) | |
11601 | |
11602 ;; Update the Xref header in this article to point to | |
11603 ;; the new crossposted article we have just created. | |
11604 (when (eq action 'crosspost) | |
11605 (save-excursion | |
11606 (set-buffer copy-buf) | |
11607 (gnus-request-article-this-buffer article gnus-newsgroup-name) | |
11608 (nnheader-replace-header | |
11609 "xref" (concat new-xref " " (gnus-group-prefixed-name | |
11610 (car art-group) to-method) | |
11611 ":" (cdr art-group))) | |
11612 (gnus-request-replace-article | |
11613 article gnus-newsgroup-name (current-buffer))))) | |
11614 | |
11615 (gnus-summary-goto-subject article) | |
11616 (when (eq action 'move) | |
11617 (gnus-summary-mark-article article gnus-canceled-mark))) | |
11618 (gnus-summary-remove-process-mark article)) | |
11619 ;; Re-activate all groups that have been moved to. | |
11620 (while to-groups | |
11621 (gnus-activate-group (pop to-groups))) | |
11622 | |
11623 (gnus-kill-buffer copy-buf) | |
11624 (gnus-summary-position-point) | |
11625 (gnus-set-mode-line 'summary))) | |
11626 | |
11627 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method) | |
11628 "Move the current article to a different newsgroup. | |
11629 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to. | |
11630 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but | |
11631 re-spool using this method." | |
11632 (interactive "P") | |
11633 (gnus-summary-move-article n nil select-method 'copy)) | |
11634 | |
11635 (defun gnus-summary-crosspost-article (&optional n) | |
11636 "Crosspost the current article to some other group." | |
11637 (interactive "P") | |
11638 (gnus-summary-move-article n nil nil 'crosspost)) | |
11639 | |
11640 (defvar gnus-summary-respool-default-method nil | |
11641 "Default method for respooling an article. | |
11642 If nil, use to the current newsgroup method.") | |
11643 | |
11644 (defun gnus-summary-respool-article (&optional n method) | |
11645 "Respool the current article. | |
11646 The article will be squeezed through the mail spooling process again, | |
11647 which means that it will be put in some mail newsgroup or other | |
11648 depending on `nnmail-split-methods'. | |
11649 If N is a positive number, respool the N next articles. | |
11650 If N is a negative number, respool the N previous articles. | |
11651 If N is nil and any articles have been marked with the process mark, | |
11652 respool those articles instead. | |
11653 | |
11654 Respooling can be done both from mail groups and \"real\" newsgroups. | |
11655 In the former case, the articles in question will be moved from the | |
11656 current group into whatever groups they are destined to. In the | |
11657 latter case, they will be copied into the relevant groups." | |
11658 (interactive | |
11659 (list current-prefix-arg | |
11660 (let* ((methods (gnus-methods-using 'respool)) | |
11661 (methname | |
11662 (symbol-name (or gnus-summary-respool-default-method | |
11663 (car (gnus-find-method-for-group | |
11664 gnus-newsgroup-name))))) | |
11665 (method | |
11666 (gnus-completing-read | |
11667 methname "What backend do you want to use when respooling?" | |
11668 methods nil t nil 'gnus-method-history)) | |
11669 ms) | |
11670 (cond | |
11671 ((zerop (length (setq ms (gnus-servers-using-backend method)))) | |
11672 (list (intern method) "")) | |
11673 ((= 1 (length ms)) | |
11674 (car ms)) | |
11675 (t | |
11676 (cdr (completing-read | |
11677 "Server name: " | |
11678 (mapcar (lambda (m) (cons (cadr m) m)) ms) nil t))))))) | |
11679 (gnus-set-global-variables) | |
11680 (unless method | |
11681 (error "No method given for respooling")) | |
11682 (if (assoc (symbol-name | |
11683 (car (gnus-find-method-for-group gnus-newsgroup-name))) | |
11684 (gnus-methods-using 'respool)) | |
11685 (gnus-summary-move-article n nil method) | |
11686 (gnus-summary-copy-article n nil method))) | |
11687 | |
11688 (defun gnus-summary-import-article (file) | |
11689 "Import a random file into a mail newsgroup." | |
11690 (interactive "fImport file: ") | |
11691 (gnus-set-global-variables) | |
11692 (let ((group gnus-newsgroup-name) | |
11693 (now (current-time)) | |
11694 atts lines) | |
11695 (or (gnus-check-backend-function 'request-accept-article group) | |
11696 (error "%s does not support article importing" group)) | |
11697 (or (file-readable-p file) | |
11698 (not (file-regular-p file)) | |
11699 (error "Can't read %s" file)) | |
11700 (save-excursion | |
11701 (set-buffer (get-buffer-create " *import file*")) | |
11702 (buffer-disable-undo (current-buffer)) | |
11703 (erase-buffer) | |
11704 (insert-file-contents file) | |
11705 (goto-char (point-min)) | |
11706 (unless (nnheader-article-p) | |
11707 ;; This doesn't look like an article, so we fudge some headers. | |
11708 (setq atts (file-attributes file) | |
11709 lines (count-lines (point-min) (point-max))) | |
11710 (insert "From: " (read-string "From: ") "\n" | |
11711 "Subject: " (read-string "Subject: ") "\n" | |
11712 "Date: " (timezone-make-date-arpa-standard | |
11713 (current-time-string (nth 5 atts)) | |
11714 (current-time-zone now) | |
11715 (current-time-zone now)) "\n" | |
11716 "Message-ID: " (message-make-message-id) "\n" | |
11717 "Lines: " (int-to-string lines) "\n" | |
11718 "Chars: " (int-to-string (nth 7 atts)) "\n\n")) | |
11719 (gnus-request-accept-article group nil t) | |
11720 (kill-buffer (current-buffer))))) | |
11721 | |
11722 (defun gnus-summary-expire-articles (&optional now) | |
11723 "Expire all articles that are marked as expirable in the current group." | |
11724 (interactive) | |
11725 (gnus-set-global-variables) | |
11726 (when (gnus-check-backend-function | |
11727 'request-expire-articles gnus-newsgroup-name) | |
11728 ;; This backend supports expiry. | |
11729 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name)) | |
11730 (expirable (if total | |
11731 (gnus-list-of-read-articles gnus-newsgroup-name) | |
11732 (setq gnus-newsgroup-expirable | |
11733 (sort gnus-newsgroup-expirable '<)))) | |
11734 (expiry-wait (if now 'immediate | |
11735 (gnus-group-get-parameter | |
11736 gnus-newsgroup-name 'expiry-wait))) | |
11737 es) | |
11738 (when expirable | |
11739 ;; There are expirable articles in this group, so we run them | |
11740 ;; through the expiry process. | |
11741 (gnus-message 6 "Expiring articles...") | |
11742 ;; The list of articles that weren't expired is returned. | |
11743 (if expiry-wait | |
11744 (let ((nnmail-expiry-wait-function nil) | |
11745 (nnmail-expiry-wait expiry-wait)) | |
11746 (setq es (gnus-request-expire-articles | |
11747 expirable gnus-newsgroup-name))) | |
11748 (setq es (gnus-request-expire-articles | |
11749 expirable gnus-newsgroup-name))) | |
11750 (or total (setq gnus-newsgroup-expirable es)) | |
11751 ;; We go through the old list of expirable, and mark all | |
11752 ;; really expired articles as nonexistent. | |
11753 (unless (eq es expirable) ;If nothing was expired, we don't mark. | |
11754 (let ((gnus-use-cache nil)) | |
11755 (while expirable | |
11756 (unless (memq (car expirable) es) | |
11757 (when (gnus-data-find (car expirable)) | |
11758 (gnus-summary-mark-article | |
11759 (car expirable) gnus-canceled-mark))) | |
11760 (setq expirable (cdr expirable))))) | |
11761 (gnus-message 6 "Expiring articles...done"))))) | |
11762 | |
11763 (defun gnus-summary-expire-articles-now () | |
11764 "Expunge all expirable articles in the current group. | |
11765 This means that *all* articles that are marked as expirable will be | |
11766 deleted forever, right now." | |
11767 (interactive) | |
11768 (gnus-set-global-variables) | |
11769 (or gnus-expert-user | |
11770 (gnus-y-or-n-p | |
11771 "Are you really, really, really sure you want to delete all these messages? ") | |
11772 (error "Phew!")) | |
11773 (gnus-summary-expire-articles t)) | |
11774 | |
11775 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. | |
11776 (defun gnus-summary-delete-article (&optional n) | |
11777 "Delete the N next (mail) articles. | |
11778 This command actually deletes articles. This is not a marking | |
11779 command. The article will disappear forever from your life, never to | |
11780 return. | |
11781 If N is negative, delete backwards. | |
11782 If N is nil and articles have been marked with the process mark, | |
11783 delete these instead." | |
11784 (interactive "P") | |
11785 (gnus-set-global-variables) | |
11786 (or (gnus-check-backend-function 'request-expire-articles | |
11787 gnus-newsgroup-name) | |
11788 (error "The current newsgroup does not support article deletion.")) | |
11789 ;; Compute the list of articles to delete. | |
11790 (let ((articles (gnus-summary-work-articles n)) | |
11791 not-deleted) | |
11792 (if (and gnus-novice-user | |
11793 (not (gnus-y-or-n-p | |
11794 (format "Do you really want to delete %s forever? " | |
11795 (if (> (length articles) 1) | |
11796 (format "these %s articles" (length articles)) | |
11797 "this article"))))) | |
11798 () | |
11799 ;; Delete the articles. | |
11800 (setq not-deleted (gnus-request-expire-articles | |
11801 articles gnus-newsgroup-name 'force)) | |
11802 (while articles | |
11803 (gnus-summary-remove-process-mark (car articles)) | |
11804 ;; The backend might not have been able to delete the article | |
11805 ;; after all. | |
11806 (or (memq (car articles) not-deleted) | |
11807 (gnus-summary-mark-article (car articles) gnus-canceled-mark)) | |
11808 (setq articles (cdr articles)))) | |
11809 (gnus-summary-position-point) | |
11810 (gnus-set-mode-line 'summary) | |
11811 not-deleted)) | |
11812 | |
11813 (defun gnus-summary-edit-article (&optional force) | |
11814 "Enter into a buffer and edit the current article. | |
11815 This will have permanent effect only in mail groups. | |
11816 If FORCE is non-nil, allow editing of articles even in read-only | |
11817 groups." | |
11818 (interactive "P") | |
11819 (save-excursion | |
11820 (set-buffer gnus-summary-buffer) | |
11821 (gnus-set-global-variables) | |
11822 (when (and (not force) | |
11823 (gnus-group-read-only-p)) | |
11824 (error "The current newsgroup does not support article editing.")) | |
11825 (gnus-summary-select-article t nil t) | |
11826 (gnus-configure-windows 'article) | |
11827 (select-window (get-buffer-window gnus-article-buffer)) | |
11828 (gnus-message 6 "C-c C-c to end edits") | |
11829 (setq buffer-read-only nil) | |
11830 (text-mode) | |
11831 (use-local-map (copy-keymap (current-local-map))) | |
11832 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done) | |
11833 (buffer-enable-undo) | |
11834 (widen) | |
11835 (goto-char (point-min)) | |
11836 (search-forward "\n\n" nil t))) | |
11837 | |
11838 (defun gnus-summary-edit-article-done () | |
11839 "Make edits to the current article permanent." | |
11840 (interactive) | |
11841 (if (gnus-group-read-only-p) | |
11842 (progn | |
11843 (gnus-summary-edit-article-postpone) | |
11844 (gnus-error | |
11845 1 "The current newsgroup does not support article editing.")) | |
11846 (let ((buf (format "%s" (buffer-string)))) | |
11847 (erase-buffer) | |
11848 (insert buf) | |
11849 (if (not (gnus-request-replace-article | |
11850 (cdr gnus-article-current) (car gnus-article-current) | |
11851 (current-buffer))) | |
11852 (error "Couldn't replace article.") | |
11853 (gnus-article-mode) | |
11854 (use-local-map gnus-article-mode-map) | |
11855 (setq buffer-read-only t) | |
11856 (buffer-disable-undo (current-buffer)) | |
11857 (gnus-configure-windows 'summary) | |
11858 (gnus-summary-update-article (cdr gnus-article-current)) | |
11859 (when gnus-use-cache | |
11860 (gnus-cache-update-article | |
11861 (car gnus-article-current) (cdr gnus-article-current))) | |
11862 (when gnus-keep-backlog | |
11863 (gnus-backlog-remove-article | |
11864 (car gnus-article-current) (cdr gnus-article-current)))) | |
11865 (save-excursion | |
11866 (when (get-buffer gnus-original-article-buffer) | |
11867 (set-buffer gnus-original-article-buffer) | |
11868 (setq gnus-original-article nil))) | |
11869 (setq gnus-article-current nil | |
11870 gnus-current-article nil) | |
11871 (run-hooks 'gnus-article-display-hook) | |
11872 (and (gnus-visual-p 'summary-highlight 'highlight) | |
11873 (run-hooks 'gnus-visual-mark-article-hook))))) | |
11874 | |
11875 (defun gnus-summary-edit-article-postpone () | |
11876 "Postpone changes to the current article." | |
11877 (interactive) | |
11878 (gnus-article-mode) | |
11879 (use-local-map gnus-article-mode-map) | |
11880 (setq buffer-read-only t) | |
11881 (buffer-disable-undo (current-buffer)) | |
11882 (gnus-configure-windows 'summary) | |
11883 (and (gnus-visual-p 'summary-highlight 'highlight) | |
11884 (run-hooks 'gnus-visual-mark-article-hook))) | |
11885 | |
11886 (defun gnus-summary-respool-query () | |
11887 "Query where the respool algorithm would put this article." | |
11888 (interactive) | |
11889 (gnus-set-global-variables) | |
11890 (gnus-summary-select-article) | |
11891 (save-excursion | |
11892 (set-buffer gnus-article-buffer) | |
11893 (save-restriction | |
11894 (goto-char (point-min)) | |
11895 (search-forward "\n\n") | |
11896 (narrow-to-region (point-min) (point)) | |
11897 (pp-eval-expression | |
11898 (list 'quote (mapcar 'car (nnmail-article-group 'identity))))))) | |
11899 | |
11900 ;; Summary marking commands. | |
11901 | |
11902 (defun gnus-summary-kill-same-subject-and-select (&optional unmark) | |
11903 "Mark articles which has the same subject as read, and then select the next. | |
11904 If UNMARK is positive, remove any kind of mark. | |
11905 If UNMARK is negative, tick articles." | |
11906 (interactive "P") | |
11907 (gnus-set-global-variables) | |
11908 (if unmark | |
11909 (setq unmark (prefix-numeric-value unmark))) | |
11910 (let ((count | |
11911 (gnus-summary-mark-same-subject | |
11912 (gnus-summary-article-subject) unmark))) | |
11913 ;; Select next unread article. If auto-select-same mode, should | |
11914 ;; select the first unread article. | |
11915 (gnus-summary-next-article t (and gnus-auto-select-same | |
11916 (gnus-summary-article-subject))) | |
11917 (gnus-message 7 "%d article%s marked as %s" | |
11918 count (if (= count 1) " is" "s are") | |
11919 (if unmark "unread" "read")))) | |
11920 | |
11921 (defun gnus-summary-kill-same-subject (&optional unmark) | |
11922 "Mark articles which has the same subject as read. | |
11923 If UNMARK is positive, remove any kind of mark. | |
11924 If UNMARK is negative, tick articles." | |
11925 (interactive "P") | |
11926 (gnus-set-global-variables) | |
11927 (if unmark | |
11928 (setq unmark (prefix-numeric-value unmark))) | |
11929 (let ((count | |
11930 (gnus-summary-mark-same-subject | |
11931 (gnus-summary-article-subject) unmark))) | |
11932 ;; If marked as read, go to next unread subject. | |
11933 (if (null unmark) | |
11934 ;; Go to next unread subject. | |
11935 (gnus-summary-next-subject 1 t)) | |
11936 (gnus-message 7 "%d articles are marked as %s" | |
11937 count (if unmark "unread" "read")))) | |
11938 | |
11939 (defun gnus-summary-mark-same-subject (subject &optional unmark) | |
11940 "Mark articles with same SUBJECT as read, and return marked number. | |
11941 If optional argument UNMARK is positive, remove any kinds of marks. | |
11942 If optional argument UNMARK is negative, mark articles as unread instead." | |
11943 (let ((count 1)) | |
11944 (save-excursion | |
11945 (cond | |
11946 ((null unmark) ; Mark as read. | |
11947 (while (and | |
11948 (progn | |
11949 (gnus-summary-mark-article-as-read gnus-killed-mark) | |
11950 (gnus-summary-show-thread) t) | |
11951 (gnus-summary-find-subject subject)) | |
11952 (setq count (1+ count)))) | |
11953 ((> unmark 0) ; Tick. | |
11954 (while (and | |
11955 (progn | |
11956 (gnus-summary-mark-article-as-unread gnus-ticked-mark) | |
11957 (gnus-summary-show-thread) t) | |
11958 (gnus-summary-find-subject subject)) | |
11959 (setq count (1+ count)))) | |
11960 (t ; Mark as unread. | |
11961 (while (and | |
11962 (progn | |
11963 (gnus-summary-mark-article-as-unread gnus-unread-mark) | |
11964 (gnus-summary-show-thread) t) | |
11965 (gnus-summary-find-subject subject)) | |
11966 (setq count (1+ count))))) | |
11967 (gnus-set-mode-line 'summary) | |
11968 ;; Return the number of marked articles. | |
11969 count))) | |
11970 | |
11971 (defun gnus-summary-mark-as-processable (n &optional unmark) | |
11972 "Set the process mark on the next N articles. | |
11973 If N is negative, mark backward instead. If UNMARK is non-nil, remove | |
11974 the process mark instead. The difference between N and the actual | |
11975 number of articles marked is returned." | |
11976 (interactive "p") | |
11977 (gnus-set-global-variables) | |
11978 (let ((backward (< n 0)) | |
11979 (n (abs n))) | |
11980 (while (and | |
11981 (> n 0) | |
11982 (if unmark | |
11983 (gnus-summary-remove-process-mark | |
11984 (gnus-summary-article-number)) | |
11985 (gnus-summary-set-process-mark (gnus-summary-article-number))) | |
11986 (zerop (gnus-summary-next-subject (if backward -1 1) nil t))) | |
11987 (setq n (1- n))) | |
11988 (if (/= 0 n) (gnus-message 7 "No more articles")) | |
11989 (gnus-summary-recenter) | |
11990 (gnus-summary-position-point) | |
11991 n)) | |
11992 | |
11993 (defun gnus-summary-unmark-as-processable (n) | |
11994 "Remove the process mark from the next N articles. | |
11995 If N is negative, mark backward instead. The difference between N and | |
11996 the actual number of articles marked is returned." | |
11997 (interactive "p") | |
11998 (gnus-set-global-variables) | |
11999 (gnus-summary-mark-as-processable n t)) | |
12000 | |
12001 (defun gnus-summary-unmark-all-processable () | |
12002 "Remove the process mark from all articles." | |
12003 (interactive) | |
12004 (gnus-set-global-variables) | |
12005 (save-excursion | |
12006 (while gnus-newsgroup-processable | |
12007 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable)))) | |
12008 (gnus-summary-position-point)) | |
12009 | |
12010 (defun gnus-summary-mark-as-expirable (n) | |
12011 "Mark N articles forward as expirable. | |
12012 If N is negative, mark backward instead. The difference between N and | |
12013 the actual number of articles marked is returned." | |
12014 (interactive "p") | |
12015 (gnus-set-global-variables) | |
12016 (gnus-summary-mark-forward n gnus-expirable-mark)) | |
12017 | |
12018 (defun gnus-summary-mark-article-as-replied (article) | |
12019 "Mark ARTICLE replied and update the summary line." | |
12020 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied)) | |
12021 (let ((buffer-read-only nil)) | |
12022 (when (gnus-summary-goto-subject article) | |
12023 (gnus-summary-update-secondary-mark article)))) | |
12024 | |
12025 (defun gnus-summary-set-bookmark (article) | |
12026 "Set a bookmark in current article." | |
12027 (interactive (list (gnus-summary-article-number))) | |
12028 (gnus-set-global-variables) | |
12029 (if (or (not (get-buffer gnus-article-buffer)) | |
12030 (not gnus-current-article) | |
12031 (not gnus-article-current) | |
12032 (not (equal gnus-newsgroup-name (car gnus-article-current)))) | |
12033 (error "No current article selected")) | |
12034 ;; Remove old bookmark, if one exists. | |
12035 (let ((old (assq article gnus-newsgroup-bookmarks))) | |
12036 (if old (setq gnus-newsgroup-bookmarks | |
12037 (delq old gnus-newsgroup-bookmarks)))) | |
12038 ;; Set the new bookmark, which is on the form | |
12039 ;; (article-number . line-number-in-body). | |
12040 (setq gnus-newsgroup-bookmarks | |
12041 (cons | |
12042 (cons article | |
12043 (save-excursion | |
12044 (set-buffer gnus-article-buffer) | |
12045 (count-lines | |
12046 (min (point) | |
12047 (save-excursion | |
12048 (goto-char (point-min)) | |
12049 (search-forward "\n\n" nil t) | |
12050 (point))) | |
12051 (point)))) | |
12052 gnus-newsgroup-bookmarks)) | |
12053 (gnus-message 6 "A bookmark has been added to the current article.")) | |
12054 | |
12055 (defun gnus-summary-remove-bookmark (article) | |
12056 "Remove the bookmark from the current article." | |
12057 (interactive (list (gnus-summary-article-number))) | |
12058 (gnus-set-global-variables) | |
12059 ;; Remove old bookmark, if one exists. | |
12060 (let ((old (assq article gnus-newsgroup-bookmarks))) | |
12061 (if old | |
12062 (progn | |
12063 (setq gnus-newsgroup-bookmarks | |
12064 (delq old gnus-newsgroup-bookmarks)) | |
12065 (gnus-message 6 "Removed bookmark.")) | |
12066 (gnus-message 6 "No bookmark in current article.")))) | |
12067 | |
12068 ;; Suggested by Daniel Quinlan <quinlan@best.com>. | |
12069 (defun gnus-summary-mark-as-dormant (n) | |
12070 "Mark N articles forward as dormant. | |
12071 If N is negative, mark backward instead. The difference between N and | |
12072 the actual number of articles marked is returned." | |
12073 (interactive "p") | |
12074 (gnus-set-global-variables) | |
12075 (gnus-summary-mark-forward n gnus-dormant-mark)) | |
12076 | |
12077 (defun gnus-summary-set-process-mark (article) | |
12078 "Set the process mark on ARTICLE and update the summary line." | |
12079 (setq gnus-newsgroup-processable | |
12080 (cons article | |
12081 (delq article gnus-newsgroup-processable))) | |
12082 (when (gnus-summary-goto-subject article) | |
12083 (gnus-summary-show-thread) | |
12084 (gnus-summary-update-secondary-mark article))) | |
12085 | |
12086 (defun gnus-summary-remove-process-mark (article) | |
12087 "Remove the process mark from ARTICLE and update the summary line." | |
12088 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable)) | |
12089 (when (gnus-summary-goto-subject article) | |
12090 (gnus-summary-show-thread) | |
12091 (gnus-summary-update-secondary-mark article))) | |
12092 | |
12093 (defun gnus-summary-set-saved-mark (article) | |
12094 "Set the process mark on ARTICLE and update the summary line." | |
12095 (push article gnus-newsgroup-saved) | |
12096 (when (gnus-summary-goto-subject article) | |
12097 (gnus-summary-update-secondary-mark article))) | |
12098 | |
12099 (defun gnus-summary-mark-forward (n &optional mark no-expire) | |
12100 "Mark N articles as read forwards. | |
12101 If N is negative, mark backwards instead. Mark with MARK, ?r by default. | |
12102 The difference between N and the actual number of articles marked is | |
12103 returned." | |
12104 (interactive "p") | |
12105 (gnus-set-global-variables) | |
12106 (let ((backward (< n 0)) | |
12107 (gnus-summary-goto-unread | |
12108 (and gnus-summary-goto-unread | |
12109 (not (eq gnus-summary-goto-unread 'never)) | |
12110 (not (memq mark (list gnus-unread-mark | |
12111 gnus-ticked-mark gnus-dormant-mark))))) | |
12112 (n (abs n)) | |
12113 (mark (or mark gnus-del-mark))) | |
12114 (while (and (> n 0) | |
12115 (gnus-summary-mark-article nil mark no-expire) | |
12116 (zerop (gnus-summary-next-subject | |
12117 (if backward -1 1) | |
12118 (and gnus-summary-goto-unread | |
12119 (not (eq gnus-summary-goto-unread 'never))) | |
12120 t))) | |
12121 (setq n (1- n))) | |
12122 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread "))) | |
12123 (gnus-summary-recenter) | |
12124 (gnus-summary-position-point) | |
12125 (gnus-set-mode-line 'summary) | |
12126 n)) | |
12127 | |
12128 (defun gnus-summary-mark-article-as-read (mark) | |
12129 "Mark the current article quickly as read with MARK." | |
12130 (let ((article (gnus-summary-article-number))) | |
12131 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads)) | |
12132 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)) | |
12133 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)) | |
12134 (setq gnus-newsgroup-reads | |
12135 (cons (cons article mark) gnus-newsgroup-reads)) | |
12136 ;; Possibly remove from cache, if that is used. | |
12137 (and gnus-use-cache (gnus-cache-enter-remove-article article)) | |
12138 ;; Allow the backend to change the mark. | |
12139 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark)) | |
12140 ;; Check for auto-expiry. | |
12141 (when (and gnus-newsgroup-auto-expire | |
12142 (or (= mark gnus-killed-mark) (= mark gnus-del-mark) | |
12143 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark) | |
12144 (= mark gnus-ancient-mark) | |
12145 (= mark gnus-read-mark) (= mark gnus-souped-mark))) | |
12146 (setq mark gnus-expirable-mark) | |
12147 (push article gnus-newsgroup-expirable)) | |
12148 ;; Set the mark in the buffer. | |
12149 (gnus-summary-update-mark mark 'unread) | |
12150 t)) | |
12151 | |
12152 (defun gnus-summary-mark-article-as-unread (mark) | |
12153 "Mark the current article quickly as unread with MARK." | |
12154 (let ((article (gnus-summary-article-number))) | |
12155 (if (< article 0) | |
12156 (gnus-error 1 "Unmarkable article") | |
12157 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)) | |
12158 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)) | |
12159 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)) | |
12160 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads)) | |
12161 (cond ((= mark gnus-ticked-mark) | |
12162 (push article gnus-newsgroup-marked)) | |
12163 ((= mark gnus-dormant-mark) | |
12164 (push article gnus-newsgroup-dormant)) | |
12165 (t | |
12166 (push article gnus-newsgroup-unreads))) | |
12167 (setq gnus-newsgroup-reads | |
12168 (delq (assq article gnus-newsgroup-reads) | |
12169 gnus-newsgroup-reads)) | |
12170 | |
12171 ;; See whether the article is to be put in the cache. | |
12172 (and gnus-use-cache | |
12173 (vectorp (gnus-summary-article-header article)) | |
12174 (save-excursion | |
12175 (gnus-cache-possibly-enter-article | |
12176 gnus-newsgroup-name article | |
12177 (gnus-summary-article-header article) | |
12178 (= mark gnus-ticked-mark) | |
12179 (= mark gnus-dormant-mark) (= mark gnus-unread-mark)))) | |
12180 | |
12181 ;; Fix the mark. | |
12182 (gnus-summary-update-mark mark 'unread)) | |
12183 t)) | |
12184 | |
12185 (defun gnus-summary-mark-article (&optional article mark no-expire) | |
12186 "Mark ARTICLE with MARK. MARK can be any character. | |
12187 Four MARK strings are reserved: `? ' (unread), `?!' (ticked), | |
12188 `??' (dormant) and `?E' (expirable). | |
12189 If MARK is nil, then the default character `?D' is used. | |
12190 If ARTICLE is nil, then the article on the current line will be | |
12191 marked." | |
12192 ;; The mark might be a string. | |
12193 (and (stringp mark) | |
12194 (setq mark (aref mark 0))) | |
12195 ;; If no mark is given, then we check auto-expiring. | |
12196 (and (not no-expire) | |
12197 gnus-newsgroup-auto-expire | |
12198 (or (not mark) | |
12199 (and (numberp mark) | |
12200 (or (= mark gnus-killed-mark) (= mark gnus-del-mark) | |
12201 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark) | |
12202 (= mark gnus-read-mark) (= mark gnus-souped-mark)))) | |
12203 (setq mark gnus-expirable-mark)) | |
12204 (let* ((mark (or mark gnus-del-mark)) | |
12205 (article (or article (gnus-summary-article-number)))) | |
12206 (or article (error "No article on current line")) | |
12207 (if (or (= mark gnus-unread-mark) | |
12208 (= mark gnus-ticked-mark) | |
12209 (= mark gnus-dormant-mark)) | |
12210 (gnus-mark-article-as-unread article mark) | |
12211 (gnus-mark-article-as-read article mark)) | |
12212 | |
12213 ;; See whether the article is to be put in the cache. | |
12214 (and gnus-use-cache | |
12215 (not (= mark gnus-canceled-mark)) | |
12216 (vectorp (gnus-summary-article-header article)) | |
12217 (save-excursion | |
12218 (gnus-cache-possibly-enter-article | |
12219 gnus-newsgroup-name article | |
12220 (gnus-summary-article-header article) | |
12221 (= mark gnus-ticked-mark) | |
12222 (= mark gnus-dormant-mark) (= mark gnus-unread-mark)))) | |
12223 | |
12224 (if (gnus-summary-goto-subject article nil t) | |
12225 (let ((buffer-read-only nil)) | |
12226 (gnus-summary-show-thread) | |
12227 ;; Fix the mark. | |
12228 (gnus-summary-update-mark mark 'unread) | |
12229 t)))) | |
12230 | |
12231 (defun gnus-summary-update-secondary-mark (article) | |
12232 "Update the secondary (read, process, cache) mark." | |
12233 (gnus-summary-update-mark | |
12234 (cond ((memq article gnus-newsgroup-processable) | |
12235 gnus-process-mark) | |
12236 ((memq article gnus-newsgroup-cached) | |
12237 gnus-cached-mark) | |
12238 ((memq article gnus-newsgroup-replied) | |
12239 gnus-replied-mark) | |
12240 ((memq article gnus-newsgroup-saved) | |
12241 gnus-saved-mark) | |
12242 (t gnus-unread-mark)) | |
12243 'replied) | |
12244 (when (gnus-visual-p 'summary-highlight 'highlight) | |
12245 (run-hooks 'gnus-summary-update-hook)) | |
12246 t) | |
12247 | |
12248 (defun gnus-summary-update-mark (mark type) | |
12249 (beginning-of-line) | |
12250 (let ((forward (cdr (assq type gnus-summary-mark-positions))) | |
12251 (buffer-read-only nil)) | |
12252 (when (and forward | |
12253 (<= (+ forward (point)) (point-max))) | |
12254 ;; Go to the right position on the line. | |
12255 (goto-char (+ forward (point))) | |
12256 ;; Replace the old mark with the new mark. | |
12257 (subst-char-in-region (point) (1+ (point)) (following-char) mark) | |
12258 ;; Optionally update the marks by some user rule. | |
12259 (when (eq type 'unread) | |
12260 (gnus-data-set-mark | |
12261 (gnus-data-find (gnus-summary-article-number)) mark) | |
12262 (gnus-summary-update-line (eq mark gnus-unread-mark)))))) | |
12263 | |
12264 (defun gnus-mark-article-as-read (article &optional mark) | |
12265 "Enter ARTICLE in the pertinent lists and remove it from others." | |
12266 ;; Make the article expirable. | |
12267 (let ((mark (or mark gnus-del-mark))) | |
12268 (if (= mark gnus-expirable-mark) | |
12269 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable)) | |
12270 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))) | |
12271 ;; Remove from unread and marked lists. | |
12272 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads)) | |
12273 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)) | |
12274 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)) | |
12275 (push (cons article mark) gnus-newsgroup-reads) | |
12276 ;; Possibly remove from cache, if that is used. | |
12277 (when gnus-use-cache | |
12278 (gnus-cache-enter-remove-article article)))) | |
12279 | |
12280 (defun gnus-mark-article-as-unread (article &optional mark) | |
12281 "Enter ARTICLE in the pertinent lists and remove it from others." | |
12282 (let ((mark (or mark gnus-ticked-mark))) | |
12283 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)) | |
12284 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)) | |
12285 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)) | |
12286 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads)) | |
12287 (cond ((= mark gnus-ticked-mark) | |
12288 (push article gnus-newsgroup-marked)) | |
12289 ((= mark gnus-dormant-mark) | |
12290 (push article gnus-newsgroup-dormant)) | |
12291 (t | |
12292 (push article gnus-newsgroup-unreads))) | |
12293 (setq gnus-newsgroup-reads | |
12294 (delq (assq article gnus-newsgroup-reads) | |
12295 gnus-newsgroup-reads)))) | |
12296 | |
12297 (defalias 'gnus-summary-mark-as-unread-forward | |
12298 'gnus-summary-tick-article-forward) | |
12299 (make-obsolete 'gnus-summary-mark-as-unread-forward | |
12300 'gnus-summary-tick-article-forward) | |
12301 (defun gnus-summary-tick-article-forward (n) | |
12302 "Tick N articles forwards. | |
12303 If N is negative, tick backwards instead. | |
12304 The difference between N and the number of articles ticked is returned." | |
12305 (interactive "p") | |
12306 (gnus-summary-mark-forward n gnus-ticked-mark)) | |
12307 | |
12308 (defalias 'gnus-summary-mark-as-unread-backward | |
12309 'gnus-summary-tick-article-backward) | |
12310 (make-obsolete 'gnus-summary-mark-as-unread-backward | |
12311 'gnus-summary-tick-article-backward) | |
12312 (defun gnus-summary-tick-article-backward (n) | |
12313 "Tick N articles backwards. | |
12314 The difference between N and the number of articles ticked is returned." | |
12315 (interactive "p") | |
12316 (gnus-summary-mark-forward (- n) gnus-ticked-mark)) | |
12317 | |
12318 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article) | |
12319 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article) | |
12320 (defun gnus-summary-tick-article (&optional article clear-mark) | |
12321 "Mark current article as unread. | |
12322 Optional 1st argument ARTICLE specifies article number to be marked as unread. | |
12323 Optional 2nd argument CLEAR-MARK remove any kinds of mark." | |
12324 (interactive) | |
12325 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark | |
12326 gnus-ticked-mark))) | |
12327 | |
12328 (defun gnus-summary-mark-as-read-forward (n) | |
12329 "Mark N articles as read forwards. | |
12330 If N is negative, mark backwards instead. | |
12331 The difference between N and the actual number of articles marked is | |
12332 returned." | |
12333 (interactive "p") | |
12334 (gnus-summary-mark-forward n gnus-del-mark t)) | |
12335 | |
12336 (defun gnus-summary-mark-as-read-backward (n) | |
12337 "Mark the N articles as read backwards. | |
12338 The difference between N and the actual number of articles marked is | |
12339 returned." | |
12340 (interactive "p") | |
12341 (gnus-summary-mark-forward (- n) gnus-del-mark t)) | |
12342 | |
12343 (defun gnus-summary-mark-as-read (&optional article mark) | |
12344 "Mark current article as read. | |
12345 ARTICLE specifies the article to be marked as read. | |
12346 MARK specifies a string to be inserted at the beginning of the line." | |
12347 (gnus-summary-mark-article article mark)) | |
12348 | |
12349 (defun gnus-summary-clear-mark-forward (n) | |
12350 "Clear marks from N articles forward. | |
12351 If N is negative, clear backward instead. | |
12352 The difference between N and the number of marks cleared is returned." | |
12353 (interactive "p") | |
12354 (gnus-summary-mark-forward n gnus-unread-mark)) | |
12355 | |
12356 (defun gnus-summary-clear-mark-backward (n) | |
12357 "Clear marks from N articles backward. | |
12358 The difference between N and the number of marks cleared is returned." | |
12359 (interactive "p") | |
12360 (gnus-summary-mark-forward (- n) gnus-unread-mark)) | |
12361 | |
12362 (defun gnus-summary-mark-unread-as-read () | |
12363 "Intended to be used by `gnus-summary-mark-article-hook'." | |
12364 (when (memq gnus-current-article gnus-newsgroup-unreads) | |
12365 (gnus-summary-mark-article gnus-current-article gnus-read-mark))) | |
12366 | |
12367 (defun gnus-summary-mark-read-and-unread-as-read () | |
12368 "Intended to be used by `gnus-summary-mark-article-hook'." | |
12369 (let ((mark (gnus-summary-article-mark))) | |
12370 (when (or (gnus-unread-mark-p mark) | |
12371 (gnus-read-mark-p mark)) | |
12372 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))) | |
12373 | |
12374 (defun gnus-summary-mark-region-as-read (point mark all) | |
12375 "Mark all unread articles between point and mark as read. | |
12376 If given a prefix, mark all articles between point and mark as read, | |
12377 even ticked and dormant ones." | |
12378 (interactive "r\nP") | |
12379 (save-excursion | |
12380 (let (article) | |
12381 (goto-char point) | |
12382 (beginning-of-line) | |
12383 (while (and | |
12384 (< (point) mark) | |
12385 (progn | |
12386 (when (or all | |
12387 (memq (setq article (gnus-summary-article-number)) | |
12388 gnus-newsgroup-unreads)) | |
12389 (gnus-summary-mark-article article gnus-del-mark)) | |
12390 t) | |
12391 (gnus-summary-find-next)))))) | |
12392 | |
12393 (defun gnus-summary-mark-below (score mark) | |
12394 "Mark articles with score less than SCORE with MARK." | |
12395 (interactive "P\ncMark: ") | |
12396 (gnus-set-global-variables) | |
12397 (setq score (if score | |
12398 (prefix-numeric-value score) | |
12399 (or gnus-summary-default-score 0))) | |
12400 (save-excursion | |
12401 (set-buffer gnus-summary-buffer) | |
12402 (goto-char (point-min)) | |
12403 (while | |
12404 (progn | |
12405 (and (< (gnus-summary-article-score) score) | |
12406 (gnus-summary-mark-article nil mark)) | |
12407 (gnus-summary-find-next))))) | |
12408 | |
12409 (defun gnus-summary-kill-below (&optional score) | |
12410 "Mark articles with score below SCORE as read." | |
12411 (interactive "P") | |
12412 (gnus-set-global-variables) | |
12413 (gnus-summary-mark-below score gnus-killed-mark)) | |
12414 | |
12415 (defun gnus-summary-clear-above (&optional score) | |
12416 "Clear all marks from articles with score above SCORE." | |
12417 (interactive "P") | |
12418 (gnus-set-global-variables) | |
12419 (gnus-summary-mark-above score gnus-unread-mark)) | |
12420 | |
12421 (defun gnus-summary-tick-above (&optional score) | |
12422 "Tick all articles with score above SCORE." | |
12423 (interactive "P") | |
12424 (gnus-set-global-variables) | |
12425 (gnus-summary-mark-above score gnus-ticked-mark)) | |
12426 | |
12427 (defun gnus-summary-mark-above (score mark) | |
12428 "Mark articles with score over SCORE with MARK." | |
12429 (interactive "P\ncMark: ") | |
12430 (gnus-set-global-variables) | |
12431 (setq score (if score | |
12432 (prefix-numeric-value score) | |
12433 (or gnus-summary-default-score 0))) | |
12434 (save-excursion | |
12435 (set-buffer gnus-summary-buffer) | |
12436 (goto-char (point-min)) | |
12437 (while (and (progn | |
12438 (if (> (gnus-summary-article-score) score) | |
12439 (gnus-summary-mark-article nil mark)) | |
12440 t) | |
12441 (gnus-summary-find-next))))) | |
12442 | |
12443 ;; Suggested by Daniel Quinlan <quinlan@best.com>. | |
12444 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged) | |
12445 (defun gnus-summary-limit-include-expunged () | |
12446 "Display all the hidden articles that were expunged for low scores." | |
12447 (interactive) | |
12448 (gnus-set-global-variables) | |
12449 (let ((buffer-read-only nil)) | |
12450 (let ((scored gnus-newsgroup-scored) | |
12451 headers h) | |
12452 (while scored | |
12453 (or (gnus-summary-goto-subject (caar scored)) | |
12454 (and (setq h (gnus-summary-article-header (caar scored))) | |
12455 (< (cdar scored) gnus-summary-expunge-below) | |
12456 (setq headers (cons h headers)))) | |
12457 (setq scored (cdr scored))) | |
12458 (or headers (error "No expunged articles hidden.")) | |
12459 (goto-char (point-min)) | |
12460 (gnus-summary-prepare-unthreaded (nreverse headers))) | |
12461 (goto-char (point-min)) | |
12462 (gnus-summary-position-point))) | |
12463 | |
12464 (defun gnus-summary-catchup (&optional all quietly to-here not-mark) | |
12465 "Mark all articles not marked as unread in this newsgroup as read. | |
12466 If prefix argument ALL is non-nil, all articles are marked as read. | |
12467 If QUIETLY is non-nil, no questions will be asked. | |
12468 If TO-HERE is non-nil, it should be a point in the buffer. All | |
12469 articles before this point will be marked as read. | |
12470 The number of articles marked as read is returned." | |
12471 (interactive "P") | |
12472 (gnus-set-global-variables) | |
12473 (prog1 | |
12474 (if (or quietly | |
12475 (not gnus-interactive-catchup) ;Without confirmation? | |
12476 gnus-expert-user | |
12477 (gnus-y-or-n-p | |
12478 (if all | |
12479 "Mark absolutely all articles as read? " | |
12480 "Mark all unread articles as read? "))) | |
12481 (if (and not-mark | |
12482 (not gnus-newsgroup-adaptive) | |
12483 (not gnus-newsgroup-auto-expire)) | |
12484 (progn | |
12485 (when all | |
12486 (setq gnus-newsgroup-marked nil | |
12487 gnus-newsgroup-dormant nil)) | |
12488 (setq gnus-newsgroup-unreads nil)) | |
12489 ;; We actually mark all articles as canceled, which we | |
12490 ;; have to do when using auto-expiry or adaptive scoring. | |
12491 (gnus-summary-show-all-threads) | |
12492 (if (gnus-summary-first-subject (not all)) | |
12493 (while (and | |
12494 (if to-here (< (point) to-here) t) | |
12495 (gnus-summary-mark-article-as-read gnus-catchup-mark) | |
12496 (gnus-summary-find-next (not all))))) | |
12497 (unless to-here | |
12498 (setq gnus-newsgroup-unreads nil)) | |
12499 (gnus-set-mode-line 'summary))) | |
12500 (let ((method (gnus-find-method-for-group gnus-newsgroup-name))) | |
12501 (if (and (not to-here) (eq 'nnvirtual (car method))) | |
12502 (nnvirtual-catchup-group | |
12503 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all))) | |
12504 (gnus-summary-position-point))) | |
12505 | |
12506 (defun gnus-summary-catchup-to-here (&optional all) | |
12507 "Mark all unticked articles before the current one as read. | |
12508 If ALL is non-nil, also mark ticked and dormant articles as read." | |
12509 (interactive "P") | |
12510 (gnus-set-global-variables) | |
12511 (save-excursion | |
12512 (gnus-save-hidden-threads | |
12513 (let ((beg (point))) | |
12514 ;; We check that there are unread articles. | |
12515 (when (or all (gnus-summary-find-prev)) | |
12516 (gnus-summary-catchup all t beg))))) | |
12517 (gnus-summary-position-point)) | |
12518 | |
12519 (defun gnus-summary-catchup-all (&optional quietly) | |
12520 "Mark all articles in this newsgroup as read." | |
12521 (interactive "P") | |
12522 (gnus-set-global-variables) | |
12523 (gnus-summary-catchup t quietly)) | |
12524 | |
12525 (defun gnus-summary-catchup-and-exit (&optional all quietly) | |
12526 "Mark all articles not marked as unread in this newsgroup as read, then exit. | |
12527 If prefix argument ALL is non-nil, all articles are marked as read." | |
12528 (interactive "P") | |
12529 (gnus-set-global-variables) | |
12530 (gnus-summary-catchup all quietly nil 'fast) | |
12531 ;; Select next newsgroup or exit. | |
12532 (if (eq gnus-auto-select-next 'quietly) | |
12533 (gnus-summary-next-group nil) | |
12534 (gnus-summary-exit))) | |
12535 | |
12536 (defun gnus-summary-catchup-all-and-exit (&optional quietly) | |
12537 "Mark all articles in this newsgroup as read, and then exit." | |
12538 (interactive "P") | |
12539 (gnus-set-global-variables) | |
12540 (gnus-summary-catchup-and-exit t quietly)) | |
12541 | |
12542 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>. | |
12543 (defun gnus-summary-catchup-and-goto-next-group (&optional all) | |
12544 "Mark all articles in this group as read and select the next group. | |
12545 If given a prefix, mark all articles, unread as well as ticked, as | |
12546 read." | |
12547 (interactive "P") | |
12548 (gnus-set-global-variables) | |
12549 (save-excursion | |
12550 (gnus-summary-catchup all)) | |
12551 (gnus-summary-next-article t nil nil t)) | |
12552 | |
12553 ;; Thread-based commands. | |
12554 | |
12555 (defun gnus-summary-articles-in-thread (&optional article) | |
12556 "Return a list of all articles in the current thread. | |
12557 If ARTICLE is non-nil, return all articles in the thread that starts | |
12558 with that article." | |
12559 (let* ((article (or article (gnus-summary-article-number))) | |
12560 (data (gnus-data-find-list article)) | |
12561 (top-level (gnus-data-level (car data))) | |
12562 (top-subject | |
12563 (cond ((null gnus-thread-operation-ignore-subject) | |
12564 (gnus-simplify-subject-re | |
12565 (mail-header-subject (gnus-data-header (car data))))) | |
12566 ((eq gnus-thread-operation-ignore-subject 'fuzzy) | |
12567 (gnus-simplify-subject-fuzzy | |
12568 (mail-header-subject (gnus-data-header (car data))))) | |
12569 (t nil))) | |
12570 (end-point (save-excursion | |
12571 (if (gnus-summary-go-to-next-thread) | |
12572 (point) (point-max)))) | |
12573 articles) | |
12574 (while (and data | |
12575 (< (gnus-data-pos (car data)) end-point)) | |
12576 (when (or (not top-subject) | |
12577 (string= top-subject | |
12578 (if (eq gnus-thread-operation-ignore-subject 'fuzzy) | |
12579 (gnus-simplify-subject-fuzzy | |
12580 (mail-header-subject | |
12581 (gnus-data-header (car data)))) | |
12582 (gnus-simplify-subject-re | |
12583 (mail-header-subject | |
12584 (gnus-data-header (car data))))))) | |
12585 (push (gnus-data-number (car data)) articles)) | |
12586 (unless (and (setq data (cdr data)) | |
12587 (> (gnus-data-level (car data)) top-level)) | |
12588 (setq data nil))) | |
12589 ;; Return the list of articles. | |
12590 (nreverse articles))) | |
12591 | |
12592 (defun gnus-summary-rethread-current () | |
12593 "Rethread the thread the current article is part of." | |
12594 (interactive) | |
12595 (gnus-set-global-variables) | |
12596 (let* ((gnus-show-threads t) | |
12597 (article (gnus-summary-article-number)) | |
12598 (id (mail-header-id (gnus-summary-article-header))) | |
12599 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id))))) | |
12600 (unless id | |
12601 (error "No article on the current line")) | |
12602 (gnus-rebuild-thread id) | |
12603 (gnus-summary-goto-subject article))) | |
12604 | |
12605 (defun gnus-summary-reparent-thread () | |
12606 "Make current article child of the marked (or previous) article. | |
12607 | |
12608 Note that the re-threading will only work if `gnus-thread-ignore-subject' | |
12609 is non-nil or the Subject: of both articles are the same." | |
12610 (interactive) | |
12611 (or (not (gnus-group-read-only-p)) | |
12612 (error "The current newsgroup does not support article editing.")) | |
12613 (or (<= (length gnus-newsgroup-processable) 1) | |
12614 (error "No more than one article may be marked.")) | |
12615 (save-window-excursion | |
12616 (let ((gnus-article-buffer " *reparent*") | |
12617 (current-article (gnus-summary-article-number)) | |
12618 ; first grab the marked article, otherwise one line up. | |
12619 (parent-article (if (not (null gnus-newsgroup-processable)) | |
12620 (car gnus-newsgroup-processable) | |
12621 (save-excursion | |
12622 (if (eq (forward-line -1) 0) | |
12623 (gnus-summary-article-number) | |
12624 (error "Beginning of summary buffer.")))))) | |
12625 (or (not (eq current-article parent-article)) | |
12626 (error "An article may not be self-referential.")) | |
12627 (let ((message-id (mail-header-id | |
12628 (gnus-summary-article-header parent-article)))) | |
12629 (or (and message-id (not (equal message-id ""))) | |
12630 (error "No message-id in desired parent.")) | |
12631 (gnus-summary-select-article t t nil current-article) | |
12632 (set-buffer gnus-article-buffer) | |
12633 (setq buffer-read-only nil) | |
12634 (let ((buf (format "%s" (buffer-string)))) | |
12635 (erase-buffer) | |
12636 (insert buf)) | |
12637 (goto-char (point-min)) | |
12638 (if (search-forward-regexp "^References: " nil t) | |
12639 (insert message-id " " ) | |
12640 (insert "References: " message-id "\n")) | |
12641 (or (gnus-request-replace-article current-article | |
12642 (car gnus-article-current) | |
12643 gnus-article-buffer) | |
12644 (error "Couldn't replace article.")) | |
12645 (set-buffer gnus-summary-buffer) | |
12646 (gnus-summary-unmark-all-processable) | |
12647 (gnus-summary-rethread-current) | |
12648 (gnus-message 3 "Article %d is now the child of article %d." | |
12649 current-article parent-article))))) | |
12650 | |
12651 (defun gnus-summary-toggle-threads (&optional arg) | |
12652 "Toggle showing conversation threads. | |
12653 If ARG is positive number, turn showing conversation threads on." | |
12654 (interactive "P") | |
12655 (gnus-set-global-variables) | |
12656 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end))) | |
12657 (setq gnus-show-threads | |
12658 (if (null arg) (not gnus-show-threads) | |
12659 (> (prefix-numeric-value arg) 0))) | |
12660 (gnus-summary-prepare) | |
12661 (gnus-summary-goto-subject current) | |
12662 (gnus-summary-position-point))) | |
12663 | |
12664 (defun gnus-summary-show-all-threads () | |
12665 "Show all threads." | |
12666 (interactive) | |
12667 (gnus-set-global-variables) | |
12668 (save-excursion | |
12669 (let ((buffer-read-only nil)) | |
12670 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t))) | |
12671 (gnus-summary-position-point)) | |
12672 | |
12673 (defun gnus-summary-show-thread () | |
12674 "Show thread subtrees. | |
12675 Returns nil if no thread was there to be shown." | |
12676 (interactive) | |
12677 (gnus-set-global-variables) | |
12678 (let ((buffer-read-only nil) | |
12679 (orig (point)) | |
12680 ;; first goto end then to beg, to have point at beg after let | |
12681 (end (progn (end-of-line) (point))) | |
12682 (beg (progn (beginning-of-line) (point)))) | |
12683 (prog1 | |
12684 ;; Any hidden lines here? | |
12685 (search-forward "\r" end t) | |
12686 (subst-char-in-region beg end ?\^M ?\n t) | |
12687 (goto-char orig) | |
12688 (gnus-summary-position-point)))) | |
12689 | |
12690 (defun gnus-summary-hide-all-threads () | |
12691 "Hide all thread subtrees." | |
12692 (interactive) | |
12693 (gnus-set-global-variables) | |
12694 (save-excursion | |
12695 (goto-char (point-min)) | |
12696 (gnus-summary-hide-thread) | |
12697 (while (zerop (gnus-summary-next-thread 1 t)) | |
12698 (gnus-summary-hide-thread))) | |
12699 (gnus-summary-position-point)) | |
12700 | |
12701 (defun gnus-summary-hide-thread () | |
12702 "Hide thread subtrees. | |
12703 Returns nil if no threads were there to be hidden." | |
12704 (interactive) | |
12705 (gnus-set-global-variables) | |
12706 (let ((buffer-read-only nil) | |
12707 (start (point)) | |
12708 (article (gnus-summary-article-number))) | |
12709 (goto-char start) | |
12710 ;; Go forward until either the buffer ends or the subthread | |
12711 ;; ends. | |
12712 (when (and (not (eobp)) | |
12713 (or (zerop (gnus-summary-next-thread 1 t)) | |
12714 (goto-char (point-max)))) | |
12715 (prog1 | |
12716 (if (and (> (point) start) | |
12717 (search-backward "\n" start t)) | |
12718 (progn | |
12719 (subst-char-in-region start (point) ?\n ?\^M) | |
12720 (gnus-summary-goto-subject article)) | |
12721 (goto-char start) | |
12722 nil) | |
12723 ;;(gnus-summary-position-point) | |
12724 )))) | |
12725 | |
12726 (defun gnus-summary-go-to-next-thread (&optional previous) | |
12727 "Go to the same level (or less) next thread. | |
12728 If PREVIOUS is non-nil, go to previous thread instead. | |
12729 Return the article number moved to, or nil if moving was impossible." | |
12730 (let ((level (gnus-summary-thread-level)) | |
12731 (way (if previous -1 1)) | |
12732 (beg (point))) | |
12733 (forward-line way) | |
12734 (while (and (not (eobp)) | |
12735 (< level (gnus-summary-thread-level))) | |
12736 (forward-line way)) | |
12737 (if (eobp) | |
12738 (progn | |
12739 (goto-char beg) | |
12740 nil) | |
12741 (setq beg (point)) | |
12742 (prog1 | |
12743 (gnus-summary-article-number) | |
12744 (goto-char beg))))) | |
12745 | |
12746 (defun gnus-summary-go-to-next-thread-old (&optional previous) | |
12747 "Go to the same level (or less) next thread. | |
12748 If PREVIOUS is non-nil, go to previous thread instead. | |
12749 Return the article number moved to, or nil if moving was impossible." | |
12750 (if (and (eq gnus-summary-make-false-root 'dummy) | |
12751 (gnus-summary-article-intangible-p)) | |
12752 (let ((beg (point))) | |
12753 (while (and (zerop (forward-line 1)) | |
12754 (not (gnus-summary-article-intangible-p)) | |
12755 (not (zerop (save-excursion | |
12756 (gnus-summary-thread-level)))))) | |
12757 (if (eobp) | |
12758 (progn | |
12759 (goto-char beg) | |
12760 nil) | |
12761 (point))) | |
12762 (let* ((level (gnus-summary-thread-level)) | |
12763 (article (gnus-summary-article-number)) | |
12764 (data (cdr (gnus-data-find-list article (gnus-data-list previous)))) | |
12765 oart) | |
12766 (while data | |
12767 (if (<= (gnus-data-level (car data)) level) | |
12768 (setq oart (gnus-data-number (car data)) | |
12769 data nil) | |
12770 (setq data (cdr data)))) | |
12771 (and oart | |
12772 (gnus-summary-goto-subject oart))))) | |
12773 | |
12774 (defun gnus-summary-next-thread (n &optional silent) | |
12775 "Go to the same level next N'th thread. | |
12776 If N is negative, search backward instead. | |
12777 Returns the difference between N and the number of skips actually | |
12778 done. | |
12779 | |
12780 If SILENT, don't output messages." | |
12781 (interactive "p") | |
12782 (gnus-set-global-variables) | |
12783 (let ((backward (< n 0)) | |
12784 (n (abs n)) | |
12785 old dum int) | |
12786 (while (and (> n 0) | |
12787 (gnus-summary-go-to-next-thread backward)) | |
12788 (decf n)) | |
12789 (unless silent | |
12790 (gnus-summary-position-point)) | |
12791 (when (and (not silent) (/= 0 n)) | |
12792 (gnus-message 7 "No more threads")) | |
12793 n)) | |
12794 | |
12795 (defun gnus-summary-prev-thread (n) | |
12796 "Go to the same level previous N'th thread. | |
12797 Returns the difference between N and the number of skips actually | |
12798 done." | |
12799 (interactive "p") | |
12800 (gnus-set-global-variables) | |
12801 (gnus-summary-next-thread (- n))) | |
12802 | |
12803 (defun gnus-summary-go-down-thread () | |
12804 "Go down one level in the current thread." | |
12805 (let ((children (gnus-summary-article-children))) | |
12806 (and children | |
12807 (gnus-summary-goto-subject (car children))))) | |
12808 | |
12809 (defun gnus-summary-go-up-thread () | |
12810 "Go up one level in the current thread." | |
12811 (let ((parent (gnus-summary-article-parent))) | |
12812 (and parent | |
12813 (gnus-summary-goto-subject parent)))) | |
12814 | |
12815 (defun gnus-summary-down-thread (n) | |
12816 "Go down thread N steps. | |
12817 If N is negative, go up instead. | |
12818 Returns the difference between N and how many steps down that were | |
12819 taken." | |
12820 (interactive "p") | |
12821 (gnus-set-global-variables) | |
12822 (let ((up (< n 0)) | |
12823 (n (abs n))) | |
12824 (while (and (> n 0) | |
12825 (if up (gnus-summary-go-up-thread) | |
12826 (gnus-summary-go-down-thread))) | |
12827 (setq n (1- n))) | |
12828 (gnus-summary-position-point) | |
12829 (if (/= 0 n) (gnus-message 7 "Can't go further")) | |
12830 n)) | |
12831 | |
12832 (defun gnus-summary-up-thread (n) | |
12833 "Go up thread N steps. | |
12834 If N is negative, go up instead. | |
12835 Returns the difference between N and how many steps down that were | |
12836 taken." | |
12837 (interactive "p") | |
12838 (gnus-set-global-variables) | |
12839 (gnus-summary-down-thread (- n))) | |
12840 | |
12841 (defun gnus-summary-top-thread () | |
12842 "Go to the top of the thread." | |
12843 (interactive) | |
12844 (gnus-set-global-variables) | |
12845 (while (gnus-summary-go-up-thread)) | |
12846 (gnus-summary-article-number)) | |
12847 | |
12848 (defun gnus-summary-kill-thread (&optional unmark) | |
12849 "Mark articles under current thread as read. | |
12850 If the prefix argument is positive, remove any kinds of marks. | |
12851 If the prefix argument is negative, tick articles instead." | |
12852 (interactive "P") | |
12853 (gnus-set-global-variables) | |
12854 (when unmark | |
12855 (setq unmark (prefix-numeric-value unmark))) | |
12856 (let ((articles (gnus-summary-articles-in-thread))) | |
12857 (save-excursion | |
12858 ;; Expand the thread. | |
12859 (gnus-summary-show-thread) | |
12860 ;; Mark all the articles. | |
12861 (while articles | |
12862 (gnus-summary-goto-subject (car articles)) | |
12863 (cond ((null unmark) | |
12864 (gnus-summary-mark-article-as-read gnus-killed-mark)) | |
12865 ((> unmark 0) | |
12866 (gnus-summary-mark-article-as-unread gnus-unread-mark)) | |
12867 (t | |
12868 (gnus-summary-mark-article-as-unread gnus-ticked-mark))) | |
12869 (setq articles (cdr articles)))) | |
12870 ;; Hide killed subtrees. | |
12871 (and (null unmark) | |
12872 gnus-thread-hide-killed | |
12873 (gnus-summary-hide-thread)) | |
12874 ;; If marked as read, go to next unread subject. | |
12875 (if (null unmark) | |
12876 ;; Go to next unread subject. | |
12877 (gnus-summary-next-subject 1 t))) | |
12878 (gnus-set-mode-line 'summary)) | |
12879 | |
12880 ;; Summary sorting commands | |
12881 | |
12882 (defun gnus-summary-sort-by-number (&optional reverse) | |
12883 "Sort summary buffer by article number. | |
12884 Argument REVERSE means reverse order." | |
12885 (interactive "P") | |
12886 (gnus-summary-sort 'number reverse)) | |
12887 | |
12888 (defun gnus-summary-sort-by-author (&optional reverse) | |
12889 "Sort summary buffer by author name alphabetically. | |
12890 If case-fold-search is non-nil, case of letters is ignored. | |
12891 Argument REVERSE means reverse order." | |
12892 (interactive "P") | |
12893 (gnus-summary-sort 'author reverse)) | |
12894 | |
12895 (defun gnus-summary-sort-by-subject (&optional reverse) | |
12896 "Sort summary buffer by subject alphabetically. `Re:'s are ignored. | |
12897 If case-fold-search is non-nil, case of letters is ignored. | |
12898 Argument REVERSE means reverse order." | |
12899 (interactive "P") | |
12900 (gnus-summary-sort 'subject reverse)) | |
12901 | |
12902 (defun gnus-summary-sort-by-date (&optional reverse) | |
12903 "Sort summary buffer by date. | |
12904 Argument REVERSE means reverse order." | |
12905 (interactive "P") | |
12906 (gnus-summary-sort 'date reverse)) | |
12907 | |
12908 (defun gnus-summary-sort-by-score (&optional reverse) | |
12909 "Sort summary buffer by score. | |
12910 Argument REVERSE means reverse order." | |
12911 (interactive "P") | |
12912 (gnus-summary-sort 'score reverse)) | |
12913 | |
12914 (defun gnus-summary-sort (predicate reverse) | |
12915 "Sort summary buffer by PREDICATE. REVERSE means reverse order." | |
12916 (gnus-set-global-variables) | |
12917 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate))) | |
12918 (article (intern (format "gnus-article-sort-by-%s" predicate))) | |
12919 (gnus-thread-sort-functions | |
12920 (list | |
12921 (if (not reverse) | |
12922 thread | |
12923 `(lambda (t1 t2) | |
12924 (,thread t2 t1))))) | |
12925 (gnus-article-sort-functions | |
12926 (list | |
12927 (if (not reverse) | |
12928 article | |
12929 `(lambda (t1 t2) | |
12930 (,article t2 t1))))) | |
12931 (buffer-read-only) | |
12932 (gnus-summary-prepare-hook nil)) | |
12933 ;; We do the sorting by regenerating the threads. | |
12934 (gnus-summary-prepare) | |
12935 ;; Hide subthreads if needed. | |
12936 (when (and gnus-show-threads gnus-thread-hide-subtree) | |
12937 (gnus-summary-hide-all-threads))) | |
12938 ;; If in async mode, we send some info to the backend. | |
12939 (when gnus-newsgroup-async | |
12940 (gnus-request-asynchronous | |
12941 gnus-newsgroup-name gnus-newsgroup-data))) | |
12942 | |
12943 (defun gnus-sortable-date (date) | |
12944 "Make sortable string by string-lessp from DATE. | |
12945 Timezone package is used." | |
12946 (condition-case () | |
12947 (progn | |
12948 (setq date (inline (timezone-fix-time | |
12949 date nil | |
12950 (aref (inline (timezone-parse-date date)) 4)))) | |
12951 (inline | |
12952 (timezone-make-sortable-date | |
12953 (aref date 0) (aref date 1) (aref date 2) | |
12954 (inline | |
12955 (timezone-make-time-string | |
12956 (aref date 3) (aref date 4) (aref date 5)))))) | |
12957 (error ""))) | |
12958 | |
12959 ;; Summary saving commands. | |
12960 | |
12961 (defun gnus-summary-save-article (&optional n not-saved) | |
12962 "Save the current article using the default saver function. | |
12963 If N is a positive number, save the N next articles. | |
12964 If N is a negative number, save the N previous articles. | |
12965 If N is nil and any articles have been marked with the process mark, | |
12966 save those articles instead. | |
12967 The variable `gnus-default-article-saver' specifies the saver function." | |
12968 (interactive "P") | |
12969 (gnus-set-global-variables) | |
12970 (let ((articles (gnus-summary-work-articles n)) | |
12971 (save-buffer (save-excursion | |
12972 (nnheader-set-temp-buffer " *Gnus Save*"))) | |
12973 file header article) | |
12974 (while articles | |
12975 (setq header (gnus-summary-article-header | |
12976 (setq article (pop articles)))) | |
12977 (if (not (vectorp header)) | |
12978 ;; This is a pseudo-article. | |
12979 (if (assq 'name header) | |
12980 (gnus-copy-file (cdr (assq 'name header))) | |
12981 (gnus-message 1 "Article %d is unsaveable" article)) | |
12982 ;; This is a real article. | |
12983 (save-window-excursion | |
12984 (gnus-summary-select-article t nil nil article)) | |
12985 (save-excursion | |
12986 (set-buffer save-buffer) | |
12987 (erase-buffer) | |
12988 (insert-buffer-substring gnus-original-article-buffer)) | |
12989 (unless gnus-save-all-headers | |
12990 ;; Remove headers accoring to `gnus-saved-headers'. | |
12991 (let ((gnus-visible-headers | |
12992 (or gnus-saved-headers gnus-visible-headers)) | |
12993 (gnus-article-buffer save-buffer)) | |
12994 (gnus-article-hide-headers 1 t))) | |
12995 (save-window-excursion | |
12996 (if (not gnus-default-article-saver) | |
12997 (error "No default saver is defined.") | |
12998 ;; !!! Magic! The saving functions all save | |
12999 ;; `gnus-original-article-buffer' (or so they think), | |
13000 ;; but we bind that variable to our save-buffer. | |
13001 (set-buffer gnus-article-buffer) | |
13002 (let ((gnus-original-article-buffer save-buffer)) | |
13003 (set-buffer gnus-summary-buffer) | |
13004 (setq file (funcall | |
13005 gnus-default-article-saver | |
13006 (cond | |
13007 ((not gnus-prompt-before-saving) | |
13008 'default) | |
13009 ((eq gnus-prompt-before-saving 'always) | |
13010 nil) | |
13011 (t file))))))) | |
13012 (gnus-summary-remove-process-mark article) | |
13013 (unless not-saved | |
13014 (gnus-summary-set-saved-mark article)))) | |
13015 (gnus-kill-buffer save-buffer) | |
13016 (gnus-summary-position-point) | |
13017 n)) | |
13018 | |
13019 (defun gnus-summary-pipe-output (&optional arg) | |
13020 "Pipe the current article to a subprocess. | |
13021 If N is a positive number, pipe the N next articles. | |
13022 If N is a negative number, pipe the N previous articles. | |
13023 If N is nil and any articles have been marked with the process mark, | |
13024 pipe those articles instead." | |
13025 (interactive "P") | |
13026 (gnus-set-global-variables) | |
13027 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe)) | |
13028 (gnus-summary-save-article arg t)) | |
13029 (gnus-configure-windows 'pipe)) | |
13030 | |
13031 (defun gnus-summary-save-article-mail (&optional arg) | |
13032 "Append the current article to an mail file. | |
13033 If N is a positive number, save the N next articles. | |
13034 If N is a negative number, save the N previous articles. | |
13035 If N is nil and any articles have been marked with the process mark, | |
13036 save those articles instead." | |
13037 (interactive "P") | |
13038 (gnus-set-global-variables) | |
13039 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail)) | |
13040 (gnus-summary-save-article arg))) | |
13041 | |
13042 (defun gnus-summary-save-article-rmail (&optional arg) | |
13043 "Append the current article to an rmail file. | |
13044 If N is a positive number, save the N next articles. | |
13045 If N is a negative number, save the N previous articles. | |
13046 If N is nil and any articles have been marked with the process mark, | |
13047 save those articles instead." | |
13048 (interactive "P") | |
13049 (gnus-set-global-variables) | |
13050 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail)) | |
13051 (gnus-summary-save-article arg))) | |
13052 | |
13053 (defun gnus-summary-save-article-file (&optional arg) | |
13054 "Append the current article to a file. | |
13055 If N is a positive number, save the N next articles. | |
13056 If N is a negative number, save the N previous articles. | |
13057 If N is nil and any articles have been marked with the process mark, | |
13058 save those articles instead." | |
13059 (interactive "P") | |
13060 (gnus-set-global-variables) | |
13061 (let ((gnus-default-article-saver 'gnus-summary-save-in-file)) | |
13062 (gnus-summary-save-article arg))) | |
13063 | |
13064 (defun gnus-summary-save-article-body-file (&optional arg) | |
13065 "Append the current article body to a file. | |
13066 If N is a positive number, save the N next articles. | |
13067 If N is a negative number, save the N previous articles. | |
13068 If N is nil and any articles have been marked with the process mark, | |
13069 save those articles instead." | |
13070 (interactive "P") | |
13071 (gnus-set-global-variables) | |
13072 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file)) | |
13073 (gnus-summary-save-article arg))) | |
13074 | |
13075 (defun gnus-get-split-value (methods) | |
13076 "Return a value based on the split METHODS." | |
13077 (let (split-name method result match) | |
13078 (when methods | |
13079 (save-excursion | |
13080 (set-buffer gnus-original-article-buffer) | |
13081 (save-restriction | |
13082 (nnheader-narrow-to-headers) | |
13083 (while methods | |
13084 (goto-char (point-min)) | |
13085 (setq method (pop methods)) | |
13086 (setq match (car method)) | |
13087 (when (cond | |
13088 ((stringp match) | |
13089 ;; Regular expression. | |
13090 (condition-case () | |
13091 (re-search-forward match nil t) | |
13092 (error nil))) | |
13093 ((gnus-functionp match) | |
13094 ;; Function. | |
13095 (save-restriction | |
13096 (widen) | |
13097 (setq result (funcall match gnus-newsgroup-name)))) | |
13098 ((consp match) | |
13099 ;; Form. | |
13100 (save-restriction | |
13101 (widen) | |
13102 (setq result (eval match))))) | |
13103 (setq split-name (append (cdr method) split-name)) | |
13104 (cond ((stringp result) | |
13105 (push result split-name)) | |
13106 ((consp result) | |
13107 (setq split-name (append result split-name))))))))) | |
13108 split-name)) | |
13109 | |
13110 (defun gnus-read-move-group-name (prompt default articles prefix) | |
13111 "Read a group name." | |
13112 (let* ((split-name (gnus-get-split-value gnus-move-split-methods)) | |
13113 (minibuffer-confirm-incomplete nil) ; XEmacs | |
13114 group-map | |
13115 (dum (mapatoms | |
13116 (lambda (g) | |
13117 (and (boundp g) | |
13118 (symbol-name g) | |
13119 (memq 'respool | |
13120 (assoc (symbol-name | |
13121 (car (gnus-find-method-for-group | |
13122 (symbol-name g)))) | |
13123 gnus-valid-select-methods)) | |
13124 (push (list (symbol-name g)) group-map))) | |
13125 gnus-active-hashtb)) | |
13126 (prom | |
13127 (format "%s %s to:" | |
13128 prompt | |
13129 (if (> (length articles) 1) | |
13130 (format "these %d articles" (length articles)) | |
13131 "this article"))) | |
13132 (to-newsgroup | |
13133 (cond | |
13134 ((null split-name) | |
13135 (gnus-completing-read default prom | |
13136 group-map nil nil prefix | |
13137 'gnus-group-history)) | |
13138 ((= 1 (length split-name)) | |
13139 (gnus-completing-read (car split-name) prom group-map | |
13140 nil nil nil | |
13141 'gnus-group-history)) | |
13142 (t | |
13143 (gnus-completing-read nil prom | |
13144 (mapcar (lambda (el) (list el)) | |
13145 (nreverse split-name)) | |
13146 nil nil nil | |
13147 'gnus-group-history))))) | |
13148 (when to-newsgroup | |
13149 (if (or (string= to-newsgroup "") | |
13150 (string= to-newsgroup prefix)) | |
13151 (setq to-newsgroup (or default ""))) | |
13152 (or (gnus-active to-newsgroup) | |
13153 (gnus-activate-group to-newsgroup) | |
13154 (if (gnus-y-or-n-p (format "No such group: %s. Create it? " | |
13155 to-newsgroup)) | |
13156 (or (and (gnus-request-create-group | |
13157 to-newsgroup (gnus-group-name-to-method to-newsgroup)) | |
13158 (gnus-activate-group to-newsgroup nil nil | |
13159 (gnus-group-name-to-method | |
13160 to-newsgroup))) | |
13161 (error "Couldn't create group %s" to-newsgroup))) | |
13162 (error "No such group: %s" to-newsgroup))) | |
13163 to-newsgroup)) | |
13164 | |
13165 (defun gnus-read-save-file-name (prompt default-name) | |
13166 (let* ((split-name (gnus-get-split-value gnus-split-methods)) | |
13167 (file | |
13168 ;; Let the split methods have their say. | |
13169 (cond | |
13170 ;; No split name was found. | |
13171 ((null split-name) | |
13172 (read-file-name | |
13173 (concat prompt " (default " | |
13174 (file-name-nondirectory default-name) ") ") | |
13175 (file-name-directory default-name) | |
13176 default-name)) | |
13177 ;; A single split name was found | |
13178 ((= 1 (length split-name)) | |
13179 (let* ((name (car split-name)) | |
13180 (dir (cond ((file-directory-p name) | |
13181 (file-name-as-directory name)) | |
13182 ((file-exists-p name) name) | |
13183 (t gnus-article-save-directory)))) | |
13184 (read-file-name | |
13185 (concat prompt " (default " name ") ") | |
13186 dir name))) | |
13187 ;; A list of splits was found. | |
13188 (t | |
13189 (setq split-name (nreverse split-name)) | |
13190 (let (result) | |
13191 (let ((file-name-history (nconc split-name file-name-history))) | |
13192 (setq result | |
13193 (read-file-name | |
13194 (concat prompt " (`M-p' for defaults) ") | |
13195 gnus-article-save-directory | |
13196 (car split-name)))) | |
13197 (car (push result file-name-history))))))) | |
13198 ;; If we have read a directory, we append the default file name. | |
13199 (when (file-directory-p file) | |
13200 (setq file (concat (file-name-as-directory file) | |
13201 (file-name-nondirectory default-name)))) | |
13202 ;; Possibly translate some charaters. | |
13203 (nnheader-translate-file-chars file))) | |
13204 | |
13205 (defun gnus-article-archive-name (group) | |
13206 "Return the first instance of an \"Archive-name\" in the current buffer." | |
13207 (let ((case-fold-search t)) | |
13208 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t) | |
13209 (match-string 1)))) | |
13210 | |
13211 (defun gnus-summary-save-in-rmail (&optional filename) | |
13212 "Append this article to Rmail file. | |
13213 Optional argument FILENAME specifies file name. | |
13214 Directory to save to is default to `gnus-article-save-directory'." | |
13215 (interactive) | |
13216 (gnus-set-global-variables) | |
13217 (let ((default-name | |
13218 (funcall gnus-rmail-save-name gnus-newsgroup-name | |
13219 gnus-current-headers gnus-newsgroup-last-rmail))) | |
13220 (setq filename | |
13221 (cond ((eq filename 'default) | |
13222 default-name) | |
13223 (filename filename) | |
13224 (t (gnus-read-save-file-name | |
13225 "Save in rmail file:" default-name)))) | |
13226 (gnus-make-directory (file-name-directory filename)) | |
13227 (gnus-eval-in-buffer-window gnus-original-article-buffer | |
13228 (save-excursion | |
13229 (save-restriction | |
13230 (widen) | |
13231 (gnus-output-to-rmail filename)))) | |
13232 ;; Remember the directory name to save articles | |
13233 (setq gnus-newsgroup-last-rmail filename))) | |
13234 | |
13235 (defun gnus-summary-save-in-mail (&optional filename) | |
13236 "Append this article to Unix mail file. | |
13237 Optional argument FILENAME specifies file name. | |
13238 Directory to save to is default to `gnus-article-save-directory'." | |
13239 (interactive) | |
13240 (gnus-set-global-variables) | |
13241 (let ((default-name | |
13242 (funcall gnus-mail-save-name gnus-newsgroup-name | |
13243 gnus-current-headers gnus-newsgroup-last-mail))) | |
13244 (setq filename | |
13245 (cond ((eq filename 'default) | |
13246 default-name) | |
13247 (filename filename) | |
13248 (t (gnus-read-save-file-name | |
13249 "Save in Unix mail file:" default-name)))) | |
13250 (setq filename | |
13251 (expand-file-name filename | |
13252 (and default-name | |
13253 (file-name-directory default-name)))) | |
13254 (gnus-make-directory (file-name-directory filename)) | |
13255 (gnus-eval-in-buffer-window gnus-original-article-buffer | |
13256 (save-excursion | |
13257 (save-restriction | |
13258 (widen) | |
13259 (if (and (file-readable-p filename) (mail-file-babyl-p filename)) | |
13260 (gnus-output-to-rmail filename) | |
13261 (let ((mail-use-rfc822 t)) | |
13262 (rmail-output filename 1 t t)))))) | |
13263 ;; Remember the directory name to save articles. | |
13264 (setq gnus-newsgroup-last-mail filename))) | |
13265 | |
13266 (defun gnus-summary-save-in-file (&optional filename) | |
13267 "Append this article to file. | |
13268 Optional argument FILENAME specifies file name. | |
13269 Directory to save to is default to `gnus-article-save-directory'." | |
13270 (interactive) | |
13271 (gnus-set-global-variables) | |
13272 (let ((default-name | |
13273 (funcall gnus-file-save-name gnus-newsgroup-name | |
13274 gnus-current-headers gnus-newsgroup-last-file))) | |
13275 (setq filename | |
13276 (cond ((eq filename 'default) | |
13277 default-name) | |
13278 (filename filename) | |
13279 (t (gnus-read-save-file-name | |
13280 "Save in file:" default-name)))) | |
13281 (gnus-make-directory (file-name-directory filename)) | |
13282 (gnus-eval-in-buffer-window gnus-original-article-buffer | |
13283 (save-excursion | |
13284 (save-restriction | |
13285 (widen) | |
13286 (gnus-output-to-file filename)))) | |
13287 ;; Remember the directory name to save articles. | |
13288 (setq gnus-newsgroup-last-file filename))) | |
13289 | |
13290 (defun gnus-summary-save-body-in-file (&optional filename) | |
13291 "Append this article body to a file. | |
13292 Optional argument FILENAME specifies file name. | |
13293 The directory to save in defaults to `gnus-article-save-directory'." | |
13294 (interactive) | |
13295 (gnus-set-global-variables) | |
13296 (let ((default-name | |
13297 (funcall gnus-file-save-name gnus-newsgroup-name | |
13298 gnus-current-headers gnus-newsgroup-last-file))) | |
13299 (setq filename | |
13300 (cond ((eq filename 'default) | |
13301 default-name) | |
13302 (filename filename) | |
13303 (t (gnus-read-save-file-name | |
13304 "Save body in file:" default-name)))) | |
13305 (gnus-make-directory (file-name-directory filename)) | |
13306 (gnus-eval-in-buffer-window gnus-original-article-buffer | |
13307 (save-excursion | |
13308 (save-restriction | |
13309 (widen) | |
13310 (goto-char (point-min)) | |
13311 (and (search-forward "\n\n" nil t) | |
13312 (narrow-to-region (point) (point-max))) | |
13313 (gnus-output-to-file filename)))) | |
13314 ;; Remember the directory name to save articles. | |
13315 (setq gnus-newsgroup-last-file filename))) | |
13316 | |
13317 (defun gnus-summary-save-in-pipe (&optional command) | |
13318 "Pipe this article to subprocess." | |
13319 (interactive) | |
13320 (gnus-set-global-variables) | |
13321 (setq command | |
13322 (cond ((eq command 'default) | |
13323 gnus-last-shell-command) | |
13324 (command command) | |
13325 (t (read-string "Shell command on article: " | |
13326 gnus-last-shell-command)))) | |
13327 (if (string-equal command "") | |
13328 (setq command gnus-last-shell-command)) | |
13329 (gnus-eval-in-buffer-window gnus-article-buffer | |
13330 (save-restriction | |
13331 (widen) | |
13332 (shell-command-on-region (point-min) (point-max) command nil))) | |
13333 (setq gnus-last-shell-command command)) | |
13334 | |
13335 ;; Summary extract commands | |
13336 | |
13337 (defun gnus-summary-insert-pseudos (pslist &optional not-view) | |
13338 (let ((buffer-read-only nil) | |
13339 (article (gnus-summary-article-number)) | |
13340 after-article b e) | |
13341 (or (gnus-summary-goto-subject article) | |
13342 (error (format "No such article: %d" article))) | |
13343 (gnus-summary-position-point) | |
13344 ;; If all commands are to be bunched up on one line, we collect | |
13345 ;; them here. | |
13346 (if gnus-view-pseudos-separately | |
13347 () | |
13348 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<))) | |
13349 files action) | |
13350 (while ps | |
13351 (setq action (cdr (assq 'action (car ps)))) | |
13352 (setq files (list (cdr (assq 'name (car ps))))) | |
13353 (while (and ps (cdr ps) | |
13354 (string= (or action "1") | |
13355 (or (cdr (assq 'action (cadr ps))) "2"))) | |
13356 (setq files (cons (cdr (assq 'name (cadr ps))) files)) | |
13357 (setcdr ps (cddr ps))) | |
13358 (if (not files) | |
13359 () | |
13360 (if (not (string-match "%s" action)) | |
13361 (setq files (cons " " files))) | |
13362 (setq files (cons " " files)) | |
13363 (and (assq 'execute (car ps)) | |
13364 (setcdr (assq 'execute (car ps)) | |
13365 (funcall (if (string-match "%s" action) | |
13366 'format 'concat) | |
13367 action | |
13368 (mapconcat (lambda (f) f) files " "))))) | |
13369 (setq ps (cdr ps))))) | |
13370 (if (and gnus-view-pseudos (not not-view)) | |
13371 (while pslist | |
13372 (and (assq 'execute (car pslist)) | |
13373 (gnus-execute-command (cdr (assq 'execute (car pslist))) | |
13374 (eq gnus-view-pseudos 'not-confirm))) | |
13375 (setq pslist (cdr pslist))) | |
13376 (save-excursion | |
13377 (while pslist | |
13378 (setq after-article (or (cdr (assq 'article (car pslist))) | |
13379 (gnus-summary-article-number))) | |
13380 (gnus-summary-goto-subject after-article) | |
13381 (forward-line 1) | |
13382 (setq b (point)) | |
13383 (insert " " (file-name-nondirectory | |
13384 (cdr (assq 'name (car pslist)))) | |
13385 ": " (or (cdr (assq 'execute (car pslist))) "") "\n") | |
13386 (setq e (point)) | |
13387 (forward-line -1) ; back to `b' | |
13388 (gnus-add-text-properties | |
13389 b (1- e) (list 'gnus-number gnus-reffed-article-number | |
13390 gnus-mouse-face-prop gnus-mouse-face)) | |
13391 (gnus-data-enter | |
13392 after-article gnus-reffed-article-number | |
13393 gnus-unread-mark b (car pslist) 0 (- e b)) | |
13394 (push gnus-reffed-article-number gnus-newsgroup-unreads) | |
13395 (setq gnus-reffed-article-number (1- gnus-reffed-article-number)) | |
13396 (setq pslist (cdr pslist))))))) | |
13397 | |
13398 (defun gnus-pseudos< (p1 p2) | |
13399 (let ((c1 (cdr (assq 'action p1))) | |
13400 (c2 (cdr (assq 'action p2)))) | |
13401 (and c1 c2 (string< c1 c2)))) | |
13402 | |
13403 (defun gnus-request-pseudo-article (props) | |
13404 (cond ((assq 'execute props) | |
13405 (gnus-execute-command (cdr (assq 'execute props))))) | |
13406 (let ((gnus-current-article (gnus-summary-article-number))) | |
13407 (run-hooks 'gnus-mark-article-hook))) | |
13408 | |
13409 (defun gnus-execute-command (command &optional automatic) | |
13410 (save-excursion | |
13411 (gnus-article-setup-buffer) | |
13412 (set-buffer gnus-article-buffer) | |
13413 (setq buffer-read-only nil) | |
13414 (let ((command (if automatic command (read-string "Command: " command))) | |
13415 ;; Just binding this here doesn't help, because there might | |
13416 ;; be output from the process after exiting the scope of | |
13417 ;; this `let'. | |
13418 ;; (buffer-read-only nil) | |
13419 ) | |
13420 (erase-buffer) | |
13421 (insert "$ " command "\n\n") | |
13422 (if gnus-view-pseudo-asynchronously | |
13423 (start-process "gnus-execute" nil shell-file-name | |
13424 shell-command-switch command) | |
13425 (call-process shell-file-name nil t nil | |
13426 shell-command-switch command))))) | |
13427 | |
13428 (defun gnus-copy-file (file &optional to) | |
13429 "Copy FILE to TO." | |
13430 (interactive | |
13431 (list (read-file-name "Copy file: " default-directory) | |
13432 (read-file-name "Copy file to: " default-directory))) | |
13433 (gnus-set-global-variables) | |
13434 (or to (setq to (read-file-name "Copy file to: " default-directory))) | |
13435 (and (file-directory-p to) | |
13436 (setq to (concat (file-name-as-directory to) | |
13437 (file-name-nondirectory file)))) | |
13438 (copy-file file to)) | |
13439 | |
13440 ;; Summary kill commands. | |
13441 | |
13442 (defun gnus-summary-edit-global-kill (article) | |
13443 "Edit the \"global\" kill file." | |
13444 (interactive (list (gnus-summary-article-number))) | |
13445 (gnus-set-global-variables) | |
13446 (gnus-group-edit-global-kill article)) | |
13447 | |
13448 (defun gnus-summary-edit-local-kill () | |
13449 "Edit a local kill file applied to the current newsgroup." | |
13450 (interactive) | |
13451 (gnus-set-global-variables) | |
13452 (setq gnus-current-headers (gnus-summary-article-header)) | |
13453 (gnus-set-global-variables) | |
13454 (gnus-group-edit-local-kill | |
13455 (gnus-summary-article-number) gnus-newsgroup-name)) | |
13456 | |
13457 | |
13458 ;;; | |
13459 ;;; Gnus article mode | |
13460 ;;; | |
13461 | |
13462 (put 'gnus-article-mode 'mode-class 'special) | |
13463 | |
13464 (if gnus-article-mode-map | |
13465 nil | |
13466 (setq gnus-article-mode-map (make-keymap)) | |
13467 (suppress-keymap gnus-article-mode-map) | |
13468 | |
13469 (gnus-define-keys gnus-article-mode-map | |
13470 " " gnus-article-goto-next-page | |
13471 "\177" gnus-article-goto-prev-page | |
13472 [delete] gnus-article-goto-prev-page | |
13473 "\C-c^" gnus-article-refer-article | |
13474 "h" gnus-article-show-summary | |
13475 "s" gnus-article-show-summary | |
13476 "\C-c\C-m" gnus-article-mail | |
13477 "?" gnus-article-describe-briefly | |
13478 gnus-mouse-2 gnus-article-push-button | |
13479 "\r" gnus-article-press-button | |
13480 "\t" gnus-article-next-button | |
13481 "\M-\t" gnus-article-prev-button | |
13482 "<" beginning-of-buffer | |
13483 ">" end-of-buffer | |
13484 "\C-c\C-b" gnus-bug) | |
13485 | |
13486 (substitute-key-definition | |
13487 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)) | |
13488 | |
13489 (defun gnus-article-mode () | |
13490 "Major mode for displaying an article. | |
13491 | |
13492 All normal editing commands are switched off. | |
13493 | |
13494 The following commands are available: | |
13495 | |
13496 \\<gnus-article-mode-map> | |
13497 \\[gnus-article-next-page]\t Scroll the article one page forwards | |
13498 \\[gnus-article-prev-page]\t Scroll the article one page backwards | |
13499 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point | |
13500 \\[gnus-article-show-summary]\t Display the summary buffer | |
13501 \\[gnus-article-mail]\t Send a reply to the address near point | |
13502 \\[gnus-article-describe-briefly]\t Describe the current mode briefly | |
13503 \\[gnus-info-find-node]\t Go to the Gnus info node" | |
13504 (interactive) | |
13505 (when (and menu-bar-mode | |
13506 (gnus-visual-p 'article-menu 'menu)) | |
13507 (gnus-article-make-menu-bar)) | |
13508 (kill-all-local-variables) | |
13509 (gnus-simplify-mode-line) | |
13510 (setq mode-name "Article") | |
13511 (setq major-mode 'gnus-article-mode) | |
13512 (make-local-variable 'minor-mode-alist) | |
13513 (or (assq 'gnus-show-mime minor-mode-alist) | |
13514 (setq minor-mode-alist | |
13515 (cons (list 'gnus-show-mime " MIME") minor-mode-alist))) | |
13516 (use-local-map gnus-article-mode-map) | |
13517 (make-local-variable 'page-delimiter) | |
13518 (setq page-delimiter gnus-page-delimiter) | |
13519 (buffer-disable-undo (current-buffer)) | |
13520 (setq buffer-read-only t) ;Disable modification | |
13521 (run-hooks 'gnus-article-mode-hook)) | |
13522 | |
13523 (defun gnus-article-setup-buffer () | |
13524 "Initialize the article buffer." | |
13525 (let* ((name (if gnus-single-article-buffer "*Article*" | |
13526 (concat "*Article " gnus-newsgroup-name "*"))) | |
13527 (original | |
13528 (progn (string-match "\\*Article" name) | |
13529 (concat " *Original Article" | |
13530 (substring name (match-end 0)))))) | |
13531 (setq gnus-article-buffer name) | |
13532 (setq gnus-original-article-buffer original) | |
13533 ;; This might be a variable local to the summary buffer. | |
13534 (unless gnus-single-article-buffer | |
13535 (save-excursion | |
13536 (set-buffer gnus-summary-buffer) | |
13537 (setq gnus-article-buffer name) | |
13538 (setq gnus-original-article-buffer original) | |
13539 (gnus-set-global-variables)) | |
13540 (make-local-variable 'gnus-summary-buffer)) | |
13541 ;; Init original article buffer. | |
13542 (save-excursion | |
13543 (set-buffer (get-buffer-create gnus-original-article-buffer)) | |
13544 (buffer-disable-undo (current-buffer)) | |
13545 (setq major-mode 'gnus-original-article-mode) | |
13546 (make-local-variable 'gnus-original-article)) | |
13547 (if (get-buffer name) | |
13548 (save-excursion | |
13549 (set-buffer name) | |
13550 (buffer-disable-undo (current-buffer)) | |
13551 (setq buffer-read-only t) | |
13552 (gnus-add-current-to-buffer-list) | |
13553 (or (eq major-mode 'gnus-article-mode) | |
13554 (gnus-article-mode)) | |
13555 (current-buffer)) | |
13556 (save-excursion | |
13557 (set-buffer (get-buffer-create name)) | |
13558 (gnus-add-current-to-buffer-list) | |
13559 (gnus-article-mode) | |
13560 (current-buffer))))) | |
13561 | |
13562 ;; Set article window start at LINE, where LINE is the number of lines | |
13563 ;; from the head of the article. | |
13564 (defun gnus-article-set-window-start (&optional line) | |
13565 (set-window-start | |
13566 (get-buffer-window gnus-article-buffer t) | |
13567 (save-excursion | |
13568 (set-buffer gnus-article-buffer) | |
13569 (goto-char (point-min)) | |
13570 (if (not line) | |
13571 (point-min) | |
13572 (gnus-message 6 "Moved to bookmark") | |
13573 (search-forward "\n\n" nil t) | |
13574 (forward-line line) | |
13575 (point))))) | |
13576 | |
13577 (defun gnus-kill-all-overlays () | |
13578 "Delete all overlays in the current buffer." | |
13579 (when (fboundp 'overlay-lists) | |
13580 (let* ((overlayss (overlay-lists)) | |
13581 (buffer-read-only nil) | |
13582 (overlays (nconc (car overlayss) (cdr overlayss)))) | |
13583 (while overlays | |
13584 (delete-overlay (pop overlays)))))) | |
13585 | |
13586 (defun gnus-request-article-this-buffer (article group) | |
13587 "Get an article and insert it into this buffer." | |
13588 (let (do-update-line) | |
13589 (prog1 | |
13590 (save-excursion | |
13591 (erase-buffer) | |
13592 (gnus-kill-all-overlays) | |
13593 (setq group (or group gnus-newsgroup-name)) | |
13594 | |
13595 ;; Open server if it has closed. | |
13596 (gnus-check-server (gnus-find-method-for-group group)) | |
13597 | |
13598 ;; Using `gnus-request-article' directly will insert the article into | |
13599 ;; `nntp-server-buffer' - so we'll save some time by not having to | |
13600 ;; copy it from the server buffer into the article buffer. | |
13601 | |
13602 ;; We only request an article by message-id when we do not have the | |
13603 ;; headers for it, so we'll have to get those. | |
13604 (when (stringp article) | |
13605 (let ((gnus-override-method gnus-refer-article-method)) | |
13606 (gnus-read-header article))) | |
13607 | |
13608 ;; If the article number is negative, that means that this article | |
13609 ;; doesn't belong in this newsgroup (possibly), so we find its | |
13610 ;; message-id and request it by id instead of number. | |
13611 (when (and (numberp article) | |
13612 gnus-summary-buffer | |
13613 (get-buffer gnus-summary-buffer) | |
13614 (buffer-name (get-buffer gnus-summary-buffer))) | |
13615 (save-excursion | |
13616 (set-buffer gnus-summary-buffer) | |
13617 (let ((header (gnus-summary-article-header article))) | |
13618 (if (< article 0) | |
13619 (cond | |
13620 ((memq article gnus-newsgroup-sparse) | |
13621 ;; This is a sparse gap article. | |
13622 (setq do-update-line article) | |
13623 (setq article (mail-header-id header)) | |
13624 (let ((gnus-override-method gnus-refer-article-method)) | |
13625 (gnus-read-header article)) | |
13626 (setq gnus-newsgroup-sparse | |
13627 (delq article gnus-newsgroup-sparse))) | |
13628 ((vectorp header) | |
13629 ;; It's a real article. | |
13630 (setq article (mail-header-id header))) | |
13631 (t | |
13632 ;; It is an extracted pseudo-article. | |
13633 (setq article 'pseudo) | |
13634 (gnus-request-pseudo-article header)))) | |
13635 | |
13636 (let ((method (gnus-find-method-for-group | |
13637 gnus-newsgroup-name))) | |
13638 (if (not (eq (car method) 'nneething)) | |
13639 () | |
13640 (let ((dir (concat (file-name-as-directory (nth 1 method)) | |
13641 (mail-header-subject header)))) | |
13642 (if (file-directory-p dir) | |
13643 (progn | |
13644 (setq article 'nneething) | |
13645 (gnus-group-enter-directory dir))))))))) | |
13646 | |
13647 (cond | |
13648 ;; Refuse to select canceled articles. | |
13649 ((and (numberp article) | |
13650 gnus-summary-buffer | |
13651 (get-buffer gnus-summary-buffer) | |
13652 (buffer-name (get-buffer gnus-summary-buffer)) | |
13653 (eq (cdr (save-excursion | |
13654 (set-buffer gnus-summary-buffer) | |
13655 (assq article gnus-newsgroup-reads))) | |
13656 gnus-canceled-mark)) | |
13657 nil) | |
13658 ;; We first check `gnus-original-article-buffer'. | |
13659 ((and (get-buffer gnus-original-article-buffer) | |
13660 (numberp article) | |
13661 (save-excursion | |
13662 (set-buffer gnus-original-article-buffer) | |
13663 (and (equal (car gnus-original-article) group) | |
13664 (eq (cdr gnus-original-article) article)))) | |
13665 (insert-buffer-substring gnus-original-article-buffer) | |
13666 'article) | |
13667 ;; Check the backlog. | |
13668 ((and gnus-keep-backlog | |
13669 (gnus-backlog-request-article group article (current-buffer))) | |
13670 'article) | |
13671 ;; Check the cache. | |
13672 ((and gnus-use-cache | |
13673 (numberp article) | |
13674 (gnus-cache-request-article article group)) | |
13675 'article) | |
13676 ;; Get the article and put into the article buffer. | |
13677 ((or (stringp article) (numberp article)) | |
13678 (let ((gnus-override-method | |
13679 (and (stringp article) gnus-refer-article-method)) | |
13680 (buffer-read-only nil)) | |
13681 (erase-buffer) | |
13682 (gnus-kill-all-overlays) | |
13683 (if (gnus-request-article article group (current-buffer)) | |
13684 (progn | |
13685 (and gnus-keep-backlog | |
13686 (numberp article) | |
13687 (gnus-backlog-enter-article | |
13688 group article (current-buffer))) | |
13689 'article)))) | |
13690 ;; It was a pseudo. | |
13691 (t article))) | |
13692 | |
13693 ;; Take the article from the original article buffer | |
13694 ;; and place it in the buffer it's supposed to be in. | |
13695 (when (and (get-buffer gnus-article-buffer) | |
13696 ;;(numberp article) | |
13697 (equal (buffer-name (current-buffer)) | |
13698 (buffer-name (get-buffer gnus-article-buffer)))) | |
13699 (save-excursion | |
13700 (if (get-buffer gnus-original-article-buffer) | |
13701 (set-buffer (get-buffer gnus-original-article-buffer)) | |
13702 (set-buffer (get-buffer-create gnus-original-article-buffer)) | |
13703 (buffer-disable-undo (current-buffer)) | |
13704 (setq major-mode 'gnus-original-article-mode) | |
13705 (setq buffer-read-only t) | |
13706 (gnus-add-current-to-buffer-list)) | |
13707 (let (buffer-read-only) | |
13708 (erase-buffer) | |
13709 (insert-buffer-substring gnus-article-buffer)) | |
13710 (setq gnus-original-article (cons group article)))) | |
13711 | |
13712 ;; Update sparse articles. | |
13713 (when (and do-update-line | |
13714 (or (numberp article) | |
13715 (stringp article))) | |
13716 (let ((buf (current-buffer))) | |
13717 (set-buffer gnus-summary-buffer) | |
13718 (gnus-summary-update-article do-update-line) | |
13719 (gnus-summary-goto-subject do-update-line nil t) | |
13720 (set-window-point (get-buffer-window (current-buffer) t) | |
13721 (point)) | |
13722 (set-buffer buf)))))) | |
13723 | |
13724 (defun gnus-read-header (id &optional header) | |
13725 "Read the headers of article ID and enter them into the Gnus system." | |
13726 (let ((group gnus-newsgroup-name) | |
13727 (gnus-override-method | |
13728 (and (gnus-news-group-p gnus-newsgroup-name) | |
13729 gnus-refer-article-method)) | |
13730 where) | |
13731 ;; First we check to see whether the header in question is already | |
13732 ;; fetched. | |
13733 (if (stringp id) | |
13734 ;; This is a Message-ID. | |
13735 (setq header (or header (gnus-id-to-header id))) | |
13736 ;; This is an article number. | |
13737 (setq header (or header (gnus-summary-article-header id)))) | |
13738 (if (and header | |
13739 (not (memq (mail-header-number header) gnus-newsgroup-sparse))) | |
13740 ;; We have found the header. | |
13741 header | |
13742 ;; We have to really fetch the header to this article. | |
13743 (when (setq where (gnus-request-head id group)) | |
13744 (save-excursion | |
13745 (set-buffer nntp-server-buffer) | |
13746 (goto-char (point-max)) | |
13747 (insert ".\n") | |
13748 (goto-char (point-min)) | |
13749 (insert "211 ") | |
13750 (princ (cond | |
13751 ((numberp id) id) | |
13752 ((cdr where) (cdr where)) | |
13753 (header (mail-header-number header)) | |
13754 (t gnus-reffed-article-number)) | |
13755 (current-buffer)) | |
13756 (insert " Article retrieved.\n")) | |
13757 ;(when (and header | |
13758 ; (memq (mail-header-number header) gnus-newsgroup-sparse)) | |
13759 ; (setcar (gnus-id-to-thread id) nil)) | |
13760 (if (not (setq header (car (gnus-get-newsgroup-headers)))) | |
13761 () ; Malformed head. | |
13762 (unless (memq (mail-header-number header) gnus-newsgroup-sparse) | |
13763 (if (and (stringp id) | |
13764 (not (string= (gnus-group-real-name group) | |
13765 (car where)))) | |
13766 ;; If we fetched by Message-ID and the article came | |
13767 ;; from a different group, we fudge some bogus article | |
13768 ;; numbers for this article. | |
13769 (mail-header-set-number header gnus-reffed-article-number)) | |
13770 (decf gnus-reffed-article-number) | |
13771 (gnus-remove-header (mail-header-number header)) | |
13772 (push header gnus-newsgroup-headers) | |
13773 (setq gnus-current-headers header) | |
13774 (push (mail-header-number header) gnus-newsgroup-limit)) | |
13775 header))))) | |
13776 | |
13777 (defun gnus-remove-header (number) | |
13778 "Remove header NUMBER from `gnus-newsgroup-headers'." | |
13779 (if (and gnus-newsgroup-headers | |
13780 (= number (mail-header-number (car gnus-newsgroup-headers)))) | |
13781 (pop gnus-newsgroup-headers) | |
13782 (let ((headers gnus-newsgroup-headers)) | |
13783 (while (and (cdr headers) | |
13784 (not (= number (mail-header-number (cadr headers))))) | |
13785 (pop headers)) | |
13786 (when (cdr headers) | |
13787 (setcdr headers (cddr headers)))))) | |
13788 | |
13789 (defun gnus-article-prepare (article &optional all-headers header) | |
13790 "Prepare ARTICLE in article mode buffer. | |
13791 ARTICLE should either be an article number or a Message-ID. | |
13792 If ARTICLE is an id, HEADER should be the article headers. | |
13793 If ALL-HEADERS is non-nil, no headers are hidden." | |
13794 (save-excursion | |
13795 ;; Make sure we start in a summary buffer. | |
13796 (unless (eq major-mode 'gnus-summary-mode) | |
13797 (set-buffer gnus-summary-buffer)) | |
13798 (setq gnus-summary-buffer (current-buffer)) | |
13799 ;; Make sure the connection to the server is alive. | |
13800 (unless (gnus-server-opened | |
13801 (gnus-find-method-for-group gnus-newsgroup-name)) | |
13802 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name)) | |
13803 (gnus-request-group gnus-newsgroup-name t)) | |
13804 (let* ((article (if header (mail-header-number header) article)) | |
13805 (summary-buffer (current-buffer)) | |
13806 (internal-hook gnus-article-internal-prepare-hook) | |
13807 (group gnus-newsgroup-name) | |
13808 result) | |
13809 (save-excursion | |
13810 (gnus-article-setup-buffer) | |
13811 (set-buffer gnus-article-buffer) | |
13812 ;; Deactivate active regions. | |
13813 (when (and (boundp 'transient-mark-mode) | |
13814 transient-mark-mode) | |
13815 (setq mark-active nil)) | |
13816 (if (not (setq result (let ((buffer-read-only nil)) | |
13817 (gnus-request-article-this-buffer | |
13818 article group)))) | |
13819 ;; There is no such article. | |
13820 (save-excursion | |
13821 (when (and (numberp article) | |
13822 (not (memq article gnus-newsgroup-sparse))) | |
13823 (setq gnus-article-current | |
13824 (cons gnus-newsgroup-name article)) | |
13825 (set-buffer gnus-summary-buffer) | |
13826 (setq gnus-current-article article) | |
13827 (gnus-summary-mark-article article gnus-canceled-mark)) | |
13828 (unless (memq article gnus-newsgroup-sparse) | |
13829 (gnus-error | |
13830 1 "No such article (may have expired or been canceled)"))) | |
13831 (if (or (eq result 'pseudo) (eq result 'nneething)) | |
13832 (progn | |
13833 (save-excursion | |
13834 (set-buffer summary-buffer) | |
13835 (setq gnus-last-article gnus-current-article | |
13836 gnus-newsgroup-history (cons gnus-current-article | |
13837 gnus-newsgroup-history) | |
13838 gnus-current-article 0 | |
13839 gnus-current-headers nil | |
13840 gnus-article-current nil) | |
13841 (if (eq result 'nneething) | |
13842 (gnus-configure-windows 'summary) | |
13843 (gnus-configure-windows 'article)) | |
13844 (gnus-set-global-variables)) | |
13845 (gnus-set-mode-line 'article)) | |
13846 ;; The result from the `request' was an actual article - | |
13847 ;; or at least some text that is now displayed in the | |
13848 ;; article buffer. | |
13849 (if (and (numberp article) | |
13850 (not (eq article gnus-current-article))) | |
13851 ;; Seems like a new article has been selected. | |
13852 ;; `gnus-current-article' must be an article number. | |
13853 (save-excursion | |
13854 (set-buffer summary-buffer) | |
13855 (setq gnus-last-article gnus-current-article | |
13856 gnus-newsgroup-history (cons gnus-current-article | |
13857 gnus-newsgroup-history) | |
13858 gnus-current-article article | |
13859 gnus-current-headers | |
13860 (gnus-summary-article-header gnus-current-article) | |
13861 gnus-article-current | |
13862 (cons gnus-newsgroup-name gnus-current-article)) | |
13863 (unless (vectorp gnus-current-headers) | |
13864 (setq gnus-current-headers nil)) | |
13865 (gnus-summary-show-thread) | |
13866 (run-hooks 'gnus-mark-article-hook) | |
13867 (gnus-set-mode-line 'summary) | |
13868 (and (gnus-visual-p 'article-highlight 'highlight) | |
13869 (run-hooks 'gnus-visual-mark-article-hook)) | |
13870 ;; Set the global newsgroup variables here. | |
13871 ;; Suggested by Jim Sisolak | |
13872 ;; <sisolak@trans4.neep.wisc.edu>. | |
13873 (gnus-set-global-variables) | |
13874 (setq gnus-have-all-headers | |
13875 (or all-headers gnus-show-all-headers)) | |
13876 (and gnus-use-cache | |
13877 (vectorp (gnus-summary-article-header article)) | |
13878 (gnus-cache-possibly-enter-article | |
13879 group article | |
13880 (gnus-summary-article-header article) | |
13881 (memq article gnus-newsgroup-marked) | |
13882 (memq article gnus-newsgroup-dormant) | |
13883 (memq article gnus-newsgroup-unreads))))) | |
13884 (when (or (numberp article) | |
13885 (stringp article)) | |
13886 ;; Hooks for getting information from the article. | |
13887 ;; This hook must be called before being narrowed. | |
13888 (let (buffer-read-only) | |
13889 (run-hooks 'internal-hook) | |
13890 (run-hooks 'gnus-article-prepare-hook) | |
13891 ;; Decode MIME message. | |
13892 (if gnus-show-mime | |
13893 (if (or (not gnus-strict-mime) | |
13894 (gnus-fetch-field "Mime-Version")) | |
13895 (funcall gnus-show-mime-method) | |
13896 (funcall gnus-decode-encoded-word-method))) | |
13897 ;; Perform the article display hooks. | |
13898 (run-hooks 'gnus-article-display-hook)) | |
13899 ;; Do page break. | |
13900 (goto-char (point-min)) | |
13901 (and gnus-break-pages (gnus-narrow-to-page))) | |
13902 (gnus-set-mode-line 'article) | |
13903 (gnus-configure-windows 'article) | |
13904 (goto-char (point-min)) | |
13905 t)))))) | |
13906 | |
13907 (defun gnus-article-show-all-headers () | |
13908 "Show all article headers in article mode buffer." | |
13909 (save-excursion | |
13910 (gnus-article-setup-buffer) | |
13911 (set-buffer gnus-article-buffer) | |
13912 (let ((buffer-read-only nil)) | |
13913 (gnus-unhide-text (point-min) (point-max))))) | |
13914 | |
13915 (defun gnus-article-hide-headers-if-wanted () | |
13916 "Hide unwanted headers if `gnus-have-all-headers' is nil. | |
13917 Provided for backwards compatibility." | |
13918 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers) | |
13919 gnus-inhibit-hiding | |
13920 (gnus-article-hide-headers))) | |
13921 | |
13922 (defsubst gnus-article-header-rank () | |
13923 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'." | |
13924 (let ((list gnus-sorted-header-list) | |
13925 (i 0)) | |
13926 (while list | |
13927 (when (looking-at (car list)) | |
13928 (setq list nil)) | |
13929 (setq list (cdr list)) | |
13930 (incf i)) | |
13931 i)) | |
13932 | |
13933 (defun gnus-article-hide-headers (&optional arg delete) | |
13934 "Toggle whether to hide unwanted headers and possibly sort them as well. | |
13935 If given a negative prefix, always show; if given a positive prefix, | |
13936 always hide." | |
13937 (interactive (gnus-hidden-arg)) | |
13938 (if (gnus-article-check-hidden-text 'headers arg) | |
13939 ;; Show boring headers as well. | |
13940 (gnus-article-show-hidden-text 'boring-headers) | |
13941 ;; This function might be inhibited. | |
13942 (unless gnus-inhibit-hiding | |
13943 (save-excursion | |
13944 (set-buffer gnus-article-buffer) | |
13945 (save-restriction | |
13946 (let ((buffer-read-only nil) | |
13947 (props (nconc (list 'gnus-type 'headers) | |
13948 gnus-hidden-properties)) | |
13949 (max (1+ (length gnus-sorted-header-list))) | |
13950 (ignored (when (not (stringp gnus-visible-headers)) | |
13951 (cond ((stringp gnus-ignored-headers) | |
13952 gnus-ignored-headers) | |
13953 ((listp gnus-ignored-headers) | |
13954 (mapconcat 'identity gnus-ignored-headers | |
13955 "\\|"))))) | |
13956 (visible | |
13957 (cond ((stringp gnus-visible-headers) | |
13958 gnus-visible-headers) | |
13959 ((and gnus-visible-headers | |
13960 (listp gnus-visible-headers)) | |
13961 (mapconcat 'identity gnus-visible-headers "\\|")))) | |
13962 (inhibit-point-motion-hooks t) | |
13963 want-list beg) | |
13964 ;; First we narrow to just the headers. | |
13965 (widen) | |
13966 (goto-char (point-min)) | |
13967 ;; Hide any "From " lines at the beginning of (mail) articles. | |
13968 (while (looking-at "From ") | |
13969 (forward-line 1)) | |
13970 (unless (bobp) | |
13971 (if delete | |
13972 (delete-region (point-min) (point)) | |
13973 (gnus-hide-text (point-min) (point) props))) | |
13974 ;; Then treat the rest of the header lines. | |
13975 (narrow-to-region | |
13976 (point) | |
13977 (progn (search-forward "\n\n" nil t) (forward-line -1) (point))) | |
13978 ;; Then we use the two regular expressions | |
13979 ;; `gnus-ignored-headers' and `gnus-visible-headers' to | |
13980 ;; select which header lines is to remain visible in the | |
13981 ;; article buffer. | |
13982 (goto-char (point-min)) | |
13983 (while (re-search-forward "^[^ \t]*:" nil t) | |
13984 (beginning-of-line) | |
13985 ;; We add the headers we want to keep to a list and delete | |
13986 ;; them from the buffer. | |
13987 (gnus-put-text-property | |
13988 (point) (1+ (point)) 'message-rank | |
13989 (if (or (and visible (looking-at visible)) | |
13990 (and ignored | |
13991 (not (looking-at ignored)))) | |
13992 (gnus-article-header-rank) | |
13993 (+ 2 max))) | |
13994 (forward-line 1)) | |
13995 (message-sort-headers-1) | |
13996 (when (setq beg (text-property-any | |
13997 (point-min) (point-max) 'message-rank (+ 2 max))) | |
13998 ;; We make the unwanted headers invisible. | |
13999 (if delete | |
14000 (delete-region beg (point-max)) | |
14001 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>. | |
14002 (gnus-hide-text-type beg (point-max) 'headers)) | |
14003 ;; Work around XEmacs lossage. | |
14004 (gnus-put-text-property (point-min) beg 'invisible nil)))))))) | |
14005 | |
14006 (defun gnus-article-hide-boring-headers (&optional arg) | |
14007 "Toggle hiding of headers that aren't very interesting. | |
14008 If given a negative prefix, always show; if given a positive prefix, | |
14009 always hide." | |
14010 (interactive (gnus-hidden-arg)) | |
14011 (unless (gnus-article-check-hidden-text 'boring-headers arg) | |
14012 (save-excursion | |
14013 (set-buffer gnus-article-buffer) | |
14014 (save-restriction | |
14015 (let ((buffer-read-only nil) | |
14016 (list gnus-boring-article-headers) | |
14017 (inhibit-point-motion-hooks t) | |
14018 elem) | |
14019 (nnheader-narrow-to-headers) | |
14020 (while list | |
14021 (setq elem (pop list)) | |
14022 (goto-char (point-min)) | |
14023 (cond | |
14024 ;; Hide empty headers. | |
14025 ((eq elem 'empty) | |
14026 (while (re-search-forward "^[^:]+:[ \t]\n[^ \t]" nil t) | |
14027 (forward-line -1) | |
14028 (gnus-hide-text-type | |
14029 (progn (beginning-of-line) (point)) | |
14030 (progn | |
14031 (end-of-line) | |
14032 (if (re-search-forward "^[^ \t]" nil t) | |
14033 (match-beginning 0) | |
14034 (point-max))) | |
14035 'boring-headers))) | |
14036 ;; Hide boring Newsgroups header. | |
14037 ((eq elem 'newsgroups) | |
14038 (when (equal (message-fetch-field "newsgroups") | |
14039 (gnus-group-real-name gnus-newsgroup-name)) | |
14040 (gnus-article-hide-header "newsgroups"))) | |
14041 ((eq elem 'followup-to) | |
14042 (when (equal (message-fetch-field "followup-to") | |
14043 (message-fetch-field "newsgroups")) | |
14044 (gnus-article-hide-header "followup-to"))) | |
14045 ((eq elem 'reply-to) | |
14046 (let ((from (message-fetch-field "from")) | |
14047 (reply-to (message-fetch-field "reply-to"))) | |
14048 (when (and | |
14049 from reply-to | |
14050 (equal | |
14051 (nth 1 (funcall gnus-extract-address-components from)) | |
14052 (nth 1 (funcall gnus-extract-address-components | |
14053 reply-to)))) | |
14054 (gnus-article-hide-header "reply-to")))) | |
14055 ((eq elem 'date) | |
14056 (let ((date (message-fetch-field "date"))) | |
14057 (when (and date | |
14058 (< (gnus-days-between date (current-time-string)) | |
14059 4)) | |
14060 (gnus-article-hide-header "date"))))))))))) | |
14061 | |
14062 (defun gnus-article-hide-header (header) | |
14063 (save-excursion | |
14064 (goto-char (point-min)) | |
14065 (when (re-search-forward (concat "^" header ":") nil t) | |
14066 (gnus-hide-text-type | |
14067 (progn (beginning-of-line) (point)) | |
14068 (progn | |
14069 (end-of-line) | |
14070 (if (re-search-forward "^[^ \t]" nil t) | |
14071 (match-beginning 0) | |
14072 (point-max))) | |
14073 'boring-headers)))) | |
14074 | |
14075 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>. | |
14076 (defun gnus-article-treat-overstrike () | |
14077 "Translate overstrikes into bold text." | |
14078 (interactive) | |
14079 (save-excursion | |
14080 (set-buffer gnus-article-buffer) | |
14081 (let ((buffer-read-only nil)) | |
14082 (while (search-forward "\b" nil t) | |
14083 (let ((next (following-char)) | |
14084 (previous (char-after (- (point) 2)))) | |
14085 (cond | |
14086 ((eq next previous) | |
14087 (gnus-put-text-property (- (point) 2) (point) 'invisible t) | |
14088 (gnus-put-text-property (point) (1+ (point)) 'face 'bold)) | |
14089 ((eq next ?_) | |
14090 (gnus-put-text-property (1- (point)) (1+ (point)) 'invisible t) | |
14091 (gnus-put-text-property | |
14092 (- (point) 2) (1- (point)) 'face 'underline)) | |
14093 ((eq previous ?_) | |
14094 (gnus-put-text-property (- (point) 2) (point) 'invisible t) | |
14095 (gnus-put-text-property | |
14096 (point) (1+ (point)) 'face 'underline)))))))) | |
14097 | |
14098 (defun gnus-article-word-wrap () | |
14099 "Format too long lines." | |
14100 (interactive) | |
14101 (save-excursion | |
14102 (set-buffer gnus-article-buffer) | |
14103 (let ((buffer-read-only nil)) | |
14104 (widen) | |
14105 (goto-char (point-min)) | |
14106 (search-forward "\n\n" nil t) | |
14107 (end-of-line 1) | |
14108 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$") | |
14109 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?") | |
14110 (adaptive-fill-mode t)) | |
14111 (while (not (eobp)) | |
14112 (and (>= (current-column) (min fill-column (window-width))) | |
14113 (/= (preceding-char) ?:) | |
14114 (fill-paragraph nil)) | |
14115 (end-of-line 2)))))) | |
14116 | |
14117 (defun gnus-article-remove-cr () | |
14118 "Remove carriage returns from an article." | |
14119 (interactive) | |
14120 (save-excursion | |
14121 (set-buffer gnus-article-buffer) | |
14122 (let ((buffer-read-only nil)) | |
14123 (goto-char (point-min)) | |
14124 (while (search-forward "\r" nil t) | |
14125 (replace-match "" t t))))) | |
14126 | |
14127 (defun gnus-article-remove-trailing-blank-lines () | |
14128 "Remove all trailing blank lines from the article." | |
14129 (interactive) | |
14130 (save-excursion | |
14131 (set-buffer gnus-article-buffer) | |
14132 (let ((buffer-read-only nil)) | |
14133 (goto-char (point-max)) | |
14134 (delete-region | |
14135 (point) | |
14136 (progn | |
14137 (while (looking-at "^[ \t]*$") | |
14138 (forward-line -1)) | |
14139 (forward-line 1) | |
14140 (point)))))) | |
14141 | |
14142 (defun gnus-article-display-x-face (&optional force) | |
14143 "Look for an X-Face header and display it if present." | |
14144 (interactive (list 'force)) | |
14145 (save-excursion | |
14146 (set-buffer gnus-article-buffer) | |
14147 ;; Delete the old process, if any. | |
14148 (when (process-status "gnus-x-face") | |
14149 (delete-process "gnus-x-face")) | |
14150 (let ((inhibit-point-motion-hooks t) | |
14151 (case-fold-search nil) | |
14152 from) | |
14153 (save-restriction | |
14154 (nnheader-narrow-to-headers) | |
14155 (setq from (message-fetch-field "from")) | |
14156 (goto-char (point-min)) | |
14157 (when (and gnus-article-x-face-command | |
14158 (or force | |
14159 ;; Check whether this face is censored. | |
14160 (not gnus-article-x-face-too-ugly) | |
14161 (and gnus-article-x-face-too-ugly from | |
14162 (not (string-match gnus-article-x-face-too-ugly | |
14163 from)))) | |
14164 ;; Has to be present. | |
14165 (re-search-forward "^X-Face: " nil t)) | |
14166 ;; We now have the area of the buffer where the X-Face is stored. | |
14167 (let ((beg (point)) | |
14168 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t)))) | |
14169 ;; We display the face. | |
14170 (if (symbolp gnus-article-x-face-command) | |
14171 ;; The command is a lisp function, so we call it. | |
14172 (if (gnus-functionp gnus-article-x-face-command) | |
14173 (funcall gnus-article-x-face-command beg end) | |
14174 (error "%s is not a function" gnus-article-x-face-command)) | |
14175 ;; The command is a string, so we interpret the command | |
14176 ;; as a, well, command, and fork it off. | |
14177 (let ((process-connection-type nil)) | |
14178 (process-kill-without-query | |
14179 (start-process | |
14180 "gnus-x-face" nil shell-file-name shell-command-switch | |
14181 gnus-article-x-face-command)) | |
14182 (process-send-region "gnus-x-face" beg end) | |
14183 (process-send-eof "gnus-x-face"))))))))) | |
14184 | |
14185 (defalias 'gnus-headers-decode-quoted-printable 'gnus-decode-rfc1522) | |
14186 (defun gnus-decode-rfc1522 () | |
14187 "Hack to remove QP encoding from headers." | |
14188 (let ((case-fold-search t) | |
14189 (inhibit-point-motion-hooks t) | |
14190 (buffer-read-only nil) | |
14191 string) | |
14192 (save-restriction | |
14193 (narrow-to-region | |
14194 (goto-char (point-min)) | |
14195 (or (search-forward "\n\n" nil t) (point-max))) | |
14196 | |
14197 (while (re-search-forward | |
14198 "=\\?iso-8859-1\\?q\\?\\([^?\t\n]*\\)\\?=" nil t) | |
14199 (setq string (match-string 1)) | |
14200 (narrow-to-region (match-beginning 0) (match-end 0)) | |
14201 (delete-region (point-min) (point-max)) | |
14202 (insert string) | |
14203 (gnus-mime-decode-quoted-printable (goto-char (point-min)) (point-max)) | |
14204 (subst-char-in-region (point-min) (point-max) ?_ ? ) | |
14205 (widen) | |
14206 (goto-char (point-min)))))) | |
14207 | |
14208 (defun gnus-article-de-quoted-unreadable (&optional force) | |
14209 "Do a naive translation of a quoted-printable-encoded article. | |
14210 This is in no way, shape or form meant as a replacement for real MIME | |
14211 processing, but is simply a stop-gap measure until MIME support is | |
14212 written. | |
14213 If FORCE, decode the article whether it is marked as quoted-printable | |
14214 or not." | |
14215 (interactive (list 'force)) | |
14216 (save-excursion | |
14217 (set-buffer gnus-article-buffer) | |
14218 (let ((case-fold-search t) | |
14219 (buffer-read-only nil) | |
14220 (type (gnus-fetch-field "content-transfer-encoding"))) | |
14221 (gnus-decode-rfc1522) | |
14222 (when (or force | |
14223 (and type (string-match "quoted-printable" (downcase type)))) | |
14224 (goto-char (point-min)) | |
14225 (search-forward "\n\n" nil 'move) | |
14226 (gnus-mime-decode-quoted-printable (point) (point-max)))))) | |
14227 | |
14228 (defun gnus-mime-decode-quoted-printable (from to) | |
14229 "Decode Quoted-Printable in the region between FROM and TO." | |
14230 (interactive "r") | |
14231 (goto-char from) | |
14232 (while (search-forward "=" to t) | |
14233 (cond ((eq (following-char) ?\n) | |
14234 (delete-char -1) | |
14235 (delete-char 1)) | |
14236 ((looking-at "[0-9A-F][0-9A-F]") | |
14237 (subst-char-in-region | |
14238 (1- (point)) (point) ?= | |
14239 (hexl-hex-string-to-integer | |
14240 (buffer-substring (point) (+ 2 (point))))) | |
14241 (delete-char 2)) | |
14242 ((looking-at "=") | |
14243 (delete-char 1)) | |
14244 ((gnus-message 3 "Malformed MIME quoted-printable message"))))) | |
14245 | |
14246 (defun gnus-article-hide-pgp (&optional arg) | |
14247 "Toggle hiding of any PGP headers and signatures in the current article. | |
14248 If given a negative prefix, always show; if given a positive prefix, | |
14249 always hide." | |
14250 (interactive (gnus-hidden-arg)) | |
14251 (unless (gnus-article-check-hidden-text 'pgp arg) | |
14252 (save-excursion | |
14253 (set-buffer gnus-article-buffer) | |
14254 (let ((props (nconc (list 'gnus-type 'pgp) gnus-hidden-properties)) | |
14255 buffer-read-only beg end) | |
14256 (widen) | |
14257 (goto-char (point-min)) | |
14258 ;; Hide the "header". | |
14259 (and (search-forward "\n-----BEGIN PGP SIGNED MESSAGE-----\n" nil t) | |
14260 (gnus-hide-text (match-beginning 0) (match-end 0) props)) | |
14261 (setq beg (point)) | |
14262 ;; Hide the actual signature. | |
14263 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t) | |
14264 (setq end (1+ (match-beginning 0))) | |
14265 (gnus-hide-text | |
14266 end | |
14267 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t) | |
14268 (match-end 0) | |
14269 ;; Perhaps we shouldn't hide to the end of the buffer | |
14270 ;; if there is no end to the signature? | |
14271 (point-max)) | |
14272 props)) | |
14273 ;; Hide "- " PGP quotation markers. | |
14274 (when (and beg end) | |
14275 (narrow-to-region beg end) | |
14276 (goto-char (point-min)) | |
14277 (while (re-search-forward "^- " nil t) | |
14278 (gnus-hide-text (match-beginning 0) (match-end 0) props)) | |
14279 (widen)))))) | |
14280 | |
14281 (defun gnus-article-hide-signature (&optional arg) | |
14282 "Hide the signature in the current article. | |
14283 If given a negative prefix, always show; if given a positive prefix, | |
14284 always hide." | |
14285 (interactive (gnus-hidden-arg)) | |
14286 (unless (gnus-article-check-hidden-text 'signature arg) | |
14287 (save-excursion | |
14288 (set-buffer gnus-article-buffer) | |
14289 (save-restriction | |
14290 (let ((buffer-read-only nil)) | |
14291 (when (gnus-narrow-to-signature) | |
14292 (gnus-hide-text-type (point-min) (point-max) 'signature))))))) | |
14293 | |
14294 (defun gnus-article-strip-leading-blank-lines () | |
14295 "Remove all blank lines from the beginning of the article." | |
14296 (interactive) | |
14297 (save-excursion | |
14298 (set-buffer gnus-article-buffer) | |
14299 (let (buffer-read-only) | |
14300 (goto-char (point-min)) | |
14301 (when (search-forward "\n\n" nil t) | |
14302 (while (looking-at "[ \t]$") | |
14303 (gnus-delete-line)))))) | |
14304 | |
14305 (defvar mime::preview/content-list) | |
14306 (defvar mime::preview-content-info/point-min) | |
14307 (defun gnus-narrow-to-signature () | |
14308 "Narrow to the signature." | |
14309 (widen) | |
14310 (if (and (boundp 'mime::preview/content-list) | |
14311 mime::preview/content-list) | |
14312 (let ((pcinfo (car (last mime::preview/content-list)))) | |
14313 (condition-case () | |
14314 (narrow-to-region | |
14315 (funcall (intern "mime::preview-content-info/point-min") pcinfo) | |
14316 (point-max)) | |
14317 (error nil)))) | |
14318 (goto-char (point-max)) | |
14319 (when (re-search-backward gnus-signature-separator nil t) | |
14320 (forward-line 1) | |
14321 (when (or (null gnus-signature-limit) | |
14322 (and (numberp gnus-signature-limit) | |
14323 (< (- (point-max) (point)) gnus-signature-limit)) | |
14324 (and (gnus-functionp gnus-signature-limit) | |
14325 (funcall gnus-signature-limit)) | |
14326 (and (stringp gnus-signature-limit) | |
14327 (not (re-search-forward gnus-signature-limit nil t)))) | |
14328 (narrow-to-region (point) (point-max)) | |
14329 t))) | |
14330 | |
14331 (defun gnus-hidden-arg () | |
14332 "Return the current prefix arg as a number, or 0 if no prefix." | |
14333 (list (if current-prefix-arg | |
14334 (prefix-numeric-value current-prefix-arg) | |
14335 0))) | |
14336 | |
14337 (defun gnus-article-check-hidden-text (type arg) | |
14338 "Return nil if hiding is necessary. | |
14339 Arg can be nil or a number. Nil and positive means hide, negative | |
14340 means show, 0 means toggle." | |
14341 (save-excursion | |
14342 (set-buffer gnus-article-buffer) | |
14343 (let ((hide (gnus-article-hidden-text-p type))) | |
14344 (cond | |
14345 ((or (null arg) | |
14346 (> arg 0)) | |
14347 nil) | |
14348 ((< arg 0) | |
14349 (gnus-article-show-hidden-text type)) | |
14350 (t | |
14351 (if (eq hide 'hidden) | |
14352 (gnus-article-show-hidden-text type) | |
14353 nil)))))) | |
14354 | |
14355 (defun gnus-article-hidden-text-p (type) | |
14356 "Say whether the current buffer contains hidden text of type TYPE." | |
14357 (let ((pos (text-property-any (point-min) (point-max) 'gnus-type type))) | |
14358 (when pos | |
14359 (if (get-text-property pos 'invisible) | |
14360 'hidden | |
14361 'shown)))) | |
14362 | |
14363 (defun gnus-article-hide (&optional arg force) | |
14364 "Hide all the gruft in the current article. | |
14365 This means that PGP stuff, signatures, cited text and (some) | |
14366 headers will be hidden. | |
14367 If given a prefix, show the hidden text instead." | |
14368 (interactive (list current-prefix-arg 'force)) | |
14369 (gnus-article-hide-headers arg) | |
14370 (gnus-article-hide-pgp arg) | |
14371 (gnus-article-hide-citation-maybe arg force) | |
14372 (gnus-article-hide-signature arg)) | |
14373 | |
14374 (defun gnus-article-show-hidden-text (type &optional hide) | |
14375 "Show all hidden text of type TYPE. | |
14376 If HIDE, hide the text instead." | |
14377 (save-excursion | |
14378 (set-buffer gnus-article-buffer) | |
14379 (let ((buffer-read-only nil) | |
14380 (inhibit-point-motion-hooks t) | |
14381 (beg (point-min))) | |
14382 (while (gnus-goto-char (text-property-any | |
14383 beg (point-max) 'gnus-type type)) | |
14384 (setq beg (point)) | |
14385 (forward-char) | |
14386 (if hide | |
14387 (gnus-hide-text beg (point) gnus-hidden-properties) | |
14388 (gnus-unhide-text beg (point))) | |
14389 (setq beg (point))) | |
14390 t))) | |
14391 | |
14392 (defvar gnus-article-time-units | |
14393 `((year . ,(* 365.25 24 60 60)) | |
14394 (week . ,(* 7 24 60 60)) | |
14395 (day . ,(* 24 60 60)) | |
14396 (hour . ,(* 60 60)) | |
14397 (minute . 60) | |
14398 (second . 1)) | |
14399 "Mapping from time units to seconds.") | |
14400 | |
14401 (defun gnus-article-date-ut (&optional type highlight) | |
14402 "Convert DATE date to universal time in the current article. | |
14403 If TYPE is `local', convert to local time; if it is `lapsed', output | |
14404 how much time has lapsed since DATE." | |
14405 (interactive (list 'ut t)) | |
14406 (let* ((header (or gnus-current-headers | |
14407 (gnus-summary-article-header) "")) | |
14408 (date (and (vectorp header) (mail-header-date header))) | |
14409 (date-regexp "^Date: \\|^X-Sent: ") | |
14410 (now (current-time)) | |
14411 (inhibit-point-motion-hooks t) | |
14412 bface eface) | |
14413 (when (and date (not (string= date ""))) | |
14414 (save-excursion | |
14415 (set-buffer gnus-article-buffer) | |
14416 (save-restriction | |
14417 (nnheader-narrow-to-headers) | |
14418 (let ((buffer-read-only nil)) | |
14419 ;; Delete any old Date headers. | |
14420 (if (re-search-forward date-regexp nil t) | |
14421 (progn | |
14422 (setq bface (get-text-property (gnus-point-at-bol) 'face) | |
14423 eface (get-text-property (1- (gnus-point-at-eol)) | |
14424 'face)) | |
14425 (message-remove-header date-regexp t) | |
14426 (beginning-of-line)) | |
14427 (goto-char (point-max))) | |
14428 (insert (gnus-make-date-line date type)) | |
14429 ;; Do highlighting. | |
14430 (forward-line -1) | |
14431 (when (and (gnus-visual-p 'article-highlight 'highlight) | |
14432 (looking-at "\\([^:]+\\): *\\(.*\\)$")) | |
14433 (gnus-put-text-property (match-beginning 1) (match-end 1) | |
14434 'face bface) | |
14435 (gnus-put-text-property (match-beginning 2) (match-end 2) | |
14436 'face eface)))))))) | |
14437 | |
14438 (defun gnus-make-date-line (date type) | |
14439 "Return a DATE line of TYPE." | |
14440 (cond | |
14441 ;; Convert to the local timezone. We have to slap a | |
14442 ;; `condition-case' round the calls to the timezone | |
14443 ;; functions since they aren't particularly resistant to | |
14444 ;; buggy dates. | |
14445 ((eq type 'local) | |
14446 (concat "Date: " (condition-case () | |
14447 (timezone-make-date-arpa-standard date) | |
14448 (error date)) | |
14449 "\n")) | |
14450 ;; Convert to Universal Time. | |
14451 ((eq type 'ut) | |
14452 (concat "Date: " | |
14453 (condition-case () | |
14454 (timezone-make-date-arpa-standard date nil "UT") | |
14455 (error date)) | |
14456 "\n")) | |
14457 ;; Get the original date from the article. | |
14458 ((eq type 'original) | |
14459 (concat "Date: " date "\n")) | |
14460 ;; Do an X-Sent lapsed format. | |
14461 ((eq type 'lapsed) | |
14462 ;; If the date is seriously mangled, the timezone | |
14463 ;; functions are liable to bug out, so we condition-case | |
14464 ;; the entire thing. | |
14465 (let* ((now (current-time)) | |
14466 (real-time | |
14467 (condition-case () | |
14468 (gnus-time-minus | |
14469 (gnus-encode-date | |
14470 (timezone-make-date-arpa-standard | |
14471 (current-time-string now) | |
14472 (current-time-zone now) "UT")) | |
14473 (gnus-encode-date | |
14474 (timezone-make-date-arpa-standard | |
14475 date nil "UT"))) | |
14476 (error '(0 0)))) | |
14477 (real-sec (+ (* (float (car real-time)) 65536) | |
14478 (cadr real-time))) | |
14479 (sec (abs real-sec)) | |
14480 num prev) | |
14481 (cond | |
14482 ((equal real-time '(0 0)) | |
14483 "X-Sent: Unknown\n") | |
14484 ((zerop sec) | |
14485 "X-Sent: Now\n") | |
14486 (t | |
14487 (concat | |
14488 "X-Sent: " | |
14489 ;; This is a bit convoluted, but basically we go | |
14490 ;; through the time units for years, weeks, etc, | |
14491 ;; and divide things to see whether that results | |
14492 ;; in positive answers. | |
14493 (mapconcat | |
14494 (lambda (unit) | |
14495 (if (zerop (setq num (ffloor (/ sec (cdr unit))))) | |
14496 ;; The (remaining) seconds are too few to | |
14497 ;; be divided into this time unit. | |
14498 "" | |
14499 ;; It's big enough, so we output it. | |
14500 (setq sec (- sec (* num (cdr unit)))) | |
14501 (prog1 | |
14502 (concat (if prev ", " "") (int-to-string | |
14503 (floor num)) | |
14504 " " (symbol-name (car unit)) | |
14505 (if (> num 1) "s" "")) | |
14506 (setq prev t)))) | |
14507 gnus-article-time-units "") | |
14508 ;; If dates are odd, then it might appear like the | |
14509 ;; article was sent in the future. | |
14510 (if (> real-sec 0) | |
14511 " ago\n" | |
14512 " in the future\n")))))) | |
14513 (t | |
14514 (error "Unknown conversion type: %s" type)))) | |
14515 | |
14516 (defun gnus-article-date-local (&optional highlight) | |
14517 "Convert the current article date to the local timezone." | |
14518 (interactive (list t)) | |
14519 (gnus-article-date-ut 'local highlight)) | |
14520 | |
14521 (defun gnus-article-date-original (&optional highlight) | |
14522 "Convert the current article date to what it was originally. | |
14523 This is only useful if you have used some other date conversion | |
14524 function and want to see what the date was before converting." | |
14525 (interactive (list t)) | |
14526 (gnus-article-date-ut 'original highlight)) | |
14527 | |
14528 (defun gnus-article-date-lapsed (&optional highlight) | |
14529 "Convert the current article date to time lapsed since it was sent." | |
14530 (interactive (list t)) | |
14531 (gnus-article-date-ut 'lapsed highlight)) | |
14532 | |
14533 (defun gnus-article-maybe-highlight () | |
14534 "Do some article highlighting if `gnus-visual' is non-nil." | |
14535 (if (gnus-visual-p 'article-highlight 'highlight) | |
14536 (gnus-article-highlight-some))) | |
14537 | |
14538 ;;; Article savers. | |
14539 | |
14540 (defun gnus-output-to-rmail (file-name) | |
14541 "Append the current article to an Rmail file named FILE-NAME." | |
14542 (require 'rmail) | |
14543 ;; Most of these codes are borrowed from rmailout.el. | |
14544 (setq file-name (expand-file-name file-name)) | |
14545 (setq rmail-default-rmail-file file-name) | |
14546 (let ((artbuf (current-buffer)) | |
14547 (tmpbuf (get-buffer-create " *Gnus-output*"))) | |
14548 (save-excursion | |
14549 (or (get-file-buffer file-name) | |
14550 (file-exists-p file-name) | |
14551 (if (gnus-yes-or-no-p | |
14552 (concat "\"" file-name "\" does not exist, create it? ")) | |
14553 (let ((file-buffer (create-file-buffer file-name))) | |
14554 (save-excursion | |
14555 (set-buffer file-buffer) | |
14556 (rmail-insert-rmail-file-header) | |
14557 (let ((require-final-newline nil)) | |
14558 (write-region (point-min) (point-max) file-name t 1))) | |
14559 (kill-buffer file-buffer)) | |
14560 (error "Output file does not exist"))) | |
14561 (set-buffer tmpbuf) | |
14562 (buffer-disable-undo (current-buffer)) | |
14563 (erase-buffer) | |
14564 (insert-buffer-substring artbuf) | |
14565 (gnus-convert-article-to-rmail) | |
14566 ;; Decide whether to append to a file or to an Emacs buffer. | |
14567 (let ((outbuf (get-file-buffer file-name))) | |
14568 (if (not outbuf) | |
14569 (append-to-file (point-min) (point-max) file-name) | |
14570 ;; File has been visited, in buffer OUTBUF. | |
14571 (set-buffer outbuf) | |
14572 (let ((buffer-read-only nil) | |
14573 (msg (and (boundp 'rmail-current-message) | |
14574 (symbol-value 'rmail-current-message)))) | |
14575 ;; If MSG is non-nil, buffer is in RMAIL mode. | |
14576 (if msg | |
14577 (progn (widen) | |
14578 (narrow-to-region (point-max) (point-max)))) | |
14579 (insert-buffer-substring tmpbuf) | |
14580 (if msg | |
14581 (progn | |
14582 (goto-char (point-min)) | |
14583 (widen) | |
14584 (search-backward "\^_") | |
14585 (narrow-to-region (point) (point-max)) | |
14586 (goto-char (1+ (point-min))) | |
14587 (rmail-count-new-messages t) | |
14588 (rmail-show-message msg))))))) | |
14589 (kill-buffer tmpbuf))) | |
14590 | |
14591 (defun gnus-output-to-file (file-name) | |
14592 "Append the current article to a file named FILE-NAME." | |
14593 (let ((artbuf (current-buffer))) | |
14594 (nnheader-temp-write nil | |
14595 (insert-buffer-substring artbuf) | |
14596 ;; Append newline at end of the buffer as separator, and then | |
14597 ;; save it to file. | |
14598 (goto-char (point-max)) | |
14599 (insert "\n") | |
14600 (append-to-file (point-min) (point-max) file-name)))) | |
14601 | |
14602 (defun gnus-convert-article-to-rmail () | |
14603 "Convert article in current buffer to Rmail message format." | |
14604 (let ((buffer-read-only nil)) | |
14605 ;; Convert article directly into Babyl format. | |
14606 ;; Suggested by Rob Austein <sra@lcs.mit.edu> | |
14607 (goto-char (point-min)) | |
14608 (insert "\^L\n0, unseen,,\n*** EOOH ***\n") | |
14609 (while (search-forward "\n\^_" nil t) ;single char | |
14610 (replace-match "\n^_" t t)) ;2 chars: "^" and "_" | |
14611 (goto-char (point-max)) | |
14612 (insert "\^_"))) | |
14613 | |
14614 (defun gnus-narrow-to-page (&optional arg) | |
14615 "Narrow the article buffer to a page. | |
14616 If given a numerical ARG, move forward ARG pages." | |
14617 (interactive "P") | |
14618 (setq arg (if arg (prefix-numeric-value arg) 0)) | |
14619 (save-excursion | |
14620 (set-buffer gnus-article-buffer) | |
14621 (goto-char (point-min)) | |
14622 (widen) | |
14623 (when (gnus-visual-p 'page-marker) | |
14624 (let ((buffer-read-only nil)) | |
14625 (gnus-remove-text-with-property 'gnus-prev) | |
14626 (gnus-remove-text-with-property 'gnus-next))) | |
14627 (when | |
14628 (cond ((< arg 0) | |
14629 (re-search-backward page-delimiter nil 'move (1+ (abs arg)))) | |
14630 ((> arg 0) | |
14631 (re-search-forward page-delimiter nil 'move arg))) | |
14632 (goto-char (match-end 0))) | |
14633 (narrow-to-region | |
14634 (point) | |
14635 (if (re-search-forward page-delimiter nil 'move) | |
14636 (match-beginning 0) | |
14637 (point))) | |
14638 (when (and (gnus-visual-p 'page-marker) | |
14639 (not (= (point-min) 1))) | |
14640 (save-excursion | |
14641 (goto-char (point-min)) | |
14642 (gnus-insert-prev-page-button))) | |
14643 (when (and (gnus-visual-p 'page-marker) | |
14644 (not (= (1- (point-max)) (buffer-size)))) | |
14645 (save-excursion | |
14646 (goto-char (point-max)) | |
14647 (gnus-insert-next-page-button))))) | |
14648 | |
14649 ;; Article mode commands | |
14650 | |
14651 (defun gnus-article-goto-next-page () | |
14652 "Show the next page of the article." | |
14653 (interactive) | |
14654 (when (gnus-article-next-page) | |
14655 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n)))) | |
14656 | |
14657 (defun gnus-article-goto-prev-page () | |
14658 "Show the next page of the article." | |
14659 (interactive) | |
14660 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?n)) | |
14661 (gnus-article-prev-page nil))) | |
14662 | |
14663 (defun gnus-article-next-page (&optional lines) | |
14664 "Show the next page of the current article. | |
14665 If end of article, return non-nil. Otherwise return nil. | |
14666 Argument LINES specifies lines to be scrolled up." | |
14667 (interactive "p") | |
14668 (move-to-window-line -1) | |
14669 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo) | |
14670 (if (save-excursion | |
14671 (end-of-line) | |
14672 (and (pos-visible-in-window-p) ;Not continuation line. | |
14673 (eobp))) | |
14674 ;; Nothing in this page. | |
14675 (if (or (not gnus-break-pages) | |
14676 (save-excursion | |
14677 (save-restriction | |
14678 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer? | |
14679 t ;Nothing more. | |
14680 (gnus-narrow-to-page 1) ;Go to next page. | |
14681 nil) | |
14682 ;; More in this page. | |
14683 (condition-case () | |
14684 (scroll-up lines) | |
14685 (end-of-buffer | |
14686 ;; Long lines may cause an end-of-buffer error. | |
14687 (goto-char (point-max)))) | |
14688 (move-to-window-line 0) | |
14689 nil)) | |
14690 | |
14691 (defun gnus-article-prev-page (&optional lines) | |
14692 "Show previous page of current article. | |
14693 Argument LINES specifies lines to be scrolled down." | |
14694 (interactive "p") | |
14695 (move-to-window-line 0) | |
14696 (if (and gnus-break-pages | |
14697 (bobp) | |
14698 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer? | |
14699 (progn | |
14700 (gnus-narrow-to-page -1) ;Go to previous page. | |
14701 (goto-char (point-max)) | |
14702 (recenter -1)) | |
14703 (prog1 | |
14704 (condition-case () | |
14705 (scroll-down lines) | |
14706 (error nil)) | |
14707 (move-to-window-line 0)))) | |
14708 | |
14709 (defun gnus-article-refer-article () | |
14710 "Read article specified by message-id around point." | |
14711 (interactive) | |
14712 (let ((point (point))) | |
14713 (search-forward ">" nil t) ;Move point to end of "<....>". | |
14714 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t) | |
14715 (let ((message-id (match-string 1))) | |
14716 (goto-char point) | |
14717 (set-buffer gnus-summary-buffer) | |
14718 (gnus-summary-refer-article message-id)) | |
14719 (goto-char (point)) | |
14720 (error "No references around point")))) | |
14721 | |
14722 (defun gnus-article-show-summary () | |
14723 "Reconfigure windows to show summary buffer." | |
14724 (interactive) | |
14725 (gnus-configure-windows 'article) | |
14726 (gnus-summary-goto-subject gnus-current-article)) | |
14727 | |
14728 (defun gnus-article-describe-briefly () | |
14729 "Describe article mode commands briefly." | |
14730 (interactive) | |
14731 (gnus-message 6 | |
14732 (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"))) | |
14733 | |
14734 (defun gnus-article-summary-command () | |
14735 "Execute the last keystroke in the summary buffer." | |
14736 (interactive) | |
14737 (let ((obuf (current-buffer)) | |
14738 (owin (current-window-configuration)) | |
14739 func) | |
14740 (switch-to-buffer gnus-summary-buffer 'norecord) | |
14741 (setq func (lookup-key (current-local-map) (this-command-keys))) | |
14742 (call-interactively func) | |
14743 (set-buffer obuf) | |
14744 (set-window-configuration owin) | |
14745 (set-window-point (get-buffer-window (current-buffer)) (point)))) | |
14746 | |
14747 (defun gnus-article-summary-command-nosave () | |
14748 "Execute the last keystroke in the summary buffer." | |
14749 (interactive) | |
14750 (let (func) | |
14751 (pop-to-buffer gnus-summary-buffer 'norecord) | |
14752 (setq func (lookup-key (current-local-map) (this-command-keys))) | |
14753 (call-interactively func))) | |
14754 | |
14755 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window) | |
14756 "Read a summary buffer key sequence and execute it from the article buffer." | |
14757 (interactive "P") | |
14758 (let ((nosaves | |
14759 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F" | |
14760 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP" | |
14761 "=" "^" "\M-^" "|")) | |
14762 keys) | |
14763 (save-excursion | |
14764 (set-buffer gnus-summary-buffer) | |
14765 (push (or key last-command-event) unread-command-events) | |
14766 (setq keys (read-key-sequence nil))) | |
14767 (message "") | |
14768 | |
14769 (if (member keys nosaves) | |
14770 (let (func) | |
14771 (pop-to-buffer gnus-summary-buffer 'norecord) | |
14772 (if (setq func (lookup-key (current-local-map) keys)) | |
14773 (call-interactively func) | |
14774 (ding))) | |
14775 (let ((obuf (current-buffer)) | |
14776 (owin (current-window-configuration)) | |
14777 (opoint (point)) | |
14778 func in-buffer) | |
14779 (if not-restore-window | |
14780 (pop-to-buffer gnus-summary-buffer 'norecord) | |
14781 (switch-to-buffer gnus-summary-buffer 'norecord)) | |
14782 (setq in-buffer (current-buffer)) | |
14783 (if (setq func (lookup-key (current-local-map) keys)) | |
14784 (call-interactively func) | |
14785 (ding)) | |
14786 (when (eq in-buffer (current-buffer)) | |
14787 (set-buffer obuf) | |
14788 (unless not-restore-window | |
14789 (set-window-configuration owin)) | |
14790 (set-window-point (get-buffer-window (current-buffer)) opoint)))))) | |
14791 | |
14792 | |
14793 ;;; | |
14794 ;;; Kill file handling. | |
14795 ;;; | |
14796 | |
14797 ;;;###autoload | |
14798 (defalias 'gnus-batch-kill 'gnus-batch-score) | |
14799 ;;;###autoload | |
14800 (defun gnus-batch-score () | |
14801 "Run batched scoring. | |
14802 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ... | |
14803 Newsgroups is a list of strings in Bnews format. If you want to score | |
14804 the comp hierarchy, you'd say \"comp.all\". If you would not like to | |
14805 score the alt hierarchy, you'd say \"!alt.all\"." | |
14806 (interactive) | |
14807 (let* ((yes-and-no | |
14808 (gnus-newsrc-parse-options | |
14809 (apply (function concat) | |
14810 (mapcar (lambda (g) (concat g " ")) | |
14811 command-line-args-left)))) | |
14812 (gnus-expert-user t) | |
14813 (nnmail-spool-file nil) | |
14814 (gnus-use-dribble-file nil) | |
14815 (yes (car yes-and-no)) | |
14816 (no (cdr yes-and-no)) | |
14817 group newsrc entry | |
14818 ;; Disable verbose message. | |
14819 gnus-novice-user gnus-large-newsgroup) | |
14820 ;; Eat all arguments. | |
14821 (setq command-line-args-left nil) | |
14822 ;; Start Gnus. | |
14823 (gnus) | |
14824 ;; Apply kills to specified newsgroups in command line arguments. | |
14825 (setq newsrc (cdr gnus-newsrc-alist)) | |
14826 (while newsrc | |
14827 (setq group (caar newsrc)) | |
14828 (setq entry (gnus-gethash group gnus-newsrc-hashtb)) | |
14829 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed) | |
14830 (and (car entry) | |
14831 (or (eq (car entry) t) | |
14832 (not (zerop (car entry))))) | |
14833 (if yes (string-match yes group) t) | |
14834 (or (null no) (not (string-match no group)))) | |
14835 (progn | |
14836 (gnus-summary-read-group group nil t nil t) | |
14837 (and (eq (current-buffer) (get-buffer gnus-summary-buffer)) | |
14838 (gnus-summary-exit)))) | |
14839 (setq newsrc (cdr newsrc))) | |
14840 ;; Exit Emacs. | |
14841 (switch-to-buffer gnus-group-buffer) | |
14842 (gnus-group-save-newsrc))) | |
14843 | |
14844 (defun gnus-apply-kill-file () | |
14845 "Apply a kill file to the current newsgroup. | |
14846 Returns the number of articles marked as read." | |
14847 (if (or (file-exists-p (gnus-newsgroup-kill-file nil)) | |
14848 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name))) | |
14849 (gnus-apply-kill-file-internal) | |
14850 0)) | |
14851 | |
14852 (defun gnus-kill-save-kill-buffer () | |
14853 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name))) | |
14854 (when (get-file-buffer file) | |
14855 (save-excursion | |
14856 (set-buffer (get-file-buffer file)) | |
14857 (and (buffer-modified-p) (save-buffer)) | |
14858 (kill-buffer (current-buffer)))))) | |
14859 | |
14860 (defvar gnus-kill-file-name "KILL" | |
14861 "Suffix of the kill files.") | |
14862 | |
14863 (defun gnus-newsgroup-kill-file (newsgroup) | |
14864 "Return the name of a kill file name for NEWSGROUP. | |
14865 If NEWSGROUP is nil, return the global kill file name instead." | |
14866 (cond | |
14867 ;; The global KILL file is placed at top of the directory. | |
14868 ((or (null newsgroup) | |
14869 (string-equal newsgroup "")) | |
14870 (expand-file-name gnus-kill-file-name | |
14871 gnus-kill-files-directory)) | |
14872 ;; Append ".KILL" to newsgroup name. | |
14873 ((gnus-use-long-file-name 'not-kill) | |
14874 (expand-file-name (concat (gnus-newsgroup-savable-name newsgroup) | |
14875 "." gnus-kill-file-name) | |
14876 gnus-kill-files-directory)) | |
14877 ;; Place "KILL" under the hierarchical directory. | |
14878 (t | |
14879 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup) | |
14880 "/" gnus-kill-file-name) | |
14881 gnus-kill-files-directory)))) | |
14882 | |
14883 | |
14884 ;;; | |
14885 ;;; Dribble file | |
14886 ;;; | |
14887 | |
14888 (defvar gnus-dribble-ignore nil) | |
14889 (defvar gnus-dribble-eval-file nil) | |
14890 | |
14891 (defun gnus-dribble-file-name () | |
14892 "Return the dribble file for the current .newsrc." | |
14893 (concat | |
14894 (if gnus-dribble-directory | |
14895 (concat (file-name-as-directory gnus-dribble-directory) | |
14896 (file-name-nondirectory gnus-current-startup-file)) | |
14897 gnus-current-startup-file) | |
14898 "-dribble")) | |
14899 | |
14900 (defun gnus-dribble-enter (string) | |
14901 "Enter STRING into the dribble buffer." | |
14902 (if (and (not gnus-dribble-ignore) | |
14903 gnus-dribble-buffer | |
14904 (buffer-name gnus-dribble-buffer)) | |
14905 (let ((obuf (current-buffer))) | |
14906 (set-buffer gnus-dribble-buffer) | |
14907 (insert string "\n") | |
14908 (set-window-point (get-buffer-window (current-buffer)) (point-max)) | |
14909 (set-buffer obuf)))) | |
14910 | |
14911 (defun gnus-dribble-read-file () | |
14912 "Read the dribble file from disk." | |
14913 (let ((dribble-file (gnus-dribble-file-name))) | |
14914 (save-excursion | |
14915 (set-buffer (setq gnus-dribble-buffer | |
14916 (get-buffer-create | |
14917 (file-name-nondirectory dribble-file)))) | |
14918 (gnus-add-current-to-buffer-list) | |
14919 (erase-buffer) | |
14920 (setq buffer-file-name dribble-file) | |
14921 (auto-save-mode t) | |
14922 (buffer-disable-undo (current-buffer)) | |
14923 (bury-buffer (current-buffer)) | |
14924 (set-buffer-modified-p nil) | |
14925 (let ((auto (make-auto-save-file-name)) | |
14926 (gnus-dribble-ignore t) | |
14927 modes) | |
14928 (when (or (file-exists-p auto) (file-exists-p dribble-file)) | |
14929 ;; Load whichever file is newest -- the auto save file | |
14930 ;; or the "real" file. | |
14931 (if (file-newer-than-file-p auto dribble-file) | |
14932 (insert-file-contents auto) | |
14933 (insert-file-contents dribble-file)) | |
14934 (unless (zerop (buffer-size)) | |
14935 (set-buffer-modified-p t)) | |
14936 ;; Set the file modes to reflect the .newsrc file modes. | |
14937 (save-buffer) | |
14938 (when (and (file-exists-p gnus-current-startup-file) | |
14939 (setq modes (file-modes gnus-current-startup-file))) | |
14940 (set-file-modes dribble-file modes)) | |
14941 ;; Possibly eval the file later. | |
14942 (when (gnus-y-or-n-p | |
14943 "Auto-save file exists. Do you want to read it? ") | |
14944 (setq gnus-dribble-eval-file t))))))) | |
14945 | |
14946 (defun gnus-dribble-eval-file () | |
14947 (when gnus-dribble-eval-file | |
14948 (setq gnus-dribble-eval-file nil) | |
14949 (save-excursion | |
14950 (let ((gnus-dribble-ignore t)) | |
14951 (set-buffer gnus-dribble-buffer) | |
14952 (eval-buffer (current-buffer)))))) | |
14953 | |
14954 (defun gnus-dribble-delete-file () | |
14955 (when (file-exists-p (gnus-dribble-file-name)) | |
14956 (delete-file (gnus-dribble-file-name))) | |
14957 (when gnus-dribble-buffer | |
14958 (save-excursion | |
14959 (set-buffer gnus-dribble-buffer) | |
14960 (let ((auto (make-auto-save-file-name))) | |
14961 (if (file-exists-p auto) | |
14962 (delete-file auto)) | |
14963 (erase-buffer) | |
14964 (set-buffer-modified-p nil))))) | |
14965 | |
14966 (defun gnus-dribble-save () | |
14967 (when (and gnus-dribble-buffer | |
14968 (buffer-name gnus-dribble-buffer)) | |
14969 (save-excursion | |
14970 (set-buffer gnus-dribble-buffer) | |
14971 (save-buffer)))) | |
14972 | |
14973 (defun gnus-dribble-clear () | |
14974 (when (gnus-buffer-exists-p gnus-dribble-buffer) | |
14975 (save-excursion | |
14976 (set-buffer gnus-dribble-buffer) | |
14977 (erase-buffer) | |
14978 (set-buffer-modified-p nil) | |
14979 (setq buffer-saved-size (buffer-size))))) | |
14980 | |
14981 | |
14982 ;;; | |
14983 ;;; Server Communication | |
14984 ;;; | |
14985 | |
14986 (defun gnus-start-news-server (&optional confirm) | |
14987 "Open a method for getting news. | |
14988 If CONFIRM is non-nil, the user will be asked for an NNTP server." | |
14989 (let (how) | |
14990 (if gnus-current-select-method | |
14991 ;; Stream is already opened. | |
14992 nil | |
14993 ;; Open NNTP server. | |
14994 (if (null gnus-nntp-service) (setq gnus-nntp-server nil)) | |
14995 (if confirm | |
14996 (progn | |
14997 ;; Read server name with completion. | |
14998 (setq gnus-nntp-server | |
14999 (completing-read "NNTP server: " | |
15000 (mapcar (lambda (server) (list server)) | |
15001 (cons (list gnus-nntp-server) | |
15002 gnus-secondary-servers)) | |
15003 nil nil gnus-nntp-server)))) | |
15004 | |
15005 (if (and gnus-nntp-server | |
15006 (stringp gnus-nntp-server) | |
15007 (not (string= gnus-nntp-server ""))) | |
15008 (setq gnus-select-method | |
15009 (cond ((or (string= gnus-nntp-server "") | |
15010 (string= gnus-nntp-server "::")) | |
15011 (list 'nnspool (system-name))) | |
15012 ((string-match "^:" gnus-nntp-server) | |
15013 (list 'nnmh gnus-nntp-server | |
15014 (list 'nnmh-directory | |
15015 (file-name-as-directory | |
15016 (expand-file-name | |
15017 (concat "~/" (substring | |
15018 gnus-nntp-server 1))))) | |
15019 (list 'nnmh-get-new-mail nil))) | |
15020 (t | |
15021 (list 'nntp gnus-nntp-server))))) | |
15022 | |
15023 (setq how (car gnus-select-method)) | |
15024 (cond ((eq how 'nnspool) | |
15025 (require 'nnspool) | |
15026 (gnus-message 5 "Looking up local news spool...")) | |
15027 ((eq how 'nnmh) | |
15028 (require 'nnmh) | |
15029 (gnus-message 5 "Looking up mh spool...")) | |
15030 (t | |
15031 (require 'nntp))) | |
15032 (setq gnus-current-select-method gnus-select-method) | |
15033 (run-hooks 'gnus-open-server-hook) | |
15034 (or | |
15035 ;; gnus-open-server-hook might have opened it | |
15036 (gnus-server-opened gnus-select-method) | |
15037 (gnus-open-server gnus-select-method) | |
15038 (gnus-y-or-n-p | |
15039 (format | |
15040 "%s (%s) open error: '%s'. Continue? " | |
15041 (car gnus-select-method) (cadr gnus-select-method) | |
15042 (gnus-status-message gnus-select-method))) | |
15043 (gnus-error 1 "Couldn't open server on %s" | |
15044 (nth 1 gnus-select-method)))))) | |
15045 | |
15046 (defun gnus-check-group (group) | |
15047 "Try to make sure that the server where GROUP exists is alive." | |
15048 (let ((method (gnus-find-method-for-group group))) | |
15049 (or (gnus-server-opened method) | |
15050 (gnus-open-server method)))) | |
15051 | |
15052 (defun gnus-check-server (&optional method silent) | |
15053 "Check whether the connection to METHOD is down. | |
15054 If METHOD is nil, use `gnus-select-method'. | |
15055 If it is down, start it up (again)." | |
15056 (let ((method (or method gnus-select-method))) | |
15057 ;; Transform virtual server names into select methods. | |
15058 (when (stringp method) | |
15059 (setq method (gnus-server-to-method method))) | |
15060 (if (gnus-server-opened method) | |
15061 ;; The stream is already opened. | |
15062 t | |
15063 ;; Open the server. | |
15064 (unless silent | |
15065 (gnus-message 5 "Opening %s server%s..." (car method) | |
15066 (if (equal (nth 1 method) "") "" | |
15067 (format " on %s" (nth 1 method))))) | |
15068 (run-hooks 'gnus-open-server-hook) | |
15069 (prog1 | |
15070 (gnus-open-server method) | |
15071 (unless silent | |
15072 (message "")))))) | |
15073 | |
15074 (defun gnus-get-function (method function &optional noerror) | |
15075 "Return a function symbol based on METHOD and FUNCTION." | |
15076 ;; Translate server names into methods. | |
15077 (unless method | |
15078 (error "Attempted use of a nil select method")) | |
15079 (when (stringp method) | |
15080 (setq method (gnus-server-to-method method))) | |
15081 (let ((func (intern (format "%s-%s" (car method) function)))) | |
15082 ;; If the functions isn't bound, we require the backend in | |
15083 ;; question. | |
15084 (unless (fboundp func) | |
15085 (require (car method)) | |
15086 (when (and (not (fboundp func)) | |
15087 (not noerror)) | |
15088 ;; This backend doesn't implement this function. | |
15089 (error "No such function: %s" func))) | |
15090 func)) | |
15091 | |
15092 | |
15093 ;;; | |
15094 ;;; Interface functions to the backends. | |
15095 ;;; | |
15096 | |
15097 (defun gnus-open-server (method) | |
15098 "Open a connection to METHOD." | |
15099 (when (stringp method) | |
15100 (setq method (gnus-server-to-method method))) | |
15101 (let ((elem (assoc method gnus-opened-servers))) | |
15102 ;; If this method was previously denied, we just return nil. | |
15103 (if (eq (nth 1 elem) 'denied) | |
15104 (progn | |
15105 (gnus-message 1 "Denied server") | |
15106 nil) | |
15107 ;; Open the server. | |
15108 (let ((result | |
15109 (funcall (gnus-get-function method 'open-server) | |
15110 (nth 1 method) (nthcdr 2 method)))) | |
15111 ;; If this hasn't been opened before, we add it to the list. | |
15112 (unless elem | |
15113 (setq elem (list method nil) | |
15114 gnus-opened-servers (cons elem gnus-opened-servers))) | |
15115 ;; Set the status of this server. | |
15116 (setcar (cdr elem) (if result 'ok 'denied)) | |
15117 ;; Return the result from the "open" call. | |
15118 result)))) | |
15119 | |
15120 (defun gnus-close-server (method) | |
15121 "Close the connection to METHOD." | |
15122 (when (stringp method) | |
15123 (setq method (gnus-server-to-method method))) | |
15124 (funcall (gnus-get-function method 'close-server) (nth 1 method))) | |
15125 | |
15126 (defun gnus-request-list (method) | |
15127 "Request the active file from METHOD." | |
15128 (when (stringp method) | |
15129 (setq method (gnus-server-to-method method))) | |
15130 (funcall (gnus-get-function method 'request-list) (nth 1 method))) | |
15131 | |
15132 (defun gnus-request-list-newsgroups (method) | |
15133 "Request the newsgroups file from METHOD." | |
15134 (when (stringp method) | |
15135 (setq method (gnus-server-to-method method))) | |
15136 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method))) | |
15137 | |
15138 (defun gnus-request-newgroups (date method) | |
15139 "Request all new groups since DATE from METHOD." | |
15140 (when (stringp method) | |
15141 (setq method (gnus-server-to-method method))) | |
15142 (funcall (gnus-get-function method 'request-newgroups) | |
15143 date (nth 1 method))) | |
15144 | |
15145 (defun gnus-server-opened (method) | |
15146 "Check whether a connection to METHOD has been opened." | |
15147 (when (stringp method) | |
15148 (setq method (gnus-server-to-method method))) | |
15149 (funcall (gnus-get-function method 'server-opened) (nth 1 method))) | |
15150 | |
15151 (defun gnus-status-message (method) | |
15152 "Return the status message from METHOD. | |
15153 If METHOD is a string, it is interpreted as a group name. The method | |
15154 this group uses will be queried." | |
15155 (let ((method (if (stringp method) (gnus-find-method-for-group method) | |
15156 method))) | |
15157 (funcall (gnus-get-function method 'status-message) (nth 1 method)))) | |
15158 | |
15159 (defun gnus-request-group (group &optional dont-check method) | |
15160 "Request GROUP. If DONT-CHECK, no information is required." | |
15161 (let ((method (or method (gnus-find-method-for-group group)))) | |
15162 (when (stringp method) | |
15163 (setq method (gnus-server-to-method method))) | |
15164 (funcall (gnus-get-function method 'request-group) | |
15165 (gnus-group-real-name group) (nth 1 method) dont-check))) | |
15166 | |
15167 (defun gnus-request-asynchronous (group &optional articles) | |
15168 "Request that GROUP behave asynchronously. | |
15169 ARTICLES is the `data' of the group." | |
15170 (let ((method (gnus-find-method-for-group group))) | |
15171 (funcall (gnus-get-function method 'request-asynchronous) | |
15172 (gnus-group-real-name group) (nth 1 method) articles))) | |
15173 | |
15174 (defun gnus-list-active-group (group) | |
15175 "Request active information on GROUP." | |
15176 (let ((method (gnus-find-method-for-group group)) | |
15177 (func 'list-active-group)) | |
15178 (when (gnus-check-backend-function func group) | |
15179 (funcall (gnus-get-function method func) | |
15180 (gnus-group-real-name group) (nth 1 method))))) | |
15181 | |
15182 (defun gnus-request-group-description (group) | |
15183 "Request a description of GROUP." | |
15184 (let ((method (gnus-find-method-for-group group)) | |
15185 (func 'request-group-description)) | |
15186 (when (gnus-check-backend-function func group) | |
15187 (funcall (gnus-get-function method func) | |
15188 (gnus-group-real-name group) (nth 1 method))))) | |
15189 | |
15190 (defun gnus-close-group (group) | |
15191 "Request the GROUP be closed." | |
15192 (let ((method (gnus-find-method-for-group group))) | |
15193 (funcall (gnus-get-function method 'close-group) | |
15194 (gnus-group-real-name group) (nth 1 method)))) | |
15195 | |
15196 (defun gnus-retrieve-headers (articles group &optional fetch-old) | |
15197 "Request headers for ARTICLES in GROUP. | |
15198 If FETCH-OLD, retrieve all headers (or some subset thereof) in the group." | |
15199 (let ((method (gnus-find-method-for-group group))) | |
15200 (if (and gnus-use-cache (numberp (car articles))) | |
15201 (gnus-cache-retrieve-headers articles group fetch-old) | |
15202 (funcall (gnus-get-function method 'retrieve-headers) | |
15203 articles (gnus-group-real-name group) (nth 1 method) | |
15204 fetch-old)))) | |
15205 | |
15206 (defun gnus-retrieve-groups (groups method) | |
15207 "Request active information on GROUPS from METHOD." | |
15208 (when (stringp method) | |
15209 (setq method (gnus-server-to-method method))) | |
15210 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method))) | |
15211 | |
15212 (defun gnus-request-type (group &optional article) | |
15213 "Return the type (`post' or `mail') of GROUP (and ARTICLE)." | |
15214 (let ((method (gnus-find-method-for-group group))) | |
15215 (if (not (gnus-check-backend-function 'request-type (car method))) | |
15216 'unknown | |
15217 (funcall (gnus-get-function method 'request-type) | |
15218 (gnus-group-real-name group) article)))) | |
15219 | |
15220 (defun gnus-request-update-mark (group article mark) | |
15221 "Return the type (`post' or `mail') of GROUP (and ARTICLE)." | |
15222 (let ((method (gnus-find-method-for-group group))) | |
15223 (if (not (gnus-check-backend-function 'request-update-mark (car method))) | |
15224 mark | |
15225 (funcall (gnus-get-function method 'request-update-mark) | |
15226 (gnus-group-real-name group) article mark)))) | |
15227 | |
15228 (defun gnus-request-article (article group &optional buffer) | |
15229 "Request the ARTICLE in GROUP. | |
15230 ARTICLE can either be an article number or an article Message-ID. | |
15231 If BUFFER, insert the article in that group." | |
15232 (let ((method (gnus-find-method-for-group group))) | |
15233 (funcall (gnus-get-function method 'request-article) | |
15234 article (gnus-group-real-name group) (nth 1 method) buffer))) | |
15235 | |
15236 (defun gnus-request-head (article group) | |
15237 "Request the head of ARTICLE in GROUP." | |
15238 (let* ((method (gnus-find-method-for-group group)) | |
15239 (head (gnus-get-function method 'request-head t))) | |
15240 (if (fboundp head) | |
15241 (funcall head article (gnus-group-real-name group) (nth 1 method)) | |
15242 (let ((res (gnus-request-article article group))) | |
15243 (when res | |
15244 (save-excursion | |
15245 (set-buffer nntp-server-buffer) | |
15246 (goto-char (point-min)) | |
15247 (when (search-forward "\n\n" nil t) | |
15248 (delete-region (1- (point)) (point-max))) | |
15249 (nnheader-fold-continuation-lines))) | |
15250 res)))) | |
15251 | |
15252 (defun gnus-request-body (article group) | |
15253 "Request the body of ARTICLE in GROUP." | |
15254 (let ((method (gnus-find-method-for-group group))) | |
15255 (funcall (gnus-get-function method 'request-body) | |
15256 article (gnus-group-real-name group) (nth 1 method)))) | |
15257 | |
15258 (defun gnus-request-post (method) | |
15259 "Post the current buffer using METHOD." | |
15260 (when (stringp method) | |
15261 (setq method (gnus-server-to-method method))) | |
15262 (funcall (gnus-get-function method 'request-post) (nth 1 method))) | |
15263 | |
15264 (defun gnus-request-scan (group method) | |
15265 "Request a SCAN being performed in GROUP from METHOD. | |
15266 If GROUP is nil, all groups on METHOD are scanned." | |
15267 (let ((method (if group (gnus-find-method-for-group group) method))) | |
15268 (funcall (gnus-get-function method 'request-scan) | |
15269 (and group (gnus-group-real-name group)) (nth 1 method)))) | |
15270 | |
15271 (defsubst gnus-request-update-info (info method) | |
15272 "Request that METHOD update INFO." | |
15273 (when (stringp method) | |
15274 (setq method (gnus-server-to-method method))) | |
15275 (when (gnus-check-backend-function 'request-update-info (car method)) | |
15276 (funcall (gnus-get-function method 'request-update-info) | |
15277 (gnus-group-real-name (gnus-info-group info)) | |
15278 info (nth 1 method)))) | |
15279 | |
15280 (defun gnus-request-expire-articles (articles group &optional force) | |
15281 (let ((method (gnus-find-method-for-group group))) | |
15282 (funcall (gnus-get-function method 'request-expire-articles) | |
15283 articles (gnus-group-real-name group) (nth 1 method) | |
15284 force))) | |
15285 | |
15286 (defun gnus-request-move-article | |
15287 (article group server accept-function &optional last) | |
15288 (let ((method (gnus-find-method-for-group group))) | |
15289 (funcall (gnus-get-function method 'request-move-article) | |
15290 article (gnus-group-real-name group) | |
15291 (nth 1 method) accept-function last))) | |
15292 | |
15293 (defun gnus-request-accept-article (group method &optional last) | |
15294 ;; Make sure there's a newline at the end of the article. | |
15295 (when (stringp method) | |
15296 (setq method (gnus-server-to-method method))) | |
15297 (when (and (not method) | |
15298 (stringp group)) | |
15299 (setq method (gnus-group-name-to-method group))) | |
15300 (goto-char (point-max)) | |
15301 (unless (bolp) | |
15302 (insert "\n")) | |
15303 (let ((func (car (or method (gnus-find-method-for-group group))))) | |
15304 (funcall (intern (format "%s-request-accept-article" func)) | |
15305 (if (stringp group) (gnus-group-real-name group) group) | |
15306 (cadr method) | |
15307 last))) | |
15308 | |
15309 (defun gnus-request-replace-article (article group buffer) | |
15310 (let ((func (car (gnus-find-method-for-group group)))) | |
15311 (funcall (intern (format "%s-request-replace-article" func)) | |
15312 article (gnus-group-real-name group) buffer))) | |
15313 | |
15314 (defun gnus-request-associate-buffer (group) | |
15315 (let ((method (gnus-find-method-for-group group))) | |
15316 (funcall (gnus-get-function method 'request-associate-buffer) | |
15317 (gnus-group-real-name group)))) | |
15318 | |
15319 (defun gnus-request-restore-buffer (article group) | |
15320 "Request a new buffer restored to the state of ARTICLE." | |
15321 (let ((method (gnus-find-method-for-group group))) | |
15322 (funcall (gnus-get-function method 'request-restore-buffer) | |
15323 article (gnus-group-real-name group) (nth 1 method)))) | |
15324 | |
15325 (defun gnus-request-create-group (group &optional method) | |
15326 (when (stringp method) | |
15327 (setq method (gnus-server-to-method method))) | |
15328 (let ((method (or method (gnus-find-method-for-group group)))) | |
15329 (funcall (gnus-get-function method 'request-create-group) | |
15330 (gnus-group-real-name group) (nth 1 method)))) | |
15331 | |
15332 (defun gnus-request-delete-group (group &optional force) | |
15333 (let ((method (gnus-find-method-for-group group))) | |
15334 (funcall (gnus-get-function method 'request-delete-group) | |
15335 (gnus-group-real-name group) force (nth 1 method)))) | |
15336 | |
15337 (defun gnus-request-rename-group (group new-name) | |
15338 (let ((method (gnus-find-method-for-group group))) | |
15339 (funcall (gnus-get-function method 'request-rename-group) | |
15340 (gnus-group-real-name group) | |
15341 (gnus-group-real-name new-name) (nth 1 method)))) | |
15342 | |
15343 (defun gnus-member-of-valid (symbol group) | |
15344 "Find out if GROUP has SYMBOL as part of its \"valid\" spec." | |
15345 (memq symbol (assoc | |
15346 (symbol-name (car (gnus-find-method-for-group group))) | |
15347 gnus-valid-select-methods))) | |
15348 | |
15349 (defun gnus-method-option-p (method option) | |
15350 "Return non-nil if select METHOD has OPTION as a parameter." | |
15351 (when (stringp method) | |
15352 (setq method (gnus-server-to-method method))) | |
15353 (memq option (assoc (format "%s" (car method)) | |
15354 gnus-valid-select-methods))) | |
15355 | |
15356 (defun gnus-server-extend-method (group method) | |
15357 ;; This function "extends" a virtual server. If the server is | |
15358 ;; "hello", and the select method is ("hello" (my-var "something")) | |
15359 ;; in the group "alt.alt", this will result in a new virtual server | |
15360 ;; called "hello+alt.alt". | |
15361 (let ((entry | |
15362 (gnus-copy-sequence | |
15363 (if (equal (car method) "native") gnus-select-method | |
15364 (cdr (assoc (car method) gnus-server-alist)))))) | |
15365 (setcar (cdr entry) (concat (nth 1 entry) "+" group)) | |
15366 (nconc entry (cdr method)))) | |
15367 | |
15368 (defun gnus-group-name-to-method (group) | |
15369 "Return a select method suitable for GROUP." | |
15370 (if (string-match ":" group) | |
15371 (let ((server (substring group 0 (match-beginning 0)))) | |
15372 (if (string-match "\\+" server) | |
15373 (list (intern (substring server 0 (match-beginning 0))) | |
15374 (substring server (match-end 0))) | |
15375 (list (intern server) ""))) | |
15376 gnus-select-method)) | |
15377 | |
15378 (defun gnus-find-method-for-group (group &optional info) | |
15379 "Find the select method that GROUP uses." | |
15380 (or gnus-override-method | |
15381 (and (not group) | |
15382 gnus-select-method) | |
15383 (let ((info (or info (gnus-get-info group))) | |
15384 method) | |
15385 (if (or (not info) | |
15386 (not (setq method (gnus-info-method info))) | |
15387 (equal method "native")) | |
15388 gnus-select-method | |
15389 (setq method | |
15390 (cond ((stringp method) | |
15391 (gnus-server-to-method method)) | |
15392 ((stringp (car method)) | |
15393 (gnus-server-extend-method group method)) | |
15394 (t | |
15395 method))) | |
15396 (cond ((equal (cadr method) "") | |
15397 method) | |
15398 ((null (cadr method)) | |
15399 (list (car method) "")) | |
15400 (t | |
15401 (gnus-server-add-address method))))))) | |
15402 | |
15403 (defun gnus-check-backend-function (func group) | |
15404 "Check whether GROUP supports function FUNC." | |
15405 (let ((method (if (stringp group) (car (gnus-find-method-for-group group)) | |
15406 group))) | |
15407 (fboundp (intern (format "%s-%s" method func))))) | |
15408 | |
15409 (defun gnus-methods-using (feature) | |
15410 "Find all methods that have FEATURE." | |
15411 (let ((valids gnus-valid-select-methods) | |
15412 outs) | |
15413 (while valids | |
15414 (if (memq feature (car valids)) | |
15415 (setq outs (cons (car valids) outs))) | |
15416 (setq valids (cdr valids))) | |
15417 outs)) | |
15418 | |
15419 | |
15420 ;;; | |
15421 ;;; Active & Newsrc File Handling | |
15422 ;;; | |
15423 | |
15424 (defun gnus-setup-news (&optional rawfile level dont-connect) | |
15425 "Setup news information. | |
15426 If RAWFILE is non-nil, the .newsrc file will also be read. | |
15427 If LEVEL is non-nil, the news will be set up at level LEVEL." | |
15428 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile))))) | |
15429 | |
15430 (when init | |
15431 ;; Clear some variables to re-initialize news information. | |
15432 (setq gnus-newsrc-alist nil | |
15433 gnus-active-hashtb nil) | |
15434 ;; Read the newsrc file and create `gnus-newsrc-hashtb'. | |
15435 (gnus-read-newsrc-file rawfile)) | |
15436 | |
15437 (when (and (not (assoc "archive" gnus-server-alist)) | |
15438 gnus-message-archive-method) | |
15439 (push (cons "archive" gnus-message-archive-method) | |
15440 gnus-server-alist)) | |
15441 | |
15442 ;; If we don't read the complete active file, we fill in the | |
15443 ;; hashtb here. | |
15444 (if (or (null gnus-read-active-file) | |
15445 (eq gnus-read-active-file 'some)) | |
15446 (gnus-update-active-hashtb-from-killed)) | |
15447 | |
15448 ;; Read the active file and create `gnus-active-hashtb'. | |
15449 ;; If `gnus-read-active-file' is nil, then we just create an empty | |
15450 ;; hash table. The partial filling out of the hash table will be | |
15451 ;; done in `gnus-get-unread-articles'. | |
15452 (and gnus-read-active-file | |
15453 (not level) | |
15454 (gnus-read-active-file)) | |
15455 | |
15456 (or gnus-active-hashtb | |
15457 (setq gnus-active-hashtb (make-vector 4095 0))) | |
15458 | |
15459 ;; Initialize the cache. | |
15460 (when gnus-use-cache | |
15461 (gnus-cache-open)) | |
15462 | |
15463 ;; Possibly eval the dribble file. | |
15464 (and init (or gnus-use-dribble-file gnus-slave) (gnus-dribble-eval-file)) | |
15465 | |
15466 ;; Slave Gnusii should then clear the dribble buffer. | |
15467 (when (and init gnus-slave) | |
15468 (gnus-dribble-clear)) | |
15469 | |
15470 (gnus-update-format-specifications) | |
15471 | |
15472 ;; See whether we need to read the description file. | |
15473 (if (and (string-match "%[-,0-9]*D" gnus-group-line-format) | |
15474 (not gnus-description-hashtb) | |
15475 (not dont-connect) | |
15476 gnus-read-active-file) | |
15477 (gnus-read-all-descriptions-files)) | |
15478 | |
15479 ;; Find new newsgroups and treat them. | |
15480 (if (and init gnus-check-new-newsgroups (not level) | |
15481 (gnus-check-server gnus-select-method)) | |
15482 (gnus-find-new-newsgroups)) | |
15483 | |
15484 ;; We might read in new NoCeM messages here. | |
15485 (when (and gnus-use-nocem | |
15486 (not level) | |
15487 (not dont-connect)) | |
15488 (gnus-nocem-scan-groups)) | |
15489 | |
15490 ;; Find the number of unread articles in each non-dead group. | |
15491 (let ((gnus-read-active-file (and (not level) gnus-read-active-file))) | |
15492 (gnus-get-unread-articles level)) | |
15493 | |
15494 (if (and init gnus-check-bogus-newsgroups | |
15495 gnus-read-active-file (not level) | |
15496 (gnus-server-opened gnus-select-method)) | |
15497 (gnus-check-bogus-newsgroups)))) | |
15498 | |
15499 (defun gnus-find-new-newsgroups (&optional arg) | |
15500 "Search for new newsgroups and add them. | |
15501 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.' | |
15502 The `-n' option line from .newsrc is respected. | |
15503 If ARG (the prefix), use the `ask-server' method to query | |
15504 the server for new groups." | |
15505 (interactive "P") | |
15506 (let ((check (if (or (and arg (not (listp gnus-check-new-newsgroups))) | |
15507 (null gnus-read-active-file) | |
15508 (eq gnus-read-active-file 'some)) | |
15509 'ask-server gnus-check-new-newsgroups))) | |
15510 (unless (gnus-check-first-time-used) | |
15511 (if (or (consp check) | |
15512 (eq check 'ask-server)) | |
15513 ;; Ask the server for new groups. | |
15514 (gnus-ask-server-for-new-groups) | |
15515 ;; Go through the active hashtb and look for new groups. | |
15516 (let ((groups 0) | |
15517 group new-newsgroups) | |
15518 (gnus-message 5 "Looking for new newsgroups...") | |
15519 (unless gnus-have-read-active-file | |
15520 (gnus-read-active-file)) | |
15521 (setq gnus-newsrc-last-checked-date (current-time-string)) | |
15522 (unless gnus-killed-hashtb | |
15523 (gnus-make-hashtable-from-killed)) | |
15524 ;; Go though every newsgroup in `gnus-active-hashtb' and compare | |
15525 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'. | |
15526 (mapatoms | |
15527 (lambda (sym) | |
15528 (if (or (null (setq group (symbol-name sym))) | |
15529 (not (boundp sym)) | |
15530 (null (symbol-value sym)) | |
15531 (gnus-gethash group gnus-killed-hashtb) | |
15532 (gnus-gethash group gnus-newsrc-hashtb)) | |
15533 () | |
15534 (let ((do-sub (gnus-matches-options-n group))) | |
15535 (cond | |
15536 ((eq do-sub 'subscribe) | |
15537 (setq groups (1+ groups)) | |
15538 (gnus-sethash group group gnus-killed-hashtb) | |
15539 (funcall gnus-subscribe-options-newsgroup-method group)) | |
15540 ((eq do-sub 'ignore) | |
15541 nil) | |
15542 (t | |
15543 (setq groups (1+ groups)) | |
15544 (gnus-sethash group group gnus-killed-hashtb) | |
15545 (if gnus-subscribe-hierarchical-interactive | |
15546 (setq new-newsgroups (cons group new-newsgroups)) | |
15547 (funcall gnus-subscribe-newsgroup-method group))))))) | |
15548 gnus-active-hashtb) | |
15549 (when new-newsgroups | |
15550 (gnus-subscribe-hierarchical-interactive new-newsgroups)) | |
15551 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>. | |
15552 (if (> groups 0) | |
15553 (gnus-message 6 "%d new newsgroup%s arrived." | |
15554 groups (if (> groups 1) "s have" " has")) | |
15555 (gnus-message 6 "No new newsgroups."))))))) | |
15556 | |
15557 (defun gnus-matches-options-n (group) | |
15558 ;; Returns `subscribe' if the group is to be unconditionally | |
15559 ;; subscribed, `ignore' if it is to be ignored, and nil if there is | |
15560 ;; no match for the group. | |
15561 | |
15562 ;; First we check the two user variables. | |
15563 (cond | |
15564 ((and gnus-options-subscribe | |
15565 (string-match gnus-options-subscribe group)) | |
15566 'subscribe) | |
15567 ((and gnus-auto-subscribed-groups | |
15568 (string-match gnus-auto-subscribed-groups group)) | |
15569 'subscribe) | |
15570 ((and gnus-options-not-subscribe | |
15571 (string-match gnus-options-not-subscribe group)) | |
15572 'ignore) | |
15573 ;; Then we go through the list that was retrieved from the .newsrc | |
15574 ;; file. This list has elements on the form | |
15575 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list | |
15576 ;; is in the reverse order of the options line) is returned. | |
15577 (t | |
15578 (let ((regs gnus-newsrc-options-n)) | |
15579 (while (and regs | |
15580 (not (string-match (caar regs) group))) | |
15581 (setq regs (cdr regs))) | |
15582 (and regs (cdar regs)))))) | |
15583 | |
15584 (defun gnus-ask-server-for-new-groups () | |
15585 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string))) | |
15586 (methods (cons gnus-select-method | |
15587 (nconc | |
15588 (when gnus-message-archive-method | |
15589 (list "archive")) | |
15590 (append | |
15591 (and (consp gnus-check-new-newsgroups) | |
15592 gnus-check-new-newsgroups) | |
15593 gnus-secondary-select-methods)))) | |
15594 (groups 0) | |
15595 (new-date (current-time-string)) | |
15596 group new-newsgroups got-new method hashtb | |
15597 gnus-override-subscribe-method) | |
15598 ;; Go through both primary and secondary select methods and | |
15599 ;; request new newsgroups. | |
15600 (while (setq method (gnus-server-get-method nil (pop methods))) | |
15601 (setq new-newsgroups nil) | |
15602 (setq gnus-override-subscribe-method method) | |
15603 (when (and (gnus-check-server method) | |
15604 (gnus-request-newgroups date method)) | |
15605 (save-excursion | |
15606 (setq got-new t) | |
15607 (setq hashtb (gnus-make-hashtable 100)) | |
15608 (set-buffer nntp-server-buffer) | |
15609 ;; Enter all the new groups into a hashtable. | |
15610 (gnus-active-to-gnus-format method hashtb 'ignore)) | |
15611 ;; Now all new groups from `method' are in `hashtb'. | |
15612 (mapatoms | |
15613 (lambda (group-sym) | |
15614 (if (or (null (setq group (symbol-name group-sym))) | |
15615 (not (boundp group-sym)) | |
15616 (null (symbol-value group-sym)) | |
15617 (gnus-gethash group gnus-newsrc-hashtb) | |
15618 (member group gnus-zombie-list) | |
15619 (member group gnus-killed-list)) | |
15620 ;; The group is already known. | |
15621 () | |
15622 ;; Make this group active. | |
15623 (when (symbol-value group-sym) | |
15624 (gnus-set-active group (symbol-value group-sym))) | |
15625 ;; Check whether we want it or not. | |
15626 (let ((do-sub (gnus-matches-options-n group))) | |
15627 (cond | |
15628 ((eq do-sub 'subscribe) | |
15629 (incf groups) | |
15630 (gnus-sethash group group gnus-killed-hashtb) | |
15631 (funcall gnus-subscribe-options-newsgroup-method group)) | |
15632 ((eq do-sub 'ignore) | |
15633 nil) | |
15634 (t | |
15635 (incf groups) | |
15636 (gnus-sethash group group gnus-killed-hashtb) | |
15637 (if gnus-subscribe-hierarchical-interactive | |
15638 (push group new-newsgroups) | |
15639 (funcall gnus-subscribe-newsgroup-method group))))))) | |
15640 hashtb)) | |
15641 (when new-newsgroups | |
15642 (gnus-subscribe-hierarchical-interactive new-newsgroups))) | |
15643 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>. | |
15644 (when (> groups 0) | |
15645 (gnus-message 6 "%d new newsgroup%s arrived." | |
15646 groups (if (> groups 1) "s have" " has"))) | |
15647 (and got-new (setq gnus-newsrc-last-checked-date new-date)) | |
15648 got-new)) | |
15649 | |
15650 (defun gnus-check-first-time-used () | |
15651 (if (or (> (length gnus-newsrc-alist) 1) | |
15652 (file-exists-p gnus-startup-file) | |
15653 (file-exists-p (concat gnus-startup-file ".el")) | |
15654 (file-exists-p (concat gnus-startup-file ".eld"))) | |
15655 nil | |
15656 (gnus-message 6 "First time user; subscribing you to default groups") | |
15657 (unless (gnus-read-active-file-p) | |
15658 (gnus-read-active-file)) | |
15659 (setq gnus-newsrc-last-checked-date (current-time-string)) | |
15660 (let ((groups gnus-default-subscribed-newsgroups) | |
15661 group) | |
15662 (if (eq groups t) | |
15663 nil | |
15664 (setq groups (or groups gnus-backup-default-subscribed-newsgroups)) | |
15665 (mapatoms | |
15666 (lambda (sym) | |
15667 (if (null (setq group (symbol-name sym))) | |
15668 () | |
15669 (let ((do-sub (gnus-matches-options-n group))) | |
15670 (cond | |
15671 ((eq do-sub 'subscribe) | |
15672 (gnus-sethash group group gnus-killed-hashtb) | |
15673 (funcall gnus-subscribe-options-newsgroup-method group)) | |
15674 ((eq do-sub 'ignore) | |
15675 nil) | |
15676 (t | |
15677 (setq gnus-killed-list (cons group gnus-killed-list))))))) | |
15678 gnus-active-hashtb) | |
15679 (while groups | |
15680 (if (gnus-active (car groups)) | |
15681 (gnus-group-change-level | |
15682 (car groups) gnus-level-default-subscribed gnus-level-killed)) | |
15683 (setq groups (cdr groups))) | |
15684 (gnus-group-make-help-group) | |
15685 (and gnus-novice-user | |
15686 (gnus-message 7 "`A k' to list killed groups")))))) | |
15687 | |
15688 (defun gnus-subscribe-group (group previous &optional method) | |
15689 (gnus-group-change-level | |
15690 (if method | |
15691 (list t group gnus-level-default-subscribed nil nil method) | |
15692 group) | |
15693 gnus-level-default-subscribed gnus-level-killed previous t)) | |
15694 | |
15695 ;; `gnus-group-change-level' is the fundamental function for changing | |
15696 ;; subscription levels of newsgroups. This might mean just changing | |
15697 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back | |
15698 ;; again, which subscribes/unsubscribes a group, which is equally | |
15699 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and | |
15700 ;; from 8-9 to 1-7 means that you remove the group from the list of | |
15701 ;; killed (or zombie) groups and add them to the (kinda) subscribed | |
15702 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8, | |
15703 ;; which is trivial. | |
15704 ;; ENTRY can either be a string (newsgroup name) or a list (if | |
15705 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST), | |
15706 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb' | |
15707 ;; entries. | |
15708 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and | |
15709 ;; PREVIOUS is the group (in hashtb entry format) to insert this group | |
15710 ;; after. | |
15711 (defun gnus-group-change-level (entry level &optional oldlevel | |
15712 previous fromkilled) | |
15713 (let (group info active num) | |
15714 ;; Glean what info we can from the arguments | |
15715 (if (consp entry) | |
15716 (if fromkilled (setq group (nth 1 entry)) | |
15717 (setq group (car (nth 2 entry)))) | |
15718 (setq group entry)) | |
15719 (if (and (stringp entry) | |
15720 oldlevel | |
15721 (< oldlevel gnus-level-zombie)) | |
15722 (setq entry (gnus-gethash entry gnus-newsrc-hashtb))) | |
15723 (if (and (not oldlevel) | |
15724 (consp entry)) | |
15725 (setq oldlevel (gnus-info-level (nth 2 entry))) | |
15726 (setq oldlevel (or oldlevel 9))) | |
15727 (if (stringp previous) | |
15728 (setq previous (gnus-gethash previous gnus-newsrc-hashtb))) | |
15729 | |
15730 (if (and (>= oldlevel gnus-level-zombie) | |
15731 (gnus-gethash group gnus-newsrc-hashtb)) | |
15732 ;; We are trying to subscribe a group that is already | |
15733 ;; subscribed. | |
15734 () ; Do nothing. | |
15735 | |
15736 (or (gnus-ephemeral-group-p group) | |
15737 (gnus-dribble-enter | |
15738 (format "(gnus-group-change-level %S %S %S %S %S)" | |
15739 group level oldlevel (car (nth 2 previous)) fromkilled))) | |
15740 | |
15741 ;; Then we remove the newgroup from any old structures, if needed. | |
15742 ;; If the group was killed, we remove it from the killed or zombie | |
15743 ;; list. If not, and it is in fact going to be killed, we remove | |
15744 ;; it from the newsrc hash table and assoc. | |
15745 (cond | |
15746 ((>= oldlevel gnus-level-zombie) | |
15747 (if (= oldlevel gnus-level-zombie) | |
15748 (setq gnus-zombie-list (delete group gnus-zombie-list)) | |
15749 (setq gnus-killed-list (delete group gnus-killed-list)))) | |
15750 (t | |
15751 (if (and (>= level gnus-level-zombie) | |
15752 entry) | |
15753 (progn | |
15754 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb) | |
15755 (if (nth 3 entry) | |
15756 (setcdr (gnus-gethash (car (nth 3 entry)) | |
15757 gnus-newsrc-hashtb) | |
15758 (cdr entry))) | |
15759 (setcdr (cdr entry) (cdddr entry)))))) | |
15760 | |
15761 ;; Finally we enter (if needed) the list where it is supposed to | |
15762 ;; go, and change the subscription level. If it is to be killed, | |
15763 ;; we enter it into the killed or zombie list. | |
15764 (cond | |
15765 ((>= level gnus-level-zombie) | |
15766 ;; Remove from the hash table. | |
15767 (gnus-sethash group nil gnus-newsrc-hashtb) | |
15768 ;; We do not enter foreign groups into the list of dead | |
15769 ;; groups. | |
15770 (unless (gnus-group-foreign-p group) | |
15771 (if (= level gnus-level-zombie) | |
15772 (setq gnus-zombie-list (cons group gnus-zombie-list)) | |
15773 (setq gnus-killed-list (cons group gnus-killed-list))))) | |
15774 (t | |
15775 ;; If the list is to be entered into the newsrc assoc, and | |
15776 ;; it was killed, we have to create an entry in the newsrc | |
15777 ;; hashtb format and fix the pointers in the newsrc assoc. | |
15778 (if (< oldlevel gnus-level-zombie) | |
15779 ;; It was alive, and it is going to stay alive, so we | |
15780 ;; just change the level and don't change any pointers or | |
15781 ;; hash table entries. | |
15782 (setcar (cdaddr entry) level) | |
15783 (if (listp entry) | |
15784 (setq info (cdr entry) | |
15785 num (car entry)) | |
15786 (setq active (gnus-active group)) | |
15787 (setq num | |
15788 (if active (- (1+ (cdr active)) (car active)) t)) | |
15789 ;; Check whether the group is foreign. If so, the | |
15790 ;; foreign select method has to be entered into the | |
15791 ;; info. | |
15792 (let ((method (or gnus-override-subscribe-method | |
15793 (gnus-group-method group)))) | |
15794 (if (eq method gnus-select-method) | |
15795 (setq info (list group level nil)) | |
15796 (setq info (list group level nil nil method))))) | |
15797 (unless previous | |
15798 (setq previous | |
15799 (let ((p gnus-newsrc-alist)) | |
15800 (while (cddr p) | |
15801 (setq p (cdr p))) | |
15802 p))) | |
15803 (setq entry (cons info (cddr previous))) | |
15804 (if (cdr previous) | |
15805 (progn | |
15806 (setcdr (cdr previous) entry) | |
15807 (gnus-sethash group (cons num (cdr previous)) | |
15808 gnus-newsrc-hashtb)) | |
15809 (setcdr previous entry) | |
15810 (gnus-sethash group (cons num previous) | |
15811 gnus-newsrc-hashtb)) | |
15812 (when (cdr entry) | |
15813 (setcdr (gnus-gethash (caadr entry) gnus-newsrc-hashtb) entry))))) | |
15814 (when gnus-group-change-level-function | |
15815 (funcall gnus-group-change-level-function group level oldlevel))))) | |
15816 | |
15817 (defun gnus-kill-newsgroup (newsgroup) | |
15818 "Obsolete function. Kills a newsgroup." | |
15819 (gnus-group-change-level | |
15820 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed)) | |
15821 | |
15822 (defun gnus-check-bogus-newsgroups (&optional confirm) | |
15823 "Remove bogus newsgroups. | |
15824 If CONFIRM is non-nil, the user has to confirm the deletion of every | |
15825 newsgroup." | |
15826 (let ((newsrc (cdr gnus-newsrc-alist)) | |
15827 bogus group entry info) | |
15828 (gnus-message 5 "Checking bogus newsgroups...") | |
15829 (unless (gnus-read-active-file-p) | |
15830 (gnus-read-active-file)) | |
15831 (when (gnus-read-active-file-p) | |
15832 ;; Find all bogus newsgroup that are subscribed. | |
15833 (while newsrc | |
15834 (setq info (pop newsrc) | |
15835 group (gnus-info-group info)) | |
15836 (unless (or (gnus-active group) ; Active | |
15837 (gnus-info-method info) ; Foreign | |
15838 (and confirm | |
15839 (not (gnus-y-or-n-p | |
15840 (format "Remove bogus newsgroup: %s " group))))) | |
15841 ;; Found a bogus newsgroup. | |
15842 (push group bogus))) | |
15843 ;; Remove all bogus subscribed groups by first killing them, and | |
15844 ;; then removing them from the list of killed groups. | |
15845 (while bogus | |
15846 (when (setq entry (gnus-gethash (setq group (pop bogus)) | |
15847 gnus-newsrc-hashtb)) | |
15848 (gnus-group-change-level entry gnus-level-killed) | |
15849 (setq gnus-killed-list (delete group gnus-killed-list)))) | |
15850 ;; Then we remove all bogus groups from the list of killed and | |
15851 ;; zombie groups. They are are removed without confirmation. | |
15852 (let ((dead-lists '(gnus-killed-list gnus-zombie-list)) | |
15853 killed) | |
15854 (while dead-lists | |
15855 (setq killed (symbol-value (car dead-lists))) | |
15856 (while killed | |
15857 (unless (gnus-active (setq group (pop killed))) | |
15858 ;; The group is bogus. | |
15859 ;; !!!Slow as hell. | |
15860 (set (car dead-lists) | |
15861 (delete group (symbol-value (car dead-lists)))))) | |
15862 (setq dead-lists (cdr dead-lists)))) | |
15863 (gnus-message 5 "Checking bogus newsgroups...done")))) | |
15864 | |
15865 (defun gnus-check-duplicate-killed-groups () | |
15866 "Remove duplicates from the list of killed groups." | |
15867 (interactive) | |
15868 (let ((killed gnus-killed-list)) | |
15869 (while killed | |
15870 (gnus-message 9 "%d" (length killed)) | |
15871 (setcdr killed (delete (car killed) (cdr killed))) | |
15872 (setq killed (cdr killed))))) | |
15873 | |
15874 ;; We want to inline a function from gnus-cache, so we cheat here: | |
15875 (eval-when-compile | |
15876 (provide 'gnus) | |
15877 (require 'gnus-cache)) | |
15878 | |
15879 (defun gnus-get-unread-articles-in-group (info active &optional update) | |
15880 (when active | |
15881 ;; Allow the backend to update the info in the group. | |
15882 (when (and update | |
15883 (gnus-request-update-info | |
15884 info (gnus-find-method-for-group (gnus-info-group info)))) | |
15885 (gnus-activate-group (gnus-info-group info) nil t)) | |
15886 (let* ((range (gnus-info-read info)) | |
15887 (num 0)) | |
15888 ;; If a cache is present, we may have to alter the active info. | |
15889 (when (and gnus-use-cache info) | |
15890 (inline (gnus-cache-possibly-alter-active | |
15891 (gnus-info-group info) active))) | |
15892 ;; Modify the list of read articles according to what articles | |
15893 ;; are available; then tally the unread articles and add the | |
15894 ;; number to the group hash table entry. | |
15895 (cond | |
15896 ((zerop (cdr active)) | |
15897 (setq num 0)) | |
15898 ((not range) | |
15899 (setq num (- (1+ (cdr active)) (car active)))) | |
15900 ((not (listp (cdr range))) | |
15901 ;; Fix a single (num . num) range according to the | |
15902 ;; active hash table. | |
15903 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>. | |
15904 (and (< (cdr range) (car active)) (setcdr range (1- (car active)))) | |
15905 (and (> (cdr range) (cdr active)) (setcdr range (cdr active))) | |
15906 ;; Compute number of unread articles. | |
15907 (setq num (max 0 (- (cdr active) (- (1+ (cdr range)) (car range)))))) | |
15908 (t | |
15909 ;; The read list is a list of ranges. Fix them according to | |
15910 ;; the active hash table. | |
15911 ;; First peel off any elements that are below the lower | |
15912 ;; active limit. | |
15913 (while (and (cdr range) | |
15914 (>= (car active) | |
15915 (or (and (atom (cadr range)) (cadr range)) | |
15916 (caadr range)))) | |
15917 (if (numberp (car range)) | |
15918 (setcar range | |
15919 (cons (car range) | |
15920 (or (and (numberp (cadr range)) | |
15921 (cadr range)) | |
15922 (cdadr range)))) | |
15923 (setcdr (car range) | |
15924 (or (and (numberp (nth 1 range)) (nth 1 range)) | |
15925 (cdadr range)))) | |
15926 (setcdr range (cddr range))) | |
15927 ;; Adjust the first element to be the same as the lower limit. | |
15928 (if (and (not (atom (car range))) | |
15929 (< (cdar range) (car active))) | |
15930 (setcdr (car range) (1- (car active)))) | |
15931 ;; Then we want to peel off any elements that are higher | |
15932 ;; than the upper active limit. | |
15933 (let ((srange range)) | |
15934 ;; Go past all legal elements. | |
15935 (while (and (cdr srange) | |
15936 (<= (or (and (atom (cadr srange)) | |
15937 (cadr srange)) | |
15938 (caadr srange)) (cdr active))) | |
15939 (setq srange (cdr srange))) | |
15940 (if (cdr srange) | |
15941 ;; Nuke all remaining illegal elements. | |
15942 (setcdr srange nil)) | |
15943 | |
15944 ;; Adjust the final element. | |
15945 (if (and (not (atom (car srange))) | |
15946 (> (cdar srange) (cdr active))) | |
15947 (setcdr (car srange) (cdr active)))) | |
15948 ;; Compute the number of unread articles. | |
15949 (while range | |
15950 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range)) | |
15951 (cdar range))) | |
15952 (or (and (atom (car range)) (car range)) | |
15953 (caar range))))) | |
15954 (setq range (cdr range))) | |
15955 (setq num (max 0 (- (cdr active) num))))) | |
15956 ;; Set the number of unread articles. | |
15957 (when info | |
15958 (setcar (gnus-gethash (gnus-info-group info) gnus-newsrc-hashtb) num)) | |
15959 num))) | |
15960 | |
15961 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb' | |
15962 ;; and compute how many unread articles there are in each group. | |
15963 (defun gnus-get-unread-articles (&optional level) | |
15964 (let* ((newsrc (cdr gnus-newsrc-alist)) | |
15965 (level (or level gnus-activate-level (1+ gnus-level-subscribed))) | |
15966 (foreign-level | |
15967 (min | |
15968 (cond ((and gnus-activate-foreign-newsgroups | |
15969 (not (numberp gnus-activate-foreign-newsgroups))) | |
15970 (1+ gnus-level-subscribed)) | |
15971 ((numberp gnus-activate-foreign-newsgroups) | |
15972 gnus-activate-foreign-newsgroups) | |
15973 (t 0)) | |
15974 level)) | |
15975 info group active method) | |
15976 (gnus-message 5 "Checking new news...") | |
15977 | |
15978 (while newsrc | |
15979 (setq active (gnus-active (setq group (gnus-info-group | |
15980 (setq info (pop newsrc)))))) | |
15981 | |
15982 ;; Check newsgroups. If the user doesn't want to check them, or | |
15983 ;; they can't be checked (for instance, if the news server can't | |
15984 ;; be reached) we just set the number of unread articles in this | |
15985 ;; newsgroup to t. This means that Gnus thinks that there are | |
15986 ;; unread articles, but it has no idea how many. | |
15987 (if (and (setq method (gnus-info-method info)) | |
15988 (not (gnus-server-equal | |
15989 gnus-select-method | |
15990 (setq method (gnus-server-get-method nil method)))) | |
15991 (not (gnus-secondary-method-p method))) | |
15992 ;; These groups are foreign. Check the level. | |
15993 (when (<= (gnus-info-level info) foreign-level) | |
15994 (setq active (gnus-activate-group group 'scan)) | |
15995 (unless (inline (gnus-virtual-group-p group)) | |
15996 (inline (gnus-close-group group))) | |
15997 (when (fboundp (intern (concat (symbol-name (car method)) | |
15998 "-request-update-info"))) | |
15999 (inline (gnus-request-update-info info method)))) | |
16000 ;; These groups are native or secondary. | |
16001 (when (and (<= (gnus-info-level info) level) | |
16002 (not gnus-read-active-file)) | |
16003 (setq active (gnus-activate-group group 'scan)) | |
16004 (inline (gnus-close-group group)))) | |
16005 | |
16006 ;; Get the number of unread articles in the group. | |
16007 (if active | |
16008 (inline (gnus-get-unread-articles-in-group info active)) | |
16009 ;; The group couldn't be reached, so we nix out the number of | |
16010 ;; unread articles and stuff. | |
16011 (gnus-set-active group nil) | |
16012 (setcar (gnus-gethash group gnus-newsrc-hashtb) t))) | |
16013 | |
16014 (gnus-message 5 "Checking new news...done"))) | |
16015 | |
16016 ;; Create a hash table out of the newsrc alist. The `car's of the | |
16017 ;; alist elements are used as keys. | |
16018 (defun gnus-make-hashtable-from-newsrc-alist () | |
16019 (let ((alist gnus-newsrc-alist) | |
16020 (ohashtb gnus-newsrc-hashtb) | |
16021 prev) | |
16022 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist))) | |
16023 (setq alist | |
16024 (setq prev (setq gnus-newsrc-alist | |
16025 (if (equal (caar gnus-newsrc-alist) | |
16026 "dummy.group") | |
16027 gnus-newsrc-alist | |
16028 (cons (list "dummy.group" 0 nil) alist))))) | |
16029 (while alist | |
16030 (gnus-sethash | |
16031 (caar alist) | |
16032 (cons (and ohashtb (car (gnus-gethash (caar alist) ohashtb))) | |
16033 prev) | |
16034 gnus-newsrc-hashtb) | |
16035 (setq prev alist | |
16036 alist (cdr alist))))) | |
16037 | |
16038 (defun gnus-make-hashtable-from-killed () | |
16039 "Create a hash table from the killed and zombie lists." | |
16040 (let ((lists '(gnus-killed-list gnus-zombie-list)) | |
16041 list) | |
16042 (setq gnus-killed-hashtb | |
16043 (gnus-make-hashtable | |
16044 (+ (length gnus-killed-list) (length gnus-zombie-list)))) | |
16045 (while (setq list (pop lists)) | |
16046 (setq list (symbol-value list)) | |
16047 (while list | |
16048 (gnus-sethash (car list) (pop list) gnus-killed-hashtb))))) | |
16049 | |
16050 (defun gnus-activate-group (group &optional scan dont-check method) | |
16051 ;; Check whether a group has been activated or not. | |
16052 ;; If SCAN, request a scan of that group as well. | |
16053 (let ((method (or method (gnus-find-method-for-group group))) | |
16054 active) | |
16055 (and (gnus-check-server method) | |
16056 ;; We escape all bugs and quit here to make it possible to | |
16057 ;; continue if a group is so out-there that it reports bugs | |
16058 ;; and stuff. | |
16059 (progn | |
16060 (and scan | |
16061 (gnus-check-backend-function 'request-scan (car method)) | |
16062 (gnus-request-scan group method)) | |
16063 t) | |
16064 (condition-case () | |
16065 (gnus-request-group group dont-check method) | |
16066 ; (error nil) | |
16067 (quit nil)) | |
16068 (save-excursion | |
16069 (set-buffer nntp-server-buffer) | |
16070 (goto-char (point-min)) | |
16071 ;; Parse the result we got from `gnus-request-group'. | |
16072 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+") | |
16073 (progn | |
16074 (goto-char (match-beginning 1)) | |
16075 (gnus-set-active | |
16076 group (setq active (cons (read (current-buffer)) | |
16077 (read (current-buffer))))) | |
16078 ;; Return the new active info. | |
16079 active)))))) | |
16080 | |
16081 (defun gnus-update-read-articles (group unread) | |
16082 "Update the list of read and ticked articles in GROUP using the | |
16083 UNREAD and TICKED lists. | |
16084 Note: UNSELECTED has to be sorted over `<'. | |
16085 Returns whether the updating was successful." | |
16086 (let* ((active (or gnus-newsgroup-active (gnus-active group))) | |
16087 (entry (gnus-gethash group gnus-newsrc-hashtb)) | |
16088 (info (nth 2 entry)) | |
16089 (prev 1) | |
16090 (unread (sort (copy-sequence unread) '<)) | |
16091 read) | |
16092 (if (or (not info) (not active)) | |
16093 ;; There is no info on this group if it was, in fact, | |
16094 ;; killed. Gnus stores no information on killed groups, so | |
16095 ;; there's nothing to be done. | |
16096 ;; One could store the information somewhere temporarily, | |
16097 ;; perhaps... Hmmm... | |
16098 () | |
16099 ;; Remove any negative articles numbers. | |
16100 (while (and unread (< (car unread) 0)) | |
16101 (setq unread (cdr unread))) | |
16102 ;; Remove any expired article numbers | |
16103 (while (and unread (< (car unread) (car active))) | |
16104 (setq unread (cdr unread))) | |
16105 ;; Compute the ranges of read articles by looking at the list of | |
16106 ;; unread articles. | |
16107 (while unread | |
16108 (if (/= (car unread) prev) | |
16109 (setq read (cons (if (= prev (1- (car unread))) prev | |
16110 (cons prev (1- (car unread)))) read))) | |
16111 (setq prev (1+ (car unread))) | |
16112 (setq unread (cdr unread))) | |
16113 (when (<= prev (cdr active)) | |
16114 (setq read (cons (cons prev (cdr active)) read))) | |
16115 ;; Enter this list into the group info. | |
16116 (gnus-info-set-read | |
16117 info (if (> (length read) 1) (nreverse read) read)) | |
16118 ;; Set the number of unread articles in gnus-newsrc-hashtb. | |
16119 (gnus-get-unread-articles-in-group info (gnus-active group)) | |
16120 t))) | |
16121 | |
16122 (defun gnus-make-articles-unread (group articles) | |
16123 "Mark ARTICLES in GROUP as unread." | |
16124 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb) | |
16125 (gnus-gethash (gnus-group-real-name group) | |
16126 gnus-newsrc-hashtb)))) | |
16127 (ranges (gnus-info-read info)) | |
16128 news article) | |
16129 (while articles | |
16130 (when (gnus-member-of-range | |
16131 (setq article (pop articles)) ranges) | |
16132 (setq news (cons article news)))) | |
16133 (when news | |
16134 (gnus-info-set-read | |
16135 info (gnus-remove-from-range (gnus-info-read info) (nreverse news))) | |
16136 (gnus-group-update-group group t)))) | |
16137 | |
16138 ;; Enter all dead groups into the hashtb. | |
16139 (defun gnus-update-active-hashtb-from-killed () | |
16140 (let ((hashtb (setq gnus-active-hashtb (make-vector 4095 0))) | |
16141 (lists (list gnus-killed-list gnus-zombie-list)) | |
16142 killed) | |
16143 (while lists | |
16144 (setq killed (car lists)) | |
16145 (while killed | |
16146 (gnus-sethash (car killed) nil hashtb) | |
16147 (setq killed (cdr killed))) | |
16148 (setq lists (cdr lists))))) | |
16149 | |
16150 (defun gnus-get-killed-groups () | |
16151 "Go through the active hashtb and all all unknown groups as killed." | |
16152 ;; First make sure active file has been read. | |
16153 (unless (gnus-read-active-file-p) | |
16154 (let ((gnus-read-active-file t)) | |
16155 (gnus-read-active-file))) | |
16156 (or gnus-killed-hashtb (gnus-make-hashtable-from-killed)) | |
16157 ;; Go through all newsgroups that are known to Gnus - enlarge kill list. | |
16158 (mapatoms | |
16159 (lambda (sym) | |
16160 (let ((groups 0) | |
16161 (group (symbol-name sym))) | |
16162 (if (or (null group) | |
16163 (gnus-gethash group gnus-killed-hashtb) | |
16164 (gnus-gethash group gnus-newsrc-hashtb)) | |
16165 () | |
16166 (let ((do-sub (gnus-matches-options-n group))) | |
16167 (if (or (eq do-sub 'subscribe) (eq do-sub 'ignore)) | |
16168 () | |
16169 (setq groups (1+ groups)) | |
16170 (setq gnus-killed-list | |
16171 (cons group gnus-killed-list)) | |
16172 (gnus-sethash group group gnus-killed-hashtb)))))) | |
16173 gnus-active-hashtb)) | |
16174 | |
16175 ;; Get the active file(s) from the backend(s). | |
16176 (defun gnus-read-active-file () | |
16177 (gnus-group-set-mode-line) | |
16178 (let ((methods | |
16179 (append | |
16180 (if (gnus-check-server gnus-select-method) | |
16181 ;; The native server is available. | |
16182 (cons gnus-select-method gnus-secondary-select-methods) | |
16183 ;; The native server is down, so we just do the | |
16184 ;; secondary ones. | |
16185 gnus-secondary-select-methods) | |
16186 ;; Also read from the archive server. | |
16187 (when gnus-message-archive-method | |
16188 (list "archive")))) | |
16189 list-type) | |
16190 (setq gnus-have-read-active-file nil) | |
16191 (save-excursion | |
16192 (set-buffer nntp-server-buffer) | |
16193 (while methods | |
16194 (let* ((method (if (stringp (car methods)) | |
16195 (gnus-server-get-method nil (car methods)) | |
16196 (car methods))) | |
16197 (where (nth 1 method)) | |
16198 (mesg (format "Reading active file%s via %s..." | |
16199 (if (and where (not (zerop (length where)))) | |
16200 (concat " from " where) "") | |
16201 (car method)))) | |
16202 (gnus-message 5 mesg) | |
16203 (when (gnus-check-server method) | |
16204 ;; Request that the backend scan its incoming messages. | |
16205 (and (gnus-check-backend-function 'request-scan (car method)) | |
16206 (gnus-request-scan nil method)) | |
16207 (cond | |
16208 ((and (eq gnus-read-active-file 'some) | |
16209 (gnus-check-backend-function 'retrieve-groups (car method))) | |
16210 (let ((newsrc (cdr gnus-newsrc-alist)) | |
16211 (gmethod (gnus-server-get-method nil method)) | |
16212 groups info) | |
16213 (while (setq info (pop newsrc)) | |
16214 (when (gnus-server-equal | |
16215 (gnus-find-method-for-group | |
16216 (gnus-info-group info) info) | |
16217 gmethod) | |
16218 (push (gnus-group-real-name (gnus-info-group info)) | |
16219 groups))) | |
16220 (when groups | |
16221 (gnus-check-server method) | |
16222 (setq list-type (gnus-retrieve-groups groups method)) | |
16223 (cond | |
16224 ((not list-type) | |
16225 (gnus-error | |
16226 1.2 "Cannot read partial active file from %s server." | |
16227 (car method))) | |
16228 ((eq list-type 'active) | |
16229 (gnus-active-to-gnus-format method gnus-active-hashtb)) | |
16230 (t | |
16231 (gnus-groups-to-gnus-format method gnus-active-hashtb)))))) | |
16232 (t | |
16233 (if (not (gnus-request-list method)) | |
16234 (unless (equal method gnus-message-archive-method) | |
16235 (gnus-error 1 "Cannot read active file from %s server." | |
16236 (car method))) | |
16237 (gnus-message 5 mesg) | |
16238 (gnus-active-to-gnus-format method gnus-active-hashtb) | |
16239 ;; We mark this active file as read. | |
16240 (push method gnus-have-read-active-file) | |
16241 (gnus-message 5 "%sdone" mesg)))))) | |
16242 (setq methods (cdr methods)))))) | |
16243 | |
16244 ;; Read an active file and place the results in `gnus-active-hashtb'. | |
16245 (defun gnus-active-to-gnus-format (&optional method hashtb ignore-errors) | |
16246 (unless method | |
16247 (setq method gnus-select-method)) | |
16248 (let ((cur (current-buffer)) | |
16249 (hashtb (or hashtb | |
16250 (if (and gnus-active-hashtb | |
16251 (not (equal method gnus-select-method))) | |
16252 gnus-active-hashtb | |
16253 (setq gnus-active-hashtb | |
16254 (if (equal method gnus-select-method) | |
16255 (gnus-make-hashtable | |
16256 (count-lines (point-min) (point-max))) | |
16257 (gnus-make-hashtable 4096))))))) | |
16258 ;; Delete unnecessary lines. | |
16259 (goto-char (point-min)) | |
16260 (while (search-forward "\nto." nil t) | |
16261 (delete-region (1+ (match-beginning 0)) | |
16262 (progn (forward-line 1) (point)))) | |
16263 (or (string= gnus-ignored-newsgroups "") | |
16264 (progn | |
16265 (goto-char (point-min)) | |
16266 (delete-matching-lines gnus-ignored-newsgroups))) | |
16267 ;; Make the group names readable as a lisp expression even if they | |
16268 ;; contain special characters. | |
16269 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>. | |
16270 (goto-char (point-max)) | |
16271 (while (re-search-backward "[][';?()#]" nil t) | |
16272 (insert ?\\)) | |
16273 ;; If these are groups from a foreign select method, we insert the | |
16274 ;; group prefix in front of the group names. | |
16275 (and method (not (gnus-server-equal | |
16276 (gnus-server-get-method nil method) | |
16277 (gnus-server-get-method nil gnus-select-method))) | |
16278 (let ((prefix (gnus-group-prefixed-name "" method))) | |
16279 (goto-char (point-min)) | |
16280 (while (and (not (eobp)) | |
16281 (progn (insert prefix) | |
16282 (zerop (forward-line 1))))))) | |
16283 ;; Store the active file in a hash table. | |
16284 (goto-char (point-min)) | |
16285 (if (string-match "%[oO]" gnus-group-line-format) | |
16286 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>. | |
16287 ;; If we want information on moderated groups, we use this | |
16288 ;; loop... | |
16289 (let* ((mod-hashtb (make-vector 7 0)) | |
16290 (m (intern "m" mod-hashtb)) | |
16291 group max min) | |
16292 (while (not (eobp)) | |
16293 (condition-case nil | |
16294 (progn | |
16295 (narrow-to-region (point) (gnus-point-at-eol)) | |
16296 (setq group (let ((obarray hashtb)) (read cur))) | |
16297 (if (and (numberp (setq max (read cur))) | |
16298 (numberp (setq min (read cur))) | |
16299 (progn | |
16300 (skip-chars-forward " \t") | |
16301 (not | |
16302 (or (= (following-char) ?=) | |
16303 (= (following-char) ?x) | |
16304 (= (following-char) ?j))))) | |
16305 (set group (cons min max)) | |
16306 (set group nil)) | |
16307 ;; Enter moderated groups into a list. | |
16308 (if (eq (let ((obarray mod-hashtb)) (read cur)) m) | |
16309 (setq gnus-moderated-list | |
16310 (cons (symbol-name group) gnus-moderated-list)))) | |
16311 (error | |
16312 (and group | |
16313 (symbolp group) | |
16314 (set group nil)))) | |
16315 (widen) | |
16316 (forward-line 1))) | |
16317 ;; And if we do not care about moderation, we use this loop, | |
16318 ;; which is faster. | |
16319 (let (group max min) | |
16320 (while (not (eobp)) | |
16321 (condition-case () | |
16322 (progn | |
16323 (narrow-to-region (point) (gnus-point-at-eol)) | |
16324 ;; group gets set to a symbol interned in the hash table | |
16325 ;; (what a hack!!) - jwz | |
16326 (setq group (let ((obarray hashtb)) (read cur))) | |
16327 (if (and (numberp (setq max (read cur))) | |
16328 (numberp (setq min (read cur))) | |
16329 (progn | |
16330 (skip-chars-forward " \t") | |
16331 (not | |
16332 (or (= (following-char) ?=) | |
16333 (= (following-char) ?x) | |
16334 (= (following-char) ?j))))) | |
16335 (set group (cons min max)) | |
16336 (set group nil))) | |
16337 (error | |
16338 (progn | |
16339 (and group | |
16340 (symbolp group) | |
16341 (set group nil)) | |
16342 (or ignore-errors | |
16343 (gnus-message 3 "Warning - illegal active: %s" | |
16344 (buffer-substring | |
16345 (gnus-point-at-bol) (gnus-point-at-eol))))))) | |
16346 (widen) | |
16347 (forward-line 1)))))) | |
16348 | |
16349 (defun gnus-groups-to-gnus-format (method &optional hashtb) | |
16350 ;; Parse a "groups" active file. | |
16351 (let ((cur (current-buffer)) | |
16352 (hashtb (or hashtb | |
16353 (if (and method gnus-active-hashtb) | |
16354 gnus-active-hashtb | |
16355 (setq gnus-active-hashtb | |
16356 (gnus-make-hashtable | |
16357 (count-lines (point-min) (point-max))))))) | |
16358 (prefix (and method | |
16359 (not (gnus-server-equal | |
16360 (gnus-server-get-method nil method) | |
16361 (gnus-server-get-method nil gnus-select-method))) | |
16362 (gnus-group-prefixed-name "" method)))) | |
16363 | |
16364 (goto-char (point-min)) | |
16365 ;; We split this into to separate loops, one with the prefix | |
16366 ;; and one without to speed the reading up somewhat. | |
16367 (if prefix | |
16368 (let (min max opoint group) | |
16369 (while (not (eobp)) | |
16370 (condition-case () | |
16371 (progn | |
16372 (read cur) (read cur) | |
16373 (setq min (read cur) | |
16374 max (read cur) | |
16375 opoint (point)) | |
16376 (skip-chars-forward " \t") | |
16377 (insert prefix) | |
16378 (goto-char opoint) | |
16379 (set (let ((obarray hashtb)) (read cur)) | |
16380 (cons min max))) | |
16381 (error (and group (symbolp group) (set group nil)))) | |
16382 (forward-line 1))) | |
16383 (let (min max group) | |
16384 (while (not (eobp)) | |
16385 (condition-case () | |
16386 (if (= (following-char) ?2) | |
16387 (progn | |
16388 (read cur) (read cur) | |
16389 (setq min (read cur) | |
16390 max (read cur)) | |
16391 (set (setq group (let ((obarray hashtb)) (read cur))) | |
16392 (cons min max)))) | |
16393 (error (and group (symbolp group) (set group nil)))) | |
16394 (forward-line 1)))))) | |
16395 | |
16396 (defun gnus-read-newsrc-file (&optional force) | |
16397 "Read startup file. | |
16398 If FORCE is non-nil, the .newsrc file is read." | |
16399 ;; Reset variables that might be defined in the .newsrc.eld file. | |
16400 (let ((variables gnus-variable-list)) | |
16401 (while variables | |
16402 (set (car variables) nil) | |
16403 (setq variables (cdr variables)))) | |
16404 (let* ((newsrc-file gnus-current-startup-file) | |
16405 (quick-file (concat newsrc-file ".el"))) | |
16406 (save-excursion | |
16407 ;; We always load the .newsrc.eld file. If always contains | |
16408 ;; much information that can not be gotten from the .newsrc | |
16409 ;; file (ticked articles, killed groups, foreign methods, etc.) | |
16410 (gnus-read-newsrc-el-file quick-file) | |
16411 | |
16412 (if (and (file-exists-p gnus-current-startup-file) | |
16413 (or force | |
16414 (and (file-newer-than-file-p newsrc-file quick-file) | |
16415 (file-newer-than-file-p newsrc-file | |
16416 (concat quick-file "d"))) | |
16417 (not gnus-newsrc-alist))) | |
16418 ;; We read the .newsrc file. Note that if there if a | |
16419 ;; .newsrc.eld file exists, it has already been read, and | |
16420 ;; the `gnus-newsrc-hashtb' has been created. While reading | |
16421 ;; the .newsrc file, Gnus will only use the information it | |
16422 ;; can find there for changing the data already read - | |
16423 ;; ie. reading the .newsrc file will not trash the data | |
16424 ;; already read (except for read articles). | |
16425 (save-excursion | |
16426 (gnus-message 5 "Reading %s..." newsrc-file) | |
16427 (set-buffer (find-file-noselect newsrc-file)) | |
16428 (buffer-disable-undo (current-buffer)) | |
16429 (gnus-newsrc-to-gnus-format) | |
16430 (kill-buffer (current-buffer)) | |
16431 (gnus-message 5 "Reading %s...done" newsrc-file))) | |
16432 | |
16433 ;; Read any slave files. | |
16434 (unless gnus-slave | |
16435 (gnus-master-read-slave-newsrc)) | |
16436 | |
16437 ;; Convert old to new. | |
16438 (gnus-convert-old-newsrc)))) | |
16439 | |
16440 (defun gnus-continuum-version (version) | |
16441 "Return VERSION as a floating point number." | |
16442 (when (or (string-match "^\\([^ ]+\\)? ?Gnus v?\\([0-9.]+\\)$" version) | |
16443 (string-match "^\\(.?\\)gnus-\\([0-9.]+\\)$" version)) | |
16444 (let* ((alpha (and (match-beginning 1) (match-string 1 version))) | |
16445 (number (match-string 2 version)) | |
16446 major minor least) | |
16447 (string-match "\\([0-9]\\)\\.\\([0-9]+\\)\\.?\\([0-9]+\\)?" number) | |
16448 (setq major (string-to-number (match-string 1 number))) | |
16449 (setq minor (string-to-number (match-string 2 number))) | |
16450 (setq least (if (match-beginning 3) | |
16451 (string-to-number (match-string 3 number)) | |
16452 0)) | |
16453 (string-to-number | |
16454 (if (zerop major) | |
16455 (format "%s00%02d%02d" | |
16456 (cond | |
16457 ((member alpha '("(ding)" "d")) "4.99") | |
16458 ((member alpha '("September" "s")) "5.01") | |
16459 ((member alpha '("Red" "r")) "5.03")) | |
16460 minor least) | |
16461 (format "%d.%02d%02d" major minor least)))))) | |
16462 | |
16463 (defun gnus-convert-old-newsrc () | |
16464 "Convert old newsrc into the new format, if needed." | |
16465 (let ((fcv (and gnus-newsrc-file-version | |
16466 (gnus-continuum-version gnus-newsrc-file-version)))) | |
16467 (cond | |
16468 ;; No .newsrc.eld file was loaded. | |
16469 ((null fcv) nil) | |
16470 ;; Gnus 5 .newsrc.eld was loaded. | |
16471 ((< fcv (gnus-continuum-version "September Gnus v0.1")) | |
16472 (gnus-convert-old-ticks))))) | |
16473 | |
16474 (defun gnus-convert-old-ticks () | |
16475 (let ((newsrc (cdr gnus-newsrc-alist)) | |
16476 marks info dormant ticked) | |
16477 (while (setq info (pop newsrc)) | |
16478 (when (setq marks (gnus-info-marks info)) | |
16479 (setq dormant (cdr (assq 'dormant marks)) | |
16480 ticked (cdr (assq 'tick marks))) | |
16481 (when (or dormant ticked) | |
16482 (gnus-info-set-read | |
16483 info | |
16484 (gnus-add-to-range | |
16485 (gnus-info-read info) | |
16486 (nconc (gnus-uncompress-range dormant) | |
16487 (gnus-uncompress-range ticked))))))))) | |
16488 | |
16489 (defun gnus-read-newsrc-el-file (file) | |
16490 (let ((ding-file (concat file "d"))) | |
16491 ;; We always, always read the .eld file. | |
16492 (gnus-message 5 "Reading %s..." ding-file) | |
16493 (let (gnus-newsrc-assoc) | |
16494 (condition-case nil | |
16495 (load ding-file t t t) | |
16496 (error | |
16497 (gnus-error 1 "Error in %s" ding-file))) | |
16498 (when gnus-newsrc-assoc | |
16499 (setq gnus-newsrc-alist gnus-newsrc-assoc))) | |
16500 (gnus-make-hashtable-from-newsrc-alist) | |
16501 (when (file-newer-than-file-p file ding-file) | |
16502 ;; Old format quick file | |
16503 (gnus-message 5 "Reading %s..." file) | |
16504 ;; The .el file is newer than the .eld file, so we read that one | |
16505 ;; as well. | |
16506 (gnus-read-old-newsrc-el-file file)))) | |
16507 | |
16508 ;; Parse the old-style quick startup file | |
16509 (defun gnus-read-old-newsrc-el-file (file) | |
16510 (let (newsrc killed marked group m info) | |
16511 (prog1 | |
16512 (let ((gnus-killed-assoc nil) | |
16513 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc) | |
16514 (prog1 | |
16515 (condition-case nil | |
16516 (load file t t t) | |
16517 (error nil)) | |
16518 (setq newsrc gnus-newsrc-assoc | |
16519 killed gnus-killed-assoc | |
16520 marked gnus-marked-assoc))) | |
16521 (setq gnus-newsrc-alist nil) | |
16522 (while (setq group (pop newsrc)) | |
16523 (if (setq info (gnus-get-info (car group))) | |
16524 (progn | |
16525 (gnus-info-set-read info (cddr group)) | |
16526 (gnus-info-set-level | |
16527 info (if (nth 1 group) gnus-level-default-subscribed | |
16528 gnus-level-default-unsubscribed)) | |
16529 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist))) | |
16530 (push (setq info | |
16531 (list (car group) | |
16532 (if (nth 1 group) gnus-level-default-subscribed | |
16533 gnus-level-default-unsubscribed) | |
16534 (cddr group))) | |
16535 gnus-newsrc-alist)) | |
16536 ;; Copy marks into info. | |
16537 (when (setq m (assoc (car group) marked)) | |
16538 (unless (nthcdr 3 info) | |
16539 (nconc info (list nil))) | |
16540 (gnus-info-set-marks | |
16541 info (list (cons 'tick (gnus-compress-sequence | |
16542 (sort (cdr m) '<) t)))))) | |
16543 (setq newsrc killed) | |
16544 (while newsrc | |
16545 (setcar newsrc (caar newsrc)) | |
16546 (setq newsrc (cdr newsrc))) | |
16547 (setq gnus-killed-list killed)) | |
16548 ;; The .el file version of this variable does not begin with | |
16549 ;; "options", while the .eld version does, so we just add it if it | |
16550 ;; isn't there. | |
16551 (and | |
16552 gnus-newsrc-options | |
16553 (progn | |
16554 (and (not (string-match "^ *options" gnus-newsrc-options)) | |
16555 (setq gnus-newsrc-options (concat "options " gnus-newsrc-options))) | |
16556 (and (not (string-match "\n$" gnus-newsrc-options)) | |
16557 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n"))) | |
16558 ;; Finally, if we read some options lines, we parse them. | |
16559 (or (string= gnus-newsrc-options "") | |
16560 (gnus-newsrc-parse-options gnus-newsrc-options)))) | |
16561 | |
16562 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)) | |
16563 (gnus-make-hashtable-from-newsrc-alist))) | |
16564 | |
16565 (defun gnus-make-newsrc-file (file) | |
16566 "Make server dependent file name by catenating FILE and server host name." | |
16567 (let* ((file (expand-file-name file nil)) | |
16568 (real-file (concat file "-" (nth 1 gnus-select-method)))) | |
16569 (if (or (file-exists-p real-file) | |
16570 (file-exists-p (concat real-file ".el")) | |
16571 (file-exists-p (concat real-file ".eld"))) | |
16572 real-file file))) | |
16573 | |
16574 (defun gnus-newsrc-to-gnus-format () | |
16575 (setq gnus-newsrc-options "") | |
16576 (setq gnus-newsrc-options-n nil) | |
16577 | |
16578 (or gnus-active-hashtb | |
16579 (setq gnus-active-hashtb (make-vector 4095 0))) | |
16580 (let ((buf (current-buffer)) | |
16581 (already-read (> (length gnus-newsrc-alist) 1)) | |
16582 group subscribed options-symbol newsrc Options-symbol | |
16583 symbol reads num1) | |
16584 (goto-char (point-min)) | |
16585 ;; We intern the symbol `options' in the active hashtb so that we | |
16586 ;; can `eq' against it later. | |
16587 (set (setq options-symbol (intern "options" gnus-active-hashtb)) nil) | |
16588 (set (setq Options-symbol (intern "Options" gnus-active-hashtb)) nil) | |
16589 | |
16590 (while (not (eobp)) | |
16591 ;; We first read the first word on the line by narrowing and | |
16592 ;; then reading into `gnus-active-hashtb'. Most groups will | |
16593 ;; already exist in that hashtb, so this will save some string | |
16594 ;; space. | |
16595 (narrow-to-region | |
16596 (point) | |
16597 (progn (skip-chars-forward "^ \t!:\n") (point))) | |
16598 (goto-char (point-min)) | |
16599 (setq symbol | |
16600 (and (/= (point-min) (point-max)) | |
16601 (let ((obarray gnus-active-hashtb)) (read buf)))) | |
16602 (widen) | |
16603 ;; Now, the symbol we have read is either `options' or a group | |
16604 ;; name. If it is an options line, we just add it to a string. | |
16605 (cond | |
16606 ((or (eq symbol options-symbol) | |
16607 (eq symbol Options-symbol)) | |
16608 (setq gnus-newsrc-options | |
16609 ;; This concating is quite inefficient, but since our | |
16610 ;; thorough studies show that approx 99.37% of all | |
16611 ;; .newsrc files only contain a single options line, we | |
16612 ;; don't give a damn, frankly, my dear. | |
16613 (concat gnus-newsrc-options | |
16614 (buffer-substring | |
16615 (gnus-point-at-bol) | |
16616 ;; Options may continue on the next line. | |
16617 (or (and (re-search-forward "^[^ \t]" nil 'move) | |
16618 (progn (beginning-of-line) (point))) | |
16619 (point))))) | |
16620 (forward-line -1)) | |
16621 (symbol | |
16622 ;; Group names can be just numbers. | |
16623 (when (numberp symbol) | |
16624 (setq symbol (intern (int-to-string symbol) gnus-active-hashtb))) | |
16625 (or (boundp symbol) (set symbol nil)) | |
16626 ;; It was a group name. | |
16627 (setq subscribed (= (following-char) ?:) | |
16628 group (symbol-name symbol) | |
16629 reads nil) | |
16630 (if (eolp) | |
16631 ;; If the line ends here, this is clearly a buggy line, so | |
16632 ;; we put point a the beginning of line and let the cond | |
16633 ;; below do the error handling. | |
16634 (beginning-of-line) | |
16635 ;; We skip to the beginning of the ranges. | |
16636 (skip-chars-forward "!: \t")) | |
16637 ;; We are now at the beginning of the list of read articles. | |
16638 ;; We read them range by range. | |
16639 (while | |
16640 (cond | |
16641 ((looking-at "[0-9]+") | |
16642 ;; We narrow and read a number instead of buffer-substring/ | |
16643 ;; string-to-int because it's faster. narrow/widen is | |
16644 ;; faster than save-restriction/narrow, and save-restriction | |
16645 ;; produces a garbage object. | |
16646 (setq num1 (progn | |
16647 (narrow-to-region (match-beginning 0) (match-end 0)) | |
16648 (read buf))) | |
16649 (widen) | |
16650 ;; If the next character is a dash, then this is a range. | |
16651 (if (= (following-char) ?-) | |
16652 (progn | |
16653 ;; We read the upper bound of the range. | |
16654 (forward-char 1) | |
16655 (if (not (looking-at "[0-9]+")) | |
16656 ;; This is a buggy line, by we pretend that | |
16657 ;; it's kinda OK. Perhaps the user should be | |
16658 ;; dinged? | |
16659 (setq reads (cons num1 reads)) | |
16660 (setq reads | |
16661 (cons | |
16662 (cons num1 | |
16663 (progn | |
16664 (narrow-to-region (match-beginning 0) | |
16665 (match-end 0)) | |
16666 (read buf))) | |
16667 reads)) | |
16668 (widen))) | |
16669 ;; It was just a simple number, so we add it to the | |
16670 ;; list of ranges. | |
16671 (setq reads (cons num1 reads))) | |
16672 ;; If the next char in ?\n, then we have reached the end | |
16673 ;; of the line and return nil. | |
16674 (/= (following-char) ?\n)) | |
16675 ((= (following-char) ?\n) | |
16676 ;; End of line, so we end. | |
16677 nil) | |
16678 (t | |
16679 ;; Not numbers and not eol, so this might be a buggy | |
16680 ;; line... | |
16681 (or (eobp) | |
16682 ;; If it was eob instead of ?\n, we allow it. | |
16683 (progn | |
16684 ;; The line was buggy. | |
16685 (setq group nil) | |
16686 (gnus-error 3.1 "Mangled line: %s" | |
16687 (buffer-substring (gnus-point-at-bol) | |
16688 (gnus-point-at-eol))))) | |
16689 nil)) | |
16690 ;; Skip past ", ". Spaces are illegal in these ranges, but | |
16691 ;; we allow them, because it's a common mistake to put a | |
16692 ;; space after the comma. | |
16693 (skip-chars-forward ", ")) | |
16694 | |
16695 ;; We have already read .newsrc.eld, so we gently update the | |
16696 ;; data in the hash table with the information we have just | |
16697 ;; read. | |
16698 (when group | |
16699 (let ((info (gnus-get-info group)) | |
16700 level) | |
16701 (if info | |
16702 ;; There is an entry for this file in the alist. | |
16703 (progn | |
16704 (gnus-info-set-read info (nreverse reads)) | |
16705 ;; We update the level very gently. In fact, we | |
16706 ;; only change it if there's been a status change | |
16707 ;; from subscribed to unsubscribed, or vice versa. | |
16708 (setq level (gnus-info-level info)) | |
16709 (cond ((and (<= level gnus-level-subscribed) | |
16710 (not subscribed)) | |
16711 (setq level (if reads | |
16712 gnus-level-default-unsubscribed | |
16713 (1+ gnus-level-default-unsubscribed)))) | |
16714 ((and (> level gnus-level-subscribed) subscribed) | |
16715 (setq level gnus-level-default-subscribed))) | |
16716 (gnus-info-set-level info level)) | |
16717 ;; This is a new group. | |
16718 (setq info (list group | |
16719 (if subscribed | |
16720 gnus-level-default-subscribed | |
16721 (if reads | |
16722 (1+ gnus-level-subscribed) | |
16723 gnus-level-default-unsubscribed)) | |
16724 (nreverse reads)))) | |
16725 (setq newsrc (cons info newsrc)))))) | |
16726 (forward-line 1)) | |
16727 | |
16728 (setq newsrc (nreverse newsrc)) | |
16729 | |
16730 (if (not already-read) | |
16731 () | |
16732 ;; We now have two newsrc lists - `newsrc', which is what we | |
16733 ;; have read from .newsrc, and `gnus-newsrc-alist', which is | |
16734 ;; what we've read from .newsrc.eld. We have to merge these | |
16735 ;; lists. We do this by "attaching" any (foreign) groups in the | |
16736 ;; gnus-newsrc-alist to the (native) group that precedes them. | |
16737 (let ((rc (cdr gnus-newsrc-alist)) | |
16738 (prev gnus-newsrc-alist) | |
16739 entry mentry) | |
16740 (while rc | |
16741 (or (null (nth 4 (car rc))) ; It's a native group. | |
16742 (assoc (caar rc) newsrc) ; It's already in the alist. | |
16743 (if (setq entry (assoc (caar prev) newsrc)) | |
16744 (setcdr (setq mentry (memq entry newsrc)) | |
16745 (cons (car rc) (cdr mentry))) | |
16746 (setq newsrc (cons (car rc) newsrc)))) | |
16747 (setq prev rc | |
16748 rc (cdr rc))))) | |
16749 | |
16750 (setq gnus-newsrc-alist newsrc) | |
16751 ;; We make the newsrc hashtb. | |
16752 (gnus-make-hashtable-from-newsrc-alist) | |
16753 | |
16754 ;; Finally, if we read some options lines, we parse them. | |
16755 (or (string= gnus-newsrc-options "") | |
16756 (gnus-newsrc-parse-options gnus-newsrc-options)))) | |
16757 | |
16758 ;; Parse options lines to find "options -n !all rec.all" and stuff. | |
16759 ;; The return value will be a list on the form | |
16760 ;; ((regexp1 . ignore) | |
16761 ;; (regexp2 . subscribe)...) | |
16762 ;; When handling new newsgroups, groups that match a `ignore' regexp | |
16763 ;; will be ignored, and groups that match a `subscribe' regexp will be | |
16764 ;; subscribed. A line like | |
16765 ;; options -n !all rec.all | |
16766 ;; will lead to a list that looks like | |
16767 ;; (("^rec\\..+" . subscribe) | |
16768 ;; ("^.+" . ignore)) | |
16769 ;; So all "rec.*" groups will be subscribed, while all the other | |
16770 ;; groups will be ignored. Note that "options -n !all rec.all" is very | |
16771 ;; different from "options -n rec.all !all". | |
16772 (defun gnus-newsrc-parse-options (options) | |
16773 (let (out eol) | |
16774 (save-excursion | |
16775 (gnus-set-work-buffer) | |
16776 (insert (regexp-quote options)) | |
16777 ;; First we treat all continuation lines. | |
16778 (goto-char (point-min)) | |
16779 (while (re-search-forward "\n[ \t]+" nil t) | |
16780 (replace-match " " t t)) | |
16781 ;; Then we transform all "all"s into ".+"s. | |
16782 (goto-char (point-min)) | |
16783 (while (re-search-forward "\\ball\\b" nil t) | |
16784 (replace-match ".+" t t)) | |
16785 (goto-char (point-min)) | |
16786 ;; We remove all other options than the "-n" ones. | |
16787 (while (re-search-forward "[ \t]-[^n][^-]*" nil t) | |
16788 (replace-match " ") | |
16789 (forward-char -1)) | |
16790 (goto-char (point-min)) | |
16791 | |
16792 ;; We are only interested in "options -n" lines - we | |
16793 ;; ignore the other option lines. | |
16794 (while (re-search-forward "[ \t]-n" nil t) | |
16795 (setq eol | |
16796 (or (save-excursion | |
16797 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t) | |
16798 (- (point) 2))) | |
16799 (gnus-point-at-eol))) | |
16800 ;; Search for all "words"... | |
16801 (while (re-search-forward "[^ \t,\n]+" eol t) | |
16802 (if (= (char-after (match-beginning 0)) ?!) | |
16803 ;; If the word begins with a bang (!), this is a "not" | |
16804 ;; spec. We put this spec (minus the bang) and the | |
16805 ;; symbol `ignore' into the list. | |
16806 (setq out (cons (cons (concat | |
16807 "^" (buffer-substring | |
16808 (1+ (match-beginning 0)) | |
16809 (match-end 0))) | |
16810 'ignore) out)) | |
16811 ;; There was no bang, so this is a "yes" spec. | |
16812 (setq out (cons (cons (concat "^" (match-string 0)) | |
16813 'subscribe) out))))) | |
16814 | |
16815 (setq gnus-newsrc-options-n out)))) | |
16816 | |
16817 (defun gnus-save-newsrc-file (&optional force) | |
16818 "Save .newsrc file." | |
16819 ;; Note: We cannot save .newsrc file if all newsgroups are removed | |
16820 ;; from the variable gnus-newsrc-alist. | |
16821 (when (and (or gnus-newsrc-alist gnus-killed-list) | |
16822 gnus-current-startup-file) | |
16823 (save-excursion | |
16824 (if (and (or gnus-use-dribble-file gnus-slave) | |
16825 (not force) | |
16826 (or (not gnus-dribble-buffer) | |
16827 (not (buffer-name gnus-dribble-buffer)) | |
16828 (zerop (save-excursion | |
16829 (set-buffer gnus-dribble-buffer) | |
16830 (buffer-size))))) | |
16831 (gnus-message 4 "(No changes need to be saved)") | |
16832 (run-hooks 'gnus-save-newsrc-hook) | |
16833 (if gnus-slave | |
16834 (gnus-slave-save-newsrc) | |
16835 ;; Save .newsrc. | |
16836 (when gnus-save-newsrc-file | |
16837 (gnus-message 5 "Saving %s..." gnus-current-startup-file) | |
16838 (gnus-gnus-to-newsrc-format) | |
16839 (gnus-message 5 "Saving %s...done" gnus-current-startup-file)) | |
16840 ;; Save .newsrc.eld. | |
16841 (set-buffer (get-buffer-create " *Gnus-newsrc*")) | |
16842 (make-local-variable 'version-control) | |
16843 (setq version-control 'never) | |
16844 (setq buffer-file-name | |
16845 (concat gnus-current-startup-file ".eld")) | |
16846 (setq default-directory (file-name-directory buffer-file-name)) | |
16847 (gnus-add-current-to-buffer-list) | |
16848 (buffer-disable-undo (current-buffer)) | |
16849 (erase-buffer) | |
16850 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file) | |
16851 (gnus-gnus-to-quick-newsrc-format) | |
16852 (run-hooks 'gnus-save-quick-newsrc-hook) | |
16853 (save-buffer) | |
16854 (kill-buffer (current-buffer)) | |
16855 (gnus-message | |
16856 5 "Saving %s.eld...done" gnus-current-startup-file)) | |
16857 (gnus-dribble-delete-file) | |
16858 (gnus-group-set-mode-line))))) | |
16859 | |
16860 (defun gnus-gnus-to-quick-newsrc-format () | |
16861 "Insert Gnus variables such as gnus-newsrc-alist in lisp format." | |
16862 (insert ";; Gnus startup file.\n") | |
16863 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n") | |
16864 (insert ";; to read .newsrc.\n") | |
16865 (insert "(setq gnus-newsrc-file-version " | |
16866 (prin1-to-string gnus-version) ")\n") | |
16867 (let ((variables | |
16868 (if gnus-save-killed-list gnus-variable-list | |
16869 ;; Remove the `gnus-killed-list' from the list of variables | |
16870 ;; to be saved, if required. | |
16871 (delq 'gnus-killed-list (copy-sequence gnus-variable-list)))) | |
16872 ;; Peel off the "dummy" group. | |
16873 (gnus-newsrc-alist (cdr gnus-newsrc-alist)) | |
16874 variable) | |
16875 ;; Insert the variables into the file. | |
16876 (while variables | |
16877 (when (and (boundp (setq variable (pop variables))) | |
16878 (symbol-value variable)) | |
16879 (insert "(setq " (symbol-name variable) " '") | |
16880 (prin1 (symbol-value variable) (current-buffer)) | |
16881 (insert ")\n"))))) | |
16882 | |
16883 (defun gnus-gnus-to-newsrc-format () | |
16884 ;; Generate and save the .newsrc file. | |
16885 (save-excursion | |
16886 (set-buffer (create-file-buffer gnus-current-startup-file)) | |
16887 (let ((newsrc (cdr gnus-newsrc-alist)) | |
16888 (standard-output (current-buffer)) | |
16889 info ranges range method) | |
16890 (setq buffer-file-name gnus-current-startup-file) | |
16891 (setq default-directory (file-name-directory buffer-file-name)) | |
16892 (buffer-disable-undo (current-buffer)) | |
16893 (erase-buffer) | |
16894 ;; Write options. | |
16895 (if gnus-newsrc-options (insert gnus-newsrc-options)) | |
16896 ;; Write subscribed and unsubscribed. | |
16897 (while (setq info (pop newsrc)) | |
16898 ;; Don't write foreign groups to .newsrc. | |
16899 (when (or (null (setq method (gnus-info-method info))) | |
16900 (equal method "native") | |
16901 (gnus-server-equal method gnus-select-method)) | |
16902 (insert (gnus-info-group info) | |
16903 (if (> (gnus-info-level info) gnus-level-subscribed) | |
16904 "!" ":")) | |
16905 (when (setq ranges (gnus-info-read info)) | |
16906 (insert " ") | |
16907 (if (not (listp (cdr ranges))) | |
16908 (if (= (car ranges) (cdr ranges)) | |
16909 (princ (car ranges)) | |
16910 (princ (car ranges)) | |
16911 (insert "-") | |
16912 (princ (cdr ranges))) | |
16913 (while (setq range (pop ranges)) | |
16914 (if (or (atom range) (= (car range) (cdr range))) | |
16915 (princ (or (and (atom range) range) (car range))) | |
16916 (princ (car range)) | |
16917 (insert "-") | |
16918 (princ (cdr range))) | |
16919 (if ranges (insert ","))))) | |
16920 (insert "\n"))) | |
16921 (make-local-variable 'version-control) | |
16922 (setq version-control 'never) | |
16923 ;; It has been reported that sometime the modtime on the .newsrc | |
16924 ;; file seems to be off. We really do want to overwrite it, so | |
16925 ;; we clear the modtime here before saving. It's a bit odd, | |
16926 ;; though... | |
16927 ;; sometimes the modtime clear isn't sufficient. most brute force: | |
16928 ;; delete the silly thing entirely first. but this fails to provide | |
16929 ;; such niceties as .newsrc~ creation. | |
16930 (if gnus-modtime-botch | |
16931 (delete-file gnus-startup-file) | |
16932 (clear-visited-file-modtime)) | |
16933 (run-hooks 'gnus-save-standard-newsrc-hook) | |
16934 (save-buffer) | |
16935 (kill-buffer (current-buffer))))) | |
16936 | |
16937 | |
16938 ;;; | |
16939 ;;; Slave functions. | |
16940 ;;; | |
16941 | |
16942 (defun gnus-slave-save-newsrc () | |
16943 (save-excursion | |
16944 (set-buffer gnus-dribble-buffer) | |
16945 (let ((slave-name | |
16946 (make-temp-name (concat gnus-current-startup-file "-slave-")))) | |
16947 (write-region (point-min) (point-max) slave-name nil 'nomesg)))) | |
16948 | |
16949 (defun gnus-master-read-slave-newsrc () | |
16950 (let ((slave-files | |
16951 (directory-files | |
16952 (file-name-directory gnus-current-startup-file) | |
16953 t (concat | |
16954 "^" (regexp-quote | |
16955 (concat | |
16956 (file-name-nondirectory gnus-current-startup-file) | |
16957 "-slave-"))) | |
16958 t)) | |
16959 file) | |
16960 (if (not slave-files) | |
16961 () ; There are no slave files to read. | |
16962 (gnus-message 7 "Reading slave newsrcs...") | |
16963 (save-excursion | |
16964 (set-buffer (get-buffer-create " *gnus slave*")) | |
16965 (buffer-disable-undo (current-buffer)) | |
16966 (setq slave-files | |
16967 (sort (mapcar (lambda (file) | |
16968 (list (nth 5 (file-attributes file)) file)) | |
16969 slave-files) | |
16970 (lambda (f1 f2) | |
16971 (or (< (caar f1) (caar f2)) | |
16972 (< (nth 1 (car f1)) (nth 1 (car f2))))))) | |
16973 (while slave-files | |
16974 (erase-buffer) | |
16975 (setq file (nth 1 (car slave-files))) | |
16976 (insert-file-contents file) | |
16977 (if (condition-case () | |
16978 (progn | |
16979 (eval-buffer (current-buffer)) | |
16980 t) | |
16981 (error | |
16982 (gnus-error 3.2 "Possible error in %s" file) | |
16983 nil)) | |
16984 (or gnus-slave ; Slaves shouldn't delete these files. | |
16985 (condition-case () | |
16986 (delete-file file) | |
16987 (error nil)))) | |
16988 (setq slave-files (cdr slave-files)))) | |
16989 (gnus-message 7 "Reading slave newsrcs...done")))) | |
16990 | |
16991 | |
16992 ;;; | |
16993 ;;; Group description. | |
16994 ;;; | |
16995 | |
16996 (defun gnus-read-all-descriptions-files () | |
16997 (let ((methods (cons gnus-select-method | |
16998 (nconc | |
16999 (when gnus-message-archive-method | |
17000 (list "archive")) | |
17001 gnus-secondary-select-methods)))) | |
17002 (while methods | |
17003 (gnus-read-descriptions-file (car methods)) | |
17004 (setq methods (cdr methods))) | |
17005 t)) | |
17006 | |
17007 (defun gnus-read-descriptions-file (&optional method) | |
17008 (let ((method (or method gnus-select-method)) | |
17009 group) | |
17010 (when (stringp method) | |
17011 (setq method (gnus-server-to-method method))) | |
17012 ;; We create the hashtable whether we manage to read the desc file | |
17013 ;; to avoid trying to re-read after a failed read. | |
17014 (or gnus-description-hashtb | |
17015 (setq gnus-description-hashtb | |
17016 (gnus-make-hashtable (length gnus-active-hashtb)))) | |
17017 ;; Mark this method's desc file as read. | |
17018 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read" | |
17019 gnus-description-hashtb) | |
17020 | |
17021 (gnus-message 5 "Reading descriptions file via %s..." (car method)) | |
17022 (cond | |
17023 ((not (gnus-check-server method)) | |
17024 (gnus-message 1 "Couldn't open server") | |
17025 nil) | |
17026 ((not (gnus-request-list-newsgroups method)) | |
17027 (gnus-message 1 "Couldn't read newsgroups descriptions") | |
17028 nil) | |
17029 (t | |
17030 (save-excursion | |
17031 (save-restriction | |
17032 (set-buffer nntp-server-buffer) | |
17033 (goto-char (point-min)) | |
17034 (when (or (search-forward "\n.\n" nil t) | |
17035 (goto-char (point-max))) | |
17036 (beginning-of-line) | |
17037 (narrow-to-region (point-min) (point))) | |
17038 ;; If these are groups from a foreign select method, we insert the | |
17039 ;; group prefix in front of the group names. | |
17040 (and method (not (gnus-server-equal | |
17041 (gnus-server-get-method nil method) | |
17042 (gnus-server-get-method nil gnus-select-method))) | |
17043 (let ((prefix (gnus-group-prefixed-name "" method))) | |
17044 (goto-char (point-min)) | |
17045 (while (and (not (eobp)) | |
17046 (progn (insert prefix) | |
17047 (zerop (forward-line 1))))))) | |
17048 (goto-char (point-min)) | |
17049 (while (not (eobp)) | |
17050 ;; If we get an error, we set group to 0, which is not a | |
17051 ;; symbol... | |
17052 (setq group | |
17053 (condition-case () | |
17054 (let ((obarray gnus-description-hashtb)) | |
17055 ;; Group is set to a symbol interned in this | |
17056 ;; hash table. | |
17057 (read nntp-server-buffer)) | |
17058 (error 0))) | |
17059 (skip-chars-forward " \t") | |
17060 ;; ... which leads to this line being effectively ignored. | |
17061 (and (symbolp group) | |
17062 (set group (buffer-substring | |
17063 (point) (progn (end-of-line) (point))))) | |
17064 (forward-line 1)))) | |
17065 (gnus-message 5 "Reading descriptions file...done") | |
17066 t)))) | |
17067 | |
17068 (defun gnus-group-get-description (group) | |
17069 "Get the description of a group by sending XGTITLE to the server." | |
17070 (when (gnus-request-group-description group) | |
17071 (save-excursion | |
17072 (set-buffer nntp-server-buffer) | |
17073 (goto-char (point-min)) | |
17074 (when (looking-at "[^ \t]+[ \t]+\\(.*\\)") | |
17075 (match-string 1))))) | |
17076 | |
17077 | |
17078 ;;; | |
17079 ;;; Buffering of read articles. | |
17080 ;;; | |
17081 | |
17082 (defvar gnus-backlog-buffer " *Gnus Backlog*") | |
17083 (defvar gnus-backlog-articles nil) | |
17084 (defvar gnus-backlog-hashtb nil) | |
17085 | |
17086 (defun gnus-backlog-buffer () | |
17087 "Return the backlog buffer." | |
17088 (or (get-buffer gnus-backlog-buffer) | |
17089 (save-excursion | |
17090 (set-buffer (get-buffer-create gnus-backlog-buffer)) | |
17091 (buffer-disable-undo (current-buffer)) | |
17092 (setq buffer-read-only t) | |
17093 (gnus-add-current-to-buffer-list) | |
17094 (get-buffer gnus-backlog-buffer)))) | |
17095 | |
17096 (defun gnus-backlog-setup () | |
17097 "Initialize backlog variables." | |
17098 (unless gnus-backlog-hashtb | |
17099 (setq gnus-backlog-hashtb (make-vector 1023 0)))) | |
17100 | |
17101 (gnus-add-shutdown 'gnus-backlog-shutdown 'gnus) | |
17102 | |
17103 (defun gnus-backlog-shutdown () | |
17104 "Clear all backlog variables and buffers." | |
17105 (when (get-buffer gnus-backlog-buffer) | |
17106 (kill-buffer gnus-backlog-buffer)) | |
17107 (setq gnus-backlog-hashtb nil | |
17108 gnus-backlog-articles nil)) | |
17109 | |
17110 (defun gnus-backlog-enter-article (group number buffer) | |
17111 (gnus-backlog-setup) | |
17112 (let ((ident (intern (concat group ":" (int-to-string number)) | |
17113 gnus-backlog-hashtb)) | |
17114 b) | |
17115 (if (memq ident gnus-backlog-articles) | |
17116 () ; It's already kept. | |
17117 ;; Remove the oldest article, if necessary. | |
17118 (and (numberp gnus-keep-backlog) | |
17119 (>= (length gnus-backlog-articles) gnus-keep-backlog) | |
17120 (gnus-backlog-remove-oldest-article)) | |
17121 (setq gnus-backlog-articles (cons ident gnus-backlog-articles)) | |
17122 ;; Insert the new article. | |
17123 (save-excursion | |
17124 (set-buffer (gnus-backlog-buffer)) | |
17125 (let (buffer-read-only) | |
17126 (goto-char (point-max)) | |
17127 (or (bolp) (insert "\n")) | |
17128 (setq b (point)) | |
17129 (insert-buffer-substring buffer) | |
17130 ;; Tag the beginning of the article with the ident. | |
17131 (gnus-put-text-property b (1+ b) 'gnus-backlog ident)))))) | |
17132 | |
17133 (defun gnus-backlog-remove-oldest-article () | |
17134 (save-excursion | |
17135 (set-buffer (gnus-backlog-buffer)) | |
17136 (goto-char (point-min)) | |
17137 (if (zerop (buffer-size)) | |
17138 () ; The buffer is empty. | |
17139 (let ((ident (get-text-property (point) 'gnus-backlog)) | |
17140 buffer-read-only) | |
17141 ;; Remove the ident from the list of articles. | |
17142 (when ident | |
17143 (setq gnus-backlog-articles (delq ident gnus-backlog-articles))) | |
17144 ;; Delete the article itself. | |
17145 (delete-region | |
17146 (point) (next-single-property-change | |
17147 (1+ (point)) 'gnus-backlog nil (point-max))))))) | |
17148 | |
17149 (defun gnus-backlog-remove-article (group number) | |
17150 "Remove article NUMBER in GROUP from the backlog." | |
17151 (when (numberp number) | |
17152 (gnus-backlog-setup) | |
17153 (let ((ident (intern (concat group ":" (int-to-string number)) | |
17154 gnus-backlog-hashtb)) | |
17155 beg end) | |
17156 (when (memq ident gnus-backlog-articles) | |
17157 ;; It was in the backlog. | |
17158 (save-excursion | |
17159 (set-buffer (gnus-backlog-buffer)) | |
17160 (let (buffer-read-only) | |
17161 (when (setq beg (text-property-any | |
17162 (point-min) (point-max) 'gnus-backlog | |
17163 ident)) | |
17164 ;; Find the end (i. e., the beginning of the next article). | |
17165 (setq end | |
17166 (next-single-property-change | |
17167 (1+ beg) 'gnus-backlog (current-buffer) (point-max))) | |
17168 (delete-region beg end) | |
17169 ;; Return success. | |
17170 t))))))) | |
17171 | |
17172 (defun gnus-backlog-request-article (group number buffer) | |
17173 (when (numberp number) | |
17174 (gnus-backlog-setup) | |
17175 (let ((ident (intern (concat group ":" (int-to-string number)) | |
17176 gnus-backlog-hashtb)) | |
17177 beg end) | |
17178 (when (memq ident gnus-backlog-articles) | |
17179 ;; It was in the backlog. | |
17180 (save-excursion | |
17181 (set-buffer (gnus-backlog-buffer)) | |
17182 (if (not (setq beg (text-property-any | |
17183 (point-min) (point-max) 'gnus-backlog | |
17184 ident))) | |
17185 ;; It wasn't in the backlog after all. | |
17186 (ignore | |
17187 (setq gnus-backlog-articles (delq ident gnus-backlog-articles))) | |
17188 ;; Find the end (i. e., the beginning of the next article). | |
17189 (setq end | |
17190 (next-single-property-change | |
17191 (1+ beg) 'gnus-backlog (current-buffer) (point-max))))) | |
17192 (let ((buffer-read-only nil)) | |
17193 (erase-buffer) | |
17194 (insert-buffer-substring gnus-backlog-buffer beg end) | |
17195 t))))) | |
17196 | |
17197 ;; Allow redefinition of Gnus functions. | |
17198 | |
17199 (gnus-ems-redefine) | |
17200 | |
17201 (provide 'gnus) | |
17202 | |
17203 ;;; gnus.el ends here |