[SOLARIS2]: Define SUNOS_5.
[emacs.git] / lisp / gnus.el
blobefbf496ce6f9257d266e08eba55fb0a17a938ba1
1 ;;; gnus.el --- a newsreader for GNU Emacs
3 ;; Copyright (C) 1987,88,89,90,93,94,95,96 Free Software Foundation, Inc.
5 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
6 ;; Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
7 ;; Keywords: news
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; any later version.
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
26 ;;; Commentary:
28 ;; Although Gnus looks suspiciously like GNUS, it isn't quite the same
29 ;; beast. Most internal structures have been changed. If you have
30 ;; written packages that depend on any of the hash tables,
31 ;; `gnus-newsrc-alist', `gnus-killed-assoc', marked lists, the .newsrc
32 ;; buffer, or internal knowledge of the `nntp-header-' macros, or
33 ;; dependence on the buffers having a certain format, your code will
34 ;; fail.
36 ;;; Code:
38 (eval '(run-hooks 'gnus-load-hook))
40 (require 'mail-utils)
41 (require 'timezone)
42 (require 'nnheader)
44 ;; Site dependent variables. These variables should be defined in
45 ;; paths.el.
47 (defvar gnus-default-nntp-server nil
48 "Specify a default NNTP server.
49 This variable should be defined in paths.el, and should never be set
50 by the user.
51 If you want to change servers, you should use `gnus-select-method'.
52 See the documentation to that variable.")
54 (defconst gnus-backup-default-subscribed-newsgroups
55 '("news.announce.newusers" "news.groups.questions" "gnu.emacs.gnus")
56 "Default default new newsgroups the first time Gnus is run.
57 Should be set in paths.el, and shouldn't be touched by the user.")
59 (defvar gnus-local-domain nil
60 "Local domain name without a host name.
61 The DOMAINNAME environment variable is used instead if it is defined.
62 If the `system-name' function returns the full Internet name, there is
63 no need to set this variable.")
65 (defvar gnus-local-organization nil
66 "String with a description of what organization (if any) the user belongs to.
67 The ORGANIZATION environment variable is used instead if it is defined.
68 If this variable contains a function, this function will be called
69 with the current newsgroup name as the argument. The function should
70 return a string.
72 In any case, if the string (either in the variable, in the environment
73 variable, or returned by the function) is a file name, the contents of
74 this file will be used as the organization.")
76 (defvar gnus-use-generic-from nil
77 "If nil, the full host name will be the system name prepended to the domain name.
78 If this is a string, the full host name will be this string.
79 If this is non-nil, non-string, the domain name will be used as the
80 full host name.")
82 (defvar gnus-use-generic-path nil
83 "If nil, use the NNTP server name in the Path header.
84 If stringp, use this; if non-nil, use no host name (user name only).")
87 ;; Customization variables
89 ;; Don't touch this variable.
90 (defvar gnus-nntp-service "nntp"
91 "*NNTP service name (\"nntp\" or 119).
92 This is an obsolete variable, which is scarcely used. If you use an
93 nntp server for your newsgroup and want to change the port number
94 used to 899, you would say something along these lines:
96 (setq gnus-select-method '(nntp \"my.nntp.server\" (nntp-port-number 899)))")
98 (defvar gnus-select-method
99 (nconc
100 (list 'nntp (or (getenv "NNTPSERVER")
101 (if (and gnus-default-nntp-server
102 (not (string= gnus-default-nntp-server "")))
103 gnus-default-nntp-server)
104 (system-name)))
105 (if (or (null gnus-nntp-service)
106 (equal gnus-nntp-service "nntp"))
107 nil
108 (list gnus-nntp-service)))
109 "*Default method for selecting a newsgroup.
110 This variable should be a list, where the first element is how the
111 news is to be fetched, the second is the address.
113 For instance, if you want to get your news via NNTP from
114 \"flab.flab.edu\", you could say:
116 (setq gnus-select-method '(nntp \"flab.flab.edu\"))
118 If you want to use your local spool, say:
120 (setq gnus-select-method (list 'nnspool (system-name)))
122 If you use this variable, you must set `gnus-nntp-server' to nil.
124 There is a lot more to know about select methods and virtual servers -
125 see the manual for details.")
127 ;; Added by Sudish Joseph <joseph@cis.ohio-state.edu>.
128 (defvar gnus-post-method nil
129 "*Preferred method for posting USENET news.
130 If this variable is nil, Gnus will use the current method to decide
131 which method to use when posting. If it is non-nil, it will override
132 the current method. This method will not be used in mail groups and
133 the like, only in \"real\" newsgroups.
135 The value must be a valid method as discussed in the documentation of
136 `gnus-select-method'.")
138 (defvar gnus-refer-article-method nil
139 "*Preferred method for fetching an article by Message-ID.
140 If you are reading news from the local spool (with nnspool), fetching
141 articles by Message-ID is painfully slow. By setting this method to an
142 nntp method, you might get acceptable results.
144 The value of this variable must be a valid select method as discussed
145 in the documentation of `gnus-select-method'")
147 (defvar gnus-secondary-select-methods nil
148 "*A list of secondary methods that will be used for reading news.
149 This is a list where each element is a complete select method (see
150 `gnus-select-method').
152 If, for instance, you want to read your mail with the nnml backend,
153 you could set this variable:
155 (setq gnus-secondary-select-methods '((nnml \"\")))")
157 (defvar gnus-secondary-servers nil
158 "*List of NNTP servers that the user can choose between interactively.
159 To make Gnus query you for a server, you have to give `gnus' a
160 non-numeric prefix - `C-u M-x gnus', in short.")
162 (defvar gnus-nntp-server nil
163 "*The name of the host running the NNTP server.
164 This variable is semi-obsolete. Use the `gnus-select-method'
165 variable instead.")
167 (defvar gnus-startup-file "~/.newsrc"
168 "*Your `.newsrc' file.
169 `.newsrc-SERVER' will be used instead if that exists.")
171 (defvar gnus-init-file "~/.gnus"
172 "*Your Gnus elisp startup file.
173 If a file with the .el or .elc suffixes exist, it will be read
174 instead.")
176 (defvar gnus-group-faq-directory
177 "/ftp@mirrors.aol.com:/pub/rtfm/usenet/"
178 "*Directory where the group FAQs are stored.
179 This will most commonly be on a remote machine, and the file will be
180 fetched by ange-ftp.
182 Note that Gnus uses an aol machine as the default directory. If this
183 feels fundamentally unclean, just think of it as a way to finally get
184 something of value back from them.
186 If the default site is too slow, try one of these:
188 North America: ftp.uu.net /usenet/news.answers
189 mirrors.aol.com /pub/rtfm/usenet
190 ftp.seas.gwu.edu /pub/rtfm
191 rtfm.mit.edu /pub/usenet/news.answers
192 Europe: ftp.uni-paderborn.de /pub/FAQ
193 ftp.Germany.EU.net /pub/newsarchive/news.answers
194 ftp.sunet.se /pub/usenet
195 Asia: nctuccca.edu.tw /USENET/FAQ
196 hwarang.postech.ac.kr /pub/usenet/news.answers
197 ftp.hk.super.net /mirror/faqs")
199 (defvar gnus-group-archive-directory
200 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
201 "*The address of the (ding) archives.")
203 (defvar gnus-group-recent-archive-directory
204 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
205 "*The address of the most recent (ding) articles.")
207 (defvar gnus-default-subscribed-newsgroups nil
208 "*This variable lists what newsgroups should be subscribed the first time Gnus is used.
209 It should be a list of strings.
210 If it is `t', Gnus will not do anything special the first time it is
211 started; it'll just use the normal newsgroups subscription methods.")
213 (defvar gnus-use-cross-reference t
214 "*Non-nil means that cross referenced articles will be marked as read.
215 If nil, ignore cross references. If t, mark articles as read in
216 subscribed newsgroups. If neither t nor nil, mark as read in all
217 newsgroups.")
219 (defvar gnus-use-dribble-file t
220 "*Non-nil means that Gnus will use a dribble file to store user updates.
221 If Emacs should crash without saving the .newsrc files, complete
222 information can be restored from the dribble file.")
224 (defvar gnus-asynchronous nil
225 "*If non-nil, Gnus will supply backends with data needed for async article fetching.")
227 (defvar gnus-asynchronous-article-function nil
228 "*Function for picking articles to pre-fetch, possibly.")
230 (defvar gnus-score-file-single-match-alist nil
231 "*Alist mapping regexps to lists of score files.
232 Each element of this alist should be of the form
233 (\"REGEXP\" [ \"SCORE-FILE-1\" ] [ \"SCORE-FILE-2\" ] ... )
235 If the name of a group is matched by REGEXP, the corresponding scorefiles
236 will be used for that group.
237 The first match found is used, subsequent matching entries are ignored (to
238 use multiple matches, see gnus-score-file-multiple-match-alist).
240 These score files are loaded in addition to any files returned by
241 gnus-score-find-score-files-function (which see).")
243 (defvar gnus-score-file-multiple-match-alist nil
244 "*Alist mapping regexps to lists of score files.
245 Each element of this alist should be of the form
246 (\"REGEXP\" [ \"SCORE-FILE-1\" ] [ \"SCORE-FILE-2\" ] ... )
248 If the name of a group is matched by REGEXP, the corresponding scorefiles
249 will be used for that group.
250 If multiple REGEXPs match a group, the score files corresponding to each
251 match will be used (for only one match to be used, see
252 gnus-score-file-single-match-alist).
254 These score files are loaded in addition to any files returned by
255 gnus-score-find-score-files-function (which see).")
258 (defvar gnus-score-file-suffix "SCORE"
259 "*Suffix of the score files.")
261 (defvar gnus-adaptive-file-suffix "ADAPT"
262 "*Suffix of the adaptive score files.")
264 (defvar gnus-score-find-score-files-function 'gnus-score-find-bnews
265 "*Function used to find score files.
266 The function will be called with the group name as the argument, and
267 should return a list of score files to apply to that group. The score
268 files do not actually have to exist.
270 Predefined values are:
272 gnus-score-find-single: Only apply the group's own score file.
273 gnus-score-find-hierarchical: Also apply score files from parent groups.
274 gnus-score-find-bnews: Apply score files whose names matches.
276 See the documentation to these functions for more information.
278 This variable can also be a list of functions to be called. Each
279 function should either return a list of score files, or a list of
280 score alists.")
282 (defvar gnus-score-interactive-default-score 1000
283 "*Scoring commands will raise/lower the score with this number as the default.")
285 (defvar gnus-large-newsgroup 200
286 "*The number of articles which indicates a large newsgroup.
287 If the number of articles in a newsgroup is greater than this value,
288 confirmation is required for selecting the newsgroup.")
290 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
291 (defvar gnus-no-groups-message "No news is horrible news"
292 "*Message displayed by Gnus when no groups are available.")
294 (defvar gnus-use-long-file-name (not (memq system-type '(usg-unix-v xenix)))
295 "*Non-nil means that the default name of a file to save articles in is the group name.
296 If it's nil, the directory form of the group name is used instead.
298 If this variable is a list, and the list contains the element
299 `not-score', long file names will not be used for score files; if it
300 contains the element `not-save', long file names will not be used for
301 saving; and if it contains the element `not-kill', long file names
302 will not be used for kill files.")
304 (defvar gnus-article-save-directory (or (getenv "SAVEDIR") "~/News/")
305 "*Name of the directory articles will be saved in (default \"~/News\").
306 Initialized from the SAVEDIR environment variable.")
308 (defvar gnus-kill-files-directory (or (getenv "SAVEDIR") "~/News/")
309 "*Name of the directory where kill files will be stored (default \"~/News\").
310 Initialized from the SAVEDIR environment variable.")
312 (defvar gnus-default-article-saver 'gnus-summary-save-in-rmail
313 "*A function to save articles in your favorite format.
314 The function must be interactively callable (in other words, it must
315 be an Emacs command).
317 Gnus provides the following functions:
319 * gnus-summary-save-in-rmail (Rmail format)
320 * gnus-summary-save-in-mail (Unix mail format)
321 * gnus-summary-save-in-folder (MH folder)
322 * gnus-summary-save-in-file (article format).
323 * gnus-summary-save-in-vm (use VM's folder format).")
325 (defvar gnus-rmail-save-name (function gnus-plain-save-name)
326 "*A function generating a file name to save articles in Rmail format.
327 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
329 (defvar gnus-mail-save-name (function gnus-plain-save-name)
330 "*A function generating a file name to save articles in Unix mail format.
331 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
333 (defvar gnus-folder-save-name (function gnus-folder-save-name)
334 "*A function generating a file name to save articles in MH folder.
335 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.")
337 (defvar gnus-file-save-name (function gnus-numeric-save-name)
338 "*A function generating a file name to save articles in article format.
339 The function is called with NEWSGROUP, HEADERS, and optional
340 LAST-FILE.")
342 (defvar gnus-split-methods nil
343 "*Variable used to suggest where articles are to be saved.
344 The syntax of this variable is the same as `nnmail-split-methods'.
346 For instance, if you would like to save articles related to Gnus in
347 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
348 you could set this variable to something like:
350 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
351 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))")
353 (defvar gnus-save-score nil
354 "*If non-nil, save group scoring info.")
356 (defvar gnus-use-adaptive-scoring nil
357 "*If non-nil, use some adaptive scoring scheme.")
359 (defvar gnus-use-cache nil
360 "*If non-nil, Gnus will cache (some) articles locally.")
362 (defvar gnus-use-scoring t
363 "*If non-nil, enable scoring.")
365 (defvar gnus-fetch-old-headers nil
366 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
367 If an unread article in the group refers to an older, already read (or
368 just marked as read) article, the old article will not normally be
369 displayed in the Summary buffer. If this variable is non-nil, Gnus
370 will attempt to grab the headers to the old articles, and thereby
371 build complete threads. If it has the value `some', only enough
372 headers to connect otherwise loose threads will be displayed.
374 The server has to support XOVER for any of this to work.")
376 ;see gnus-cus.el
377 ;(defvar gnus-visual t
378 ; "*If non-nil, will do various highlighting.
379 ;If nil, no mouse highlights (or any other highlights) will be
380 ;performed. This might speed up Gnus some when generating large group
381 ;and summary buffers.")
383 (defvar gnus-novice-user t
384 "*Non-nil means that you are a usenet novice.
385 If non-nil, verbose messages may be displayed and confirmations may be
386 required.")
388 (defvar gnus-expert-user nil
389 "*Non-nil means that you will never be asked for confirmation about anything.
390 And that means *anything*.")
392 (defvar gnus-verbose 7
393 "*Integer that says how verbose Gnus should be.
394 The higher the number, the more messages Gnus will flash to say what
395 it's doing. At zero, Gnus will be totally mute; at five, Gnus will
396 display most important messages; and at ten, Gnus will keep on
397 jabbering all the time.")
399 (defvar gnus-keep-same-level nil
400 "*Non-nil means that the next newsgroup after the current will be on the same level.
401 When you type, for instance, `n' after reading the last article in the
402 current newsgroup, you will go to the next newsgroup. If this variable
403 is nil, the next newsgroup will be the next from the group
404 buffer.
405 If this variable is non-nil, Gnus will either put you in the
406 next newsgroup with the same level, or, if no such newsgroup is
407 available, the next newsgroup with the lowest possible level higher
408 than the current level.
409 If this variable is `best', Gnus will make the next newsgroup the one
410 with the best level.")
412 (defvar gnus-summary-make-false-root 'adopt
413 "*nil means that Gnus won't gather loose threads.
414 If the root of a thread has expired or been read in a previous
415 session, the information necessary to build a complete thread has been
416 lost. Instead of having many small sub-threads from this original thread
417 scattered all over the summary buffer, Gnus can gather them.
419 If non-nil, Gnus will try to gather all loose sub-threads from an
420 original thread into one large thread.
422 If this variable is non-nil, it should be one of `none', `adopt',
423 `dummy' or `empty'.
425 If this variable is `none', Gnus will not make a false root, but just
426 present the sub-threads after another.
427 If this variable is `dummy', Gnus will create a dummy root that will
428 have all the sub-threads as children.
429 If this variable is `adopt', Gnus will make one of the \"children\"
430 the parent and mark all the step-children as such.
431 If this variable is `empty', the \"children\" are printed with empty
432 subject fields. (Or rather, they will be printed with a string
433 given by the `gnus-summary-same-subject' variable.)")
435 (defvar gnus-summary-gather-subject-limit nil
436 "*Maximum length of subject comparisons when gathering loose threads.
437 Use nil to compare full subjects. Setting this variable to a low
438 number will help gather threads that have been corrupted by
439 newsreaders chopping off subject lines, but it might also mean that
440 unrelated articles that have subject that happen to begin with the
441 same few characters will be incorrectly gathered.
443 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
444 comparing subjects.")
446 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
447 (defvar gnus-summary-same-subject ""
448 "*String indicating that the current article has the same subject as the previous.
449 This variable will only be used if the value of
450 `gnus-summary-make-false-root' is `empty'.")
452 (defvar gnus-summary-goto-unread t
453 "*If non-nil, marking commands will go to the next unread article.")
455 (defvar gnus-group-goto-unread t
456 "*If non-nil, movement commands will go to the next unread and subscribed group.")
458 (defvar gnus-check-new-newsgroups t
459 "*Non-nil means that Gnus will add new newsgroups at startup.
460 If this variable is `ask-server', Gnus will ask the server for new
461 groups since the last time it checked. This means that the killed list
462 is no longer necessary, so you could set `gnus-save-killed-list' to
463 nil.
465 A variant is to have this variable be a list of select methods. Gnus
466 will then use the `ask-server' method on all these select methods to
467 query for new groups from all those servers.
470 (setq gnus-check-new-newsgroups
471 '((nntp \"some.server\") (nntp \"other.server\")))
473 If this variable is nil, then you have to tell Gnus explicitly to
474 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].")
476 (defvar gnus-check-bogus-newsgroups nil
477 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup.
478 If this variable is nil, then you have to tell Gnus explicitly to
479 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].")
481 (defvar gnus-read-active-file t
482 "*Non-nil means that Gnus will read the entire active file at startup.
483 If this variable is nil, Gnus will only know about the groups in your
484 `.newsrc' file.
486 If this variable is `some', Gnus will try to only read the relevant
487 parts of the active file from the server. Not all servers support
488 this, and it might be quite slow with other servers, but this should
489 generally be faster than both the t and nil value.
491 If you set this variable to nil or `some', you probably still want to
492 be told about new newsgroups that arrive. To do that, set
493 `gnus-check-new-newsgroups' to `ask-server'. This may not work
494 properly with all servers.")
496 (defvar gnus-level-subscribed 5
497 "*Groups with levels less than or equal to this variable are subscribed.")
499 (defvar gnus-level-unsubscribed 7
500 "*Groups with levels less than or equal to this variable are unsubscribed.
501 Groups with levels less than `gnus-level-subscribed', which should be
502 less than this variable, are subscribed.")
504 (defvar gnus-level-zombie 8
505 "*Groups with this level are zombie groups.")
507 (defvar gnus-level-killed 9
508 "*Groups with this level are killed.")
510 (defvar gnus-level-default-subscribed 3
511 "*New subscribed groups will be subscribed at this level.")
513 (defvar gnus-level-default-unsubscribed 6
514 "*New unsubscribed groups will be unsubscribed at this level.")
516 (defvar gnus-activate-foreign-newsgroups 4
517 "*If nil, Gnus will not check foreign newsgroups at startup.
518 If it is non-nil, it should be a number between one and nine. Foreign
519 newsgroups that have a level lower or equal to this number will be
520 activated on startup. For instance, if you want to active all
521 subscribed newsgroups, but not the rest, you'd set this variable to
522 `gnus-level-subscribed'.
524 If you subscribe to lots of newsgroups from different servers, startup
525 might take a while. By setting this variable to nil, you'll save time,
526 but you won't be told how many unread articles there are in the
527 groups.")
529 (defvar gnus-save-newsrc-file t
530 "*Non-nil means that Gnus will save the `.newsrc' file.
531 Gnus always saves its own startup file, which is called
532 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
533 be readily understood by other newsreaders. If you don't plan on
534 using other newsreaders, set this variable to nil to save some time on
535 exit.")
537 (defvar gnus-save-killed-list t
538 "*If non-nil, save the list of killed groups to the startup file.
539 This will save both time (when starting and quitting) and space (both
540 memory and disk), but it will also mean that Gnus has no record of
541 which groups are new and which are old, so the automatic new
542 newsgroups subscription methods become meaningless. You should always
543 set `gnus-check-new-newsgroups' to `ask-server' or nil if you set this
544 variable to nil.")
546 (defvar gnus-interactive-catchup t
547 "*If non-nil, require your confirmation when catching up a group.")
549 (defvar gnus-interactive-post t
550 "*If non-nil, group name will be asked for when posting.")
552 (defvar gnus-interactive-exit t
553 "*If non-nil, require your confirmation when exiting Gnus.")
555 (defvar gnus-kill-killed t
556 "*If non-nil, Gnus will apply kill files to already killed articles.
557 If it is nil, Gnus will never apply kill files to articles that have
558 already been through the scoring process, which might very well save lots
559 of time.")
561 (defvar gnus-extract-address-components 'gnus-extract-address-components
562 "*Function for extracting address components from a From header.
563 Two pre-defined function exist: `gnus-extract-address-components',
564 which is the default, quite fast, and too simplistic solution, and
565 `mail-extract-address-components', which works much better, but is
566 slower.")
568 (defvar gnus-summary-default-score 0
569 "*Default article score level.
570 If this variable is nil, scoring will be disabled.")
572 (defvar gnus-summary-zcore-fuzz 0
573 "*Fuzziness factor for the zcore in the summary buffer.
574 Articles with scores closer than this to `gnus-summary-default-score'
575 will not be marked.")
577 (defvar gnus-simplify-subject-fuzzy-regexp nil
578 "*Regular expression that will be removed from subject strings if
579 fuzzy subject simplification is selected.")
581 (defvar gnus-group-default-list-level gnus-level-subscribed
582 "*Default listing level.
583 Ignored if `gnus-group-use-permanent-levels' is non-nil.")
585 (defvar gnus-group-use-permanent-levels nil
586 "*If non-nil, once you set a level, Gnus will use this level.")
588 (defvar gnus-show-mime nil
589 "*If non-nil, do mime processing of articles.
590 The articles will simply be fed to the function given by
591 `gnus-show-mime-method'.")
593 (defvar gnus-strict-mime t
594 "*If nil, decode MIME header even if there is not Mime-Version field.")
596 (defvar gnus-show-mime-method (function metamail-buffer)
597 "*Function to process a MIME message.
598 The function is called from the article buffer.")
600 (defvar gnus-show-threads t
601 "*If non-nil, display threads in summary mode.")
603 (defvar gnus-thread-hide-subtree nil
604 "*If non-nil, hide all threads initially.
605 If threads are hidden, you have to run the command
606 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
607 to expose hidden threads.")
609 (defvar gnus-thread-hide-killed t
610 "*If non-nil, hide killed threads automatically.")
612 (defvar gnus-thread-ignore-subject nil
613 "*If non-nil, ignore subjects and do all threading based on the Reference header.
614 If nil, which is the default, articles that have different subjects
615 from their parents will start separate threads.")
617 (defvar gnus-thread-indent-level 4
618 "*Number that says how much each sub-thread should be indented.")
620 (defvar gnus-ignored-newsgroups
621 (purecopy (mapconcat 'identity
622 '("^to\\." ; not "real" groups
623 "^[0-9. \t]+ " ; all digits in name
624 "[][\"#'()]" ; bogus characters
626 "\\|"))
627 "*A regexp to match uninteresting newsgroups in the active file.
628 Any lines in the active file matching this regular expression are
629 removed from the newsgroup list before anything else is done to it,
630 thus making them effectively non-existent.")
632 (defvar gnus-ignored-headers
633 "^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:"
634 "*All headers that match this regexp will be hidden.
635 If `gnus-visible-headers' is non-nil, this variable will be ignored.")
637 (defvar gnus-visible-headers "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^Cc:"
638 "*All headers that do not match this regexp will be hidden.
639 If this variable is non-nil, `gnus-ignored-headers' will be ignored.")
641 (defvar gnus-sorted-header-list
642 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
643 "^Cc:" "^Date:" "^Organization:")
644 "*This variable is a list of regular expressions.
645 If it is non-nil, headers that match the regular expressions will
646 be placed first in the article buffer in the sequence specified by
647 this list.")
649 (defvar gnus-show-all-headers nil
650 "*If non-nil, don't hide any headers.")
652 (defvar gnus-save-all-headers t
653 "*If non-nil, don't remove any headers before saving.")
655 (defvar gnus-inhibit-startup-message nil
656 "*If non-nil, the startup message will not be displayed.")
658 (defvar gnus-signature-separator "^-- *$"
659 "Regexp matching signature separator.")
661 (defvar gnus-auto-extend-newsgroup t
662 "*If non-nil, extend newsgroup forward and backward when requested.")
664 (defvar gnus-auto-select-first t
665 "*If non-nil, select the first unread article when entering a group.
666 If you want to prevent automatic selection of the first unread article
667 in some newsgroups, set the variable to nil in
668 `gnus-select-group-hook'.")
670 (defvar gnus-auto-select-next t
671 "*If non-nil, offer to go to the next group from the end of the previous.
672 If the value is t and the next newsgroup is empty, Gnus will exit
673 summary mode and go back to group mode. If the value is neither nil
674 nor t, Gnus will select the following unread newsgroup. In
675 particular, if the value is the symbol `quietly', the next unread
676 newsgroup will be selected without any confirmations.")
678 (defvar gnus-auto-select-same nil
679 "*If non-nil, select the next article with the same subject.")
681 (defvar gnus-summary-check-current nil
682 "*If non-nil, consider the current article when moving.
683 The \"unread\" movement commands will stay on the same line if the
684 current article is unread.")
686 (defvar gnus-auto-center-summary t
687 "*If non-nil, always center the current summary buffer.")
689 (defvar gnus-break-pages t
690 "*If non-nil, do page breaking on articles.
691 The page delimiter is specified by the `gnus-page-delimiter'
692 variable.")
694 (defvar gnus-page-delimiter "^\^L"
695 "*Regexp describing what to use as article page delimiters.
696 The default value is \"^\^L\", which is a form linefeed at the
697 beginning of a line.")
699 (defvar gnus-use-full-window t
700 "*If non-nil, use the entire Emacs screen.")
702 (defvar gnus-window-configuration nil
703 "Obsolete variable. See `gnus-buffer-configuration'.")
705 (defvar gnus-buffer-configuration
706 '((group ([group 1.0 point]
707 (if gnus-carpal [group-carpal 4])))
708 (summary ([summary 1.0 point]
709 (if gnus-carpal [summary-carpal 4])))
710 (article ([summary 0.25 point]
711 (if gnus-carpal [summary-carpal 4])
712 [article 1.0]))
713 (pipe ([summary 0.25 point]
714 (if gnus-carpal [summary-carpal 4])
715 [pipe 1.0]))
716 (server ([server 1.0 point]
717 (if gnus-carpal [server-carpal 2])))
718 (browse ([browse 1.0 point]
719 (if gnus-carpal [browse-carpal 2])))
720 (group-mail ([mail 1.0 point]))
721 (summary-mail ([mail 1.0 point]))
722 (summary-reply ([article 0.5]
723 [mail 1.0 point]))
724 (info ([nil 1.0 point]))
725 (summary-faq ([summary 0.25]
726 [faq 1.0 point]))
727 (edit-group ([group 0.5]
728 [edit-group 1.0 point]))
729 (edit-server ([server 0.5]
730 [edit-server 1.0 point]))
731 (edit-score ([summary 0.25]
732 [edit-score 1.0 point]))
733 (post ([post 1.0 point]))
734 (reply ([article 0.5]
735 [mail 1.0 point]))
736 (mail-forward ([mail 1.0 point]))
737 (post-forward ([post 1.0 point]))
738 (reply-yank ([mail 1.0 point]))
739 (followup ([article 0.5]
740 [post 1.0 point]))
741 (followup-yank ([post 1.0 point])))
742 "Window configuration for all possible Gnus buffers.
743 This variable is a list of lists. Each of these lists has a NAME and
744 a RULE. The NAMEs are common-sense names like `group', which names a
745 rule used when displaying the group buffer; `summary', which names a
746 rule for what happens when you enter a group and do not display an
747 article buffer; and so on. See the value of this variable for a
748 complete list of NAMEs.
750 Each RULE is a list of vectors. The first element in this vector is
751 the name of the buffer to be displayed; the second element is the
752 percentage of the screen this buffer is to occupy (a number in the
753 0.0-0.99 range); the optional third element is `point', which should
754 be present to denote which buffer point is to go to after making this
755 buffer configuration.")
757 (defvar gnus-window-to-buffer
758 '((group . gnus-group-buffer)
759 (summary . gnus-summary-buffer)
760 (article . gnus-article-buffer)
761 (server . gnus-server-buffer)
762 (browse . "*Gnus Browse Server*")
763 (pipe . "*Shell Command Output*")
764 (edit-group . gnus-group-edit-buffer)
765 (edit-server . gnus-server-edit-buffer)
766 (group-carpal . gnus-carpal-group-buffer)
767 (summary-carpal . gnus-carpal-summary-buffer)
768 (server-carpal . gnus-carpal-server-buffer)
769 (browse-carpal . gnus-carpal-browse-buffer)
770 (edit-score . gnus-score-edit-buffer)
771 (mail . gnus-mail-buffer)
772 (post . gnus-post-news-buffer)
773 (faq . gnus-faq-buffer))
774 "Mapping from short symbols to buffer names or buffer variables.")
776 (defvar gnus-carpal nil
777 "*If non-nil, display clickable icons.")
779 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
780 "*Function called with a group name when new group is detected.
781 A few pre-made functions are supplied: `gnus-subscribe-randomly'
782 inserts new groups at the beginning of the list of groups;
783 `gnus-subscribe-alphabetically' inserts new groups in strict
784 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
785 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
786 for your decision.")
788 ;; Suggested by a bug report by Hallvard B Furuseth.
789 ;; <h.b.furuseth@usit.uio.no>.
790 (defvar gnus-subscribe-options-newsgroup-method
791 (function gnus-subscribe-alphabetically)
792 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
793 If, for instance, you want to subscribe to all newsgroups in the
794 \"no\" and \"alt\" hierarchies, you'd put the following in your
795 .newsrc file:
797 options -n no.all alt.all
799 Gnus will the subscribe all new newsgroups in these hierarchies with
800 the subscription method in this variable.")
802 (defvar gnus-subscribe-hierarchical-interactive nil
803 "*If non-nil, Gnus will offer to subscribe hierarchically.
804 When a new hierarchy appears, Gnus will ask the user:
806 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
808 If the user pressed `d', Gnus will descend the hierarchy, `y' will
809 subscribe to all newsgroups in the hierarchy and `s' will skip this
810 hierarchy in its entirety.")
812 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
813 "*Function used for sorting the group buffer.
814 This function will be called with group info entries as the arguments
815 for the groups to be sorted. Pre-made functions include
816 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-unread' and
817 `gnus-group-sort-by-level'")
819 ;; Mark variables suggested by Thomas Michanek
820 ;; <Thomas.Michanek@telelogic.se>.
821 (defvar gnus-unread-mark ?
822 "*Mark used for unread articles.")
823 (defvar gnus-ticked-mark ?!
824 "*Mark used for ticked articles.")
825 (defvar gnus-dormant-mark ??
826 "*Mark used for dormant articles.")
827 (defvar gnus-del-mark ?r
828 "*Mark used for del'd articles.")
829 (defvar gnus-read-mark ?R
830 "*Mark used for read articles.")
831 (defvar gnus-expirable-mark ?E
832 "*Mark used for expirable articles.")
833 (defvar gnus-killed-mark ?K
834 "*Mark used for killed articles.")
835 (defvar gnus-kill-file-mark ?X
836 "*Mark used for articles killed by kill files.")
837 (defvar gnus-low-score-mark ?Y
838 "*Mark used for articles with a low score.")
839 (defvar gnus-catchup-mark ?C
840 "*Mark used for articles that are caught up.")
841 (defvar gnus-replied-mark ?A
842 "*Mark used for articles that have been replied to.")
843 (defvar gnus-process-mark ?#
844 "*Process mark.")
845 (defvar gnus-ancient-mark ?O
846 "*Mark used for ancient articles.")
847 (defvar gnus-canceled-mark ?G
848 "*Mark used for canceled articles.")
849 (defvar gnus-score-over-mark ?+
850 "*Score mark used for articles with high scores.")
851 (defvar gnus-score-below-mark ?-
852 "*Score mark used for articles with low scores.")
853 (defvar gnus-empty-thread-mark ?
854 "*There is no thread under the article.")
855 (defvar gnus-not-empty-thread-mark ?=
856 "*There is a thread under the article.")
857 (defvar gnus-dummy-mark ?Z
858 "*This is a dummy article.")
860 (defvar gnus-view-pseudo-asynchronously nil
861 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
863 (defvar gnus-view-pseudos nil
864 "*If `automatic', pseudo-articles will be viewed automatically.
865 If `not-confirm', pseudos will be viewed automatically, and the user
866 will not be asked to confirm the command.")
868 (defvar gnus-view-pseudos-separately t
869 "*If non-nil, one pseudo-article will be created for each file to be viewed.
870 If nil, all files that use the same viewing command will be given as a
871 list of parameters to that command.")
873 (defvar gnus-group-line-format "%M%S%p%5y: %(%g%)\n"
874 "*Format of group lines.
875 It works along the same lines as a normal formatting string,
876 with some simple extensions.
878 %M Only marked articles (character, \"*\" or \" \")
879 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
880 %L Level of subscribedness (integer)
881 %N Number of unread articles (integer)
882 %I Number of dormant articles (integer)
883 %i Number of ticked and dormant (integer)
884 %T Number of ticked articles (integer)
885 %R Number of read articles (integer)
886 %t Total number of articles (integer)
887 %y Number of unread, unticked articles (integer)
888 %G Group name (string)
889 %g Qualified group name (string)
890 %D Group description (string)
891 %s Select method (string)
892 %o Moderated group (char, \"m\")
893 %p Process mark (char)
894 %O Moderated group (string, \"(m)\" or \"\")
895 %n Select from where (string)
896 %z A string that look like `<%s:%n>' if a foreign select method is used
897 %u User defined specifier. The next character in the format string should
898 be a letter. Gnus will call the function gnus-user-format-function-X,
899 where X is the letter following %u. The function will be passed the
900 current header as argument. The function should return a string, which
901 will be inserted into the buffer just like information from any other
902 group specifier.
904 Text between %( and %) will be highlighted with `gnus-mouse-face' when
905 the mouse point move inside the area. There can only be one such area.
907 Note that this format specification is not always respected. For
908 reasons of efficiency, when listing killed groups, this specification
909 is ignored altogether. If the spec is changed considerably, your
910 output may end up looking strange when listing both alive and killed
911 groups.
913 If you use %o or %O, reading the active file will be slower and quite
914 a bit of extra memory will be used. %D will also worsen performance.
915 Also note that if you change the format specification to include any
916 of these specs, you must probably re-start Gnus to see them go into
917 effect.")
919 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
920 "*The format specification of the lines in the summary buffer.
922 It works along the same lines as a normal formatting string,
923 with some simple extensions.
925 %N Article number, left padded with spaces (string)
926 %S Subject (string)
927 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
928 %n Name of the poster (string)
929 %a Extracted name of the poster (string)
930 %A Extracted address of the poster (string)
931 %F Contents of the From: header (string)
932 %x Contents of the Xref: header (string)
933 %D Date of the article (string)
934 %d Date of the article (string) in DD-MMM format
935 %M Message-id of the article (string)
936 %r References of the article (string)
937 %c Number of characters in the article (integer)
938 %L Number of lines in the article (integer)
939 %I Indentation based on thread level (a string of spaces)
940 %T A string with two possible values: 80 spaces if the article
941 is on thread level two or larger and 0 spaces on level one
942 %R \"A\" if this article has been replied to, \" \" otherwise (character)
943 %U Status of this article (character, \"R\", \"K\", \"-\" or \" \")
944 %[ Opening bracket (character, \"[\" or \"<\")
945 %] Closing bracket (character, \"]\" or \">\")
946 %> Spaces of length thread-level (string)
947 %< Spaces of length (- 20 thread-level) (string)
948 %i Article score (number)
949 %z Article zcore (character)
950 %t Number of articles under the current thread (number).
951 %e Whether the thread is empty or not (character).
952 %u User defined specifier. The next character in the format string should
953 be a letter. Gnus will call the function gnus-user-format-function-X,
954 where X is the letter following %u. The function will be passed the
955 current header as argument. The function should return a string, which
956 will be inserted into the summary just like information from any other
957 summary specifier.
959 Text between %( and %) will be highlighted with `gnus-mouse-face'
960 when the mouse point is placed inside the area. There can only be one
961 such area.
963 The %U (status), %R (replied) and %z (zcore) specs have to be handled
964 with care. For reasons of efficiency, Gnus will compute what column
965 these characters will end up in, and \"hard-code\" that. This means that
966 it is illegal to have these specs after a variable-length spec. Well,
967 you might not be arrested, but your summary buffer will look strange,
968 which is bad enough.
970 The smart choice is to have these specs as for to the left as
971 possible.
973 This restriction may disappear in later versions of Gnus.")
975 (defvar gnus-summary-dummy-line-format "* : : %S\n"
976 "*The format specification for the dummy roots in the summary buffer.
977 It works along the same lines as a normal formatting string,
978 with some simple extensions.
980 %S The subject")
982 (defvar gnus-summary-mode-line-format "Gnus: %b [%A] %Z"
983 "*The format specification for the summary mode line.")
985 (defvar gnus-article-mode-line-format "Gnus: %b %S"
986 "*The format specification for the article mode line.")
988 (defvar gnus-group-mode-line-format "Gnus: %b {%M:%S} "
989 "*The format specification for the group mode line.")
991 (defvar gnus-valid-select-methods
992 '(("nntp" post address prompt-address)
993 ("nnspool" post)
994 ("nnvirtual" none virtual prompt-address)
995 ("nnmbox" mail respool)
996 ("nnml" mail respool)
997 ("nnmh" mail respool)
998 ("nndir" none prompt-address address)
999 ("nneething" none prompt-address)
1000 ("nndigest" none)
1001 ("nndoc" none prompt-address)
1002 ("nnbabyl" mail respool)
1003 ("nnkiboze" post virtual)
1004 ;;("nnsoup" post)
1005 ("nnfolder" mail respool))
1006 "An alist of valid select methods.
1007 The first element of each list lists should be a string with the name
1008 of the select method. The other elements may be be the category of
1009 this method (ie. `post', `mail', `none' or whatever) or other
1010 properties that this method has (like being respoolable).
1011 If you implement a new select method, all you should have to change is
1012 this variable. I think.")
1014 (defvar gnus-updated-mode-lines '(group article summary)
1015 "*List of buffers that should update their mode lines.
1016 The list may contain the symbols `group', `article' and `summary'. If
1017 the corresponding symbol is present, Gnus will keep that mode line
1018 updated with information that may be pertinent.
1019 If this variable is nil, screen refresh may be quicker.")
1021 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
1022 (defvar gnus-mode-non-string-length nil
1023 "*Max length of mode-line non-string contents.
1024 If this is nil, Gnus will take space as is needed, leaving the rest
1025 of the modeline intact.")
1027 ;see gnus-cus.el
1028 ;(defvar gnus-mouse-face 'highlight
1029 ; "*Face used for mouse highlighting in Gnus.
1030 ;No mouse highlights will be done if `gnus-visual' is nil.")
1032 (defvar gnus-summary-mark-below nil
1033 "*Mark all articles with a score below this variable as read.
1034 This variable is local to each summary buffer and usually set by the
1035 score file.")
1037 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
1038 "*List of functions used for sorting threads in the summary buffer.
1039 By default, threads are sorted by article number.
1041 Each function takes two threads and return non-nil if the first thread
1042 should be sorted before the other. If you use more than one function,
1043 the primary sort function should be the last.
1045 Ready-mady functions include `gnus-thread-sort-by-number',
1046 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
1047 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
1048 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
1050 (defvar gnus-thread-score-function '+
1051 "*Function used for calculating the total score of a thread.
1053 The function is called with the scores of the article and each
1054 subthread and should then return the score of the thread.
1056 Some functions you can use are `+', `max', or `min'.")
1058 (defvar gnus-options-subscribe nil
1059 "*All new groups matching this regexp will be subscribed unconditionally.
1060 Note that this variable deals only with new newsgroups. This variable
1061 does not affect old newsgroups.")
1063 (defvar gnus-options-not-subscribe nil
1064 "*All new groups matching this regexp will be ignored.
1065 Note that this variable deals only with new newsgroups. This variable
1066 does not affect old (already subscribed) newsgroups.")
1068 (defvar gnus-auto-expirable-newsgroups nil
1069 "*Groups in which to automatically mark read articles as expirable.
1070 If non-nil, this should be a regexp that should match all groups in
1071 which to perform auto-expiry. This only makes sense for mail groups.")
1073 (defvar gnus-hidden-properties '(invisible t intangible t)
1074 "Property list to use for hiding text.")
1076 (defvar gnus-modtime-botch nil
1077 "*Non-nil means .newsrc should be deleted prior to save. Its use is
1078 due to the bogus appearance that .newsrc was modified on disc.")
1080 ;; Hooks.
1082 (defvar gnus-group-mode-hook nil
1083 "*A hook for Gnus group mode.")
1085 (defvar gnus-summary-mode-hook nil
1086 "*A hook for Gnus summary mode.
1087 This hook is run before any variables are set in the summary buffer.")
1089 (defvar gnus-article-mode-hook nil
1090 "*A hook for Gnus article mode.")
1092 (defun gnus-summary-prepare-exit-hook nil
1093 "*A hook called when preparing to exit from the summary buffer.
1094 It calls `gnus-summary-expire-articles' by default.")
1095 (add-hook 'gnus-summary-prepare-exit-hook 'gnus-summary-expire-articles)
1097 (defun gnus-summary-exit-hook nil
1098 "*A hook called on exit from the summary buffer.")
1100 (defvar gnus-open-server-hook nil
1101 "*A hook called just before opening connection to the news server.")
1103 (defvar gnus-load-hook nil
1104 "*A hook run while Gnus is loaded.")
1106 (defvar gnus-startup-hook nil
1107 "*A hook called at startup.
1108 This hook is called after Gnus is connected to the NNTP server.")
1110 (defvar gnus-get-new-news-hook nil
1111 "*A hook run just before Gnus checks for new news.")
1113 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
1114 "*A function that is called to generate the group buffer.
1115 The function is called with three arguments: The first is a number;
1116 all group with a level less or equal to that number should be listed,
1117 if the second is non-nil, empty groups should also be displayed. If
1118 the third is non-nil, it is a number. No groups with a level lower
1119 than this number should be displayed.
1121 The only current function implemented is `gnus-group-prepare-flat'.")
1123 (defvar gnus-group-prepare-hook nil
1124 "*A hook called after the group buffer has been generated.
1125 If you want to modify the group buffer, you can use this hook.")
1127 (defvar gnus-summary-prepare-hook nil
1128 "*A hook called after the summary buffer has been generated.
1129 If you want to modify the summary buffer, you can use this hook.")
1131 (defvar gnus-article-prepare-hook nil
1132 "*A hook called after an article has been prepared in the article buffer.
1133 If you want to run a special decoding program like nkf, use this hook.")
1135 ;(defvar gnus-article-display-hook nil
1136 ; "*A hook called after the article is displayed in the article buffer.
1137 ;The hook is designed to change the contents of the article
1138 ;buffer. Typical functions that this hook may contain are
1139 ;`gnus-article-hide-headers' (hide selected headers),
1140 ;`gnus-article-maybe-highlight' (perform fancy article highlighting),
1141 ;`gnus-article-hide-signature' (hide signature) and
1142 ;`gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1143 ;(add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1144 ;(add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1145 ;(add-hook 'gnus-article-display-hook 'gnus-article-maybe-highlight)
1147 (defvar gnus-article-x-face-command
1148 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -"
1149 "String or function to be executed to display an X-Face header.
1150 If it is a string, the command will be executed in a sub-shell
1151 asynchronously. The compressed face will be piped to this command.")
1153 (defvar gnus-article-x-face-too-ugly nil
1154 "Regexp matching posters whose face shouldn't be shown automatically.")
1156 (defvar gnus-select-group-hook nil
1157 "*A hook called when a newsgroup is selected.
1159 If you'd like to simplify subjects like the
1160 `gnus-summary-next-same-subject' command does, you can use the
1161 following hook:
1163 (setq gnus-select-group-hook
1164 (list
1165 (lambda ()
1166 (mapcar (lambda (header)
1167 (mail-header-set-subject
1168 header
1169 (gnus-simplify-subject
1170 (mail-header-subject header) 're-only)))
1171 gnus-newsgroup-headers))))")
1173 (defvar gnus-select-article-hook
1174 '(gnus-summary-show-thread)
1175 "*A hook called when an article is selected.
1176 The default hook shows conversation thread subtrees of the selected
1177 article automatically using `gnus-summary-show-thread'.")
1179 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
1180 "*A hook called to apply kill files to a group.
1181 This hook is intended to apply a kill file to the selected newsgroup.
1182 The function `gnus-apply-kill-file' is called by default.
1184 Since a general kill file is too heavy to use only for a few
1185 newsgroups, I recommend you to use a lighter hook function. For
1186 example, if you'd like to apply a kill file to articles which contains
1187 a string `rmgroup' in subject in newsgroup `control', you can use the
1188 following hook:
1190 (setq gnus-apply-kill-hook
1191 (list
1192 (lambda ()
1193 (cond ((string-match \"control\" gnus-newsgroup-name)
1194 (gnus-kill \"Subject\" \"rmgroup\")
1195 (gnus-expunge \"X\"))))))")
1197 (defvar gnus-visual-mark-article-hook
1198 (list 'gnus-highlight-selected-summary)
1199 "*Hook run after selecting an article in the summary buffer.
1200 It is meant to be used for highlighting the article in some way. It
1201 is not run if `gnus-visual' is nil.")
1203 (defun gnus-parse-headers-hook nil
1204 "*A hook called before parsing the headers.")
1206 (defvar gnus-exit-group-hook nil
1207 "*A hook called when exiting (not quitting) summary mode.")
1209 (defvar gnus-suspend-gnus-hook nil
1210 "*A hook called when suspending (not exiting) Gnus.")
1212 (defvar gnus-exit-gnus-hook nil
1213 "*A hook called when exiting Gnus.")
1215 (defvar gnus-save-newsrc-hook nil
1216 "*A hook called when saving the newsrc file.")
1218 (defvar gnus-summary-update-hook
1219 (list 'gnus-summary-highlight-line)
1220 "*A hook called when a summary line is changed.
1221 The hook will not be called if `gnus-visual' is nil.
1223 The default function `gnus-summary-highlight-line' will
1224 highlight the line according to the `gnus-summary-highlight'
1225 variable.")
1227 (defvar gnus-mark-article-hook (list 'gnus-summary-mark-unread-as-read)
1228 "*A hook called when an article is selected for the first time.
1229 The hook is intended to mark an article as read (or unread)
1230 automatically when it is selected.")
1232 ;; Remove any hilit infestation.
1233 (add-hook 'gnus-startup-hook
1234 (lambda ()
1235 (remove-hook 'gnus-summary-prepare-hook
1236 'hilit-rehighlight-buffer-quietly)
1237 (remove-hook 'gnus-summary-prepare-hook 'hilit-install-line-hooks)
1238 (setq gnus-mark-article-hook '(gnus-summary-mark-unread-as-read))
1239 (remove-hook 'gnus-article-prepare-hook
1240 'hilit-rehighlight-buffer-quietly)))
1244 ;; Internal variables
1246 ;; Avoid highlighting in kill files.
1247 (defvar gnus-summary-inhibit-highlight nil)
1248 (defvar gnus-newsgroup-selected-overlay nil)
1250 (defvar gnus-article-mode-map nil)
1251 (defvar gnus-dribble-buffer nil)
1252 (defvar gnus-headers-retrieved-by nil)
1253 (defvar gnus-article-reply nil)
1254 (defvar gnus-override-method nil)
1255 (defvar gnus-article-check-size nil)
1257 (defvar gnus-current-score-file nil)
1258 (defvar gnus-internal-global-score-files nil)
1259 (defvar gnus-score-file-list nil)
1260 (defvar gnus-scores-exclude-files nil)
1262 (defvar gnus-current-move-group nil)
1264 (defvar gnus-newsgroup-dependencies nil)
1265 (defvar gnus-newsgroup-threads nil)
1266 (defvar gnus-newsgroup-async nil)
1267 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1269 (defvar gnus-newsgroup-adaptive nil)
1271 (defvar gnus-summary-display-table nil)
1273 (defconst gnus-group-line-format-alist
1274 (list (list ?M 'marked ?c)
1275 (list ?S 'subscribed ?c)
1276 (list ?L 'level ?d)
1277 (list ?N 'number ?s)
1278 (list ?I 'number-of-dormant ?d)
1279 (list ?T 'number-of-ticked ?d)
1280 (list ?R 'number-of-read ?s)
1281 (list ?t 'number-total ?d)
1282 (list ?y 'number-of-unread-unticked ?s)
1283 (list ?i 'number-of-ticked-and-dormant ?d)
1284 (list ?g 'group ?s)
1285 (list ?G 'qualified-group ?s)
1286 (list ?D 'newsgroup-description ?s)
1287 (list ?o 'moderated ?c)
1288 (list ?O 'moderated-string ?s)
1289 (list ?p 'process-marked ?c)
1290 (list ?s 'news-server ?s)
1291 (list ?n 'news-method ?s)
1292 (list ?z 'news-method-string ?s)
1293 (list ?u 'user-defined ?s)))
1295 (defconst gnus-summary-line-format-alist
1296 (list (list ?N 'number ?d)
1297 (list ?S 'subject ?s)
1298 (list ?s 'subject-or-nil ?s)
1299 (list ?n 'name ?s)
1300 (list ?A '(car (cdr (funcall gnus-extract-address-components from)))
1302 (list ?a '(or (car (funcall gnus-extract-address-components from))
1303 from) ?s)
1304 (list ?F 'from ?s)
1305 (list ?x (macroexpand '(mail-header-xref header)) ?s)
1306 (list ?D (macroexpand '(mail-header-date header)) ?s)
1307 (list ?d '(gnus-dd-mmm (mail-header-date header)) ?s)
1308 (list ?M (macroexpand '(mail-header-id header)) ?s)
1309 (list ?r (macroexpand '(mail-header-references header)) ?s)
1310 (list ?c '(or (mail-header-chars header) 0) ?d)
1311 (list ?L 'lines ?d)
1312 (list ?I 'indentation ?s)
1313 (list ?T '(if (= level 0) "" (make-string (frame-width) ? )) ?s)
1314 (list ?R 'replied ?c)
1315 (list ?\[ 'opening-bracket ?c)
1316 (list ?\] 'closing-bracket ?c)
1317 (list ?\> '(make-string level ? ) ?s)
1318 (list ?\< '(make-string (max 0 (- 20 level)) ? ) ?s)
1319 (list ?i 'score ?d)
1320 (list ?z 'score-char ?c)
1321 (list ?U 'unread ?c)
1322 (list ?t '(gnus-summary-number-of-articles-in-thread
1323 (and (boundp 'thread) (car thread)))
1325 (list ?e '(gnus-summary-number-of-articles-in-thread
1326 (and (boundp 'thread) (car thread)) t)
1328 (list ?u 'user-defined ?s))
1329 "An alist of format specifications that can appear in summary lines,
1330 and what variables they correspond with, along with the type of the
1331 variable (string, integer, character, etc).")
1333 (defconst gnus-summary-dummy-line-format-alist
1334 (list (list ?S 'subject ?s)
1335 (list ?N 'number ?d)
1336 (list ?u 'user-defined ?s)))
1338 (defconst gnus-summary-mode-line-format-alist
1339 (list (list ?G 'group-name ?s)
1340 (list ?g '(gnus-short-group-name group-name) ?s)
1341 (list ?A 'article-number ?d)
1342 (list ?Z 'unread-and-unselected ?s)
1343 (list ?V 'gnus-version ?s)
1344 (list ?U 'unread ?d)
1345 (list ?S 'subject ?s)
1346 (list ?e 'unselected ?d)
1347 (list ?u 'user-defined ?s)
1348 (list ?b 'buffer-name ?s)
1349 (list ?s '(gnus-current-score-file-nondirectory) ?s)))
1351 (defconst gnus-group-mode-line-format-alist
1352 (list (list ?S 'news-server ?s)
1353 (list ?M 'news-method ?s)
1354 (list ?b '(buffer-name) ?s)
1355 (list ?u 'user-defined ?s)))
1357 (defvar gnus-have-read-active-file nil)
1359 (defconst gnus-maintainer
1360 "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)"
1361 "The mail address of the Gnus maintainers.")
1363 (defconst gnus-version "Gnus v5.1"
1364 "Version number for this version of Gnus.")
1366 (defvar gnus-info-nodes
1367 '((gnus-group-mode "(gnus)The Group Buffer")
1368 (gnus-summary-mode "(gnus)The Summary Buffer")
1369 (gnus-article-mode "(gnus)The Article Buffer"))
1370 "Assoc list of major modes and related Info nodes.")
1372 (defvar gnus-group-buffer "*Group*")
1373 (defvar gnus-summary-buffer "*Summary*")
1374 (defvar gnus-article-buffer "*Article*")
1375 (defvar gnus-server-buffer "*Server*")
1377 (defvar gnus-work-buffer " *gnus work*")
1379 (defvar gnus-buffer-list nil
1380 "Gnus buffers that should be killed on exit.")
1382 (defvar gnus-server-alist nil
1383 "List of available servers.")
1385 (defvar gnus-variable-list
1386 '(gnus-newsrc-options gnus-newsrc-options-n
1387 gnus-newsrc-last-checked-date
1388 gnus-newsrc-alist gnus-server-alist
1389 gnus-killed-list gnus-zombie-list)
1390 "Gnus variables saved in the quick startup file.")
1392 (defvar gnus-overload-functions
1393 '((news-inews gnus-inews-news "rnewspost"))
1394 "Functions overloaded by gnus.
1395 It is a list of `(original overload &optional file)'.")
1397 (defvar gnus-newsrc-options nil
1398 "Options line in the .newsrc file.")
1400 (defvar gnus-newsrc-options-n nil
1401 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1403 (defvar gnus-newsrc-last-checked-date nil
1404 "Date Gnus last asked server for new newsgroups.")
1406 (defvar gnus-newsrc-alist nil
1407 "Assoc list of read articles.
1408 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1410 (defvar gnus-newsrc-hashtb nil
1411 "Hashtable of gnus-newsrc-alist.")
1413 (defvar gnus-killed-list nil
1414 "List of killed newsgroups.")
1416 (defvar gnus-killed-hashtb nil
1417 "Hash table equivalent of gnus-killed-list.")
1419 (defvar gnus-zombie-list nil
1420 "List of almost dead newsgroups.")
1422 (defvar gnus-description-hashtb nil
1423 "Descriptions of newsgroups.")
1425 (defvar gnus-list-of-killed-groups nil
1426 "List of newsgroups that have recently been killed by the user.")
1428 (defvar gnus-active-hashtb nil
1429 "Hashtable of active articles.")
1431 (defvar gnus-moderated-list nil
1432 "List of moderated newsgroups.")
1434 (defvar gnus-group-marked nil)
1436 (defvar gnus-current-startup-file nil
1437 "Startup file for the current host.")
1439 (defvar gnus-last-search-regexp nil
1440 "Default regexp for article search command.")
1442 (defvar gnus-last-shell-command nil
1443 "Default shell command on article.")
1445 (defvar gnus-current-select-method nil
1446 "The current method for selecting a newsgroup.")
1448 (defvar gnus-group-list-mode nil)
1450 (defvar gnus-article-internal-prepare-hook nil)
1452 (defvar gnus-newsgroup-name nil)
1453 (defvar gnus-newsgroup-begin nil)
1454 (defvar gnus-newsgroup-end nil)
1455 (defvar gnus-newsgroup-last-rmail nil)
1456 (defvar gnus-newsgroup-last-mail nil)
1457 (defvar gnus-newsgroup-last-folder nil)
1458 (defvar gnus-newsgroup-last-file nil)
1459 (defvar gnus-newsgroup-auto-expire nil)
1460 (defvar gnus-newsgroup-active nil)
1462 (defvar gnus-newsgroup-unreads nil
1463 "List of unread articles in the current newsgroup.")
1465 (defvar gnus-newsgroup-unselected nil
1466 "List of unselected unread articles in the current newsgroup.")
1468 (defvar gnus-newsgroup-reads nil
1469 "Alist of read articles and article marks in the current newsgroup.")
1471 (defvar gnus-newsgroup-marked nil
1472 "List of ticked articles in the current newsgroup (a subset of unread art).")
1474 (defvar gnus-newsgroup-killed nil
1475 "List of ranges of articles that have been through the scoring process.")
1477 (defvar gnus-newsgroup-kill-headers nil)
1479 (defvar gnus-newsgroup-replied nil
1480 "List of articles that have been replied to in the current newsgroup.")
1482 (defvar gnus-newsgroup-expirable nil
1483 "List of articles in the current newsgroup that can be expired.")
1485 (defvar gnus-newsgroup-processable nil
1486 "List of articles in the current newsgroup that can be processed.")
1488 (defvar gnus-newsgroup-bookmarks nil
1489 "List of articles in the current newsgroup that have bookmarks.")
1491 (defvar gnus-newsgroup-dormant nil
1492 "List of dormant articles in the current newsgroup.")
1494 (defvar gnus-newsgroup-scored nil
1495 "List of scored articles in the current newsgroup.")
1497 (defvar gnus-newsgroup-headers nil
1498 "List of article headers in the current newsgroup.")
1499 (defvar gnus-newsgroup-headers-hashtb-by-number nil)
1501 (defvar gnus-newsgroup-ancient nil
1502 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1504 (defvar gnus-current-article nil)
1505 (defvar gnus-article-current nil)
1506 (defvar gnus-current-headers nil)
1507 (defvar gnus-have-all-headers nil)
1508 (defvar gnus-last-article nil)
1509 (defvar gnus-newsgroup-history nil)
1510 (defvar gnus-current-kill-article nil)
1512 ;; Save window configuration.
1513 (defvar gnus-prev-winconf nil)
1515 ;; Format specs
1516 (defvar gnus-summary-line-format-spec nil)
1517 (defvar gnus-summary-dummy-line-format-spec nil)
1518 (defvar gnus-group-line-format-spec nil)
1519 (defvar gnus-summary-mode-line-format-spec nil)
1520 (defvar gnus-article-mode-line-format-spec nil)
1521 (defvar gnus-group-mode-line-format-spec nil)
1522 (defvar gnus-summary-mark-positions nil)
1523 (defvar gnus-group-mark-positions nil)
1525 (defvar gnus-summary-expunge-below nil)
1526 (defvar gnus-reffed-article-number nil)
1528 ; Let the byte-compiler know that we know about this variable.
1529 (defvar rmail-default-rmail-file)
1531 (defvar gnus-cache-removable-articles nil)
1533 (defconst gnus-summary-local-variables
1534 '(gnus-newsgroup-name
1535 gnus-newsgroup-begin gnus-newsgroup-end
1536 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1537 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1538 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1539 gnus-newsgroup-unselected gnus-newsgroup-marked
1540 gnus-newsgroup-reads
1541 gnus-newsgroup-replied gnus-newsgroup-expirable
1542 gnus-newsgroup-processable gnus-newsgroup-killed
1543 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1544 gnus-newsgroup-headers gnus-newsgroup-headers-hashtb-by-number
1545 gnus-current-article gnus-current-headers gnus-have-all-headers
1546 gnus-last-article gnus-article-internal-prepare-hook
1547 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1548 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1549 gnus-newsgroup-threads gnus-newsgroup-async
1550 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1551 gnus-summary-mark-below gnus-newsgroup-active gnus-scores-exclude-files
1552 gnus-newsgroup-history gnus-newsgroup-ancient
1553 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1554 gnus-cache-removable-articles)
1555 "Variables that are buffer-local to the summary buffers.")
1557 (defconst gnus-bug-message
1558 "Sending a bug report to the Gnus Towers.
1559 ========================================
1561 The buffer below is a mail buffer. When you press `C-c C-c', it will
1562 be sent to the Gnus Bug Exterminators.
1564 At the bottom of the buffer you'll see lots of variable settings.
1565 Please do not delete those. They will tell the Bug People what your
1566 environment is, so that it will be easier to locate the bugs.
1568 If you have found a bug that makes Emacs go \"beep\", set
1569 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
1570 and include the backtrace in your bug report.
1572 Please describe the bug in annoying, painstaking detail.
1574 Thank you for your help in stamping out bugs.
1577 ;;; End of variables.
1579 ;; Define some autoload functions Gnus might use.
1580 (eval-and-compile
1582 ;; Various
1583 (autoload 'metamail-buffer "metamail")
1584 (autoload 'Info-goto-node "info")
1585 (autoload 'hexl-hex-string-to-integer "hexl")
1586 (autoload 'pp "pp")
1587 (autoload 'pp-to-string "pp")
1588 (autoload 'pp-eval-expression "pp")
1589 (autoload 'mail-extract-address-components "mail-extr")
1591 (autoload 'nnmail-split-fancy "nnmail")
1592 (autoload 'nnvirtual-catchup-group "nnvirtual")
1594 ;; timezone
1595 (autoload 'timezone-make-date-arpa-standard "timezone")
1596 (autoload 'timezone-fix-time "timezone")
1597 (autoload 'timezone-make-sortable-date "timezone")
1598 (autoload 'timezone-make-time-string "timezone")
1600 ;; rmail & friends
1601 (autoload 'mail-position-on-field "sendmail")
1602 (autoload 'mail-setup "sendmail")
1603 (autoload 'rmail-output "rmailout")
1604 (autoload 'news-mail-other-window "rnewspost")
1605 (autoload 'news-reply-yank-original "rnewspost")
1606 (autoload 'news-caesar-buffer-body "rnewspost")
1607 (autoload 'rmail-insert-rmail-file-header "rmail")
1608 (autoload 'rmail-count-new-messages "rmail")
1609 (autoload 'rmail-show-message "rmail")
1611 ;; gnus-soup
1612 ;;(autoload 'gnus-group-brew-soup "gnus-soup" nil t)
1613 ;;(autoload 'gnus-brew-soup "gnus-soup" nil t)
1614 ;;(autoload 'gnus-soup-add-article "gnus-soup" nil t)
1615 ;;(autoload 'gnus-soup-send-replies "gnus-soup" nil t)
1616 ;;(autoload 'gnus-soup-save-areas "gnus-soup" nil t)
1617 ;;(autoload 'gnus-soup-pack-packet "gnus-soup" nil t)
1618 ;;(autoload 'nnsoup-pack-replies "nnsoup" nil t)
1620 ;; gnus-mh
1621 (autoload 'gnus-mail-reply-using-mhe "gnus-mh")
1622 (autoload 'gnus-mail-forward-using-mhe "gnus-mh")
1623 (autoload 'gnus-mail-other-window-using-mhe "gnus-mh")
1624 (autoload 'gnus-summary-save-in-folder "gnus-mh" nil t)
1625 (autoload 'gnus-summary-save-article-folder "gnus-mh")
1626 (autoload 'gnus-Folder-save-name "gnus-mh")
1627 (autoload 'gnus-folder-save-name "gnus-mh")
1629 ;; gnus-vis misc
1630 (autoload 'gnus-group-make-menu-bar "gnus-vis")
1631 (autoload 'gnus-summary-make-menu-bar "gnus-vis")
1632 (autoload 'gnus-server-make-menu-bar "gnus-vis")
1633 (autoload 'gnus-article-make-menu-bar "gnus-vis")
1634 (autoload 'gnus-browse-make-menu-bar "gnus-vis")
1635 (autoload 'gnus-highlight-selected-summary "gnus-vis")
1636 (autoload 'gnus-summary-highlight-line "gnus-vis")
1637 (autoload 'gnus-carpal-setup-buffer "gnus-vis")
1639 ;; gnus-vis article
1640 (autoload 'gnus-article-push-button "gnus-vis" nil t)
1641 (autoload 'gnus-article-press-button "gnus-vis" nil t)
1642 (autoload 'gnus-article-highlight "gnus-vis" nil t)
1643 (autoload 'gnus-article-highlight-some "gnus-vis" nil t)
1644 (autoload 'gnus-article-hide "gnus-vis" nil t)
1645 (autoload 'gnus-article-hide-signature "gnus-vis" nil t)
1646 (autoload 'gnus-article-highlight-headers "gnus-vis" nil t)
1647 (autoload 'gnus-article-highlight-signature "gnus-vis" nil t)
1648 (autoload 'gnus-article-add-buttons "gnus-vis" nil t)
1649 (autoload 'gnus-article-next-button "gnus-vis" nil t)
1650 (autoload 'gnus-article-add-button "gnus-vis")
1652 ;; gnus-cite
1653 (autoload 'gnus-article-highlight-citation "gnus-cite" nil t)
1654 (autoload 'gnus-article-hide-citation-maybe "gnus-cite" nil t)
1655 (autoload 'gnus-article-hide-citation "gnus-cite" nil t)
1657 ;; gnus-kill
1658 (autoload 'gnus-kill "gnus-kill")
1659 (autoload 'gnus-apply-kill-file-internal "gnus-kill")
1660 (autoload 'gnus-kill-file-edit-file "gnus-kill")
1661 (autoload 'gnus-kill-file-raise-followups-to-author "gnus-kill")
1662 (autoload 'gnus-execute "gnus-kill")
1663 (autoload 'gnus-expunge "gnus-kill")
1665 ;; gnus-cache
1666 (autoload 'gnus-cache-possibly-enter-article "gnus-cache")
1667 (autoload 'gnus-cache-save-buffers "gnus-cache")
1668 (autoload 'gnus-cache-possibly-remove-articles "gnus-cache")
1669 (autoload 'gnus-cache-request-article "gnus-cache")
1670 (autoload 'gnus-cache-retrieve-headers "gnus-cache")
1671 (autoload 'gnus-cache-possibly-alter-active "gnus-cache")
1672 (autoload 'gnus-jog-cache "gnus-cache" nil t)
1673 (autoload 'gnus-cache-enter-remove-article "gnus-cache")
1675 ;; gnus-score
1676 (autoload 'gnus-summary-increase-score "gnus-score" nil t)
1677 (autoload 'gnus-summary-lower-score "gnus-score" nil t)
1678 (autoload 'gnus-summary-score-map "gnus-score" nil nil 'keymap)
1679 (autoload 'gnus-score-save "gnus-score")
1680 (autoload 'gnus-score-headers "gnus-score")
1681 (autoload 'gnus-current-score-file-nondirectory "gnus-score")
1682 (autoload 'gnus-score-adaptive "gnus-score")
1683 (autoload 'gnus-score-remove-lines-adaptive "gnus-score")
1684 (autoload 'gnus-score-find-trace "gnus-score")
1686 ;; gnus-edit
1687 (autoload 'gnus-score-customize "gnus-edit" nil t)
1689 ;; gnus-uu
1690 (autoload 'gnus-uu-extract-map "gnus-uu" nil nil 'keymap)
1691 (autoload 'gnus-uu-mark-map "gnus-uu" nil nil 'keymap)
1692 (autoload 'gnus-uu-digest-mail-forward "gnus-uu" nil t)
1693 (autoload 'gnus-uu-digest-post-forward "gnus-uu" nil t)
1694 (autoload 'gnus-uu-mark-series "gnus-uu" nil t)
1695 (autoload 'gnus-uu-mark-region "gnus-uu" nil t)
1696 (autoload 'gnus-uu-mark-by-regexp "gnus-uu" nil t)
1697 (autoload 'gnus-uu-mark-all "gnus-uu" nil t)
1698 (autoload 'gnus-uu-mark-sparse "gnus-uu" nil t)
1699 (autoload 'gnus-uu-mark-thread "gnus-uu" nil t)
1700 (autoload 'gnus-uu-decode-uu "gnus-uu" nil t)
1701 (autoload 'gnus-uu-decode-uu-and-save "gnus-uu" nil t)
1702 (autoload 'gnus-uu-decode-unshar "gnus-uu" nil t)
1703 (autoload 'gnus-uu-decode-unshar-and-save "gnus-uu" nil t)
1704 (autoload 'gnus-uu-decode-save "gnus-uu" nil t)
1705 (autoload 'gnus-uu-decode-binhex "gnus-uu" nil t)
1706 (autoload 'gnus-uu-decode-uu-view "gnus-uu" nil t)
1707 (autoload 'gnus-uu-decode-uu-and-save-view "gnus-uu" nil t)
1708 (autoload 'gnus-uu-decode-unshar-view "gnus-uu" nil t)
1709 (autoload 'gnus-uu-decode-unshar-and-save-view "gnus-uu" nil t)
1710 (autoload 'gnus-uu-decode-save-view "gnus-uu" nil t)
1711 (autoload 'gnus-uu-decode-binhex-view "gnus-uu" nil t)
1713 ;; gnus-msg
1714 (autoload 'gnus-summary-send-map "gnus-msg" nil nil 'keymap)
1715 (autoload 'gnus-group-post-news "gnus-msg" nil t)
1716 (autoload 'gnus-group-mail "gnus-msg" nil t)
1717 (autoload 'gnus-summary-post-news "gnus-msg" nil t)
1718 (autoload 'gnus-summary-followup "gnus-msg" nil t)
1719 (autoload 'gnus-summary-followup-with-original "gnus-msg" nil t)
1720 (autoload 'gnus-summary-followup-and-reply "gnus-msg" nil t)
1721 (autoload 'gnus-summary-followup-and-reply-with-original "gnus-msg" nil t)
1722 (autoload 'gnus-summary-cancel-article "gnus-msg" nil t)
1723 (autoload 'gnus-summary-supersede-article "gnus-msg" nil t)
1724 (autoload 'gnus-post-news "gnus-msg" nil t)
1725 (autoload 'gnus-inews-news "gnus-msg" nil t)
1726 (autoload 'gnus-cancel-news "gnus-msg" nil t)
1727 (autoload 'gnus-summary-reply "gnus-msg" nil t)
1728 (autoload 'gnus-summary-reply-with-original "gnus-msg" nil t)
1729 (autoload 'gnus-summary-mail-forward "gnus-msg" nil t)
1730 (autoload 'gnus-summary-mail-other-window "gnus-msg" nil t)
1731 (autoload 'gnus-mail-reply-using-mail "gnus-msg")
1732 (autoload 'gnus-mail-yank-original "gnus-msg")
1733 (autoload 'gnus-mail-send-and-exit "gnus-msg")
1734 (autoload 'gnus-mail-forward-using-mail "gnus-msg")
1735 (autoload 'gnus-mail-other-window-using-mail "gnus-msg")
1736 (autoload 'gnus-article-mail "gnus-msg")
1737 (autoload 'gnus-bug "gnus-msg" nil t)
1739 ;; gnus-vm
1740 (autoload 'gnus-summary-save-in-vm "gnus-vm" nil t)
1741 (autoload 'gnus-summary-save-article-vm "gnus-vm" nil t)
1742 (autoload 'gnus-mail-forward-using-vm "gnus-vm")
1743 (autoload 'gnus-mail-reply-using-vm "gnus-vm")
1744 (autoload 'gnus-mail-other-window-using-vm "gnus-vm" nil t)
1745 (autoload 'gnus-yank-article "gnus-vm" nil t)
1751 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1752 ;; If you want the cursor to go somewhere else, set these two
1753 ;; functions in some startup hook to whatever you want.
1754 (defalias 'gnus-summary-position-cursor 'gnus-goto-colon)
1755 (defalias 'gnus-group-position-cursor 'gnus-goto-colon)
1757 ;;; Various macros and substs.
1759 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
1760 "Pop to BUFFER, evaluate FORMS, and then returns to original window."
1761 (` (let ((GnusStartBufferWindow (selected-window)))
1762 (unwind-protect
1763 (progn
1764 (pop-to-buffer (, buffer))
1765 (,@ forms))
1766 (select-window GnusStartBufferWindow)))))
1768 (defmacro gnus-gethash (string hashtable)
1769 "Get hash value of STRING in HASHTABLE."
1770 ;;(` (symbol-value (abbrev-symbol (, string) (, hashtable))))
1771 ;;(` (abbrev-expansion (, string) (, hashtable)))
1772 (` (symbol-value (intern-soft (, string) (, hashtable)))))
1774 (defmacro gnus-sethash (string value hashtable)
1775 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
1776 ;; We cannot use define-abbrev since it only accepts string as value.
1777 ;; (set (intern string hashtable) value))
1778 (` (set (intern (, string) (, hashtable)) (, value))))
1780 (defsubst gnus-buffer-substring (beg end)
1781 (buffer-substring (match-beginning beg) (match-end end)))
1783 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
1784 ;; function `substring' might cut on a middle of multi-octet
1785 ;; character.
1786 (defun gnus-truncate-string (str width)
1787 (substring str 0 width))
1789 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way
1790 ;; to limit the length of a string. This function is necessary since
1791 ;; `(substr "abc" 0 30)' pukes with "Args out of range".
1792 (defsubst gnus-limit-string (str width)
1793 (if (> (length str) width)
1794 (substring str 0 width)
1795 str))
1797 (defsubst gnus-simplify-subject-re (subject)
1798 "Remove \"Re:\" from subject lines."
1799 (let ((case-fold-search t))
1800 (if (string-match "^re: *" subject)
1801 (substring subject (match-end 0))
1802 subject)))
1804 (defsubst gnus-goto-char (point)
1805 (and point (goto-char point)))
1807 (defmacro gnus-buffer-exists-p (buffer)
1808 (` (and (, buffer)
1809 (funcall (if (stringp (, buffer)) 'get-buffer 'buffer-name)
1810 (, buffer)))))
1812 (defmacro gnus-kill-buffer (buffer)
1813 (` (if (gnus-buffer-exists-p (, buffer))
1814 (kill-buffer (, buffer)))))
1816 (defsubst gnus-point-at-bol ()
1817 "Return point at the beginning of line."
1818 (let ((p (point)))
1819 (beginning-of-line)
1820 (prog1
1821 (point)
1822 (goto-char p))))
1824 (defsubst gnus-point-at-eol ()
1825 "Return point at the beginning of line."
1826 (let ((p (point)))
1827 (end-of-line)
1828 (prog1
1829 (point)
1830 (goto-char p))))
1832 ;; Delete the current line (and the next N lines.);
1833 (defmacro gnus-delete-line (&optional n)
1834 (` (delete-region (progn (beginning-of-line) (point))
1835 (progn (forward-line (, (or n 1))) (point)))))
1837 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
1838 (defvar gnus-init-inhibit nil)
1839 (defun gnus-read-init-file (&optional inhibit-next)
1840 (if gnus-init-inhibit
1841 (setq gnus-init-inhibit nil)
1842 (setq gnus-init-inhibit inhibit-next)
1843 (and gnus-init-file
1844 (or (and (file-exists-p gnus-init-file)
1845 ;; Don't try to load a directory.
1846 (not (file-directory-p gnus-init-file)))
1847 (file-exists-p (concat gnus-init-file ".el"))
1848 (file-exists-p (concat gnus-init-file ".elc")))
1849 (load gnus-init-file nil t))))
1851 ;;; Load the user startup file.
1852 ;; (eval '(gnus-read-init-file 'inhibit))
1854 ;;; Load the compatibility functions.
1856 (require 'gnus-cus)
1857 (require 'gnus-ems)
1861 ;;; Gnus Utility Functions
1864 (defun gnus-extract-address-components (from)
1865 (let (name address)
1866 ;; First find the address - the thing with the @ in it. This may
1867 ;; not be accurate in mail addresses, but does the trick most of
1868 ;; the time in news messages.
1869 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
1870 (setq address (substring from (match-beginning 0) (match-end 0))))
1871 ;; Then we check whether the "name <address>" format is used.
1872 (and address
1873 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>
1874 ;; Linear white space is not required.
1875 (string-match (concat "[ \t]*<" (regexp-quote address) ">") from)
1876 (and (setq name (substring from 0 (match-beginning 0)))
1877 ;; Strip any quotes from the name.
1878 (string-match "\".*\"" name)
1879 (setq name (substring name 1 (1- (match-end 0))))))
1880 ;; If not, then "address (name)" is used.
1881 (or name
1882 (and (string-match "(.+)" from)
1883 (setq name (substring from (1+ (match-beginning 0))
1884 (1- (match-end 0)))))
1885 (and (string-match "()" from)
1886 (setq name address))
1887 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>.
1888 ;; XOVER might not support folded From headers.
1889 (and (string-match "(.*" from)
1890 (setq name (substring from (1+ (match-beginning 0))
1891 (match-end 0)))))
1892 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1893 (list (or name from) (or address from))))
1895 (defun gnus-fetch-field (field)
1896 "Return the value of the header FIELD of current article."
1897 (save-excursion
1898 (save-restriction
1899 (let ((case-fold-search t))
1900 (gnus-narrow-to-headers)
1901 (mail-fetch-field field)))))
1903 (defun gnus-goto-colon ()
1904 (beginning-of-line)
1905 (search-forward ":" (gnus-point-at-eol) t))
1907 (defun gnus-narrow-to-headers ()
1908 (widen)
1909 (save-excursion
1910 (narrow-to-region
1911 (goto-char (point-min))
1912 (if (search-forward "\n\n" nil t)
1913 (1- (point))
1914 (point-max)))))
1916 (defvar gnus-old-specs nil)
1918 (defun gnus-update-format-specifications ()
1919 (gnus-make-thread-indent-array)
1921 (let ((formats '(summary summary-dummy group
1922 summary-mode group-mode article-mode))
1923 old-format new-format)
1924 (while formats
1925 (setq new-format (symbol-value
1926 (intern (format "gnus-%s-line-format" (car formats)))))
1927 (or (and (setq old-format (cdr (assq (car formats) gnus-old-specs)))
1928 (equal old-format new-format))
1929 (set (intern (format "gnus-%s-line-format-spec" (car formats)))
1930 (gnus-parse-format
1931 new-format
1932 (symbol-value
1933 (intern (format "gnus-%s-line-format-alist"
1934 (if (eq (car formats) 'article-mode)
1935 'summary-mode (car formats))))))))
1936 (setq gnus-old-specs (cons (cons (car formats) new-format)
1937 (delq (car formats) gnus-old-specs)))
1938 (setq formats (cdr formats))))
1940 (gnus-update-group-mark-positions)
1941 (gnus-update-summary-mark-positions)
1943 (if (and (string-match "%D" gnus-group-line-format)
1944 (not gnus-description-hashtb)
1945 gnus-read-active-file)
1946 (gnus-read-all-descriptions-files)))
1948 (defun gnus-update-summary-mark-positions ()
1949 (save-excursion
1950 (let ((gnus-replied-mark 129)
1951 (gnus-score-below-mark 130)
1952 (gnus-score-over-mark 130)
1953 (thread nil)
1954 pos)
1955 (gnus-set-work-buffer)
1956 (gnus-summary-insert-line
1957 nil [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
1958 (goto-char (point-min))
1959 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
1960 (- (point) 2)))))
1961 (goto-char (point-min))
1962 (setq pos (cons (cons 'replied (and (search-forward "\201" nil t)
1963 (- (point) 2))) pos))
1964 (goto-char (point-min))
1965 (setq pos (cons (cons 'score (and (search-forward "\202" nil t)
1966 (- (point) 2))) pos))
1967 (setq gnus-summary-mark-positions pos))))
1969 (defun gnus-update-group-mark-positions ()
1970 (save-excursion
1971 (let ((gnus-process-mark 128)
1972 (gnus-group-marked '("dummy.group")))
1973 (gnus-sethash "dummy.group" '(0 . 0) gnus-active-hashtb)
1974 (gnus-set-work-buffer)
1975 (gnus-group-insert-group-line nil "dummy.group" 0 nil 0 nil)
1976 (goto-char (point-min))
1977 (setq gnus-group-mark-positions
1978 (list (cons 'process (and (search-forward "\200" nil t)
1979 (- (point) 2))))))))
1981 (defun gnus-mouse-face-function (form)
1982 (` (let ((string (, form)))
1983 (put-text-property 0 (length string) 'mouse-face gnus-mouse-face string)
1984 string)))
1986 (defun gnus-max-width-function (el max-width)
1987 (or (numberp max-width) (signal 'wrong-type-argument '(numberp max-width)))
1988 (` (let* ((val (eval (, el)))
1989 (valstr (if (numberp val)
1990 (int-to-string val) val)))
1991 (if (> (length valstr) (, max-width))
1992 (substring valstr 0 (, max-width))
1993 valstr))))
1995 (defun gnus-parse-format (format spec-alist)
1996 ;; This function parses the FORMAT string with the help of the
1997 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
1998 ;; string. If the FORMAT string contains the specifiers %( and %)
1999 ;; the text between them will have the mouse-face text property.
2000 (if (string-match "\\`\\(.*\\)%(\\(.*\\)%)\\(.*\n?\\)\\'" format)
2001 (if (and gnus-visual gnus-mouse-face)
2002 (let ((pre (substring format (match-beginning 1) (match-end 1)))
2003 (button (substring format (match-beginning 2) (match-end 2)))
2004 (post (substring format (match-beginning 3) (match-end 3))))
2005 (list 'concat
2006 (gnus-parse-simple-format pre spec-alist)
2007 (gnus-mouse-face-function
2008 (gnus-parse-simple-format button spec-alist))
2009 (gnus-parse-simple-format post spec-alist)))
2010 (gnus-parse-simple-format
2011 (concat (substring format (match-beginning 1) (match-end 1))
2012 (substring format (match-beginning 2) (match-end 2))
2013 (substring format (match-beginning 3) (match-end 3)))
2014 spec-alist))
2015 (gnus-parse-simple-format format spec-alist)))
2017 (defun gnus-parse-simple-format (format spec-alist)
2018 ;; This function parses the FORMAT string with the help of the
2019 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
2020 ;; string. The list will consist of the symbol `format', a format
2021 ;; specification string, and a list of forms depending on the
2022 ;; SPEC-ALIST.
2023 (let ((max-width 0)
2024 spec flist fstring newspec elem beg)
2025 (save-excursion
2026 (gnus-set-work-buffer)
2027 (insert format)
2028 (goto-char (point-min))
2029 (while (re-search-forward "%[-0-9]*\\(,[0-9]+\\)?\\([^0-9]\\)\\(.\\)?" nil t)
2030 (setq spec (string-to-char (buffer-substring (match-beginning 2)
2031 (match-end 2))))
2032 ;; First check if there are any specs that look anything like
2033 ;; "%12,12A", ie. with a "max width specification". These have
2034 ;; to be treated specially.
2035 (if (setq beg (match-beginning 1))
2036 (setq max-width
2037 (string-to-int
2038 (buffer-substring (1+ (match-beginning 1)) (match-end 1))))
2039 (setq max-width 0)
2040 (setq beg (match-beginning 2)))
2041 ;; Find the specification from `spec-alist'.
2042 (if (not (setq elem (cdr (assq spec spec-alist))))
2043 (setq elem '("*" ?s)))
2044 ;; Treat user defined format specifiers specially
2045 (and (eq (car elem) 'user-defined)
2046 (setq elem
2047 (list
2048 (list (intern (concat "gnus-user-format-function-"
2049 (buffer-substring
2050 (match-beginning 3)
2051 (match-end 3))))
2052 'header)
2053 ?s))
2054 (delete-region (match-beginning 3) (match-end 3)))
2055 (if (not (zerop max-width))
2056 (let ((el (car elem)))
2057 (cond ((= (car (cdr elem)) ?c)
2058 (setq el (list 'char-to-string el)))
2059 ((= (car (cdr elem)) ?d)
2060 (numberp el) (setq el (list 'int-to-string el))))
2061 (setq flist (cons (gnus-max-width-function el max-width)
2062 flist))
2063 (setq newspec ?s))
2064 (setq flist (cons (car elem) flist))
2065 (setq newspec (car (cdr elem))))
2066 ;; Remove the old specification (and possibly a ",12" string).
2067 (delete-region beg (match-end 2))
2068 ;; Insert the new specification.
2069 (goto-char beg)
2070 (insert newspec))
2071 (setq fstring (buffer-substring 1 (point-max))))
2072 (cons 'format (cons fstring (nreverse flist)))))
2074 (defun gnus-set-work-buffer ()
2075 (if (get-buffer gnus-work-buffer)
2076 (progn
2077 (set-buffer gnus-work-buffer)
2078 (erase-buffer))
2079 (set-buffer (get-buffer-create gnus-work-buffer))
2080 (kill-all-local-variables)
2081 (buffer-disable-undo (current-buffer))
2082 (gnus-add-current-to-buffer-list)))
2084 ;; Article file names when saving.
2086 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2087 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2088 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
2089 Otherwise, it is like ~/News/news/group/num."
2090 (let ((default
2091 (expand-file-name
2092 (concat (if (gnus-use-long-file-name 'not-save)
2093 (gnus-capitalize-newsgroup newsgroup)
2094 (gnus-newsgroup-directory-form newsgroup))
2095 "/" (int-to-string (mail-header-number headers)))
2096 (or gnus-article-save-directory "~/News"))))
2097 (if (and last-file
2098 (string-equal (file-name-directory default)
2099 (file-name-directory last-file))
2100 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2101 default
2102 (or last-file default))))
2104 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2105 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2106 If variable `gnus-use-long-file-name' is non-nil, it is
2107 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2108 (let ((default
2109 (expand-file-name
2110 (concat (if (gnus-use-long-file-name 'not-save)
2111 newsgroup
2112 (gnus-newsgroup-directory-form newsgroup))
2113 "/" (int-to-string (mail-header-number headers)))
2114 (or gnus-article-save-directory "~/News"))))
2115 (if (and last-file
2116 (string-equal (file-name-directory default)
2117 (file-name-directory last-file))
2118 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2119 default
2120 (or last-file default))))
2122 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2123 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2124 If variable `gnus-use-long-file-name' is non-nil, it is
2125 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2126 (or last-file
2127 (expand-file-name
2128 (if (gnus-use-long-file-name 'not-save)
2129 (gnus-capitalize-newsgroup newsgroup)
2130 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2131 (or gnus-article-save-directory "~/News"))))
2133 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2134 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2135 If variable `gnus-use-long-file-name' is non-nil, it is
2136 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2137 (or last-file
2138 (expand-file-name
2139 (if (gnus-use-long-file-name 'not-save)
2140 newsgroup
2141 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2142 (or gnus-article-save-directory "~/News"))))
2144 ;; For subscribing new newsgroup
2146 (defun gnus-subscribe-hierarchical-interactive (groups)
2147 (let ((groups (sort groups 'string<))
2148 prefixes prefix start ans group starts)
2149 (while groups
2150 (setq prefixes (list "^"))
2151 (while (and groups prefixes)
2152 (while (not (string-match (car prefixes) (car groups)))
2153 (setq prefixes (cdr prefixes)))
2154 (setq prefix (car prefixes))
2155 (setq start (1- (length prefix)))
2156 (if (and (string-match "[^\\.]\\." (car groups) start)
2157 (cdr groups)
2158 (setq prefix
2159 (concat "^" (substring (car groups) 0 (match-end 0))))
2160 (string-match prefix (car (cdr groups))))
2161 (progn
2162 (setq prefixes (cons prefix prefixes))
2163 (message "Descend hierarchy %s? ([y]nsq): "
2164 (substring prefix 1 (1- (length prefix))))
2165 (setq ans (read-char))
2166 (cond ((= ans ?n)
2167 (while (and groups
2168 (string-match prefix
2169 (setq group (car groups))))
2170 (setq gnus-killed-list
2171 (cons group gnus-killed-list))
2172 (gnus-sethash group group gnus-killed-hashtb)
2173 (setq groups (cdr groups)))
2174 (setq starts (cdr starts)))
2175 ((= ans ?s)
2176 (while (and groups
2177 (string-match prefix
2178 (setq group (car groups))))
2179 (gnus-sethash group group gnus-killed-hashtb)
2180 (gnus-subscribe-alphabetically (car groups))
2181 (setq groups (cdr groups)))
2182 (setq starts (cdr starts)))
2183 ((= ans ?q)
2184 (while groups
2185 (setq group (car groups))
2186 (setq gnus-killed-list (cons group gnus-killed-list))
2187 (gnus-sethash group group gnus-killed-hashtb)
2188 (setq groups (cdr groups))))
2189 (t nil)))
2190 (message "Subscribe %s? ([n]yq)" (car groups))
2191 (setq ans (read-char))
2192 (setq group (car groups))
2193 (cond ((= ans ?y)
2194 (gnus-subscribe-alphabetically (car groups))
2195 (gnus-sethash group group gnus-killed-hashtb))
2196 ((= ans ?q)
2197 (while groups
2198 (setq group (car groups))
2199 (setq gnus-killed-list (cons group gnus-killed-list))
2200 (gnus-sethash group group gnus-killed-hashtb)
2201 (setq groups (cdr groups))))
2203 (setq gnus-killed-list (cons group gnus-killed-list))
2204 (gnus-sethash group group gnus-killed-hashtb)))
2205 (setq groups (cdr groups)))))))
2207 (defun gnus-subscribe-randomly (newsgroup)
2208 "Subscribe new NEWSGROUP by making it the first newsgroup."
2209 (gnus-subscribe-newsgroup newsgroup))
2211 (defun gnus-subscribe-alphabetically (newgroup)
2212 "Subscribe new NEWSGROUP and insert it in alphabetical order."
2213 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2214 (let ((groups (cdr gnus-newsrc-alist))
2215 before)
2216 (while (and (not before) groups)
2217 (if (string< newgroup (car (car groups)))
2218 (setq before (car (car groups)))
2219 (setq groups (cdr groups))))
2220 (gnus-subscribe-newsgroup newgroup before)))
2222 (defun gnus-subscribe-hierarchically (newgroup)
2223 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
2224 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2225 (save-excursion
2226 (set-buffer (find-file-noselect gnus-current-startup-file))
2227 (let ((groupkey newgroup)
2228 before)
2229 (while (and (not before) groupkey)
2230 (goto-char (point-min))
2231 (let ((groupkey-re
2232 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
2233 (while (and (re-search-forward groupkey-re nil t)
2234 (progn
2235 (setq before (buffer-substring
2236 (match-beginning 1) (match-end 1)))
2237 (string< before newgroup)))))
2238 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
2239 (setq groupkey
2240 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
2241 (substring groupkey (match-beginning 1) (match-end 1)))))
2242 (gnus-subscribe-newsgroup newgroup before))))
2244 (defun gnus-subscribe-interactively (newsgroup)
2245 "Subscribe new NEWSGROUP interactively.
2246 It is inserted in hierarchical newsgroup order if subscribed. If not,
2247 it is killed."
2248 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " newsgroup))
2249 (gnus-subscribe-hierarchically newsgroup)
2250 (setq gnus-killed-list (cons newsgroup gnus-killed-list))))
2252 (defun gnus-subscribe-zombies (newsgroup)
2253 "Make new NEWSGROUP a zombie group."
2254 (setq gnus-zombie-list (cons newsgroup gnus-zombie-list)))
2256 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
2257 "Subscribe new NEWSGROUP.
2258 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
2259 the first newsgroup."
2260 ;; We subscribe the group by changing its level to `subscribed'.
2261 (gnus-group-change-level
2262 newsgroup gnus-level-default-subscribed
2263 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
2264 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
2266 ;; For directories
2268 (defun gnus-newsgroup-directory-form (newsgroup)
2269 "Make hierarchical directory name from NEWSGROUP name."
2270 (let ((newsgroup (gnus-newsgroup-savable-name newsgroup))
2271 (len (length newsgroup))
2272 idx)
2273 ;; If this is a foreign group, we don't want to translate the
2274 ;; entire name.
2275 (if (setq idx (string-match ":" newsgroup))
2276 (aset newsgroup idx ?/)
2277 (setq idx 0))
2278 ;; Replace all occurrences of `.' with `/'.
2279 (while (< idx len)
2280 (if (= (aref newsgroup idx) ?.)
2281 (aset newsgroup idx ?/))
2282 (setq idx (1+ idx)))
2283 newsgroup))
2285 (defun gnus-newsgroup-savable-name (group)
2286 ;; Replace any slashes in a group name (eg. an ange-ftp nndoc group)
2287 ;; with dots.
2288 (gnus-replace-chars-in-string group ?/ ?.))
2290 (defun gnus-make-directory (dir)
2291 "Make DIRECTORY recursively."
2292 ;; Why don't we use `(make-directory dir 'parents)'? That's just one
2293 ;; of the many mysteries of the universe.
2294 (let* ((dir (expand-file-name dir default-directory))
2295 dirs err)
2296 (if (string-match "/$" dir)
2297 (setq dir (substring dir 0 (match-beginning 0))))
2298 ;; First go down the path until we find a directory that exists.
2299 (while (not (file-exists-p dir))
2300 (setq dirs (cons dir dirs))
2301 (string-match "/[^/]+$" dir)
2302 (setq dir (substring dir 0 (match-beginning 0))))
2303 ;; Then create all the subdirs.
2304 (while (and dirs (not err))
2305 (condition-case ()
2306 (make-directory (car dirs))
2307 (error (setq err t)))
2308 (setq dirs (cdr dirs)))
2309 ;; We return whether we were successful or not.
2310 (not dirs)))
2312 (defun gnus-capitalize-newsgroup (newsgroup)
2313 "Capitalize NEWSGROUP name."
2314 (and (not (zerop (length newsgroup)))
2315 (concat (char-to-string (upcase (aref newsgroup 0)))
2316 (substring newsgroup 1))))
2318 ;; Var
2320 (defun gnus-simplify-subject (subject &optional re-only)
2321 "Remove `Re:' and words in parentheses.
2322 If optional argument RE-ONLY is non-nil, strip `Re:' only."
2323 (let ((case-fold-search t)) ;Ignore case.
2324 ;; Remove `Re:' and `Re^N:'.
2325 (if (string-match "^re:[ \t]*" subject)
2326 (setq subject (substring subject (match-end 0))))
2327 ;; Remove words in parentheses from end.
2328 (or re-only
2329 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
2330 (setq subject (substring subject 0 (match-beginning 0)))))
2331 ;; Return subject string.
2332 subject))
2334 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
2335 ;; all whitespace.
2336 (defun gnus-simplify-subject-fuzzy (subject)
2337 (let ((case-fold-search t))
2338 (save-excursion
2339 (gnus-set-work-buffer)
2340 (insert subject)
2341 (inline (gnus-simplify-buffer-fuzzy))
2342 (buffer-string))))
2344 (defun gnus-simplify-buffer-fuzzy ()
2345 (goto-char (point-min))
2346 ;; Fix by Stainless Steel Rat <ratinox@ccs.neu.edu>.
2347 (while (re-search-forward "^[ \t]*\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;][ \t]*"
2348 nil t)
2349 (replace-match "" t t))
2350 (goto-char (point-min))
2351 (while (re-search-forward "[ \t\n]*([^()]*)[ \t\n]*$" nil t)
2352 (replace-match "" t t))
2353 (goto-char (point-min))
2354 (while (re-search-forward "[ \t]+" nil t)
2355 (replace-match " " t t))
2356 (goto-char (point-min))
2357 (while (re-search-forward "[ \t]+$" nil t)
2358 (replace-match "" t t))
2359 (goto-char (point-min))
2360 (while (re-search-forward "^[ \t]+" nil t)
2361 (replace-match "" t t))
2362 (if gnus-simplify-subject-fuzzy-regexp
2363 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
2364 (replace-match "" t t))))
2366 ;; Add the current buffer to the list of buffers to be killed on exit.
2367 (defun gnus-add-current-to-buffer-list ()
2368 (or (memq (current-buffer) gnus-buffer-list)
2369 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list))))
2371 (defun gnus-string> (s1 s2)
2372 (not (or (string< s1 s2)
2373 (string= s1 s2))))
2375 ;; Functions accessing headers.
2376 ;; Functions are more convenient than macros in some cases.
2378 (defun gnus-header-number (header)
2379 (mail-header-number header))
2381 (defun gnus-header-subject (header)
2382 (mail-header-subject header))
2384 (defun gnus-header-from (header)
2385 (mail-header-from header))
2387 (defun gnus-header-xref (header)
2388 (mail-header-xref header))
2390 (defun gnus-header-lines (header)
2391 (mail-header-lines header))
2393 (defun gnus-header-date (header)
2394 (mail-header-date header))
2396 (defun gnus-header-id (header)
2397 (mail-header-id header))
2399 (defun gnus-header-message-id (header)
2400 (mail-header-id header))
2402 (defun gnus-header-chars (header)
2403 (mail-header-chars header))
2405 (defun gnus-header-references (header)
2406 (mail-header-references header))
2408 ;;; General various misc type functions.
2410 (defun gnus-clear-system ()
2411 "Clear all variables and buffers."
2412 ;; Clear Gnus variables.
2413 (let ((variables gnus-variable-list))
2414 (while variables
2415 (set (car variables) nil)
2416 (setq variables (cdr variables))))
2417 ;; Clear other internal variables.
2418 (setq gnus-list-of-killed-groups nil
2419 gnus-have-read-active-file nil
2420 gnus-newsrc-alist nil
2421 gnus-newsrc-hashtb nil
2422 gnus-killed-list nil
2423 gnus-zombie-list nil
2424 gnus-killed-hashtb nil
2425 gnus-active-hashtb nil
2426 gnus-moderated-list nil
2427 gnus-description-hashtb nil
2428 gnus-newsgroup-headers nil
2429 gnus-newsgroup-headers-hashtb-by-number nil
2430 gnus-newsgroup-name nil
2431 gnus-server-alist nil
2432 gnus-current-select-method nil)
2433 ;; Reset any score variables.
2434 (and (boundp 'gnus-score-cache)
2435 (set 'gnus-score-cache nil))
2436 (and (boundp 'gnus-internal-global-score-files)
2437 (set 'gnus-internal-global-score-files nil))
2438 ;; Kill the startup file.
2439 (and gnus-current-startup-file
2440 (get-file-buffer gnus-current-startup-file)
2441 (kill-buffer (get-file-buffer gnus-current-startup-file)))
2442 ;; Save any cache buffers.
2443 (and gnus-use-cache (gnus-cache-save-buffers))
2444 ;; Clear the dribble buffer.
2445 (gnus-dribble-clear)
2446 ;; Kill global KILL file buffer.
2447 (if (get-file-buffer (gnus-newsgroup-kill-file nil))
2448 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
2449 (gnus-kill-buffer nntp-server-buffer)
2450 ;; Kill Gnus buffers.
2451 (while gnus-buffer-list
2452 (gnus-kill-buffer (car gnus-buffer-list))
2453 (setq gnus-buffer-list (cdr gnus-buffer-list))))
2455 (defun gnus-windows-old-to-new (setting)
2456 ;; First we take care of the really, really old Gnus 3 actions.
2457 (if (symbolp setting)
2458 (setq setting
2459 (cond ((memq setting '(SelectArticle))
2460 'article)
2461 ((memq setting '(SelectSubject ExpandSubject))
2462 'summary)
2463 ((memq setting '(SelectNewsgroup ExitNewsgroup))
2464 'group)
2465 (t setting))))
2466 (if (or (listp setting)
2467 (not (and gnus-window-configuration
2468 (memq setting '(group summary article)))))
2469 setting
2470 (let* ((setting (if (eq setting 'group)
2471 (if (assq 'newsgroup gnus-window-configuration)
2472 'newsgroup
2473 'newsgroups) setting))
2474 (elem (car (cdr (assq setting gnus-window-configuration))))
2475 (total (apply '+ elem))
2476 (types '(group summary article))
2477 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
2478 (i 0)
2479 perc
2480 out)
2481 (while (< i 3)
2482 (or (not (numberp (nth i elem)))
2483 (zerop (nth i elem))
2484 (progn
2485 (setq perc (/ (* 1.0 (nth 0 elem)) total))
2486 (setq out (cons (if (eq pbuf (nth i types))
2487 (vector (nth i types) perc 'point)
2488 (vector (nth i types) perc))
2489 out))))
2490 (setq i (1+ i)))
2491 (list (nreverse out)))))
2493 (defun gnus-add-configuration (conf)
2494 (setq gnus-buffer-configuration
2495 (cons conf (delq (assq (car conf) gnus-buffer-configuration)
2496 gnus-buffer-configuration))))
2498 (defun gnus-configure-windows (setting &optional force)
2499 (setq setting (gnus-windows-old-to-new setting))
2500 (let ((r (if (symbolp setting)
2501 (cdr (assq setting gnus-buffer-configuration))
2502 setting))
2503 (in-buf (current-buffer))
2504 rule val w height hor ohor heights sub jump-buffer
2505 rel total to-buf all-visible)
2506 (or r (error "No such setting: %s" setting))
2508 (if (and (not force) (setq all-visible (gnus-all-windows-visible-p r)))
2509 ;; All the windows mentioned are already visible, so we just
2510 ;; put point in the assigned buffer, and do not touch the
2511 ;; winconf.
2512 (select-window (get-buffer-window all-visible t))
2515 ;; Either remove all windows or just remove all Gnus windows.
2516 (if gnus-use-full-window
2517 (delete-other-windows)
2518 (gnus-remove-some-windows)
2519 (switch-to-buffer nntp-server-buffer))
2521 (while r
2522 (setq hor (car r)
2523 ohor nil)
2525 ;; We have to do the (possible) horizontal splitting before the
2526 ;; vertical.
2527 (if (and (listp (car hor))
2528 (eq (car (car hor)) 'horizontal))
2529 (progn
2530 (split-window
2532 (if (integerp (nth 1 (car hor)))
2533 (nth 1 (car hor))
2534 (- (frame-width) (floor (* (frame-width) (nth 1 (car hor))))))
2536 (setq hor (cdr hor))))
2538 ;; Go through the rules and eval the elements that are to be
2539 ;; evalled.
2540 (while hor
2541 (if (setq val (if (vectorp (car hor)) (car hor) (eval (car hor))))
2542 (progn
2543 ;; Expand short buffer name.
2544 (setq w (aref val 0))
2545 (and (setq w (cdr (assq w gnus-window-to-buffer)))
2546 (progn
2547 (setq val (apply 'vector (mapcar 'identity val)))
2548 (aset val 0 w)))
2549 (setq ohor (cons val ohor))))
2550 (setq hor (cdr hor)))
2551 (setq rule (cons (nreverse ohor) rule))
2552 (setq r (cdr r)))
2553 (setq rule (nreverse rule))
2555 ;; We tally the window sizes.
2556 (setq total (window-height))
2557 (while rule
2558 (setq hor (car rule))
2559 (if (and (listp (car hor)) (eq (car (car hor)) 'horizontal))
2560 (setq hor (cdr hor)))
2561 (setq sub 0)
2562 (while hor
2563 (setq rel (aref (car hor) 1)
2564 heights (cons
2565 (cond ((and (floatp rel) (= 1.0 rel))
2567 ((integerp rel)
2568 rel)
2570 (max (floor (* total rel)) 4)))
2571 heights)
2572 sub (+ sub (if (numberp (car heights)) (car heights) 0))
2573 hor (cdr hor)))
2574 (setq heights (nreverse heights)
2575 hor (car rule))
2577 ;; We then go through these heights and create windows for them.
2578 (while heights
2579 (setq height (car heights)
2580 heights (cdr heights))
2581 (and (eq height 'x)
2582 (setq height (- total sub)))
2583 (and heights
2584 (split-window nil height))
2585 (setq to-buf (aref (car hor) 0))
2586 (switch-to-buffer
2587 (cond ((not to-buf)
2588 in-buf)
2589 ((symbolp to-buf)
2590 (symbol-value (aref (car hor) 0)))
2592 (aref (car hor) 0))))
2593 (and (> (length (car hor)) 2)
2594 (eq (aref (car hor) 2) 'point)
2595 (setq jump-buffer (current-buffer)))
2596 (other-window 1)
2597 (setq hor (cdr hor)))
2599 (setq rule (cdr rule)))
2601 ;; Finally, we pop to the buffer that's supposed to have point.
2602 (or jump-buffer (error "Missing `point' in spec for %s" setting))
2604 (select-window (get-buffer-window jump-buffer t))
2605 (set-buffer jump-buffer))))
2607 (defun gnus-all-windows-visible-p (rule)
2608 (let (invisible hor jump-buffer val buffer)
2609 ;; Go through the rules and eval the elements that are to be
2610 ;; evalled.
2611 (while (and rule (not invisible))
2612 (setq hor (car rule)
2613 rule (cdr rule))
2614 (while (and hor (not invisible))
2615 (if (setq val (if (vectorp (car hor))
2616 (car hor)
2617 (if (not (eq (car (car hor)) 'horizontal))
2618 (eval (car hor)))))
2619 (progn
2620 ;; Expand short buffer name.
2621 (setq buffer (or (cdr (assq (aref val 0) gnus-window-to-buffer))
2622 (aref val 0)))
2623 (setq buffer (if (symbolp buffer) (symbol-value buffer)
2624 buffer))
2625 (and (> (length val) 2) (eq 'point (aref val 2))
2626 (setq jump-buffer buffer))
2627 (setq invisible (not (and buffer (get-buffer-window buffer))))))
2628 (setq hor (cdr hor))))
2629 (and (not invisible) jump-buffer)))
2631 (defun gnus-window-top-edge (&optional window)
2632 (nth 1 (window-edges window)))
2634 (defun gnus-remove-some-windows ()
2635 (let ((buffers gnus-window-to-buffer)
2636 buf bufs lowest-buf lowest)
2637 (save-excursion
2638 ;; Remove windows on all known Gnus buffers.
2639 (while buffers
2640 (setq buf (cdr (car buffers)))
2641 (if (symbolp buf)
2642 (setq buf (and (boundp buf) (symbol-value buf))))
2643 (and buf
2644 (get-buffer-window buf)
2645 (progn
2646 (setq bufs (cons buf bufs))
2647 (pop-to-buffer buf)
2648 (if (or (not lowest)
2649 (< (gnus-window-top-edge) lowest))
2650 (progn
2651 (setq lowest (gnus-window-top-edge))
2652 (setq lowest-buf buf)))))
2653 (setq buffers (cdr buffers)))
2654 ;; Remove windows on *all* summary buffers.
2655 (let (wins)
2656 (walk-windows
2657 (lambda (win)
2658 (let ((buf (window-buffer win)))
2659 (if (string-match "^\\*Summary" (buffer-name buf))
2660 (progn
2661 (setq bufs (cons buf bufs))
2662 (pop-to-buffer buf)
2663 (if (or (not lowest)
2664 (< (gnus-window-top-edge) lowest))
2665 (progn
2666 (setq lowest-buf buf)
2667 (setq lowest (gnus-window-top-edge))))))))))
2668 (and lowest-buf
2669 (progn
2670 (pop-to-buffer lowest-buf)
2671 (switch-to-buffer nntp-server-buffer)))
2672 (while bufs
2673 (and (not (eq (car bufs) lowest-buf))
2674 (delete-windows-on (car bufs)))
2675 (setq bufs (cdr bufs))))))
2677 (defun gnus-version ()
2678 "Version numbers of this version of Gnus."
2679 (interactive)
2680 (let ((methods gnus-valid-select-methods)
2681 (mess gnus-version)
2682 meth)
2683 ;; Go through all the legal select methods and add their version
2684 ;; numbers to the total version string. Only the backends that are
2685 ;; currently in use will have their message numbers taken into
2686 ;; consideration.
2687 (while methods
2688 (setq meth (intern (concat (car (car methods)) "-version")))
2689 (and (boundp meth)
2690 (stringp (symbol-value meth))
2691 (setq mess (concat mess "; " (symbol-value meth))))
2692 (setq methods (cdr methods)))
2693 (gnus-message 2 mess)))
2695 (defun gnus-info-find-node ()
2696 "Find Info documentation of Gnus."
2697 (interactive)
2698 ;; Enlarge info window if needed.
2699 (let ((mode major-mode))
2700 (gnus-configure-windows 'info)
2701 (Info-goto-node (car (cdr (assq mode gnus-info-nodes))))))
2703 (defun gnus-overload-functions (&optional overloads)
2704 "Overload functions specified by optional argument OVERLOADS.
2705 If nothing is specified, use the variable gnus-overload-functions."
2706 (let ((defs nil)
2707 (overloads (or overloads gnus-overload-functions)))
2708 (while overloads
2709 (setq defs (car overloads))
2710 (setq overloads (cdr overloads))
2711 ;; Load file before overloading function if necessary. Make
2712 ;; sure we cannot use `require' always.
2713 (and (not (fboundp (car defs)))
2714 (car (cdr (cdr defs)))
2715 (load (car (cdr (cdr defs))) nil 'nomessage))
2716 (fset (car defs) (car (cdr defs))))))
2718 (defun gnus-replace-chars-in-string (string &rest pairs)
2719 "Replace characters in STRING from FROM to TO."
2720 (let ((string (substring string 0)) ;Copy string.
2721 (len (length string))
2722 (idx 0)
2723 sym to)
2724 (or (zerop (% (length pairs) 2))
2725 (error "Odd number of translation pairs"))
2726 (setplist 'sym pairs)
2727 ;; Replace all occurrences of FROM with TO.
2728 (while (< idx len)
2729 (if (setq to (get 'sym (aref string idx)))
2730 (aset string idx to))
2731 (setq idx (1+ idx)))
2732 string))
2734 (defun gnus-days-between (date1 date2)
2735 ;; Return the number of days between date1 and date2.
2736 (- (gnus-day-number date1) (gnus-day-number date2)))
2738 (defun gnus-day-number (date)
2739 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
2740 (timezone-parse-date date))))
2741 (timezone-absolute-from-gregorian
2742 (nth 1 dat) (nth 2 dat) (car dat))))
2744 ;; Returns a floating point number that says how many seconds have
2745 ;; lapsed between Jan 1 12:00:00 1970 and DATE.
2746 (defun gnus-seconds-since-epoch (date)
2747 (let* ((tdate (mapcar (lambda (ti) (and ti (string-to-int ti)))
2748 (timezone-parse-date date)))
2749 (ttime (mapcar (lambda (ti) (and ti (string-to-int ti)))
2750 (timezone-parse-time
2751 (aref (timezone-parse-date date) 3))))
2752 (edate (mapcar (lambda (ti) (and ti (string-to-int ti)))
2753 (timezone-parse-date "Jan 1 12:00:00 1970")))
2754 (tday (- (timezone-absolute-from-gregorian
2755 (nth 1 tdate) (nth 2 tdate) (nth 0 tdate))
2756 (timezone-absolute-from-gregorian
2757 (nth 1 edate) (nth 2 edate) (nth 0 edate)))))
2758 (+ (nth 2 ttime)
2759 (* (nth 1 ttime) 60)
2760 (* 1.0 (nth 0 ttime) 60 60)
2761 (* 1.0 tday 60 60 24))))
2763 (defun gnus-file-newer-than (file date)
2764 (let ((fdate (nth 5 (file-attributes file))))
2765 (or (> (car fdate) (car date))
2766 (and (= (car fdate) (car date))
2767 (> (nth 1 fdate) (nth 1 date))))))
2769 (defun gnus-group-read-only-p (&optional group)
2770 "Check whether GROUP supports editing or not.
2771 If GROUP is nil, `gnus-newsgroup-name' will be checked instead. Note
2772 that that variable is buffer-local to the summary buffers."
2773 (let ((group (or group gnus-newsgroup-name)))
2774 (not (gnus-check-backend-function 'request-replace-article group))))
2776 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
2777 ;; the echo area.
2778 (defun gnus-y-or-n-p (prompt)
2779 (prog1
2780 (y-or-n-p prompt)
2781 (message "")))
2783 (defun gnus-yes-or-no-p (prompt)
2784 (prog1
2785 (yes-or-no-p prompt)
2786 (message "")))
2788 ;; Check whether to use long file names.
2789 (defun gnus-use-long-file-name (symbol)
2790 ;; The variable has to be set...
2791 (and gnus-use-long-file-name
2792 ;; If it isn't a list, then we return t.
2793 (or (not (listp gnus-use-long-file-name))
2794 ;; If it is a list, and the list contains `symbol', we
2795 ;; return nil.
2796 (not (memq symbol gnus-use-long-file-name)))))
2798 ;; I suspect there's a better way, but I haven't taken the time to do
2799 ;; it yet. -erik selberg@cs.washington.edu
2800 (defun gnus-dd-mmm (messy-date)
2801 "Return a string like DD-MMM from a big messy string"
2802 (let ((datevec (timezone-parse-date messy-date)))
2803 (format "%2s-%s"
2804 (or (aref datevec 2) "??")
2805 (capitalize
2806 (or (car
2807 (nth (1- (string-to-number (aref datevec 1)))
2808 timezone-months-assoc))
2809 "???")))))
2811 ;; Make a hash table (default and minimum size is 255).
2812 ;; Optional argument HASHSIZE specifies the table size.
2813 (defun gnus-make-hashtable (&optional hashsize)
2814 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
2816 ;; Make a number that is suitable for hashing; bigger than MIN and one
2817 ;; less than 2^x.
2818 (defun gnus-create-hash-size (min)
2819 (let ((i 1))
2820 (while (< i min)
2821 (setq i (* 2 i)))
2822 (1- i)))
2824 ;; Show message if message has a lower level than `gnus-verbose'.
2825 ;; Guide-line for numbers:
2826 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
2827 ;; for things that take a long time, 7 - not very important messages
2828 ;; on stuff, 9 - messages inside loops.
2829 (defun gnus-message (level &rest args)
2830 (if (<= level gnus-verbose)
2831 (apply 'message args)
2832 ;; We have to do this format thingy here even if the result isn't
2833 ;; shown - the return value has to be the same as the return value
2834 ;; from `message'.
2835 (apply 'format args)))
2837 ;; Generate a unique new group name.
2838 (defun gnus-generate-new-group-name (leaf)
2839 (let ((name leaf)
2840 (num 0))
2841 (while (gnus-gethash name gnus-newsrc-hashtb)
2842 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
2843 name))
2845 (defun gnus-ephemeral-group-p (group)
2846 "Say whether GROUP is ephemeral or not."
2847 (assoc 'quit-config (gnus-find-method-for-group group)))
2849 (defun gnus-group-quit-config (group)
2850 "Return the quit-config of GROUP."
2851 (nth 1 (assoc 'quit-config (gnus-find-method-for-group group))))
2853 (defun gnus-simplify-mode-line ()
2854 "Make mode lines a bit simpler."
2855 (setq mode-line-modified "-- ")
2856 (if (listp mode-line-format)
2857 (progn
2858 (make-local-variable 'mode-line-format)
2859 (setq mode-line-format (copy-sequence mode-line-format))
2860 (and (equal (nth 3 mode-line-format) " ")
2861 (setcar (nthcdr 3 mode-line-format) "")))))
2863 ;;; List and range functions
2865 (defun gnus-last-element (list)
2866 "Return last element of LIST."
2867 (while (cdr list)
2868 (setq list (cdr list)))
2869 (car list))
2871 (defun gnus-copy-sequence (list)
2872 "Do a complete, total copy of a list."
2873 (if (and (consp list) (not (consp (cdr list))))
2874 (cons (car list) (cdr list))
2875 (mapcar (lambda (elem) (if (consp elem)
2876 (if (consp (cdr elem))
2877 (gnus-copy-sequence elem)
2878 (cons (car elem) (cdr elem)))
2879 elem))
2880 list)))
2882 (defun gnus-set-difference (list1 list2)
2883 "Return a list of elements of LIST1 that do not appear in LIST2."
2884 (let ((list1 (copy-sequence list1)))
2885 (while list2
2886 (setq list1 (delq (car list2) list1))
2887 (setq list2 (cdr list2)))
2888 list1))
2890 (defun gnus-sorted-complement (list1 list2)
2891 "Return a list of elements of LIST1 that do not appear in LIST2.
2892 Both lists have to be sorted over <."
2893 (let (out)
2894 (if (or (null list1) (null list2))
2895 (or list1 list2)
2896 (while (and list1 list2)
2897 (cond ((= (car list1) (car list2))
2898 (setq list1 (cdr list1)
2899 list2 (cdr list2)))
2900 ((< (car list1) (car list2))
2901 (setq out (cons (car list1) out))
2902 (setq list1 (cdr list1)))
2904 (setq out (cons (car list2) out))
2905 (setq list2 (cdr list2)))))
2906 (nconc (nreverse out) (or list1 list2)))))
2908 (defun gnus-intersection (list1 list2)
2909 (let ((result nil))
2910 (while list2
2911 (if (memq (car list2) list1)
2912 (setq result (cons (car list2) result)))
2913 (setq list2 (cdr list2)))
2914 result))
2916 (defun gnus-sorted-intersection (list1 list2)
2917 ;; LIST1 and LIST2 have to be sorted over <.
2918 (let (out)
2919 (while (and list1 list2)
2920 (cond ((= (car list1) (car list2))
2921 (setq out (cons (car list1) out)
2922 list1 (cdr list1)
2923 list2 (cdr list2)))
2924 ((< (car list1) (car list2))
2925 (setq list1 (cdr list1)))
2927 (setq list2 (cdr list2)))))
2928 (nreverse out)))
2930 (defun gnus-set-sorted-intersection (list1 list2)
2931 ;; LIST1 and LIST2 have to be sorted over <.
2932 ;; This function modifies LIST1.
2933 (let* ((top (cons nil list1))
2934 (prev top))
2935 (while (and list1 list2)
2936 (cond ((= (car list1) (car list2))
2937 (setq prev list1
2938 list1 (cdr list1)
2939 list2 (cdr list2)))
2940 ((< (car list1) (car list2))
2941 (setcdr prev (cdr list1))
2942 (setq list1 (cdr list1)))
2944 (setq list2 (cdr list2)))))
2945 (setcdr prev nil)
2946 (cdr top)))
2948 (defun gnus-compress-sequence (numbers &optional always-list)
2949 "Convert list of numbers to a list of ranges or a single range.
2950 If ALWAYS-LIST is non-nil, this function will always release a list of
2951 ranges."
2952 (let* ((first (car numbers))
2953 (last (car numbers))
2954 result)
2955 (if (null numbers)
2957 (if (not (listp (cdr numbers)))
2958 numbers
2959 (while numbers
2960 (cond ((= last (car numbers)) nil) ;Omit duplicated number
2961 ((= (1+ last) (car numbers)) ;Still in sequence
2962 (setq last (car numbers)))
2963 (t ;End of one sequence
2964 (setq result
2965 (cons (if (= first last) first
2966 (cons first last)) result))
2967 (setq first (car numbers))
2968 (setq last (car numbers))))
2969 (setq numbers (cdr numbers)))
2970 (if (and (not always-list) (null result))
2971 (if (= first last) (list first) (cons first last))
2972 (nreverse (cons (if (= first last) first (cons first last))
2973 result)))))))
2975 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
2976 (defun gnus-uncompress-range (ranges)
2977 "Expand a list of ranges into a list of numbers.
2978 RANGES is either a single range on the form `(num . num)' or a list of
2979 these ranges."
2980 (let (first last result)
2981 (cond
2982 ((null ranges)
2983 nil)
2984 ((not (listp (cdr ranges)))
2985 (setq first (car ranges))
2986 (setq last (cdr ranges))
2987 (while (<= first last)
2988 (setq result (cons first result))
2989 (setq first (1+ first)))
2990 (nreverse result))
2992 (while ranges
2993 (if (atom (car ranges))
2994 (if (numberp (car ranges))
2995 (setq result (cons (car ranges) result)))
2996 (setq first (car (car ranges)))
2997 (setq last (cdr (car ranges)))
2998 (while (<= first last)
2999 (setq result (cons first result))
3000 (setq first (1+ first))))
3001 (setq ranges (cdr ranges)))
3002 (nreverse result)))))
3004 (defun gnus-add-to-range (ranges list)
3005 "Return a list of ranges that has all articles from both RANGES and LIST.
3006 Note: LIST has to be sorted over `<'."
3007 (if (not ranges)
3008 (gnus-compress-sequence list t)
3009 (setq list (copy-sequence list))
3010 (or (listp (cdr ranges))
3011 (setq ranges (list ranges)))
3012 (let ((out ranges)
3013 ilist lowest highest temp)
3014 (while (and ranges list)
3015 (setq ilist list)
3016 (setq lowest (or (and (atom (car ranges)) (car ranges))
3017 (car (car ranges))))
3018 (while (and list (cdr list) (< (car (cdr list)) lowest))
3019 (setq list (cdr list)))
3020 (if (< (car ilist) lowest)
3021 (progn
3022 (setq temp list)
3023 (setq list (cdr list))
3024 (setcdr temp nil)
3025 (setq out (nconc (gnus-compress-sequence ilist t) out))))
3026 (setq highest (or (and (atom (car ranges)) (car ranges))
3027 (cdr (car ranges))))
3028 (while (and list (<= (car list) highest))
3029 (setq list (cdr list)))
3030 (setq ranges (cdr ranges)))
3031 (if list
3032 (setq out (nconc (gnus-compress-sequence list t) out)))
3033 (setq out (sort out (lambda (r1 r2)
3034 (< (or (and (atom r1) r1) (car r1))
3035 (or (and (atom r2) r2) (car r2))))))
3036 (setq ranges out)
3037 (while ranges
3038 (if (atom (car ranges))
3039 (if (cdr ranges)
3040 (if (atom (car (cdr ranges)))
3041 (if (= (1+ (car ranges)) (car (cdr ranges)))
3042 (progn
3043 (setcar ranges (cons (car ranges)
3044 (car (cdr ranges))))
3045 (setcdr ranges (cdr (cdr ranges)))))
3046 (if (= (1+ (car ranges)) (car (car (cdr ranges))))
3047 (progn
3048 (setcar (car (cdr ranges)) (car ranges))
3049 (setcar ranges (car (cdr ranges)))
3050 (setcdr ranges (cdr (cdr ranges)))))))
3051 (if (cdr ranges)
3052 (if (atom (car (cdr ranges)))
3053 (if (= (1+ (cdr (car ranges))) (car (cdr ranges)))
3054 (progn
3055 (setcdr (car ranges) (car (cdr ranges)))
3056 (setcdr ranges (cdr (cdr ranges)))))
3057 (if (= (1+ (cdr (car ranges))) (car (car (cdr ranges))))
3058 (progn
3059 (setcdr (car ranges) (cdr (car (cdr ranges))))
3060 (setcdr ranges (cdr (cdr ranges))))))))
3061 (setq ranges (cdr ranges)))
3062 out)))
3064 (defun gnus-remove-from-range (ranges list)
3065 "Return a list of ranges that has all articles from LIST removed from RANGES.
3066 Note: LIST has to be sorted over `<'."
3067 ;; !!! This function shouldn't look like this, but I've got a headache.
3068 (gnus-compress-sequence
3069 (gnus-sorted-complement
3070 (gnus-uncompress-range ranges) list)))
3072 (defun gnus-member-of-range (number ranges)
3073 (if (not (listp (cdr ranges)))
3074 (and (>= number (car ranges))
3075 (<= number (cdr ranges)))
3076 (let ((not-stop t))
3077 (while (and ranges
3078 (if (numberp (car ranges))
3079 (>= number (car ranges))
3080 (>= number (car (car ranges))))
3081 not-stop)
3082 (if (if (numberp (car ranges))
3083 (= number (car ranges))
3084 (and (>= number (car (car ranges)))
3085 (<= number (cdr (car ranges)))))
3086 (setq not-stop nil))
3087 (setq ranges (cdr ranges)))
3088 (not not-stop))))
3092 ;;; Gnus group mode
3095 (defvar gnus-group-mode-map nil)
3096 (defvar gnus-group-group-map nil)
3097 (defvar gnus-group-mark-map nil)
3098 (defvar gnus-group-list-map nil)
3099 (defvar gnus-group-help-map nil)
3100 (defvar gnus-group-sub-map nil)
3101 (put 'gnus-group-mode 'mode-class 'special)
3103 (if gnus-group-mode-map
3105 (setq gnus-group-mode-map (make-keymap))
3106 (suppress-keymap gnus-group-mode-map)
3107 (define-key gnus-group-mode-map " " 'gnus-group-read-group)
3108 (define-key gnus-group-mode-map "=" 'gnus-group-select-group)
3109 (define-key gnus-group-mode-map "\r" 'gnus-group-select-group)
3110 (define-key gnus-group-mode-map "j" 'gnus-group-jump-to-group)
3111 (define-key gnus-group-mode-map "n" 'gnus-group-next-unread-group)
3112 (define-key gnus-group-mode-map "p" 'gnus-group-prev-unread-group)
3113 (define-key gnus-group-mode-map "\177" 'gnus-group-prev-unread-group)
3114 (define-key gnus-group-mode-map "N" 'gnus-group-next-group)
3115 (define-key gnus-group-mode-map "P" 'gnus-group-prev-group)
3116 (define-key gnus-group-mode-map
3117 "\M-n" 'gnus-group-next-unread-group-same-level)
3118 (define-key gnus-group-mode-map
3119 "\M-p" 'gnus-group-prev-unread-group-same-level)
3120 (define-key gnus-group-mode-map "," 'gnus-group-best-unread-group)
3121 (define-key gnus-group-mode-map "." 'gnus-group-first-unread-group)
3122 (define-key gnus-group-mode-map "u" 'gnus-group-unsubscribe-current-group)
3123 (define-key gnus-group-mode-map "U" 'gnus-group-unsubscribe-group)
3124 (define-key gnus-group-mode-map "c" 'gnus-group-catchup-current)
3125 (define-key gnus-group-mode-map "C" 'gnus-group-catchup-current-all)
3126 (define-key gnus-group-mode-map "l" 'gnus-group-list-groups)
3127 (define-key gnus-group-mode-map "L" 'gnus-group-list-all-groups)
3128 (define-key gnus-group-mode-map "m" 'gnus-group-mail)
3129 (define-key gnus-group-mode-map "g" 'gnus-group-get-new-news)
3130 (define-key gnus-group-mode-map "\M-g" 'gnus-group-get-new-news-this-group)
3131 (define-key gnus-group-mode-map "R" 'gnus-group-restart)
3132 (define-key gnus-group-mode-map "r" 'gnus-group-read-init-file)
3133 (define-key gnus-group-mode-map "B" 'gnus-group-browse-foreign-server)
3134 (define-key gnus-group-mode-map "b" 'gnus-group-check-bogus-groups)
3135 (define-key gnus-group-mode-map "F" 'gnus-find-new-newsgroups)
3136 (define-key gnus-group-mode-map "\C-c\C-d" 'gnus-group-describe-group)
3137 (define-key gnus-group-mode-map "\M-d" 'gnus-group-describe-all-groups)
3138 (define-key gnus-group-mode-map "\C-c\C-a" 'gnus-group-apropos)
3139 (define-key gnus-group-mode-map "\C-c\M-\C-a" 'gnus-group-description-apropos)
3140 (define-key gnus-group-mode-map "a" 'gnus-group-post-news)
3141 (define-key gnus-group-mode-map "\ek" 'gnus-group-edit-local-kill)
3142 (define-key gnus-group-mode-map "\eK" 'gnus-group-edit-global-kill)
3143 (define-key gnus-group-mode-map "\C-k" 'gnus-group-kill-group)
3144 (define-key gnus-group-mode-map "\C-y" 'gnus-group-yank-group)
3145 (define-key gnus-group-mode-map "\C-w" 'gnus-group-kill-region)
3146 (define-key gnus-group-mode-map "\C-x\C-t" 'gnus-group-transpose-groups)
3147 (define-key gnus-group-mode-map "\C-c\C-l" 'gnus-group-list-killed)
3148 (define-key gnus-group-mode-map "\C-c\C-x" 'gnus-group-expire-articles)
3149 (define-key gnus-group-mode-map "\C-c\M-\C-x" 'gnus-group-expire-all-groups)
3150 (define-key gnus-group-mode-map "V" 'gnus-version)
3151 (define-key gnus-group-mode-map "s" 'gnus-group-save-newsrc)
3152 (define-key gnus-group-mode-map "z" 'gnus-group-suspend)
3153 (define-key gnus-group-mode-map "Z" 'gnus-group-clear-dribble)
3154 (define-key gnus-group-mode-map "q" 'gnus-group-exit)
3155 (define-key gnus-group-mode-map "Q" 'gnus-group-quit)
3156 (define-key gnus-group-mode-map "?" 'gnus-group-describe-briefly)
3157 (define-key gnus-group-mode-map "\C-c\C-i" 'gnus-info-find-node)
3158 (define-key gnus-group-mode-map "\M-e" 'gnus-group-edit-group-method)
3159 (define-key gnus-group-mode-map "^" 'gnus-group-enter-server-mode)
3160 (define-key gnus-group-mode-map gnus-mouse-2 'gnus-mouse-pick-group)
3161 (define-key gnus-group-mode-map "<" 'beginning-of-buffer)
3162 (define-key gnus-group-mode-map ">" 'end-of-buffer)
3163 (define-key gnus-group-mode-map "\C-c\C-b" 'gnus-bug)
3164 (define-key gnus-group-mode-map "\C-c\C-s" 'gnus-group-sort-groups)
3166 (define-key gnus-group-mode-map "#" 'gnus-group-mark-group)
3167 (define-key gnus-group-mode-map "\M-#" 'gnus-group-unmark-group)
3168 (define-prefix-command 'gnus-group-mark-map)
3169 (define-key gnus-group-mode-map "M" 'gnus-group-mark-map)
3170 (define-key gnus-group-mark-map "m" 'gnus-group-mark-group)
3171 (define-key gnus-group-mark-map "u" 'gnus-group-unmark-group)
3172 (define-key gnus-group-mark-map "w" 'gnus-group-mark-region)
3174 (define-prefix-command 'gnus-group-group-map)
3175 (define-key gnus-group-mode-map "G" 'gnus-group-group-map)
3176 (define-key gnus-group-group-map "d" 'gnus-group-make-directory-group)
3177 (define-key gnus-group-group-map "h" 'gnus-group-make-help-group)
3178 (define-key gnus-group-group-map "a" 'gnus-group-make-archive-group)
3179 (define-key gnus-group-group-map "k" 'gnus-group-make-kiboze-group)
3180 (define-key gnus-group-group-map "m" 'gnus-group-make-group)
3181 (define-key gnus-group-group-map "E" 'gnus-group-edit-group)
3182 (define-key gnus-group-group-map "e" 'gnus-group-edit-group-method)
3183 (define-key gnus-group-group-map "p" 'gnus-group-edit-group-parameters)
3184 (define-key gnus-group-group-map "v" 'gnus-group-add-to-virtual)
3185 (define-key gnus-group-group-map "V" 'gnus-group-make-empty-virtual)
3186 (define-key gnus-group-group-map "D" 'gnus-group-enter-directory)
3187 (define-key gnus-group-group-map "f" 'gnus-group-make-doc-group)
3188 ;;(define-key gnus-group-group-map "sb" 'gnus-group-brew-soup)
3189 ;;(define-key gnus-group-group-map "sw" 'gnus-soup-save-areas)
3190 ;;(define-key gnus-group-group-map "ss" 'gnus-soup-send-replies)
3191 ;;(define-key gnus-group-group-map "sp" 'gnus-soup-pack-packet)
3192 ;;(define-key gnus-group-group-map "sr" 'nnsoup-pack-replies)
3194 (define-prefix-command 'gnus-group-list-map)
3195 (define-key gnus-group-mode-map "A" 'gnus-group-list-map)
3196 (define-key gnus-group-list-map "k" 'gnus-group-list-killed)
3197 (define-key gnus-group-list-map "z" 'gnus-group-list-zombies)
3198 (define-key gnus-group-list-map "s" 'gnus-group-list-groups)
3199 (define-key gnus-group-list-map "u" 'gnus-group-list-all-groups)
3200 (define-key gnus-group-list-map "a" 'gnus-group-apropos)
3201 (define-key gnus-group-list-map "d" 'gnus-group-description-apropos)
3202 (define-key gnus-group-list-map "m" 'gnus-group-list-matching)
3203 (define-key gnus-group-list-map "M" 'gnus-group-list-all-matching)
3205 (define-prefix-command 'gnus-group-help-map)
3206 (define-key gnus-group-mode-map "H" 'gnus-group-help-map)
3207 (define-key gnus-group-help-map "f" 'gnus-group-fetch-faq)
3209 (define-prefix-command 'gnus-group-sub-map)
3210 (define-key gnus-group-mode-map "S" 'gnus-group-sub-map)
3211 (define-key gnus-group-sub-map "l" 'gnus-group-set-current-level)
3212 (define-key gnus-group-sub-map "t" 'gnus-group-unsubscribe-current-group)
3213 (define-key gnus-group-sub-map "s" 'gnus-group-unsubscribe-group)
3214 (define-key gnus-group-sub-map "k" 'gnus-group-kill-group)
3215 (define-key gnus-group-sub-map "y" 'gnus-group-yank-group)
3216 (define-key gnus-group-sub-map "w" 'gnus-group-kill-region)
3217 (define-key gnus-group-sub-map "z" 'gnus-group-kill-all-zombies))
3219 (defun gnus-group-mode ()
3220 "Major mode for reading news.
3222 All normal editing commands are switched off.
3223 \\<gnus-group-mode-map>
3224 The group buffer lists (some of) the groups available. For instance,
3225 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
3226 lists all zombie groups.
3228 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
3229 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
3231 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
3233 The following commands are available:
3235 \\{gnus-group-mode-map}"
3236 (interactive)
3237 (if gnus-visual (gnus-group-make-menu-bar))
3238 (kill-all-local-variables)
3239 (gnus-simplify-mode-line)
3240 (setq major-mode 'gnus-group-mode)
3241 (setq mode-name "Group")
3242 (gnus-group-set-mode-line)
3243 (setq mode-line-process nil)
3244 (use-local-map gnus-group-mode-map)
3245 (buffer-disable-undo (current-buffer))
3246 (setq truncate-lines t)
3247 (setq buffer-read-only t)
3248 (run-hooks 'gnus-group-mode-hook))
3250 (defun gnus-mouse-pick-group (e)
3251 (interactive "e")
3252 (mouse-set-point e)
3253 (gnus-group-read-group nil))
3255 ;; Look at LEVEL and find out what the level is really supposed to be.
3256 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
3257 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
3258 (defun gnus-group-default-level (&optional level number-or-nil)
3259 (cond
3260 (gnus-group-use-permanent-levels
3261 (setq gnus-group-default-list-level
3262 (or level gnus-group-default-list-level))
3263 (or gnus-group-default-list-level gnus-level-subscribed))
3264 (number-or-nil
3265 level)
3267 (or level gnus-group-default-list-level gnus-level-subscribed))))
3270 (defvar gnus-tmp-prev-perm nil)
3272 ;;;###autoload
3273 (defun gnus-no-server (&optional arg)
3274 "Read network news.
3275 If ARG is a positive number, Gnus will use that as the
3276 startup level. If ARG is nil, Gnus will be started at level 2.
3277 If ARG is non-nil and not a positive number, Gnus will
3278 prompt the user for the name of an NNTP server to use.
3279 As opposed to `gnus', this command will not connect to the local server."
3280 (interactive "P")
3281 (let ((perm
3282 (cons gnus-group-use-permanent-levels gnus-group-default-list-level)))
3283 (setq gnus-tmp-prev-perm nil)
3284 (setq gnus-group-use-permanent-levels t)
3285 (gnus (or arg (1- gnus-level-default-subscribed)) t)
3286 (setq gnus-tmp-prev-perm perm)))
3288 ;;;###autoload
3289 (defun read-news (&optional arg dont-connect)
3290 "Read network news. This is an alias for the `gnus' command."
3291 (gnus arg dont-connect))
3293 ;;;###autoload
3294 (defun gnus (&optional arg dont-connect)
3295 "Read network news.
3296 If ARG is non-nil and a positive number, Gnus will use that as the
3297 startup level. If ARG is non-nil and not a positive number, Gnus will
3298 prompt the user for the name of an NNTP server to use."
3299 (interactive "P")
3300 (if (get-buffer gnus-group-buffer)
3301 (progn
3302 (switch-to-buffer gnus-group-buffer)
3303 (gnus-group-get-new-news))
3305 (gnus-clear-system)
3307 (nnheader-init-server-buffer)
3308 ;; We do this if `gnus-no-server' has been run.
3309 (if gnus-tmp-prev-perm
3310 (setq gnus-group-use-permanent-levels (car gnus-tmp-prev-perm)
3311 gnus-group-default-list-level (cdr gnus-tmp-prev-perm)
3312 gnus-tmp-prev-perm nil))
3313 (gnus-read-init-file)
3315 (gnus-group-setup-buffer)
3316 (let ((buffer-read-only nil))
3317 (erase-buffer)
3318 (if (not gnus-inhibit-startup-message)
3319 (progn
3320 (gnus-group-startup-message)
3321 (sit-for 0))))
3323 (let ((level (and arg (numberp arg) (> arg 0) arg))
3324 did-connect)
3325 (unwind-protect
3326 (progn
3327 (or dont-connect
3328 (setq did-connect
3329 (gnus-start-news-server (and arg (not level))))))
3330 (if (and (not dont-connect)
3331 (not did-connect))
3332 (gnus-group-quit)
3333 (run-hooks 'gnus-startup-hook)
3334 ;; NNTP server is successfully open.
3336 ;; Find the current startup file name.
3337 (setq gnus-current-startup-file
3338 (gnus-make-newsrc-file gnus-startup-file))
3340 ;; Read the dribble file.
3341 (and gnus-use-dribble-file (gnus-dribble-read-file))
3343 (gnus-summary-make-display-table)
3344 (gnus-setup-news nil level)
3345 (gnus-group-list-groups level)
3346 (gnus-configure-windows 'group))))))
3348 (defun gnus-unload ()
3349 "Unload all Gnus features."
3350 (interactive)
3351 (or (boundp 'load-history)
3352 (error "Sorry, `gnus-unload' is not implemented in this Emacs version."))
3353 (let ((history load-history)
3354 feature)
3355 (while history
3356 (and (string-match "^gnus" (car (car history)))
3357 (setq feature (cdr (assq 'provide (car history))))
3358 (unload-feature feature 'force))
3359 (setq history (cdr history)))))
3361 (defun gnus-group-startup-message (&optional x y)
3362 "Insert startup message in current buffer."
3363 ;; Insert the message.
3364 (erase-buffer)
3365 (insert
3366 (format "
3367 _ ___ _ _
3368 _ ___ __ ___ __ _ ___
3369 __ _ ___ __ ___
3370 _ ___ _
3371 _ _ __ _
3372 ___ __ _
3373 __ _
3374 _ _ _
3375 _ _ _
3376 _ _ _
3377 __ ___
3378 _ _ _ _
3379 _ _
3380 _ _
3381 _ _
3386 Gnus * A newsreader for Emacsen
3387 A Praxis release * larsi@ifi.uio.no
3389 gnus-version))
3390 ;; And then hack it.
3391 ;; 18 is the longest line.
3392 (indent-rigidly (point-min) (point-max)
3393 (/ (max (- (window-width) (or x 46)) 0) 2))
3394 (goto-char (point-min))
3395 (let* ((pheight (count-lines (point-min) (point-max)))
3396 (wheight (window-height))
3397 (rest (- wheight pheight)))
3398 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
3402 ;; Fontify some.
3403 (goto-char (point-min))
3404 (search-forward "Praxis")
3405 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold)
3406 (goto-char (point-min)))
3408 (defun gnus-group-startup-message-old (&optional x y)
3409 "Insert startup message in current buffer."
3410 ;; Insert the message.
3411 (erase-buffer)
3412 (insert
3413 (format "
3415 A newsreader
3416 for GNU Emacs
3418 Based on GNUS
3419 written by
3420 Masanobu UMEDA
3422 A Praxis Release
3423 larsi@ifi.uio.no
3425 gnus-version))
3426 ;; And then hack it.
3427 ;; 18 is the longest line.
3428 (indent-rigidly (point-min) (point-max)
3429 (/ (max (- (window-width) (or x 28)) 0) 2))
3430 (goto-char (point-min))
3431 ;; +4 is fuzzy factor.
3432 (insert-char ?\n (/ (max (- (window-height) (or y 12)) 0) 2))
3434 ;; Fontify some.
3435 (goto-char (point-min))
3436 (search-forward "Praxis")
3437 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold)
3438 (goto-char (point-min)))
3440 (defun gnus-group-setup-buffer ()
3441 (or (get-buffer gnus-group-buffer)
3442 (progn
3443 (switch-to-buffer gnus-group-buffer)
3444 (gnus-add-current-to-buffer-list)
3445 (gnus-group-mode)
3446 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
3448 (defun gnus-group-list-groups (&optional level unread)
3449 "List newsgroups with level LEVEL or lower that have unread articles.
3450 Default is all subscribed groups.
3451 If argument UNREAD is non-nil, groups with no unread articles are also
3452 listed."
3453 (interactive (list (if current-prefix-arg
3454 (prefix-numeric-value current-prefix-arg)
3456 (gnus-group-default-level nil t)
3457 gnus-group-default-list-level
3458 gnus-level-subscribed))))
3459 (or level
3460 (setq level (car gnus-group-list-mode)
3461 unread (cdr gnus-group-list-mode)))
3462 (setq level (gnus-group-default-level level))
3463 (gnus-group-setup-buffer) ;May call from out of group buffer
3464 (let ((case-fold-search nil)
3465 (group (gnus-group-group-name)))
3466 (funcall gnus-group-prepare-function level unread nil)
3467 (if (zerop (buffer-size))
3468 (gnus-message 5 gnus-no-groups-message)
3469 (goto-char (point-min))
3470 (if (not group)
3471 ;; Go to the first group with unread articles.
3472 (gnus-group-search-forward nil nil nil t)
3473 ;; Find the right group to put point on. If the current group
3474 ;; has disappeared in the new listing, try to find the next
3475 ;; one. If no next one can be found, just leave point at the
3476 ;; first newsgroup in the buffer.
3477 (if (not (gnus-goto-char
3478 (text-property-any (point-min) (point-max)
3479 'gnus-group (intern group))))
3480 (let ((newsrc (nthcdr 3 (gnus-gethash group gnus-newsrc-hashtb))))
3481 (while (and newsrc
3482 (not (gnus-goto-char
3483 (text-property-any
3484 (point-min) (point-max) 'gnus-group
3485 (intern (car (car newsrc)))))))
3486 (setq newsrc (cdr newsrc)))
3487 (or newsrc (progn (goto-char (point-max))
3488 (forward-line -1))))))
3489 ;; Adjust cursor point.
3490 (gnus-group-position-cursor))))
3492 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
3493 "List all newsgroups with unread articles of level LEVEL or lower.
3494 If ALL is non-nil, list groups that have no unread articles.
3495 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
3496 If REGEXP, only list groups matching REGEXP."
3497 (set-buffer gnus-group-buffer)
3498 (let ((buffer-read-only nil)
3499 (newsrc (cdr gnus-newsrc-alist))
3500 (lowest (or lowest 1))
3501 info clevel unread group)
3502 (erase-buffer)
3503 (if (< lowest gnus-level-zombie)
3504 ;; List living groups.
3505 (while newsrc
3506 (setq info (car newsrc)
3507 group (car info)
3508 newsrc (cdr newsrc)
3509 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
3510 (and unread ; This group might be bogus
3511 (or (not regexp)
3512 (string-match regexp group))
3513 (<= (setq clevel (car (cdr info))) level)
3514 (>= clevel lowest)
3515 (or all ; We list all groups?
3516 (eq unread t) ; We list unactivated groups
3517 (> unread 0) ; We list groups with unread articles
3518 (cdr (assq 'tick (nth 3 info)))) ; And ticked groups
3519 (gnus-group-insert-group-line
3520 nil group (car (cdr info)) (nth 3 info) unread (nth 4 info)))))
3522 ;; List dead groups.
3523 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
3524 (gnus-group-prepare-flat-list-dead
3525 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
3526 gnus-level-zombie ?Z
3527 regexp))
3528 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
3529 (gnus-group-prepare-flat-list-dead
3530 (setq gnus-killed-list (sort gnus-killed-list 'string<))
3531 gnus-level-killed ?K regexp))
3533 (gnus-group-set-mode-line)
3534 (setq gnus-group-list-mode (cons level all))
3535 (run-hooks 'gnus-group-prepare-hook)))
3537 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
3538 ;; List zombies and killed lists somewhat faster, which was
3539 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
3540 ;; this by ignoring the group format specification altogether.
3541 (let (group beg)
3542 (while groups
3543 (setq group (car groups)
3544 groups (cdr groups))
3545 (if (or (not regexp)
3546 (string-match regexp group))
3547 (progn
3548 (setq beg (point))
3549 (insert (format " %c *: %s\n" mark group))
3550 (add-text-properties
3551 beg (1+ beg)
3552 (list 'gnus-group (intern group)
3553 'gnus-unread t
3554 'gnus-level level)))))))
3556 (defun gnus-group-real-name (group)
3557 "Find the real name of a foreign newsgroup."
3558 (if (string-match ":[^:]+$" group)
3559 (substring group (1+ (match-beginning 0)))
3560 group))
3562 (defun gnus-group-prefixed-name (group method)
3563 "Return the whole name from GROUP and METHOD."
3564 (and (stringp method) (setq method (gnus-server-to-method method)))
3565 (concat (format "%s" (car method))
3566 (if (and
3567 (assoc (format "%s" (car method)) (gnus-methods-using 'address))
3568 (not (string= (nth 1 method) "")))
3569 (concat "+" (nth 1 method)))
3570 ":" group))
3572 (defun gnus-group-real-prefix (group)
3573 "Return the prefix of the current group name."
3574 (if (string-match "^[^:]+:" group)
3575 (substring group 0 (match-end 0))
3576 ""))
3578 (defun gnus-group-method-name (group)
3579 "Return the method used for selecting GROUP."
3580 (let ((prefix (gnus-group-real-prefix group)))
3581 (if (equal prefix "")
3582 gnus-select-method
3583 (if (string-match "^[^\\+]+\\+" prefix)
3584 (list (intern (substring prefix 0 (1- (match-end 0))))
3585 (substring prefix (match-end 0) (1- (length prefix))))
3586 (list (intern (substring prefix 0 (1- (length prefix)))) "")))))
3588 (defun gnus-group-foreign-p (group)
3589 "Return nil if GROUP is native, non-nil if it is foreign."
3590 (string-match ":" group))
3592 (defun gnus-group-set-info (info &optional method-only-group part)
3593 (let* ((entry (gnus-gethash
3594 (or method-only-group (car info)) gnus-newsrc-hashtb))
3595 (part-info info)
3596 (info (if method-only-group (nth 2 entry) info)))
3597 (if (not method-only-group)
3599 (or entry
3600 (error "Trying to change non-existent group %s" method-only-group))
3601 ;; We have received parts of the actual group info - either the
3602 ;; select method or the group parameters. We first check
3603 ;; whether we have to extend the info, and if so, do that.
3604 (let ((len (length info))
3605 (total (if (eq part 'method) 5 6)))
3606 (and (< len total)
3607 (setcdr (nthcdr (1- len) info)
3608 (make-list (- total len) nil)))
3609 ;; Then we enter the new info.
3610 (setcar (nthcdr (1- total) info) part-info)))
3611 ;; We uncompress some lists of marked articles.
3612 (let (marked)
3613 (if (not (setq marked (nth 3 info)))
3615 (while marked
3616 (or (eq 'score (car (car marked)))
3617 (eq 'bookmark (car (car marked)))
3618 (eq 'killed (car (car marked)))
3619 (setcdr (car marked)
3620 (gnus-uncompress-range (cdr (car marked)))))
3621 (setq marked (cdr marked)))))
3622 (if entry
3624 ;; This is a new group, so we just create it.
3625 (save-excursion
3626 (set-buffer gnus-group-buffer)
3627 (if (nth 4 info)
3628 ;; It's a foreign group...
3629 (gnus-group-make-group
3630 (gnus-group-real-name (car info))
3631 (prin1-to-string (car (nth 4 info)))
3632 (nth 1 (nth 4 info)))
3633 ;; It's a native group.
3634 (gnus-group-make-group (car info)))
3635 (gnus-message 6 "Note: New group created")
3636 (setq entry
3637 (gnus-gethash (gnus-group-prefixed-name
3638 (gnus-group-real-name (car info))
3639 (or (nth 4 info) gnus-select-method))
3640 gnus-newsrc-hashtb))))
3641 ;; Whether it was a new group or not, we now have the entry, so we
3642 ;; can do the update.
3643 (if entry
3644 (progn
3645 (setcar (nthcdr 2 entry) info)
3646 (if (and (not (eq (car entry) t))
3647 (gnus-gethash (car info) gnus-active-hashtb))
3648 (let ((marked (nth 3 info)))
3649 (setcar entry
3650 (max 0 (- (length (gnus-list-of-unread-articles
3651 (car info)))
3652 (length (cdr (assq 'tick marked)))
3653 (length (cdr (assq 'dormant marked)))))))))
3654 (error "No such group: %s" (car info)))))
3656 (defun gnus-group-set-method-info (group select-method)
3657 (gnus-group-set-info select-method group 'method))
3659 (defun gnus-group-set-params-info (group params)
3660 (gnus-group-set-info params group 'params))
3662 (defun gnus-group-update-group-line ()
3663 "This function updates the current line in the newsgroup buffer and
3664 moves the point to the colon."
3665 (let* ((buffer-read-only nil)
3666 (group (gnus-group-group-name))
3667 (entry (and group (gnus-gethash group gnus-newsrc-hashtb))))
3668 (if (and entry (not (gnus-ephemeral-group-p group)))
3669 (gnus-dribble-enter
3670 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
3671 ")")))
3672 (beginning-of-line)
3673 (delete-region (point) (progn (forward-line 1) (point)))
3674 (gnus-group-insert-group-line-info group)
3675 (forward-line -1)
3676 (gnus-group-position-cursor)))
3678 (defun gnus-group-insert-group-line-info (group)
3679 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
3680 active info)
3681 (if entry
3682 (progn
3683 (setq info (nth 2 entry))
3684 (gnus-group-insert-group-line
3685 nil group (nth 1 info) (nth 3 info) (car entry) (nth 4 info)))
3686 (setq active (gnus-gethash group gnus-active-hashtb))
3687 (gnus-group-insert-group-line
3688 nil group
3689 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
3690 nil (if active (- (1+ (cdr active)) (car active)) 0) nil))))
3692 (defun gnus-group-insert-group-line (gformat group level marked number method)
3693 (let* ((gformat (or gformat gnus-group-line-format-spec))
3694 (active (gnus-gethash group gnus-active-hashtb))
3695 (number-total (if active (1+ (- (cdr active) (car active))) 0))
3696 (number-of-dormant (length (cdr (assq 'dormant marked))))
3697 (number-of-ticked (length (cdr (assq 'tick marked))))
3698 (number-of-ticked-and-dormant
3699 (+ number-of-ticked number-of-dormant))
3700 (number-of-unread-unticked
3701 (if (numberp number) (int-to-string (max 0 number))
3702 "*"))
3703 (number-of-read
3704 (if (numberp number)
3705 (max 0 (- number-total number))
3706 "*"))
3707 (subscribed (cond ((<= level gnus-level-subscribed) ? )
3708 ((<= level gnus-level-unsubscribed) ?U)
3709 ((= level gnus-level-zombie) ?Z)
3710 (t ?K)))
3711 (qualified-group (gnus-group-real-name group))
3712 (newsgroup-description
3713 (if gnus-description-hashtb
3714 (or (gnus-gethash group gnus-description-hashtb) "")
3715 ""))
3716 (moderated (if (member group gnus-moderated-list) ?m ? ))
3717 (moderated-string (if (eq moderated ?m) "(m)" ""))
3718 (method (gnus-server-get-method group method))
3719 (news-server (or (car (cdr method)) ""))
3720 (news-method (or (car method) ""))
3721 (news-method-string
3722 (if method (format "(%s:%s)" (car method) (car (cdr method))) ""))
3723 (marked (if (and
3724 (numberp number)
3725 (zerop number)
3726 (> number-of-ticked 0))
3727 ?* ? ))
3728 (number (if (eq number t) "*" (+ number number-of-dormant
3729 number-of-ticked)))
3730 (process-marked (if (member group gnus-group-marked)
3731 gnus-process-mark ? ))
3732 (buffer-read-only nil)
3733 header ; passed as parameter to user-funcs.
3735 (beginning-of-line)
3736 (setq b (point))
3737 ;; Insert the text.
3738 (insert (eval gformat))
3740 (add-text-properties
3741 b (1+ b) (list 'gnus-group (intern group)
3742 'gnus-unread (if (numberp number)
3743 (string-to-int number-of-unread-unticked)
3745 'gnus-marked marked
3746 'gnus-level level))))
3748 (defun gnus-group-update-group (group &optional visible-only)
3749 "Update newsgroup info of GROUP.
3750 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't already."
3751 (save-excursion
3752 (set-buffer gnus-group-buffer)
3753 (let ((buffer-read-only nil)
3754 visible)
3755 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
3756 (if (and entry
3757 (not (gnus-ephemeral-group-p group)))
3758 (gnus-dribble-enter
3759 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
3760 ")"))))
3761 ;; Buffer may be narrowed.
3762 (save-restriction
3763 (widen)
3764 ;; Search a line to modify. If the buffer is large, the search
3765 ;; takes long time. In most cases, current point is on the line
3766 ;; we are looking for. So, first of all, check current line.
3767 (if (or (progn
3768 (beginning-of-line)
3769 (eq (get-text-property (point) 'gnus-group)
3770 (intern group)))
3771 (progn
3772 (gnus-goto-char
3773 (text-property-any
3774 (point-min) (point-max) 'gnus-group (intern group)))))
3775 ;; GROUP is listed in current buffer. So, delete old line.
3776 (progn
3777 (setq visible t)
3778 (beginning-of-line)
3779 (delete-region (point) (progn (forward-line 1) (point))))
3780 ;; No such line in the buffer, find out where it's supposed to
3781 ;; go, and insert it there (or at the end of the buffer).
3782 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
3783 (or visible-only
3784 (let ((entry
3785 (cdr (cdr (gnus-gethash group gnus-newsrc-hashtb)))))
3786 (while (and entry
3787 (car entry)
3788 (not
3789 (gnus-goto-char
3790 (text-property-any
3791 (point-min) (point-max)
3792 'gnus-group (intern (car (car entry)))))))
3793 (setq entry (cdr entry)))
3794 (or entry (goto-char (point-max)))))))
3795 (if (or visible (not visible-only))
3796 (gnus-group-insert-group-line-info group))
3797 (gnus-group-set-mode-line))))
3799 (defun gnus-group-set-mode-line ()
3800 (if (memq 'group gnus-updated-mode-lines)
3801 (let* ((gformat (or gnus-group-mode-line-format-spec
3802 (setq gnus-group-mode-line-format-spec
3803 (gnus-parse-format
3804 gnus-group-mode-line-format
3805 gnus-group-mode-line-format-alist))))
3806 (news-server (car (cdr gnus-select-method)))
3807 (news-method (car gnus-select-method))
3808 (max-len 60)
3809 header ;Dummy binding for user-defined specs.
3810 (mode-string (eval gformat)))
3811 (setq mode-string (eval gformat))
3812 (if (> (length mode-string) max-len)
3813 (setq mode-string (substring mode-string 0 (- max-len 4))))
3814 (setq mode-line-buffer-identification mode-string)
3815 (set-buffer-modified-p t))))
3817 (defun gnus-group-group-name ()
3818 "Get the name of the newsgroup on the current line."
3819 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
3820 (and group (symbol-name group))))
3822 (defun gnus-group-group-level ()
3823 "Get the level of the newsgroup on the current line."
3824 (get-text-property (gnus-point-at-bol) 'gnus-level))
3826 (defun gnus-group-group-unread ()
3827 "Get the number of unread articles of the newsgroup on the current line."
3828 (get-text-property (gnus-point-at-bol) 'gnus-unread))
3830 (defun gnus-group-search-forward (&optional backward all level first-too)
3831 "Find the next newsgroup with unread articles.
3832 If BACKWARD is non-nil, find the previous newsgroup instead.
3833 If ALL is non-nil, just find any newsgroup.
3834 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
3835 group exists.
3836 If FIRST-TOO, the current line is also eligible as a target."
3837 (let ((way (if backward -1 1))
3838 (low gnus-level-killed)
3839 (beg (point))
3840 pos found lev)
3841 (if (and backward (progn (beginning-of-line)) (bobp))
3843 (or first-too (forward-line way))
3844 (while (and
3845 (not (eobp))
3846 (not (setq
3847 found
3848 (and (or all
3849 (and
3850 (let ((unread
3851 (get-text-property (point) 'gnus-unread)))
3852 (or (eq unread t) (and unread (> unread 0))))
3853 (setq lev (get-text-property (point)
3854 'gnus-level))
3855 (<= lev gnus-level-subscribed)))
3856 (or (not level)
3857 (and (setq lev (get-text-property (point)
3858 'gnus-level))
3859 (or (= lev level)
3860 (and (< lev low)
3861 (< level lev)
3862 (progn
3863 (setq low lev)
3864 (setq pos (point))
3865 nil))))))))
3866 (zerop (forward-line way)))))
3867 (if found
3868 (progn (gnus-group-position-cursor) t)
3869 (goto-char (or pos beg))
3870 (and pos t))))
3872 ;;; Gnus group mode commands
3874 ;; Group marking.
3876 (defun gnus-group-mark-group (n &optional unmark no-advance)
3877 "Mark the current group."
3878 (interactive "p")
3879 (let ((buffer-read-only nil)
3880 group)
3881 (while
3882 (and (> n 0)
3883 (setq group (gnus-group-group-name))
3884 (progn
3885 (beginning-of-line)
3886 (forward-char
3887 (or (cdr (assq 'process gnus-group-mark-positions)) 2))
3888 (delete-char 1)
3889 (if unmark
3890 (progn
3891 (insert " ")
3892 (setq gnus-group-marked (delete group gnus-group-marked)))
3893 (insert "#")
3894 (setq gnus-group-marked
3895 (cons group (delete group gnus-group-marked))))
3897 (or no-advance (zerop (gnus-group-next-group 1))))
3898 (setq n (1- n)))
3899 (gnus-summary-position-cursor)
3902 (defun gnus-group-unmark-group (n)
3903 "Remove the mark from the current group."
3904 (interactive "p")
3905 (gnus-group-mark-group n 'unmark))
3907 (defun gnus-group-mark-region (unmark beg end)
3908 "Mark all groups between point and mark.
3909 If UNMARK, remove the mark instead."
3910 (interactive "P\nr")
3911 (let ((num (count-lines beg end)))
3912 (save-excursion
3913 (goto-char beg)
3914 (- num (gnus-group-mark-group num unmark)))))
3916 (defun gnus-group-remove-mark (group)
3917 (and (gnus-group-goto-group group)
3918 (save-excursion
3919 (gnus-group-mark-group 1 'unmark t))))
3921 ;; Return a list of groups to work on. Take into consideration N (the
3922 ;; prefix) and the list of marked groups.
3923 (defun gnus-group-process-prefix (n)
3924 (cond (n
3925 (setq n (prefix-numeric-value n))
3926 ;; There is a prefix, so we return a list of the N next
3927 ;; groups.
3928 (let ((way (if (< n 0) -1 1))
3929 (n (abs n))
3930 group groups)
3931 (save-excursion
3932 (while (and (> n 0)
3933 (setq group (gnus-group-group-name)))
3934 (setq groups (cons group groups))
3935 (setq n (1- n))
3936 (forward-line way)))
3937 (nreverse groups)))
3938 (gnus-group-marked
3939 ;; No prefix, but a list of marked articles.
3940 (reverse gnus-group-marked))
3942 ;; Neither marked articles or a prefix, so we return the
3943 ;; current group.
3944 (let ((group (gnus-group-group-name)))
3945 (and group (list group))))))
3947 ;; Selecting groups.
3949 (defun gnus-group-read-group (&optional all no-article group)
3950 "Read news in this newsgroup.
3951 If the prefix argument ALL is non-nil, already read articles become
3952 readable. If the optional argument NO-ARTICLE is non-nil, no article
3953 will be auto-selected upon group entry."
3954 (interactive "P")
3955 (let ((group (or group (gnus-group-group-name)))
3956 number active marked entry)
3957 (or group (error "No group on current line"))
3958 (setq marked
3959 (nth 3 (nth 2 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))))
3960 ;; This group might be a dead group. In that case we have to get
3961 ;; the number of unread articles from `gnus-active-hashtb'.
3962 (if entry
3963 (setq number (car entry))
3964 (if (setq active (gnus-gethash group gnus-active-hashtb))
3965 (setq number (- (1+ (cdr active)) (car active)))))
3966 (gnus-summary-read-group
3967 group (or all (and (numberp number)
3968 (zerop (+ number (length (cdr (assq 'tick marked)))
3969 (length (cdr (assq 'dormant marked)))))))
3970 no-article)))
3972 (defun gnus-group-select-group (&optional all)
3973 "Select this newsgroup.
3974 No article is selected automatically.
3975 If argument ALL is non-nil, already read articles become readable."
3976 (interactive "P")
3977 (gnus-group-read-group all t))
3979 (defun gnus-group-select-group-all ()
3980 "Select the current group and display all articles in it."
3981 (interactive)
3982 (gnus-group-select-group 'all))
3984 ;; Enter a group that is not in the group buffer. Non-nil is returned
3985 ;; if selection was successful.
3986 (defun gnus-group-read-ephemeral-group
3987 (group method &optional activate quit-config)
3988 (let ((group (if (gnus-group-foreign-p group) group
3989 (gnus-group-prefixed-name group method))))
3990 (gnus-sethash
3991 group
3992 (list t nil (list group gnus-level-default-subscribed nil nil
3993 (append method
3994 (list
3995 (list 'quit-config
3996 (if quit-config quit-config
3997 (cons (current-buffer) 'summary)))))))
3998 gnus-newsrc-hashtb)
3999 (set-buffer gnus-group-buffer)
4000 (or (gnus-check-server method)
4001 (error "Unable to contact server: %s" (gnus-status-message method)))
4002 (if activate (or (gnus-request-group group)
4003 (error "Couldn't request group")))
4004 (condition-case ()
4005 (gnus-group-read-group t t group)
4006 (error nil)
4007 (quit nil))
4008 (not (equal major-mode 'gnus-group-mode))))
4010 (defun gnus-group-jump-to-group (group)
4011 "Jump to newsgroup GROUP."
4012 (interactive
4013 (list (completing-read
4014 "Group: " gnus-active-hashtb nil
4015 (memq gnus-select-method gnus-have-read-active-file))))
4017 (if (equal group "")
4018 (error "Empty group name"))
4020 (let ((b (text-property-any
4021 (point-min) (point-max) 'gnus-group (intern group))))
4022 (if b
4023 ;; Either go to the line in the group buffer...
4024 (goto-char b)
4025 ;; ... or insert the line.
4027 (gnus-gethash group gnus-active-hashtb)
4028 (gnus-activate-group group)
4029 (error "%s error: %s" group (gnus-status-message group)))
4031 (gnus-group-update-group group)
4032 (goto-char (text-property-any
4033 (point-min) (point-max) 'gnus-group (intern group)))))
4034 ;; Adjust cursor point.
4035 (gnus-group-position-cursor))
4037 (defun gnus-group-goto-group (group)
4038 "Goto to newsgroup GROUP."
4039 (let ((b (text-property-any (point-min) (point-max)
4040 'gnus-group (intern group))))
4041 (and b (goto-char b))))
4043 (defun gnus-group-next-group (n)
4044 "Go to next N'th newsgroup.
4045 If N is negative, search backward instead.
4046 Returns the difference between N and the number of skips actually
4047 done."
4048 (interactive "p")
4049 (gnus-group-next-unread-group n t))
4051 (defun gnus-group-next-unread-group (n &optional all level)
4052 "Go to next N'th unread newsgroup.
4053 If N is negative, search backward instead.
4054 If ALL is non-nil, choose any newsgroup, unread or not.
4055 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
4056 such group can be found, the next group with a level higher than
4057 LEVEL.
4058 Returns the difference between N and the number of skips actually
4059 made."
4060 (interactive "p")
4061 (let ((backward (< n 0))
4062 (n (abs n)))
4063 (while (and (> n 0)
4064 (gnus-group-search-forward
4065 backward (or (not gnus-group-goto-unread) all) level))
4066 (setq n (1- n)))
4067 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
4068 (if level " on this level or higher" "")))
4071 (defun gnus-group-prev-group (n)
4072 "Go to previous N'th newsgroup.
4073 Returns the difference between N and the number of skips actually
4074 done."
4075 (interactive "p")
4076 (gnus-group-next-unread-group (- n) t))
4078 (defun gnus-group-prev-unread-group (n)
4079 "Go to previous N'th unread newsgroup.
4080 Returns the difference between N and the number of skips actually
4081 done."
4082 (interactive "p")
4083 (gnus-group-next-unread-group (- n)))
4085 (defun gnus-group-next-unread-group-same-level (n)
4086 "Go to next N'th unread newsgroup on the same level.
4087 If N is negative, search backward instead.
4088 Returns the difference between N and the number of skips actually
4089 done."
4090 (interactive "p")
4091 (gnus-group-next-unread-group n t (gnus-group-group-level))
4092 (gnus-group-position-cursor))
4094 (defun gnus-group-prev-unread-group-same-level (n)
4095 "Go to next N'th unread newsgroup on the same level.
4096 Returns the difference between N and the number of skips actually
4097 done."
4098 (interactive "p")
4099 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
4100 (gnus-group-position-cursor))
4102 (defun gnus-group-best-unread-group (&optional exclude-group)
4103 "Go to the group with the highest level.
4104 If EXCLUDE-GROUP, do not go to that group."
4105 (interactive)
4106 (goto-char (point-min))
4107 (let ((best 100000)
4108 unread best-point)
4109 (while (setq unread (get-text-property (point) 'gnus-unread))
4110 (if (and (numberp unread) (> unread 0))
4111 (progn
4112 (if (and (< (get-text-property (point) 'gnus-level) best)
4113 (or (not exclude-group)
4114 (not (equal exclude-group (gnus-group-group-name)))))
4115 (progn
4116 (setq best (get-text-property (point) 'gnus-level))
4117 (setq best-point (point))))))
4118 (forward-line 1))
4119 (if best-point (goto-char best-point))
4120 (gnus-summary-position-cursor)
4121 (and best-point (gnus-group-group-name))))
4123 (defun gnus-group-first-unread-group ()
4124 "Go to the first group with unread articles."
4125 (interactive)
4126 (prog1
4127 (let ((opoint (point))
4128 unread)
4129 (goto-char (point-min))
4130 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
4131 (not (zerop unread)) ; Has unread articles.
4132 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
4133 (point) ; Success.
4134 (goto-char opoint)
4135 nil)) ; Not success.
4136 (gnus-group-position-cursor)))
4138 (defun gnus-group-enter-server-mode ()
4139 "Jump to the server buffer."
4140 (interactive)
4141 (gnus-server-setup-buffer)
4142 (gnus-configure-windows 'server)
4143 (gnus-server-prepare))
4145 (defun gnus-group-make-group (name &optional method address)
4146 "Add a new newsgroup.
4147 The user will be prompted for a NAME, for a select METHOD, and an
4148 ADDRESS."
4149 (interactive
4150 (cons
4151 (read-string "Group name: ")
4152 (let ((method
4153 (completing-read
4154 "Method: " (append gnus-valid-select-methods gnus-server-alist)
4155 nil t)))
4156 (if (assoc method gnus-valid-select-methods)
4157 (list method
4158 (if (memq 'prompt-address
4159 (assoc method gnus-valid-select-methods))
4160 (read-string "Address: ")
4161 ""))
4162 (list method nil)))))
4164 (let* ((meth (and method (if address (list (intern method) address) method)))
4165 (nname (if method (gnus-group-prefixed-name name meth) name))
4166 info)
4167 (and (gnus-gethash nname gnus-newsrc-hashtb)
4168 (error "Group %s already exists" nname))
4169 (gnus-group-change-level
4170 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
4171 gnus-level-default-subscribed gnus-level-killed
4172 (and (gnus-group-group-name)
4173 (gnus-gethash (gnus-group-group-name)
4174 gnus-newsrc-hashtb))
4176 (gnus-sethash nname (cons 1 0) gnus-active-hashtb)
4177 (or (gnus-ephemeral-group-p name)
4178 (gnus-dribble-enter
4179 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")")))
4180 (gnus-group-insert-group-line-info nname)
4182 (if (assoc method gnus-valid-select-methods)
4183 (require (intern method)))
4184 (and (gnus-check-backend-function 'request-create-group nname)
4185 (gnus-request-create-group nname))))
4187 (defun gnus-group-edit-group (group &optional part)
4188 "Edit the group on the current line."
4189 (interactive (list (gnus-group-group-name)))
4190 (let ((done-func '(lambda ()
4191 "Exit editing mode and update the information."
4192 (interactive)
4193 (gnus-group-edit-group-done 'part 'group)))
4194 (part (or part 'info))
4195 (winconf (current-window-configuration))
4196 info)
4197 (or group (error "No group on current line"))
4198 (or (setq info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
4199 (error "Killed group; can't be edited"))
4200 (set-buffer (get-buffer-create gnus-group-edit-buffer))
4201 (gnus-configure-windows 'edit-group)
4202 (gnus-add-current-to-buffer-list)
4203 (emacs-lisp-mode)
4204 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4205 (use-local-map (copy-keymap emacs-lisp-mode-map))
4206 (local-set-key "\C-c\C-c" done-func)
4207 (make-local-variable 'gnus-prev-winconf)
4208 (setq gnus-prev-winconf winconf)
4209 ;; We modify the func to let it know what part it is editing.
4210 (setcar (cdr (nth 4 done-func)) (list 'quote part))
4211 (setcar (cdr (cdr (nth 4 done-func))) group)
4212 (erase-buffer)
4213 (insert
4214 (cond
4215 ((eq part 'method)
4216 ";; Type `C-c C-c' after editing the select method.\n\n")
4217 ((eq part 'params)
4218 ";; Type `C-c C-c' after editing the group parameters.\n\n")
4219 ((eq part 'info)
4220 ";; Type `C-c C-c' after editing the group info.\n\n")))
4221 (let ((cinfo (gnus-copy-sequence info))
4222 marked)
4223 (if (not (setq marked (nth 3 cinfo)))
4225 (while marked
4226 (or (eq 'score (car (car marked)))
4227 (eq 'bookmark (car (car marked)))
4228 (eq 'killed (car (car marked)))
4229 (not (numberp (car (cdr (car marked)))))
4230 (setcdr (car marked)
4231 (gnus-compress-sequence (sort (cdr (car marked)) '<) t)))
4232 (setq marked (cdr marked))))
4233 (insert
4234 (pp-to-string
4235 (cond ((eq part 'method)
4236 (or (nth 4 info) "native"))
4237 ((eq part 'params)
4238 (nth 5 info))
4240 cinfo)))
4241 "\n"))))
4243 (defun gnus-group-edit-group-method (group)
4244 "Edit the select method of GROUP."
4245 (interactive (list (gnus-group-group-name)))
4246 (gnus-group-edit-group group 'method))
4248 (defun gnus-group-edit-group-parameters (group)
4249 "Edit the group parameters of GROUP."
4250 (interactive (list (gnus-group-group-name)))
4251 (gnus-group-edit-group group 'params))
4253 (defun gnus-group-edit-group-done (part group)
4254 "Get info from buffer, update variables and jump to the group buffer."
4255 (set-buffer (get-buffer-create gnus-group-edit-buffer))
4256 (goto-char (point-min))
4257 (let ((form (read (current-buffer)))
4258 (winconf gnus-prev-winconf))
4259 (if (eq part 'info)
4260 (gnus-group-set-info form)
4261 (gnus-group-set-info form group part))
4262 (kill-buffer (current-buffer))
4263 (and winconf (set-window-configuration winconf))
4264 (set-buffer gnus-group-buffer)
4265 (gnus-group-update-group (gnus-group-group-name))
4266 (gnus-group-position-cursor)))
4268 (defun gnus-group-make-help-group ()
4269 "Create the Gnus documentation group."
4270 (interactive)
4271 (let ((path (if installation-directory
4272 (cons (concat installation-directory "etc/") load-path)
4273 (cons data-directory load-path)))
4274 (name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
4275 file)
4276 (and (gnus-gethash name gnus-newsrc-hashtb)
4277 (error "Documentation group already exists"))
4278 (while (and path
4279 (not (file-exists-p
4280 (setq file (concat (file-name-as-directory (car path))
4281 "gnus-tut.txt")))))
4282 (setq path (cdr path)))
4283 (if (not path)
4284 (message "Couldn't find doc group")
4285 (gnus-group-make-group
4286 (gnus-group-real-name name)
4287 (list 'nndoc name
4288 (list 'nndoc-address file)
4289 (list 'nndoc-article-type 'mbox)))))
4290 (gnus-group-position-cursor))
4292 (defun gnus-group-make-doc-group (file type)
4293 "Create a group that uses a single file as the source."
4294 (interactive
4295 (list (read-file-name "File name: ")
4296 (let ((err "")
4297 found char)
4298 (while (not found)
4299 (message "%sFile type (mbox, babyl, digest) [mbd]: " err)
4300 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
4301 ((= char ?b) 'babyl)
4302 ((= char ?d) 'digest)
4303 (t (setq err (format "%c unknown. " char))
4304 nil))))
4305 found)))
4306 (let* ((file (expand-file-name file))
4307 (name (gnus-generate-new-group-name
4308 (gnus-group-prefixed-name
4309 (file-name-nondirectory file) '(nndoc "")))))
4310 (gnus-group-make-group
4311 (gnus-group-real-name name)
4312 (list 'nndoc name
4313 (list 'nndoc-address file)
4314 (list 'nndoc-article-type type)))))
4316 (defun gnus-group-make-archive-group (&optional all)
4317 "Create the (ding) Gnus archive group of the most recent articles.
4318 Given a prefix, create a full group."
4319 (interactive "P")
4320 (let ((group (gnus-group-prefixed-name
4321 (if all "ding.archives" "ding.recent") '(nndir ""))))
4322 (and (gnus-gethash group gnus-newsrc-hashtb)
4323 (error "Archive group already exists"))
4324 (gnus-group-make-group
4325 (gnus-group-real-name group)
4326 "nndir"
4327 (if all gnus-group-archive-directory
4328 gnus-group-recent-archive-directory)))
4329 (gnus-group-position-cursor))
4331 (defun gnus-group-make-directory-group (dir)
4332 "Create an nndir group.
4333 The user will be prompted for a directory. The contents of this
4334 directory will be used as a newsgroup. The directory should contain
4335 mail messages or news articles in files that have numeric names."
4336 (interactive
4337 (list (read-file-name "Create group from directory: ")))
4338 (or (file-exists-p dir) (error "No such directory"))
4339 (or (file-directory-p dir) (error "Not a directory"))
4340 (gnus-group-make-group dir "nndir" dir)
4341 (gnus-group-position-cursor))
4343 (defun gnus-group-make-kiboze-group (group address scores)
4344 "Create an nnkiboze group.
4345 The user will be prompted for a name, a regexp to match groups, and
4346 score file entries for articles to include in the group."
4347 (interactive
4348 (list
4349 (read-string "nnkiboze group name: ")
4350 (read-string "Source groups (regexp): ")
4351 (let ((headers (mapcar (lambda (group) (list group))
4352 '("subject" "from" "number" "date" "message-id"
4353 "references" "chars" "lines" "xref")))
4354 scores header regexp regexps)
4355 (while (not (equal "" (setq header (completing-read
4356 "Match on header: " headers nil t))))
4357 (setq regexps nil)
4358 (while (not (equal "" (setq regexp (read-string
4359 (format "Match on %s (string): "
4360 header)))))
4361 (setq regexps (cons (list regexp nil nil 'r) regexps)))
4362 (setq scores (cons (cons header regexps) scores)))
4363 scores)))
4364 (gnus-group-make-group group "nnkiboze" address)
4365 (save-excursion
4366 (gnus-set-work-buffer)
4367 (let (emacs-lisp-mode-hook)
4368 (pp scores (current-buffer)))
4369 (write-region (point-min) (point-max)
4370 (concat (or gnus-kill-files-directory "~/News")
4371 "nnkiboze:" group "." gnus-score-file-suffix)))
4372 (gnus-group-position-cursor))
4374 (defun gnus-group-add-to-virtual (n vgroup)
4375 "Add the current group to a virtual group."
4376 (interactive
4377 (list current-prefix-arg
4378 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
4379 "nnvirtual:")))
4380 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
4381 (error "%s is not an nnvirtual group" vgroup))
4382 (let* ((groups (gnus-group-process-prefix n))
4383 (method (nth 4 (nth 2 (gnus-gethash vgroup gnus-newsrc-hashtb)))))
4384 (setcar (cdr method)
4385 (concat
4386 (nth 1 method) "\\|"
4387 (mapconcat
4388 (lambda (s)
4389 (gnus-group-remove-mark s)
4390 (concat "\\(^" (regexp-quote s) "$\\)"))
4391 groups "\\|"))))
4392 (gnus-group-position-cursor))
4394 (defun gnus-group-make-empty-virtual (group)
4395 "Create a new, fresh, empty virtual group."
4396 (interactive "sCreate new, empty virtual group: ")
4397 (let* ((method (list 'nnvirtual "^$"))
4398 (pgroup (gnus-group-prefixed-name group method)))
4399 ;; Check whether it exists already.
4400 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
4401 (error "Group %s already exists." pgroup))
4402 ;; Subscribe the new group after the group on the current line.
4403 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
4404 (gnus-group-update-group pgroup)
4405 (forward-line -1)
4406 (gnus-group-position-cursor)))
4408 (defun gnus-group-enter-directory (dir)
4409 "Enter an ephemeral nneething group."
4410 (interactive "DDirectory to read: ")
4411 (let* ((method (list 'nneething dir))
4412 (leaf (gnus-group-prefixed-name
4413 (file-name-nondirectory (directory-file-name dir))
4414 method))
4415 (name (gnus-generate-new-group-name leaf)))
4416 (let ((nneething-read-only t))
4417 (or (gnus-group-read-ephemeral-group
4418 name method t
4419 (cons (current-buffer) (if (eq major-mode 'gnus-summary-mode)
4420 'summary 'group)))
4421 (error "Couldn't enter %s" dir)))))
4423 ;; Group sorting commands
4424 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
4426 (defun gnus-group-sort-groups ()
4427 "Sort the group buffer using `gnus-group-sort-function'."
4428 (interactive)
4429 (setq gnus-newsrc-alist
4430 (sort (cdr gnus-newsrc-alist) gnus-group-sort-function))
4431 (gnus-make-hashtable-from-newsrc-alist)
4432 (gnus-group-list-groups))
4434 (defun gnus-group-sort-by-alphabet (info1 info2)
4435 (string< (car info1) (car info2)))
4437 (defun gnus-group-sort-by-unread (info1 info2)
4438 (let ((n1 (car (gnus-gethash (car info1) gnus-newsrc-hashtb)))
4439 (n2 (car (gnus-gethash (car info2) gnus-newsrc-hashtb))))
4440 (< (or (and (numberp n1) n1) 0)
4441 (or (and (numberp n2) n2) 0))))
4443 (defun gnus-group-sort-by-level (info1 info2)
4444 (< (nth 1 info1) (nth 1 info2)))
4446 ;; Group catching up.
4448 (defun gnus-group-catchup-current (&optional n all)
4449 "Mark all articles not marked as unread in current newsgroup as read.
4450 If prefix argument N is numeric, the ARG next newsgroups will be
4451 caught up. If ALL is non-nil, marked articles will also be marked as
4452 read. Cross references (Xref: header) of articles are ignored.
4453 The difference between N and actual number of newsgroups that were
4454 caught up is returned."
4455 (interactive "P")
4456 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
4457 gnus-expert-user
4458 (gnus-y-or-n-p
4459 (if all
4460 "Do you really want to mark all articles as read? "
4461 "Mark all unread articles as read? "))))
4463 (let ((groups (gnus-group-process-prefix n))
4464 (ret 0))
4465 (while groups
4466 ;; Virtual groups have to be given special treatment.
4467 (let ((method (gnus-find-method-for-group (car groups))))
4468 (if (eq 'nnvirtual (car method))
4469 (nnvirtual-catchup-group
4470 (gnus-group-real-name (car groups)) (nth 1 method) all)))
4471 (gnus-group-remove-mark (car groups))
4472 (if (prog1
4473 (gnus-group-goto-group (car groups))
4474 (gnus-group-catchup (car groups) all))
4475 (gnus-group-update-group-line)
4476 (setq ret (1+ ret)))
4477 (setq groups (cdr groups)))
4478 (gnus-group-next-unread-group 1)
4479 ret)))
4481 (defun gnus-group-catchup-current-all (&optional n)
4482 "Mark all articles in current newsgroup as read.
4483 Cross references (Xref: header) of articles are ignored."
4484 (interactive "P")
4485 (gnus-group-catchup-current n 'all))
4487 (defun gnus-group-catchup (group &optional all)
4488 "Mark all articles in GROUP as read.
4489 If ALL is non-nil, all articles are marked as read.
4490 The return value is the number of articles that were marked as read,
4491 or nil if no action could be taken."
4492 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4493 (num (car entry))
4494 (marked (nth 3 (nth 2 entry))))
4495 (if (not (numberp (car entry)))
4496 (gnus-message 1 "Can't catch up; non-active group")
4497 ;; Do the updating only if the newsgroup isn't killed.
4498 (if (not entry)
4500 (gnus-update-read-articles
4501 group (and (not all) (append (cdr (assq 'tick marked))
4502 (cdr (assq 'dormant marked))))
4503 nil (and (not all) (cdr (assq 'tick marked))))
4504 (and all
4505 (setq marked (nth 3 (nth 2 entry)))
4506 (setcar (nthcdr 3 (nth 2 entry))
4507 (delq (assq 'dormant marked)
4508 (nth 3 (nth 2 entry)))))))
4509 num))
4511 (defun gnus-group-expire-articles (&optional n)
4512 "Expire all expirable articles in the current newsgroup."
4513 (interactive "P")
4514 (let ((groups (gnus-group-process-prefix n))
4515 group)
4516 (or groups (error "No groups to expire"))
4517 (while groups
4518 (setq group (car groups)
4519 groups (cdr groups))
4520 (gnus-group-remove-mark group)
4521 (if (not (gnus-check-backend-function 'request-expire-articles group))
4523 (let* ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
4524 (expirable (if (memq 'total-expire (nth 5 info))
4525 (cons nil (gnus-list-of-read-articles group))
4526 (assq 'expire (nth 3 info)))))
4527 (and expirable
4528 (setcdr expirable
4529 (gnus-request-expire-articles
4530 (cdr expirable) group))))))))
4532 (defun gnus-group-expire-all-groups ()
4533 "Expire all expirable articles in all newsgroups."
4534 (interactive)
4535 (save-excursion
4536 (gnus-message 5 "Expiring...")
4537 (let ((gnus-group-marked (mapcar (lambda (info) (car info))
4538 (cdr gnus-newsrc-alist))))
4539 (gnus-group-expire-articles nil)))
4540 (gnus-group-position-cursor)
4541 (gnus-message 5 "Expiring...done"))
4543 (defun gnus-group-set-current-level (n level)
4544 "Set the level of the next N groups to LEVEL."
4545 (interactive "P\nnLevel: ")
4546 (or (and (>= level 1) (<= level gnus-level-killed))
4547 (error "Illegal level: %d" level))
4548 (let ((groups (gnus-group-process-prefix n))
4549 group)
4550 (while groups
4551 (setq group (car groups)
4552 groups (cdr groups))
4553 (gnus-group-remove-mark group)
4554 (gnus-message 6 "Changed level of %s from %d to %d"
4555 group (gnus-group-group-level) level)
4556 (gnus-group-change-level group level
4557 (gnus-group-group-level))
4558 (gnus-group-update-group-line)))
4559 (gnus-group-position-cursor))
4561 (defun gnus-group-unsubscribe-current-group (&optional n)
4562 "Toggle subscription of the current group.
4563 If given numerical prefix, toggle the N next groups."
4564 (interactive "P")
4565 (let ((groups (gnus-group-process-prefix n))
4566 group)
4567 (while groups
4568 (setq group (car groups)
4569 groups (cdr groups))
4570 (gnus-group-remove-mark group)
4571 (gnus-group-unsubscribe-group
4572 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
4573 gnus-level-default-unsubscribed
4574 gnus-level-default-subscribed))
4575 (gnus-group-update-group-line))
4576 (gnus-group-next-group 1)))
4578 (defun gnus-group-unsubscribe-group (group &optional level)
4579 "Toggle subscribe from/to unsubscribe GROUP.
4580 New newsgroup is added to .newsrc automatically."
4581 (interactive
4582 (list (completing-read
4583 "Group: " gnus-active-hashtb nil
4584 (memq gnus-select-method gnus-have-read-active-file))))
4585 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
4586 (cond
4587 ((string-match "^[ \t]$" group)
4588 (error "Empty group name"))
4589 (newsrc
4590 ;; Toggle subscription flag.
4591 (gnus-group-change-level
4592 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
4593 gnus-level-subscribed)
4594 (1+ gnus-level-subscribed)
4595 gnus-level-default-subscribed)))
4596 (gnus-group-update-group group))
4597 ((and (stringp group)
4598 (or (not (memq gnus-select-method gnus-have-read-active-file))
4599 (gnus-gethash group gnus-active-hashtb)))
4600 ;; Add new newsgroup.
4601 (gnus-group-change-level
4602 group
4603 (if level level gnus-level-default-subscribed)
4604 (or (and (member group gnus-zombie-list)
4605 gnus-level-zombie)
4606 gnus-level-killed)
4607 (and (gnus-group-group-name)
4608 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
4609 (gnus-group-update-group group))
4610 (t (error "No such newsgroup: %s" group)))
4611 (gnus-group-position-cursor)))
4613 (defun gnus-group-transpose-groups (n)
4614 "Move the current newsgroup up N places.
4615 If given a negative prefix, move down instead. The difference between
4616 N and the number of steps taken is returned."
4617 (interactive "p")
4618 (or (gnus-group-group-name)
4619 (error "No group on current line"))
4620 (gnus-group-kill-group 1)
4621 (prog1
4622 (forward-line (- n))
4623 (gnus-group-yank-group)
4624 (gnus-group-position-cursor)))
4626 (defun gnus-group-kill-all-zombies ()
4627 "Kill all zombie newsgroups."
4628 (interactive)
4629 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
4630 (setq gnus-zombie-list nil)
4631 (gnus-group-list-groups))
4633 (defun gnus-group-kill-region (begin end)
4634 "Kill newsgroups in current region (excluding current point).
4635 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
4636 (interactive "r")
4637 (let ((lines
4638 ;; Count lines.
4639 (save-excursion
4640 (count-lines
4641 (progn
4642 (goto-char begin)
4643 (beginning-of-line)
4644 (point))
4645 (progn
4646 (goto-char end)
4647 (beginning-of-line)
4648 (point))))))
4649 (goto-char begin)
4650 (beginning-of-line) ;Important when LINES < 1
4651 (gnus-group-kill-group lines)))
4653 (defun gnus-group-kill-group (&optional n)
4654 "The the next N groups.
4655 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
4656 However, only groups that were alive can be yanked; already killed
4657 groups or zombie groups can't be yanked.
4658 The return value is the name of the (last) group that was killed."
4659 (interactive "P")
4660 (let ((buffer-read-only nil)
4661 (groups (gnus-group-process-prefix n))
4662 group entry level)
4663 (while groups
4664 (setq group (car groups)
4665 groups (cdr groups))
4666 (gnus-group-remove-mark group)
4667 (setq level (gnus-group-group-level))
4668 (gnus-delete-line)
4669 (if (setq entry (gnus-gethash group gnus-newsrc-hashtb))
4670 (setq gnus-list-of-killed-groups
4671 (cons (cons (car entry) (nth 2 entry))
4672 gnus-list-of-killed-groups)))
4673 (gnus-group-change-level
4674 (if entry entry group) gnus-level-killed (if entry nil level)))
4675 (gnus-group-position-cursor)
4676 group))
4678 (defun gnus-group-yank-group (&optional arg)
4679 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
4680 inserting it before the current newsgroup. The numeric ARG specifies
4681 how many newsgroups are to be yanked. The name of the (last)
4682 newsgroup yanked is returned."
4683 (interactive "p")
4684 (if (not arg) (setq arg 1))
4685 (let (info group prev)
4686 (while (>= (setq arg (1- arg)) 0)
4687 (if (not (setq info (car gnus-list-of-killed-groups)))
4688 (error "No more newsgroups to yank"))
4689 (setq group (nth 2 info))
4690 ;; Find which newsgroup to insert this one before - search
4691 ;; backward until something suitable is found. If there are no
4692 ;; other newsgroups in this buffer, just make this newsgroup the
4693 ;; first newsgroup.
4694 (setq prev (gnus-group-group-name))
4695 (gnus-group-change-level
4696 info (nth 2 info) gnus-level-killed
4697 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
4699 (gnus-group-insert-group-line-info (nth 1 info))
4700 (setq gnus-list-of-killed-groups
4701 (cdr gnus-list-of-killed-groups)))
4702 (forward-line -1)
4703 (gnus-group-position-cursor)
4704 group))
4706 (defun gnus-group-list-all-groups (&optional arg)
4707 "List all newsgroups with level ARG or lower.
4708 Default is gnus-level-unsubscribed, which lists all subscribed and most
4709 unsubscribed groups."
4710 (interactive "P")
4711 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
4713 (defun gnus-group-list-killed ()
4714 "List all killed newsgroups in the group buffer."
4715 (interactive)
4716 (if (not gnus-killed-list)
4717 (gnus-message 6 "No killed groups")
4718 (let (gnus-group-list-mode)
4719 (funcall gnus-group-prepare-function
4720 gnus-level-killed t gnus-level-killed))
4721 (goto-char (point-min)))
4722 (gnus-group-position-cursor))
4724 (defun gnus-group-list-zombies ()
4725 "List all zombie newsgroups in the group buffer."
4726 (interactive)
4727 (if (not gnus-zombie-list)
4728 (gnus-message 6 "No zombie groups")
4729 (let (gnus-group-list-mode)
4730 (funcall gnus-group-prepare-function
4731 gnus-level-zombie t gnus-level-zombie))
4732 (goto-char (point-min)))
4733 (gnus-group-position-cursor))
4735 (defun gnus-group-get-new-news (&optional arg)
4736 "Get newly arrived articles.
4737 If ARG is non-nil, it should be a number between one and nine to
4738 specify which levels you are interested in re-scanning."
4739 (interactive "P")
4740 (run-hooks 'gnus-get-new-news-hook)
4741 (setq arg (gnus-group-default-level arg t))
4742 (if (and gnus-read-active-file (not arg))
4743 (progn
4744 (gnus-read-active-file)
4745 (gnus-get-unread-articles (or arg (1+ gnus-level-subscribed))))
4746 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
4747 (gnus-get-unread-articles (or arg (1+ gnus-level-subscribed)))))
4748 (gnus-group-list-groups))
4750 (defun gnus-group-get-new-news-this-group (&optional n)
4751 "Check for newly arrived news in the current group (and the N-1 next groups).
4752 The difference between N and the number of newsgroup checked is returned.
4753 If N is negative, this group and the N-1 previous groups will be checked."
4754 (interactive "P")
4755 (let* ((groups (gnus-group-process-prefix n))
4756 (ret (if (numberp n) (- n (length groups)) 0))
4757 group)
4758 (while groups
4759 (setq group (car groups)
4760 groups (cdr groups))
4761 (gnus-group-remove-mark group)
4762 (or (gnus-get-new-news-in-group group)
4763 (progn
4764 (ding)
4765 (message "%s error: %s" group (gnus-status-message group))
4766 (sit-for 2))))
4767 (gnus-group-next-unread-group 1 t)
4768 (gnus-summary-position-cursor)
4769 ret))
4771 (defun gnus-get-new-news-in-group (group)
4772 (and group
4773 (gnus-activate-group group)
4774 (progn
4775 (gnus-get-unread-articles-in-group
4776 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))
4777 (gnus-gethash group gnus-active-hashtb))
4778 (gnus-group-update-group-line)
4779 t)))
4781 (defun gnus-group-fetch-faq (group)
4782 "Fetch the FAQ for the current group."
4783 (interactive (list (gnus-group-real-name (gnus-group-group-name))))
4784 (or group (error "No group name given"))
4785 (let ((file (concat gnus-group-faq-directory (gnus-group-real-name group))))
4786 (if (not (file-exists-p file))
4787 (error "No such file: %s" file)
4788 (find-file file))))
4790 (defun gnus-group-describe-group (force &optional group)
4791 "Display a description of the current newsgroup."
4792 (interactive (list current-prefix-arg (gnus-group-group-name)))
4793 (and force (setq gnus-description-hashtb nil))
4794 (let ((method (gnus-find-method-for-group group))
4795 desc)
4796 (or group (error "No group name given"))
4797 (and (or (and gnus-description-hashtb
4798 ;; We check whether this group's method has been
4799 ;; queried for a description file.
4800 (gnus-gethash
4801 (gnus-group-prefixed-name "" method)
4802 gnus-description-hashtb))
4803 (setq desc (gnus-group-get-description group))
4804 (gnus-read-descriptions-file method))
4805 (message
4806 (or desc (gnus-gethash group gnus-description-hashtb)
4807 "No description available")))))
4809 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4810 (defun gnus-group-describe-all-groups (&optional force)
4811 "Pop up a buffer with descriptions of all newsgroups."
4812 (interactive "P")
4813 (and force (setq gnus-description-hashtb nil))
4814 (if (not (or gnus-description-hashtb
4815 (gnus-read-all-descriptions-files)))
4816 (error "Couldn't request descriptions file"))
4817 (let ((buffer-read-only nil)
4819 (erase-buffer)
4820 (mapatoms
4821 (lambda (group)
4822 (setq b (point))
4823 (insert (format " *: %-20s %s\n" (symbol-name group)
4824 (symbol-value group)))
4825 (add-text-properties
4826 b (1+ b) (list 'gnus-group group
4827 'gnus-unread t 'gnus-marked nil
4828 'gnus-level (1+ gnus-level-subscribed))))
4829 gnus-description-hashtb)
4830 (goto-char (point-min))
4831 (gnus-group-position-cursor)))
4833 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
4834 (defun gnus-group-apropos (regexp &optional search-description)
4835 "List all newsgroups that have names that match a regexp."
4836 (interactive "sGnus apropos (regexp): ")
4837 (let ((prev "")
4838 (obuf (current-buffer))
4839 groups des)
4840 ;; Go through all newsgroups that are known to Gnus.
4841 (mapatoms
4842 (lambda (group)
4843 (and (symbol-name group)
4844 (string-match regexp (symbol-name group))
4845 (setq groups (cons (symbol-name group) groups))))
4846 gnus-active-hashtb)
4847 ;; Go through all descriptions that are known to Gnus.
4848 (if search-description
4849 (mapatoms
4850 (lambda (group)
4851 (and (string-match regexp (symbol-value group))
4852 (gnus-gethash (symbol-name group) gnus-active-hashtb)
4853 (setq groups (cons (symbol-name group) groups))))
4854 gnus-description-hashtb))
4855 (if (not groups)
4856 (gnus-message 3 "No groups matched \"%s\"." regexp)
4857 ;; Print out all the groups.
4858 (save-excursion
4859 (pop-to-buffer "*Gnus Help*")
4860 (buffer-disable-undo (current-buffer))
4861 (erase-buffer)
4862 (setq groups (sort groups 'string<))
4863 (while groups
4864 ;; Groups may be entered twice into the list of groups.
4865 (if (not (string= (car groups) prev))
4866 (progn
4867 (insert (setq prev (car groups)) "\n")
4868 (if (and gnus-description-hashtb
4869 (setq des (gnus-gethash (car groups)
4870 gnus-description-hashtb)))
4871 (insert " " des "\n"))))
4872 (setq groups (cdr groups)))
4873 (goto-char (point-min))))
4874 (pop-to-buffer obuf)))
4876 (defun gnus-group-description-apropos (regexp)
4877 "List all newsgroups that have names or descriptions that match a regexp."
4878 (interactive "sGnus description apropos (regexp): ")
4879 (if (not (or gnus-description-hashtb
4880 (gnus-read-all-descriptions-files)))
4881 (error "Couldn't request descriptions file"))
4882 (gnus-group-apropos regexp t))
4884 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4885 (defun gnus-group-list-matching (level regexp &optional all lowest)
4886 "List all groups with unread articles that match REGEXP.
4887 If the prefix LEVEL is non-nil, it should be a number that says which
4888 level to cut off listing groups.
4889 If ALL, also list groups with no unread articles.
4890 If LOWEST, don't list groups with level lower than LOWEST."
4891 (interactive "P\nsList newsgroups matching: ")
4892 (gnus-group-prepare-flat (or level gnus-level-subscribed)
4893 all (or lowest 1) regexp)
4894 (goto-char (point-min))
4895 (gnus-group-position-cursor))
4897 (defun gnus-group-list-all-matching (level regexp &optional lowest)
4898 "List all groups that match REGEXP.
4899 If the prefix LEVEL is non-nil, it should be a number that says which
4900 level to cut off listing groups.
4901 If LOWEST, don't list groups with level lower than LOWEST."
4902 (interactive "P\nsList newsgroups matching: ")
4903 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
4905 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
4906 (defun gnus-group-save-newsrc ()
4907 "Save the Gnus startup files."
4908 (interactive)
4909 (gnus-save-newsrc-file))
4911 (defun gnus-group-restart (&optional arg)
4912 "Force Gnus to read the .newsrc file."
4913 (interactive "P")
4914 (gnus-save-newsrc-file)
4915 (gnus-setup-news 'force)
4916 (gnus-group-list-groups arg))
4918 (defun gnus-group-read-init-file ()
4919 "Read the Gnus elisp init file."
4920 (interactive)
4921 (gnus-read-init-file))
4923 (defun gnus-group-check-bogus-groups (&optional silent)
4924 "Check bogus newsgroups.
4925 If given a prefix, don't ask for confirmation before removing a bogus
4926 group."
4927 (interactive "P")
4928 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
4929 (gnus-group-list-groups))
4931 (defun gnus-group-edit-global-kill (&optional article group)
4932 "Edit the global kill file.
4933 If GROUP, edit that local kill file instead."
4934 (interactive "P")
4935 (setq gnus-current-kill-article article)
4936 (gnus-kill-file-edit-file group)
4937 (gnus-message
4939 (substitute-command-keys
4940 "Editing a global kill file (Type \\[gnus-kill-file-exit] to exit)")))
4942 (defun gnus-group-edit-local-kill (article group)
4943 "Edit a local kill file."
4944 (interactive (list nil (gnus-group-group-name)))
4945 (gnus-group-edit-global-kill article group))
4947 (defun gnus-group-force-update ()
4948 "Update `.newsrc' file."
4949 (interactive)
4950 (gnus-save-newsrc-file))
4952 (defun gnus-group-suspend ()
4953 "Suspend the current Gnus session.
4954 In fact, cleanup buffers except for group mode buffer.
4955 The hook gnus-suspend-gnus-hook is called before actually suspending."
4956 (interactive)
4957 (run-hooks 'gnus-suspend-gnus-hook)
4958 ;; Kill Gnus buffers except for group mode buffer.
4959 (let ((group-buf (get-buffer gnus-group-buffer)))
4960 ;; Do this on a separate list in case the user does a ^G before we finish
4961 (let ((gnus-buffer-list
4962 (delq group-buf (delq gnus-dribble-buffer
4963 (append gnus-buffer-list nil)))))
4964 (while gnus-buffer-list
4965 (gnus-kill-buffer (car gnus-buffer-list))
4966 (setq gnus-buffer-list (cdr gnus-buffer-list))))
4967 (if group-buf
4968 (progn
4969 (setq gnus-buffer-list (list group-buf))
4970 (bury-buffer group-buf)
4971 (delete-windows-on group-buf t)))))
4973 (defun gnus-group-clear-dribble ()
4974 "Clear all information from the dribble buffer."
4975 (interactive)
4976 (gnus-dribble-clear))
4978 (defun gnus-group-exit ()
4979 "Quit reading news after updating .newsrc.eld and .newsrc.
4980 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4981 (interactive)
4982 (if (or noninteractive ;For gnus-batch-kill
4983 (not (gnus-server-opened gnus-select-method)) ;NNTP connection closed
4984 (not gnus-interactive-exit) ;Without confirmation
4985 gnus-expert-user
4986 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
4987 (progn
4988 (run-hooks 'gnus-exit-gnus-hook)
4989 ;; Offer to save data from non-quitted summary buffers.
4990 (gnus-offer-save-summaries)
4991 ;; Save the newsrc file(s).
4992 (gnus-save-newsrc-file)
4993 ;; Kill-em-all.
4994 (gnus-close-backends)
4995 ;; Reset everything.
4996 (gnus-clear-system))))
4998 (defun gnus-close-backends ()
4999 ;; Send a close request to all backends that support such a request.
5000 (let ((methods gnus-valid-select-methods)
5001 func)
5002 (while methods
5003 (if (fboundp (setq func (intern (concat (car (car methods))
5004 "-request-close"))))
5005 (funcall func))
5006 (setq methods (cdr methods)))))
5008 (defun gnus-group-quit ()
5009 "Quit reading news without updating .newsrc.eld or .newsrc.
5010 The hook `gnus-exit-gnus-hook' is called before actually exiting."
5011 (interactive)
5012 (if (or noninteractive ;For gnus-batch-kill
5013 (zerop (buffer-size))
5014 (not (gnus-server-opened gnus-select-method))
5015 gnus-expert-user
5016 (not gnus-current-startup-file)
5017 (gnus-yes-or-no-p
5018 (format "Quit reading news without saving %s? "
5019 (file-name-nondirectory gnus-current-startup-file))))
5020 (progn
5021 (run-hooks 'gnus-exit-gnus-hook)
5022 (if gnus-use-full-window
5023 (delete-other-windows)
5024 (gnus-remove-some-windows))
5025 (gnus-dribble-save)
5026 (gnus-close-backends)
5027 (gnus-clear-system))))
5029 (defun gnus-offer-save-summaries ()
5030 (save-excursion
5031 (let ((buflist (buffer-list))
5032 buffers bufname)
5033 (while buflist
5034 (and (setq bufname (buffer-name (car buflist)))
5035 (string-match "Summary" bufname)
5036 (save-excursion
5037 (set-buffer bufname)
5038 ;; We check that this is, indeed, a summary buffer.
5039 (eq major-mode 'gnus-summary-mode))
5040 (setq buffers (cons bufname buffers)))
5041 (setq buflist (cdr buflist)))
5042 (and buffers
5043 (map-y-or-n-p
5044 "Update summary buffer %s? "
5045 (lambda (buf)
5046 (set-buffer buf)
5047 (gnus-summary-exit))
5048 buffers)))))
5050 (defun gnus-group-describe-briefly ()
5051 "Give a one line description of the group mode commands."
5052 (interactive)
5053 (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")))
5055 (defun gnus-group-browse-foreign-server (method)
5056 "Browse a foreign news server.
5057 If called interactively, this function will ask for a select method
5058 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
5059 If not, METHOD should be a list where the first element is the method
5060 and the second element is the address."
5061 (interactive
5062 (list (let ((how (completing-read
5063 "Which backend: "
5064 (append gnus-valid-select-methods gnus-server-alist)
5065 nil t "nntp")))
5066 ;; We either got a backend name or a virtual server name.
5067 ;; If the first, we also need an address.
5068 (if (assoc how gnus-valid-select-methods)
5069 (list (intern how)
5070 ;; Suggested by mapjph@bath.ac.uk.
5071 (completing-read
5072 "Address: "
5073 (mapcar (lambda (server) (list server))
5074 gnus-secondary-servers)))
5075 ;; We got a server name, so we find the method.
5076 (gnus-server-to-method how)))))
5077 (gnus-browse-foreign-server method))
5081 ;;; Browse Server Mode
5084 (defvar gnus-browse-mode-hook nil)
5085 (defvar gnus-browse-mode-map nil)
5086 (put 'gnus-browse-mode 'mode-class 'special)
5088 (if gnus-browse-mode-map
5090 (setq gnus-browse-mode-map (make-keymap))
5091 (suppress-keymap gnus-browse-mode-map)
5092 (define-key gnus-browse-mode-map " " 'gnus-browse-read-group)
5093 (define-key gnus-browse-mode-map "=" 'gnus-browse-select-group)
5094 (define-key gnus-browse-mode-map "n" 'gnus-browse-next-group)
5095 (define-key gnus-browse-mode-map "p" 'gnus-browse-prev-group)
5096 (define-key gnus-browse-mode-map "\177" 'gnus-browse-prev-group)
5097 (define-key gnus-browse-mode-map "N" 'gnus-browse-next-group)
5098 (define-key gnus-browse-mode-map "P" 'gnus-browse-prev-group)
5099 (define-key gnus-browse-mode-map "\M-n" 'gnus-browse-next-group)
5100 (define-key gnus-browse-mode-map "\M-p" 'gnus-browse-prev-group)
5101 (define-key gnus-browse-mode-map "\r" 'gnus-browse-select-group)
5102 (define-key gnus-browse-mode-map "u" 'gnus-browse-unsubscribe-current-group)
5103 (define-key gnus-browse-mode-map "l" 'gnus-browse-exit)
5104 (define-key gnus-browse-mode-map "L" 'gnus-browse-exit)
5105 (define-key gnus-browse-mode-map "q" 'gnus-browse-exit)
5106 (define-key gnus-browse-mode-map "Q" 'gnus-browse-exit)
5107 (define-key gnus-browse-mode-map "\C-c\C-c" 'gnus-browse-exit)
5108 (define-key gnus-browse-mode-map "?" 'gnus-browse-describe-briefly)
5109 (define-key gnus-browse-mode-map "\C-c\C-i" 'gnus-info-find-node)
5112 (defvar gnus-browse-current-method nil)
5113 (defvar gnus-browse-return-buffer nil)
5115 (defvar gnus-browse-buffer "*Gnus Browse Server*")
5117 (defun gnus-browse-foreign-server (method &optional return-buffer)
5118 (setq gnus-browse-current-method method)
5119 (setq gnus-browse-return-buffer return-buffer)
5120 (let ((gnus-select-method method)
5121 groups group)
5122 (gnus-message 5 "Connecting to %s..." (nth 1 method))
5123 (or (gnus-check-server method)
5124 (error "Unable to contact server: %s" (gnus-status-message method)))
5125 (or (gnus-request-list method)
5126 (error "Couldn't request list: %s" (gnus-status-message method)))
5127 (get-buffer-create gnus-browse-buffer)
5128 (gnus-add-current-to-buffer-list)
5129 (and gnus-carpal (gnus-carpal-setup-buffer 'browse))
5130 (gnus-configure-windows 'browse)
5131 (buffer-disable-undo (current-buffer))
5132 (let ((buffer-read-only nil))
5133 (erase-buffer))
5134 (gnus-browse-mode)
5135 (setq mode-line-buffer-identification
5136 (format
5137 "Gnus Browse Server {%s:%s}" (car method) (car (cdr method))))
5138 (save-excursion
5139 (set-buffer nntp-server-buffer)
5140 (let ((cur (current-buffer)))
5141 (goto-char (point-min))
5142 (or (string= gnus-ignored-newsgroups "")
5143 (delete-matching-lines gnus-ignored-newsgroups))
5144 (while (re-search-forward
5145 "\\(^[^ \t]+\\)[ \t]+[0-9]+[ \t]+[0-9]+" nil t)
5146 (goto-char (match-end 1))
5147 (setq groups (cons (cons (buffer-substring (match-beginning 1)
5148 (match-end 1))
5149 (max 0 (- (1+ (read cur)) (read cur))))
5150 groups)))))
5151 (setq groups (sort groups
5152 (lambda (l1 l2)
5153 (string< (car l1) (car l2)))))
5154 (let ((buffer-read-only nil))
5155 (while groups
5156 (setq group (car groups))
5157 (insert
5158 (format "K%7d: %s\n" (cdr group) (car group)))
5159 (setq groups (cdr groups))))
5160 (switch-to-buffer (current-buffer))
5161 (goto-char (point-min))
5162 (gnus-group-position-cursor)))
5164 (defun gnus-browse-mode ()
5165 "Major mode for browsing a foreign server.
5167 All normal editing commands are switched off.
5169 \\<gnus-browse-mode-map>
5170 The only things you can do in this buffer is
5172 1) `\\[gnus-browse-unsubscribe-current-group]' to subscribe to a group.
5173 The group will be inserted into the group buffer upon exit from this
5174 buffer.
5176 2) `\\[gnus-browse-read-group]' to read a group ephemerally.
5178 3) `\\[gnus-browse-exit]' to return to the group buffer."
5179 (interactive)
5180 (kill-all-local-variables)
5181 (if gnus-visual (gnus-browse-make-menu-bar))
5182 (gnus-simplify-mode-line)
5183 (setq major-mode 'gnus-browse-mode)
5184 (setq mode-name "Browse Server")
5185 (setq mode-line-process nil)
5186 (use-local-map gnus-browse-mode-map)
5187 (buffer-disable-undo (current-buffer))
5188 (setq truncate-lines t)
5189 (setq buffer-read-only t)
5190 (run-hooks 'gnus-browse-mode-hook))
5192 (defun gnus-browse-read-group (&optional no-article)
5193 "Enter the group at the current line."
5194 (interactive)
5195 (let ((group (gnus-browse-group-name)))
5196 (or (gnus-group-read-ephemeral-group
5197 group gnus-browse-current-method nil
5198 (cons (current-buffer) 'browse))
5199 (error "Couldn't enter %s" group))))
5201 (defun gnus-browse-select-group ()
5202 "Select the current group."
5203 (interactive)
5204 (gnus-browse-read-group 'no))
5206 (defun gnus-browse-next-group (n)
5207 "Go to the next group."
5208 (interactive "p")
5209 (prog1
5210 (forward-line n)
5211 (gnus-group-position-cursor)))
5213 (defun gnus-browse-prev-group (n)
5214 "Go to the next group."
5215 (interactive "p")
5216 (gnus-browse-next-group (- n)))
5218 (defun gnus-browse-unsubscribe-current-group (arg)
5219 "(Un)subscribe to the next ARG groups."
5220 (interactive "p")
5221 (and (eobp)
5222 (error "No group at current line."))
5223 (let ((ward (if (< arg 0) -1 1))
5224 (arg (abs arg)))
5225 (while (and (> arg 0)
5226 (not (eobp))
5227 (gnus-browse-unsubscribe-group)
5228 (zerop (gnus-browse-next-group ward)))
5229 (setq arg (1- arg)))
5230 (gnus-group-position-cursor)
5231 (if (/= 0 arg) (gnus-message 7 "No more newsgroups"))
5232 arg))
5234 (defun gnus-browse-group-name ()
5235 (save-excursion
5236 (beginning-of-line)
5237 (if (not (re-search-forward ": \\(.*\\)$" (gnus-point-at-eol) t))
5239 (gnus-group-prefixed-name
5240 (buffer-substring (match-beginning 1) (match-end 1))
5241 gnus-browse-current-method))))
5243 (defun gnus-browse-unsubscribe-group ()
5244 "Toggle subscription of the current group in the browse buffer."
5245 (let ((sub nil)
5246 (buffer-read-only nil)
5247 group)
5248 (save-excursion
5249 (beginning-of-line)
5250 ;; If this group it killed, then we want to subscribe it.
5251 (if (= (following-char) ?K) (setq sub t))
5252 (setq group (gnus-browse-group-name))
5253 (delete-char 1)
5254 (if sub
5255 (progn
5256 (gnus-group-change-level
5257 (list t group gnus-level-default-subscribed
5258 nil nil gnus-browse-current-method)
5259 gnus-level-default-subscribed gnus-level-killed
5260 (and (car (nth 1 gnus-newsrc-alist))
5261 (gnus-gethash (car (nth 1 gnus-newsrc-alist))
5262 gnus-newsrc-hashtb))
5264 (insert ? ))
5265 (gnus-group-change-level
5266 group gnus-level-killed gnus-level-default-subscribed)
5267 (insert ?K)))
5270 (defun gnus-browse-exit ()
5271 "Quit browsing and return to the group buffer."
5272 (interactive)
5273 (if (eq major-mode 'gnus-browse-mode)
5274 (kill-buffer (current-buffer)))
5275 (if gnus-browse-return-buffer
5276 (gnus-configure-windows 'server 'force)
5277 (gnus-configure-windows 'group 'force)
5278 (gnus-group-list-groups nil)))
5280 (defun gnus-browse-describe-briefly ()
5281 "Give a one line description of the group mode commands."
5282 (interactive)
5283 (gnus-message 6
5284 (substitute-command-keys "\\<gnus-browse-mode-map>\\[gnus-group-next-group]:Forward \\[gnus-group-prev-group]:Backward \\[gnus-browse-exit]:Exit \\[gnus-info-find-node]:Run Info \\[gnus-browse-describe-briefly]:This help")))
5288 ;;; Gnus summary mode
5291 (defvar gnus-summary-mode-map nil)
5292 (defvar gnus-summary-mark-map nil)
5293 (defvar gnus-summary-mscore-map nil)
5294 (defvar gnus-summary-article-map nil)
5295 (defvar gnus-summary-thread-map nil)
5296 (defvar gnus-summary-goto-map nil)
5297 (defvar gnus-summary-exit-map nil)
5298 (defvar gnus-summary-interest-map nil)
5299 (defvar gnus-summary-sort-map nil)
5300 (defvar gnus-summary-backend-map nil)
5301 (defvar gnus-summary-save-map nil)
5302 (defvar gnus-summary-wash-map nil)
5303 (defvar gnus-summary-wash-hide-map nil)
5304 (defvar gnus-summary-wash-highlight-map nil)
5305 (defvar gnus-summary-wash-time-map nil)
5306 (defvar gnus-summary-help-map nil)
5308 (put 'gnus-summary-mode 'mode-class 'special)
5310 (if gnus-summary-mode-map
5312 (setq gnus-summary-mode-map (make-keymap))
5313 (suppress-keymap gnus-summary-mode-map)
5315 ;; Non-orthogonal keys
5317 (define-key gnus-summary-mode-map " " 'gnus-summary-next-page)
5318 (define-key gnus-summary-mode-map "\177" 'gnus-summary-prev-page)
5319 (define-key gnus-summary-mode-map "\r" 'gnus-summary-scroll-up)
5320 (define-key gnus-summary-mode-map "n" 'gnus-summary-next-unread-article)
5321 (define-key gnus-summary-mode-map "p" 'gnus-summary-prev-unread-article)
5322 (define-key gnus-summary-mode-map "N" 'gnus-summary-next-article)
5323 (define-key gnus-summary-mode-map "P" 'gnus-summary-prev-article)
5324 (define-key gnus-summary-mode-map "\M-\C-n" 'gnus-summary-next-same-subject)
5325 (define-key gnus-summary-mode-map "\M-\C-p" 'gnus-summary-prev-same-subject)
5326 (define-key gnus-summary-mode-map "\M-n" 'gnus-summary-next-unread-subject)
5327 (define-key gnus-summary-mode-map "\M-p" 'gnus-summary-prev-unread-subject)
5328 (define-key gnus-summary-mode-map "." 'gnus-summary-first-unread-article)
5329 (define-key gnus-summary-mode-map "," 'gnus-summary-best-unread-article)
5330 (define-key gnus-summary-mode-map
5331 "\M-s" 'gnus-summary-search-article-forward)
5332 (define-key gnus-summary-mode-map
5333 "\M-r" 'gnus-summary-search-article-backward)
5334 (define-key gnus-summary-mode-map "<" 'gnus-summary-beginning-of-article)
5335 (define-key gnus-summary-mode-map ">" 'gnus-summary-end-of-article)
5336 (define-key gnus-summary-mode-map "j" 'gnus-summary-goto-subject)
5337 (define-key gnus-summary-mode-map "^" 'gnus-summary-refer-parent-article)
5338 (define-key gnus-summary-mode-map "\M-^" 'gnus-summary-refer-article)
5339 (define-key gnus-summary-mode-map "u" 'gnus-summary-tick-article-forward)
5340 (define-key gnus-summary-mode-map "!" 'gnus-summary-tick-article-forward)
5341 (define-key gnus-summary-mode-map "U" 'gnus-summary-tick-article-backward)
5342 (define-key gnus-summary-mode-map "d" 'gnus-summary-mark-as-read-forward)
5343 (define-key gnus-summary-mode-map "D" 'gnus-summary-mark-as-read-backward)
5344 (define-key gnus-summary-mode-map "E" 'gnus-summary-mark-as-expirable)
5345 (define-key gnus-summary-mode-map "\M-u" 'gnus-summary-clear-mark-forward)
5346 (define-key gnus-summary-mode-map "\M-U" 'gnus-summary-clear-mark-backward)
5347 (define-key gnus-summary-mode-map
5348 "k" 'gnus-summary-kill-same-subject-and-select)
5349 (define-key gnus-summary-mode-map "\C-k" 'gnus-summary-kill-same-subject)
5350 (define-key gnus-summary-mode-map "\M-\C-k" 'gnus-summary-kill-thread)
5351 (define-key gnus-summary-mode-map "\M-\C-l" 'gnus-summary-lower-thread)
5352 (define-key gnus-summary-mode-map "e" 'gnus-summary-edit-article)
5353 (define-key gnus-summary-mode-map "#" 'gnus-summary-mark-as-processable)
5354 (define-key gnus-summary-mode-map "\M-#" 'gnus-summary-unmark-as-processable)
5355 (define-key gnus-summary-mode-map "\M-\C-t" 'gnus-summary-toggle-threads)
5356 (define-key gnus-summary-mode-map "\M-\C-s" 'gnus-summary-show-thread)
5357 (define-key gnus-summary-mode-map "\M-\C-h" 'gnus-summary-hide-thread)
5358 (define-key gnus-summary-mode-map "\M-\C-f" 'gnus-summary-next-thread)
5359 (define-key gnus-summary-mode-map "\M-\C-b" 'gnus-summary-prev-thread)
5360 (define-key gnus-summary-mode-map "\M-\C-u" 'gnus-summary-up-thread)
5361 (define-key gnus-summary-mode-map "\M-\C-d" 'gnus-summary-down-thread)
5362 (define-key gnus-summary-mode-map "&" 'gnus-summary-execute-command)
5363 (define-key gnus-summary-mode-map "c" 'gnus-summary-catchup-and-exit)
5364 (define-key gnus-summary-mode-map "\C-w" 'gnus-summary-mark-region-as-read)
5365 (define-key gnus-summary-mode-map "\C-t" 'gnus-summary-toggle-truncation)
5366 (define-key gnus-summary-mode-map "?" 'gnus-summary-mark-as-dormant)
5367 (define-key gnus-summary-mode-map
5368 "\C-c\M-\C-s" 'gnus-summary-show-all-expunged)
5369 (define-key gnus-summary-mode-map
5370 "\C-c\C-s\C-n" 'gnus-summary-sort-by-number)
5371 (define-key gnus-summary-mode-map
5372 "\C-c\C-s\C-a" 'gnus-summary-sort-by-author)
5373 (define-key gnus-summary-mode-map
5374 "\C-c\C-s\C-s" 'gnus-summary-sort-by-subject)
5375 (define-key gnus-summary-mode-map "\C-c\C-s\C-d" 'gnus-summary-sort-by-date)
5376 (define-key gnus-summary-mode-map "\C-c\C-s\C-i" 'gnus-summary-sort-by-score)
5377 (define-key gnus-summary-mode-map "=" 'gnus-summary-expand-window)
5378 (define-key gnus-summary-mode-map
5379 "\C-x\C-s" 'gnus-summary-reselect-current-group)
5380 (define-key gnus-summary-mode-map "\M-g" 'gnus-summary-rescan-group)
5381 (define-key gnus-summary-mode-map "w" 'gnus-summary-stop-page-breaking)
5382 (define-key gnus-summary-mode-map "\C-c\C-r" 'gnus-summary-caesar-message)
5383 (define-key gnus-summary-mode-map "\M-t" 'gnus-summary-toggle-mime)
5384 (define-key gnus-summary-mode-map "f" 'gnus-summary-followup)
5385 (define-key gnus-summary-mode-map "F" 'gnus-summary-followup-with-original)
5386 (define-key gnus-summary-mode-map "C" 'gnus-summary-cancel-article)
5387 (define-key gnus-summary-mode-map "r" 'gnus-summary-reply)
5388 (define-key gnus-summary-mode-map "R" 'gnus-summary-reply-with-original)
5389 (define-key gnus-summary-mode-map "\C-c\C-f" 'gnus-summary-mail-forward)
5390 (define-key gnus-summary-mode-map "o" 'gnus-summary-save-article)
5391 (define-key gnus-summary-mode-map "\C-o" 'gnus-summary-save-article-mail)
5392 (define-key gnus-summary-mode-map "|" 'gnus-summary-pipe-output)
5393 (define-key gnus-summary-mode-map "\M-k" 'gnus-summary-edit-local-kill)
5394 (define-key gnus-summary-mode-map "\M-K" 'gnus-summary-edit-global-kill)
5395 (define-key gnus-summary-mode-map "V" 'gnus-version)
5396 (define-key gnus-summary-mode-map "\C-c\C-d" 'gnus-summary-describe-group)
5397 (define-key gnus-summary-mode-map "q" 'gnus-summary-exit)
5398 (define-key gnus-summary-mode-map "Q" 'gnus-summary-exit-no-update)
5399 (define-key gnus-summary-mode-map "\C-c\C-i" 'gnus-info-find-node)
5400 (define-key gnus-summary-mode-map gnus-mouse-2 'gnus-mouse-pick-article)
5401 (define-key gnus-summary-mode-map "m" 'gnus-summary-mail-other-window)
5402 (define-key gnus-summary-mode-map "a" 'gnus-summary-post-news)
5403 (define-key gnus-summary-mode-map
5404 "x" 'gnus-summary-remove-lines-marked-as-read)
5405 ; (define-key gnus-summary-mode-map "X" 'gnus-summary-remove-lines-marked-with)
5406 (define-key gnus-summary-mode-map "s" 'gnus-summary-isearch-article)
5407 (define-key gnus-summary-mode-map "t" 'gnus-summary-toggle-header)
5408 (define-key gnus-summary-mode-map "g" 'gnus-summary-show-article)
5409 ; (define-key gnus-summary-mode-map "?" 'gnus-summary-describe-briefly)
5410 (define-key gnus-summary-mode-map "l" 'gnus-summary-goto-last-article)
5411 (define-key gnus-summary-mode-map "\C-c\C-v\C-v" 'gnus-uu-decode-uu-view)
5412 (define-key gnus-summary-mode-map "\C-d" 'gnus-summary-enter-digest-group)
5413 (define-key gnus-summary-mode-map "v" 'gnus-summary-verbose-headers)
5414 (define-key gnus-summary-mode-map "\C-c\C-b" 'gnus-bug)
5417 ;; Sort of orthogonal keymap
5418 (define-prefix-command 'gnus-summary-mark-map)
5419 (define-key gnus-summary-mode-map "M" 'gnus-summary-mark-map)
5420 (define-key gnus-summary-mark-map "t" 'gnus-summary-tick-article-forward)
5421 (define-key gnus-summary-mark-map "!" 'gnus-summary-tick-article-forward)
5422 (define-key gnus-summary-mark-map "d" 'gnus-summary-mark-as-read-forward)
5423 (define-key gnus-summary-mark-map "r" 'gnus-summary-mark-as-read-forward)
5424 (define-key gnus-summary-mark-map "c" 'gnus-summary-clear-mark-forward)
5425 (define-key gnus-summary-mark-map " " 'gnus-summary-clear-mark-forward)
5426 (define-key gnus-summary-mark-map "e" 'gnus-summary-mark-as-expirable)
5427 (define-key gnus-summary-mark-map "x" 'gnus-summary-mark-as-expirable)
5428 (define-key gnus-summary-mark-map "?" 'gnus-summary-mark-as-dormant)
5429 (define-key gnus-summary-mark-map "b" 'gnus-summary-set-bookmark)
5430 (define-key gnus-summary-mark-map "B" 'gnus-summary-remove-bookmark)
5431 (define-key gnus-summary-mark-map "#" 'gnus-summary-mark-as-processable)
5432 (define-key gnus-summary-mark-map "\M-#" 'gnus-summary-unmark-as-processable)
5433 (define-key gnus-summary-mark-map
5434 "\M-r" 'gnus-summary-remove-lines-marked-as-read)
5435 (define-key gnus-summary-mark-map
5436 "\M-\C-r" 'gnus-summary-remove-lines-marked-with)
5437 (define-key gnus-summary-mark-map "D" 'gnus-summary-show-all-dormant)
5438 (define-key gnus-summary-mark-map "\M-D" 'gnus-summary-hide-all-dormant)
5439 (define-key gnus-summary-mark-map "S" 'gnus-summary-show-all-expunged)
5440 (define-key gnus-summary-mark-map "C" 'gnus-summary-catchup)
5441 (define-key gnus-summary-mark-map "H" 'gnus-summary-catchup-to-here)
5442 (define-key gnus-summary-mark-map "\C-c" 'gnus-summary-catchup-all)
5443 (define-key gnus-summary-mark-map
5444 "k" 'gnus-summary-kill-same-subject-and-select)
5445 (define-key gnus-summary-mark-map "K" 'gnus-summary-kill-same-subject)
5447 (define-prefix-command 'gnus-summary-mscore-map)
5448 (define-key gnus-summary-mark-map "V" 'gnus-summary-mscore-map)
5449 (define-key gnus-summary-mscore-map "c" 'gnus-summary-clear-above)
5450 (define-key gnus-summary-mscore-map "u" 'gnus-summary-tick-above)
5451 (define-key gnus-summary-mscore-map "m" 'gnus-summary-mark-above)
5452 (define-key gnus-summary-mscore-map "k" 'gnus-summary-kill-below)
5454 (define-key gnus-summary-mark-map "P" 'gnus-uu-mark-map)
5456 (define-key gnus-summary-mode-map "S" 'gnus-summary-send-map)
5458 (define-prefix-command 'gnus-summary-goto-map)
5459 (define-key gnus-summary-mode-map "G" 'gnus-summary-goto-map)
5460 (define-key gnus-summary-goto-map "n" 'gnus-summary-next-unread-article)
5461 (define-key gnus-summary-goto-map "p" 'gnus-summary-prev-unread-article)
5462 (define-key gnus-summary-goto-map "N" 'gnus-summary-next-article)
5463 (define-key gnus-summary-goto-map "P" 'gnus-summary-prev-article)
5464 (define-key gnus-summary-goto-map "\C-n" 'gnus-summary-next-same-subject)
5465 (define-key gnus-summary-goto-map "\C-p" 'gnus-summary-prev-same-subject)
5466 (define-key gnus-summary-goto-map "\M-n" 'gnus-summary-next-unread-subject)
5467 (define-key gnus-summary-goto-map "\M-p" 'gnus-summary-prev-unread-subject)
5468 (define-key gnus-summary-goto-map "f" 'gnus-summary-first-unread-article)
5469 (define-key gnus-summary-goto-map "b" 'gnus-summary-best-unread-article)
5470 (define-key gnus-summary-goto-map "g" 'gnus-summary-goto-subject)
5471 (define-key gnus-summary-goto-map "l" 'gnus-summary-goto-last-article)
5472 (define-key gnus-summary-goto-map "p" 'gnus-summary-pop-article)
5475 (define-prefix-command 'gnus-summary-thread-map)
5476 (define-key gnus-summary-mode-map "T" 'gnus-summary-thread-map)
5477 (define-key gnus-summary-thread-map "k" 'gnus-summary-kill-thread)
5478 (define-key gnus-summary-thread-map "l" 'gnus-summary-lower-thread)
5479 (define-key gnus-summary-thread-map "i" 'gnus-summary-raise-thread)
5480 (define-key gnus-summary-thread-map "T" 'gnus-summary-toggle-threads)
5481 (define-key gnus-summary-thread-map "s" 'gnus-summary-show-thread)
5482 (define-key gnus-summary-thread-map "S" 'gnus-summary-show-all-threads)
5483 (define-key gnus-summary-thread-map "h" 'gnus-summary-hide-thread)
5484 (define-key gnus-summary-thread-map "H" 'gnus-summary-hide-all-threads)
5485 (define-key gnus-summary-thread-map "n" 'gnus-summary-next-thread)
5486 (define-key gnus-summary-thread-map "p" 'gnus-summary-prev-thread)
5487 (define-key gnus-summary-thread-map "u" 'gnus-summary-up-thread)
5488 (define-key gnus-summary-thread-map "d" 'gnus-summary-down-thread)
5489 (define-key gnus-summary-thread-map "#" 'gnus-uu-mark-thread)
5492 (define-prefix-command 'gnus-summary-exit-map)
5493 (define-key gnus-summary-mode-map "Z" 'gnus-summary-exit-map)
5494 (define-key gnus-summary-exit-map "c" 'gnus-summary-catchup-and-exit)
5495 (define-key gnus-summary-exit-map "C" 'gnus-summary-catchup-all-and-exit)
5496 (define-key gnus-summary-exit-map "E" 'gnus-summary-exit-no-update)
5497 (define-key gnus-summary-exit-map "Q" 'gnus-summary-exit)
5498 (define-key gnus-summary-exit-map "Z" 'gnus-summary-exit)
5499 (define-key gnus-summary-exit-map
5500 "n" 'gnus-summary-catchup-and-goto-next-group)
5501 (define-key gnus-summary-exit-map "R" 'gnus-summary-reselect-current-group)
5502 (define-key gnus-summary-exit-map "G" 'gnus-summary-rescan-group)
5503 (define-key gnus-summary-exit-map "N" 'gnus-summary-next-group)
5504 (define-key gnus-summary-exit-map "P" 'gnus-summary-prev-group)
5507 (define-prefix-command 'gnus-summary-article-map)
5508 (define-key gnus-summary-mode-map "A" 'gnus-summary-article-map)
5509 (define-key gnus-summary-article-map " " 'gnus-summary-next-page)
5510 (define-key gnus-summary-article-map "n" 'gnus-summary-next-page)
5511 (define-key gnus-summary-article-map "\177" 'gnus-summary-prev-page)
5512 (define-key gnus-summary-article-map "p" 'gnus-summary-prev-page)
5513 (define-key gnus-summary-article-map "\r" 'gnus-summary-scroll-up)
5514 (define-key gnus-summary-article-map "<" 'gnus-summary-beginning-of-article)
5515 (define-key gnus-summary-article-map ">" 'gnus-summary-end-of-article)
5516 (define-key gnus-summary-article-map "b" 'gnus-summary-beginning-of-article)
5517 (define-key gnus-summary-article-map "e" 'gnus-summary-end-of-article)
5518 (define-key gnus-summary-article-map "^" 'gnus-summary-refer-parent-article)
5519 (define-key gnus-summary-article-map "r" 'gnus-summary-refer-parent-article)
5520 (define-key gnus-summary-article-map "g" 'gnus-summary-show-article)
5521 (define-key gnus-summary-article-map "s" 'gnus-summary-isearch-article)
5525 (define-prefix-command 'gnus-summary-wash-map)
5526 (define-key gnus-summary-mode-map "W" 'gnus-summary-wash-map)
5528 (define-prefix-command 'gnus-summary-wash-hide-map)
5529 (define-key gnus-summary-wash-map "W" 'gnus-summary-wash-hide-map)
5530 (define-key gnus-summary-wash-hide-map "a" 'gnus-article-hide)
5531 (define-key gnus-summary-wash-hide-map "h" 'gnus-article-hide-headers)
5532 (define-key gnus-summary-wash-hide-map "s" 'gnus-article-hide-signature)
5533 (define-key gnus-summary-wash-hide-map "c" 'gnus-article-hide-citation)
5534 (define-key gnus-summary-wash-hide-map
5535 "\C-c" 'gnus-article-hide-citation-maybe)
5537 (define-prefix-command 'gnus-summary-wash-highlight-map)
5538 (define-key gnus-summary-wash-map "H" 'gnus-summary-wash-highlight-map)
5539 (define-key gnus-summary-wash-highlight-map "a" 'gnus-article-highlight)
5540 (define-key gnus-summary-wash-highlight-map
5541 "h" 'gnus-article-highlight-headers)
5542 (define-key gnus-summary-wash-highlight-map
5543 "c" 'gnus-article-highlight-citation)
5544 (define-key gnus-summary-wash-highlight-map
5545 "s" 'gnus-article-highlight-signature)
5547 (define-prefix-command 'gnus-summary-wash-time-map)
5548 (define-key gnus-summary-wash-map "T" 'gnus-summary-wash-time-map)
5549 (define-key gnus-summary-wash-time-map "z" 'gnus-article-date-ut)
5550 (define-key gnus-summary-wash-time-map "u" 'gnus-article-date-ut)
5551 (define-key gnus-summary-wash-time-map "l" 'gnus-article-date-local)
5552 (define-key gnus-summary-wash-time-map "e" 'gnus-article-date-lapsed)
5554 (define-key gnus-summary-wash-map "b" 'gnus-article-add-buttons)
5555 (define-key gnus-summary-wash-map "o" 'gnus-article-treat-overstrike)
5556 (define-key gnus-summary-wash-map "w" 'gnus-article-word-wrap)
5557 (define-key gnus-summary-wash-map "c" 'gnus-article-remove-cr)
5558 (define-key gnus-summary-wash-map "q" 'gnus-article-de-quoted-unreadable)
5559 (define-key gnus-summary-wash-map "f" 'gnus-article-display-x-face)
5560 (define-key gnus-summary-wash-map "l" 'gnus-summary-stop-page-breaking)
5561 (define-key gnus-summary-wash-map "r" 'gnus-summary-caesar-message)
5562 (define-key gnus-summary-wash-map "t" 'gnus-summary-toggle-header)
5563 (define-key gnus-summary-wash-map "m" 'gnus-summary-toggle-mime)
5566 (define-prefix-command 'gnus-summary-help-map)
5567 (define-key gnus-summary-mode-map "H" 'gnus-summary-help-map)
5568 (define-key gnus-summary-help-map "v" 'gnus-version)
5569 (define-key gnus-summary-help-map "f" 'gnus-summary-fetch-faq)
5570 (define-key gnus-summary-help-map "d" 'gnus-summary-describe-group)
5571 (define-key gnus-summary-help-map "h" 'gnus-summary-describe-briefly)
5572 (define-key gnus-summary-help-map "i" 'gnus-info-find-node)
5575 (define-prefix-command 'gnus-summary-backend-map)
5576 (define-key gnus-summary-mode-map "B" 'gnus-summary-backend-map)
5577 (define-key gnus-summary-backend-map "e" 'gnus-summary-expire-articles)
5578 (define-key gnus-summary-backend-map "\M-\C-e"
5579 'gnus-summary-expire-articles-now)
5580 (define-key gnus-summary-backend-map "\177" 'gnus-summary-delete-article)
5581 (define-key gnus-summary-backend-map "m" 'gnus-summary-move-article)
5582 (define-key gnus-summary-backend-map "r" 'gnus-summary-respool-article)
5583 (define-key gnus-summary-backend-map "w" 'gnus-summary-edit-article)
5584 (define-key gnus-summary-backend-map "c" 'gnus-summary-copy-article)
5585 (define-key gnus-summary-backend-map "q" 'gnus-summary-fancy-query)
5586 (define-key gnus-summary-backend-map "i" 'gnus-summary-import-article)
5589 (define-prefix-command 'gnus-summary-save-map)
5590 (define-key gnus-summary-mode-map "O" 'gnus-summary-save-map)
5591 (define-key gnus-summary-save-map "o" 'gnus-summary-save-article)
5592 (define-key gnus-summary-save-map "m" 'gnus-summary-save-article-mail)
5593 (define-key gnus-summary-save-map "r" 'gnus-summary-save-article-rmail)
5594 (define-key gnus-summary-save-map "f" 'gnus-summary-save-article-file)
5595 (define-key gnus-summary-save-map "h" 'gnus-summary-save-article-folder)
5596 (define-key gnus-summary-save-map "v" 'gnus-summary-save-article-vm)
5597 (define-key gnus-summary-save-map "p" 'gnus-summary-pipe-output)
5598 ; (define-key gnus-summary-save-map "s" 'gnus-soup-add-article)
5600 (define-key gnus-summary-mode-map "X" 'gnus-uu-extract-map)
5602 (define-key gnus-summary-mode-map "\M-&" 'gnus-summary-universal-argument)
5603 ; (define-key gnus-summary-various-map "\C-s" 'gnus-summary-search-article-forward)
5604 ; (define-key gnus-summary-various-map "\C-r" 'gnus-summary-search-article-backward)
5605 ; (define-key gnus-summary-various-map "r" 'gnus-summary-refer-article)
5606 ; (define-key gnus-summary-various-map "&" 'gnus-summary-execute-command)
5607 ; (define-key gnus-summary-various-map "T" 'gnus-summary-toggle-truncation)
5608 ; (define-key gnus-summary-various-map "e" 'gnus-summary-expand-window)
5609 (define-key gnus-summary-article-map "D" 'gnus-summary-enter-digest-group)
5610 ; (define-key gnus-summary-various-map "k" 'gnus-summary-edit-local-kill)
5611 ; (define-key gnus-summary-various-map "K" 'gnus-summary-edit-global-kill)
5613 (define-key gnus-summary-mode-map "V" 'gnus-summary-score-map)
5615 ; (define-prefix-command 'gnus-summary-sort-map)
5616 ; (define-key gnus-summary-various-map "s" 'gnus-summary-sort-map)
5617 ; (define-key gnus-summary-sort-map "n" 'gnus-summary-sort-by-number)
5618 ; (define-key gnus-summary-sort-map "a" 'gnus-summary-sort-by-author)
5619 ; (define-key gnus-summary-sort-map "s" 'gnus-summary-sort-by-subject)
5620 ; (define-key gnus-summary-sort-map "d" 'gnus-summary-sort-by-date)
5621 ; (define-key gnus-summary-sort-map "i" 'gnus-summary-sort-by-score)
5623 (define-key gnus-summary-mode-map "I" 'gnus-summary-increase-score)
5624 (define-key gnus-summary-mode-map "L" 'gnus-summary-lower-score)
5630 (defun gnus-summary-mode (&optional group)
5631 "Major mode for reading articles.
5633 All normal editing commands are switched off.
5634 \\<gnus-summary-mode-map>
5635 Each line in this buffer represents one article. To read an
5636 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
5637 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
5638 respectively.
5640 You can also post articles and send mail from this buffer. To
5641 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
5642 of an article, type `\\[gnus-summary-reply]'.
5644 There are approx. one gazillion commands you can execute in this
5645 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
5647 The following commands are available:
5649 \\{gnus-summary-mode-map}"
5650 (interactive)
5651 (if gnus-visual (gnus-summary-make-menu-bar))
5652 (kill-all-local-variables)
5653 (let ((locals gnus-summary-local-variables))
5654 (while locals
5655 (if (consp (car locals))
5656 (progn
5657 (make-local-variable (car (car locals)))
5658 (set (car (car locals)) (eval (cdr (car locals)))))
5659 (make-local-variable (car locals))
5660 (set (car locals) nil))
5661 (setq locals (cdr locals))))
5662 (gnus-make-thread-indent-array)
5663 (gnus-simplify-mode-line)
5664 (setq major-mode 'gnus-summary-mode)
5665 (setq mode-name "Summary")
5666 (make-local-variable 'minor-mode-alist)
5667 (use-local-map gnus-summary-mode-map)
5668 (buffer-disable-undo (current-buffer))
5669 (setq buffer-read-only t) ;Disable modification
5670 (setq truncate-lines t)
5671 (setq selective-display t)
5672 (setq selective-display-ellipses t) ;Display `...'
5673 (setq buffer-display-table gnus-summary-display-table)
5674 (setq gnus-newsgroup-name group)
5675 (run-hooks 'gnus-summary-mode-hook))
5677 (defun gnus-summary-make-display-table ()
5678 ;; Change the display table. Odd characters have a tendency to mess
5679 ;; up nicely formatted displays - we make all possible glyphs
5680 ;; display only a single character.
5682 ;; We start from the standard display table, if any.
5683 (setq gnus-summary-display-table
5684 (or (copy-sequence standard-display-table)
5685 (make-display-table)))
5686 ;; Nix out all the control chars...
5687 (let ((i 32))
5688 (while (>= (setq i (1- i)) 0)
5689 (aset gnus-summary-display-table i [??])))
5690 ;; ... but not newline and cr, of course. (cr is necessary for the
5691 ;; selective display).
5692 (aset gnus-summary-display-table ?\n nil)
5693 (aset gnus-summary-display-table ?\r nil)
5694 ;; We nix out any glyphs over 126 that are not set already.
5695 (let ((i 256))
5696 (while (>= (setq i (1- i)) 127)
5697 ;; Only modify if the entry is nil.
5698 (or (aref gnus-summary-display-table i)
5699 (aset gnus-summary-display-table i [??])))))
5701 (defun gnus-summary-clear-local-variables ()
5702 (let ((locals gnus-summary-local-variables))
5703 (while locals
5704 (if (consp (car locals))
5705 (and (vectorp (car (car locals)))
5706 (set (car (car locals)) nil))
5707 (and (vectorp (car locals))
5708 (set (car locals) nil)))
5709 (setq locals (cdr locals)))))
5711 ;; Some summary mode macros.
5713 ;; Return a header specified by a NUMBER.
5714 (defun gnus-get-header-by-number (number)
5715 (save-excursion
5716 (set-buffer gnus-summary-buffer)
5717 (or gnus-newsgroup-headers-hashtb-by-number
5718 (gnus-make-headers-hashtable-by-number))
5719 (gnus-gethash (int-to-string number)
5720 gnus-newsgroup-headers-hashtb-by-number)))
5722 ;; Fast version of the function above.
5723 (defmacro gnus-get-header-by-num (number)
5724 (` (gnus-gethash (int-to-string (, number))
5725 gnus-newsgroup-headers-hashtb-by-number)))
5727 (defmacro gnus-summary-search-forward (&optional unread subject backward)
5728 "Search for article forward.
5729 If UNREAD is non-nil, only unread articles are selected.
5730 If SUBJECT is non-nil, the article which has the same subject will be
5731 searched for.
5732 If BACKWARD is non-nil, the search will be performed backwards instead."
5733 (` (gnus-summary-search-subject (, backward) (, unread) (, subject))))
5735 (defmacro gnus-summary-search-backward (&optional unread subject)
5736 "Search for article backward.
5737 If 1st optional argument UNREAD is non-nil, only unread article is selected.
5738 If 2nd optional argument SUBJECT is non-nil, the article which has
5739 the same subject will be searched for."
5740 (` (gnus-summary-search-forward (, unread) (, subject) t)))
5742 (defmacro gnus-summary-article-number (&optional number-or-nil)
5743 "The article number of the article on the current line.
5744 If there isn's an article number here, then we return the current
5745 article number."
5746 (if number-or-nil
5747 '(get-text-property (gnus-point-at-bol) 'gnus-number)
5748 '(or (get-text-property (gnus-point-at-bol) 'gnus-number)
5749 gnus-current-article)))
5751 (defmacro gnus-summary-thread-level ()
5752 "The thread level of the article on the current line."
5753 '(or (get-text-property (gnus-point-at-bol) 'gnus-level)
5756 (defmacro gnus-summary-article-mark ()
5757 "The mark on the current line."
5758 '(get-text-property (gnus-point-at-bol) 'gnus-mark))
5760 (defun gnus-summary-subject-string ()
5761 "Return current subject string or nil if nothing."
5762 (let ((article (gnus-summary-article-number))
5763 header)
5764 (and article
5765 (setq header (gnus-get-header-by-num article))
5766 (vectorp header)
5767 (mail-header-subject header))))
5769 ;; Various summary mode internalish functions.
5771 (defun gnus-mouse-pick-article (e)
5772 (interactive "e")
5773 (mouse-set-point e)
5774 (gnus-summary-next-page nil t))
5776 (defun gnus-summary-setup-buffer (group)
5777 "Initialize summary buffer."
5778 (let ((buffer (concat "*Summary " group "*")))
5779 (if (get-buffer buffer)
5780 (progn
5781 (set-buffer buffer)
5782 (not gnus-newsgroup-begin))
5783 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
5784 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
5785 (gnus-add-current-to-buffer-list)
5786 (gnus-summary-mode group)
5787 (and gnus-carpal (gnus-carpal-setup-buffer 'summary))
5788 (setq gnus-newsgroup-name group)
5789 t)))
5791 (defun gnus-set-global-variables ()
5792 ;; Set the global equivalents of the summary buffer-local variables
5793 ;; to the latest values they had. These reflect the summary buffer
5794 ;; that was in action when the last article was fetched.
5795 (if (eq major-mode 'gnus-summary-mode)
5796 (progn
5797 (setq gnus-summary-buffer (current-buffer))
5798 (let ((name gnus-newsgroup-name)
5799 (marked gnus-newsgroup-marked)
5800 (unread gnus-newsgroup-unreads)
5801 (headers gnus-current-headers)
5802 (score-file gnus-current-score-file))
5803 (save-excursion
5804 (set-buffer gnus-group-buffer)
5805 (setq gnus-newsgroup-name name)
5806 (setq gnus-newsgroup-marked marked)
5807 (setq gnus-newsgroup-unreads unread)
5808 (setq gnus-current-headers headers)
5809 (setq gnus-current-score-file score-file))))))
5811 (defun gnus-summary-insert-dummy-line (sformat subject number)
5812 (if (not sformat)
5813 (setq sformat gnus-summary-dummy-line-format-spec))
5814 (let (b)
5815 (beginning-of-line)
5816 (setq b (point))
5817 (insert (eval sformat))
5818 (add-text-properties
5819 b (1+ b)
5820 (list 'gnus-number number
5821 'gnus-mark gnus-dummy-mark
5822 'gnus-level 0))))
5824 (defvar gnus-thread-indent-array nil)
5825 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
5826 (defun gnus-make-thread-indent-array ()
5827 (let ((n 200))
5828 (if (and gnus-thread-indent-array
5829 (= gnus-thread-indent-level gnus-thread-indent-array-level))
5831 (setq gnus-thread-indent-array (make-vector 201 "")
5832 gnus-thread-indent-array-level gnus-thread-indent-level)
5833 (while (>= n 0)
5834 (aset gnus-thread-indent-array n
5835 (make-string (* n gnus-thread-indent-level) ? ))
5836 (setq n (1- n))))))
5838 (defun gnus-summary-insert-line
5839 (sformat header level current unread replied expirable subject-or-nil
5840 &optional dummy score process)
5841 (or sformat (setq sformat gnus-summary-line-format-spec))
5842 (let* ((indentation (aref gnus-thread-indent-array level))
5843 (lines (mail-header-lines header))
5844 (score (or score gnus-summary-default-score 0))
5845 (score-char
5846 (if (or (null gnus-summary-default-score)
5847 (<= (abs (- score gnus-summary-default-score))
5848 gnus-summary-zcore-fuzz)) ?
5849 (if (< score gnus-summary-default-score)
5850 gnus-score-below-mark gnus-score-over-mark)))
5851 (replied (cond (process gnus-process-mark)
5852 (replied gnus-replied-mark)
5853 (t gnus-unread-mark)))
5854 (from (mail-header-from header))
5855 (name (cond
5856 ((string-match "(.+)" from)
5857 (substring from (1+ (match-beginning 0)) (1- (match-end 0))))
5858 ((string-match "<[^>]+> *$" from)
5859 (let ((beg (match-beginning 0)))
5860 (or (and (string-match "^\"[^\"]*\"" from)
5861 (substring from (1+ (match-beginning 0))
5862 (1- (match-end 0))))
5863 (substring from 0 beg))))
5864 (t from)))
5865 (subject (mail-header-subject header))
5866 (number (mail-header-number header))
5867 (opening-bracket (if dummy ?\< ?\[))
5868 (closing-bracket (if dummy ?\> ?\]))
5869 (buffer-read-only nil)
5870 (b (progn (beginning-of-line) (point))))
5871 (or (numberp lines) (setq lines 0))
5872 (insert (eval sformat))
5873 (add-text-properties
5874 b (1+ b) (list 'gnus-number number
5875 'gnus-mark (or unread gnus-unread-mark)
5876 'gnus-level level))))
5878 (defun gnus-summary-update-line (&optional dont-update)
5879 ;; Update summary line after change.
5880 (or (not gnus-summary-default-score)
5881 gnus-summary-inhibit-highlight
5882 (let ((gnus-summary-inhibit-highlight t)
5883 (article (gnus-summary-article-number)))
5884 (progn
5885 (or dont-update
5886 (if (and gnus-summary-mark-below
5887 (< (gnus-summary-article-score)
5888 gnus-summary-mark-below))
5889 (and (not (memq article gnus-newsgroup-marked))
5890 (not (memq article gnus-newsgroup-dormant))
5891 (memq article gnus-newsgroup-unreads)
5892 (gnus-summary-mark-article-as-read gnus-low-score-mark))
5893 (and (eq (gnus-summary-article-mark) gnus-low-score-mark)
5894 (gnus-summary-mark-article-as-unread gnus-unread-mark))))
5895 (and gnus-visual
5896 (run-hooks 'gnus-summary-update-hook))))))
5898 (defun gnus-summary-update-lines (&optional beg end)
5899 ;; Mark article as read (or not) by taking into account scores.
5900 (let ((beg (or beg (point-min)))
5901 (end (or end (point-max))))
5902 (if (or (not gnus-summary-default-score)
5903 gnus-summary-inhibit-highlight)
5905 (let ((gnus-summary-inhibit-highlight t)
5906 article)
5907 (save-excursion
5908 (set-buffer gnus-summary-buffer)
5909 (goto-char beg)
5910 (beginning-of-line)
5911 (while (and (not (eobp)) (< (point) end))
5912 (if (and gnus-summary-mark-below
5913 (< (or (cdr (assq
5914 (setq article (get-text-property
5915 (point) 'gnus-number))
5916 gnus-newsgroup-scored))
5917 gnus-summary-default-score 0)
5918 gnus-summary-mark-below))
5919 ;; We want to possibly mark it as read...
5920 (and (not (memq article gnus-newsgroup-marked))
5921 (not (memq article gnus-newsgroup-dormant))
5922 (memq article gnus-newsgroup-unreads)
5923 (gnus-summary-mark-article-as-read gnus-low-score-mark))
5924 ;; We want to possibly mark it as unread.
5925 (and (eq (get-text-property (point) 'gnus-mark)
5926 gnus-low-score-mark)
5927 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
5928 ;; Do the visual highlights at the same time.
5929 (and gnus-visual (run-hooks 'gnus-summary-update-hook))
5930 (forward-line 1)))))))
5932 (defvar gnus-tmp-gathered nil)
5934 (defun gnus-summary-number-of-articles-in-thread (thread &optional char)
5935 ;; Sum up all elements (and sub-elements) in a list.
5936 (let* ((number
5937 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
5938 (if (and (consp thread) (cdr thread))
5939 (apply
5940 '+ 1 (mapcar
5941 'gnus-summary-number-of-articles-in-thread
5942 (cdr thread)))
5943 1)))
5944 (if char
5945 (if (> number 1) gnus-not-empty-thread-mark
5946 gnus-empty-thread-mark)
5947 number)))
5949 (defun gnus-summary-read-group
5950 (group &optional show-all no-article kill-buffer)
5951 "Start reading news in newsgroup GROUP.
5952 If SHOW-ALL is non-nil, already read articles are also listed.
5953 If NO-ARTICLE is non-nil, no article is selected initially."
5954 (gnus-message 5 "Retrieving newsgroup: %s..." group)
5955 (let* ((new-group (gnus-summary-setup-buffer group))
5956 (quit-config (gnus-group-quit-config group))
5957 (did-select (and new-group (gnus-select-newsgroup group show-all))))
5958 (cond
5959 ((not new-group)
5960 (gnus-set-global-variables)
5961 (gnus-kill-buffer kill-buffer)
5962 (gnus-configure-windows 'summary 'force)
5963 (gnus-set-mode-line 'summary)
5964 (gnus-summary-position-cursor)
5965 (message "")
5967 ((null did-select)
5968 (and (eq major-mode 'gnus-summary-mode)
5969 (not (equal (current-buffer) kill-buffer))
5970 (progn
5971 (kill-buffer (current-buffer))
5972 (if (not quit-config)
5973 (progn
5974 (set-buffer gnus-group-buffer)
5975 (gnus-group-jump-to-group group)
5976 (gnus-group-next-unread-group 1))
5977 (if (not (buffer-name (car quit-config)))
5978 (gnus-configure-windows 'group 'force)
5979 (set-buffer (car quit-config))
5980 (and (eq major-mode 'gnus-summary-mode)
5981 (gnus-set-global-variables))
5982 (gnus-configure-windows (cdr quit-config))))))
5983 (message "Can't select group")
5984 nil)
5985 ((eq did-select 'quit)
5986 (and (eq major-mode 'gnus-summary-mode)
5987 (not (equal (current-buffer) kill-buffer))
5988 (kill-buffer (current-buffer)))
5989 (gnus-kill-buffer kill-buffer)
5990 (if (not quit-config)
5991 (progn
5992 (set-buffer gnus-group-buffer)
5993 (gnus-group-jump-to-group group)
5994 (gnus-group-next-unread-group 1)
5995 (gnus-configure-windows 'group 'force))
5996 (if (not (buffer-name (car quit-config)))
5997 (gnus-configure-windows 'group 'force)
5998 (set-buffer (car quit-config))
5999 (and (eq major-mode 'gnus-summary-mode)
6000 (gnus-set-global-variables))
6001 (gnus-configure-windows (cdr quit-config))))
6002 (signal 'quit nil))
6004 (gnus-set-global-variables)
6005 ;; Save the active value in effect when the group was entered.
6006 (setq gnus-newsgroup-active
6007 (gnus-copy-sequence
6008 (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
6009 ;; You can change the subjects in this hook.
6010 (run-hooks 'gnus-select-group-hook)
6011 ;; Do score processing.
6012 (and gnus-use-scoring (gnus-possibly-score-headers))
6013 (gnus-update-format-specifications)
6014 ;; Generate the summary buffer.
6015 (gnus-summary-prepare)
6016 (if (zerop (buffer-size))
6017 (cond (gnus-newsgroup-dormant
6018 (gnus-summary-show-all-dormant))
6019 ((and gnus-newsgroup-scored show-all)
6020 (gnus-summary-show-all-expunged))))
6021 ;; Function `gnus-apply-kill-file' must be called in this hook.
6022 (run-hooks 'gnus-apply-kill-hook)
6023 (if (zerop (buffer-size))
6024 (progn
6025 ;; This newsgroup is empty.
6026 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
6027 (gnus-message 6 "No unread news")
6028 (gnus-kill-buffer kill-buffer)
6029 nil)
6030 ;;(save-excursion
6031 ;; (if kill-buffer
6032 ;; (let ((gnus-summary-buffer kill-buffer))
6033 ;; (gnus-configure-windows 'group))))
6034 ;; Hide conversation thread subtrees. We cannot do this in
6035 ;; gnus-summary-prepare-hook since kill processing may not
6036 ;; work with hidden articles.
6037 (and gnus-show-threads
6038 gnus-thread-hide-subtree
6039 (gnus-summary-hide-all-threads))
6040 ;; Show first unread article if requested.
6041 (goto-char (point-min))
6042 (if (and (not no-article)
6043 gnus-auto-select-first
6044 (gnus-summary-first-unread-article))
6046 (gnus-configure-windows 'summary 'force))
6047 (gnus-set-mode-line 'summary)
6048 (gnus-summary-position-cursor)
6049 ;; If in async mode, we send some info to the backend.
6050 (and gnus-newsgroup-async
6051 (setq gnus-newsgroup-threads (nreverse gnus-newsgroup-threads))
6052 (gnus-request-asynchronous
6053 gnus-newsgroup-name
6054 (if (and gnus-asynchronous-article-function
6055 (fboundp gnus-asynchronous-article-function))
6056 (funcall gnus-asynchronous-article-function
6057 gnus-newsgroup-threads)
6058 gnus-newsgroup-threads)))
6059 (gnus-kill-buffer kill-buffer)
6060 (if (not (get-buffer-window gnus-group-buffer))
6062 ;; gotta use windows, because recenter does weird stuff if
6063 ;; the current buffer ain't the displayed window.
6064 (let ((owin (selected-window)))
6065 (select-window (get-buffer-window gnus-group-buffer))
6066 (and (gnus-group-goto-group group)
6067 (recenter))
6068 (select-window owin))))
6069 t))))
6071 (defun gnus-summary-prepare ()
6072 ;; Generate the summary buffer.
6073 (let ((buffer-read-only nil))
6074 (erase-buffer)
6075 (gnus-summary-prepare-threads
6076 (if gnus-show-threads
6077 (gnus-gather-threads
6078 (gnus-sort-threads
6079 (if (and gnus-summary-expunge-below
6080 (not gnus-fetch-old-headers))
6081 (gnus-make-threads-and-expunge)
6082 (gnus-make-threads))))
6083 gnus-newsgroup-headers)
6084 'cull)
6085 (gnus-summary-update-lines)
6086 ;; Create the header hashtb.
6087 (gnus-make-headers-hashtable-by-number)
6088 ;; Call hooks for modifying summary buffer.
6089 ;; Suggested by sven@tde.LTH.Se (Sven Mattisson).
6090 (goto-char (point-min))
6091 (run-hooks 'gnus-summary-prepare-hook)))
6093 (defun gnus-gather-threads (threads)
6094 "Gather threads that have lost their roots."
6095 (if (not gnus-summary-make-false-root)
6096 threads
6097 (let ((hashtb (gnus-make-hashtable 1023))
6098 (prev threads)
6099 (result threads)
6100 subject hthread whole-subject)
6101 (while threads
6102 (setq whole-subject
6103 (setq subject (mail-header-subject (car (car threads)))))
6104 (if gnus-summary-gather-subject-limit
6105 (or (and (numberp gnus-summary-gather-subject-limit)
6106 (> (length subject) gnus-summary-gather-subject-limit)
6107 (setq subject
6108 (substring subject 0
6109 gnus-summary-gather-subject-limit)))
6110 (and (eq 'fuzzy gnus-summary-gather-subject-limit)
6111 (setq subject (gnus-simplify-subject-fuzzy subject))))
6112 (setq subject (gnus-simplify-subject-re subject)))
6113 (if (setq hthread
6114 (gnus-gethash subject hashtb))
6115 (progn
6116 (or (stringp (car (car hthread)))
6117 (setcar hthread (list whole-subject (car hthread))))
6118 (setcdr (car hthread) (nconc (cdr (car hthread))
6119 (list (car threads))))
6120 (setcdr prev (cdr threads))
6121 (setq threads prev))
6122 (gnus-sethash subject threads hashtb))
6123 (setq prev threads)
6124 (setq threads (cdr threads)))
6125 result)))
6127 (defun gnus-make-threads ()
6128 ;; This function takes the dependencies already made by
6129 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go
6130 ;; through the dependencies in the hash table and finds all the
6131 ;; roots. Roots do not refer back to any valid articles.
6132 (gnus-message 6 "Threading...")
6133 (let (roots new-roots)
6134 (and gnus-fetch-old-headers
6135 (eq gnus-headers-retrieved-by 'nov)
6136 (gnus-build-old-threads))
6137 (mapatoms
6138 (lambda (refs)
6139 (if (not (car (symbol-value refs)))
6140 (setq roots (append (cdr (symbol-value refs)) roots))
6141 ;; Ok, these refer back to valid articles, but if
6142 ;; `gnus-thread-ignore-subject' is nil, we have to check that
6143 ;; the root has the same subject as its children. The children
6144 ;; that do not are made into roots and removed from the list
6145 ;; of children.
6146 (or gnus-thread-ignore-subject
6147 (let* ((prev (symbol-value refs))
6148 (subject (gnus-simplify-subject-re
6149 (mail-header-subject (car prev))))
6150 (headers (cdr prev)))
6151 (while headers
6152 (if (not (string= subject
6153 (gnus-simplify-subject-re
6154 (mail-header-subject (car headers)))))
6155 (progn
6156 (setq new-roots (cons (car headers) new-roots))
6157 (setcdr prev (cdr headers)))
6158 (setq prev headers))
6159 (setq headers (cdr headers)))))))
6160 gnus-newsgroup-dependencies)
6162 ;; We enter the new roots into the dependencies structure to
6163 ;; ensure that any possible later thread-regeneration will be
6164 ;; possible.
6165 (let ((r new-roots))
6166 (while r
6167 (gnus-sethash (concat (mail-header-id (car r)) ".boo")
6168 (list nil (car r)) gnus-newsgroup-dependencies)
6169 (setq r (cdr r))))
6171 (setq roots (nconc new-roots roots))
6173 (prog1
6174 (mapcar 'gnus-trim-thread
6175 (apply 'append
6176 (mapcar 'gnus-cut-thread
6177 (mapcar 'gnus-make-sub-thread roots))))
6178 (gnus-message 6 "Threading...done"))))
6181 (defun gnus-make-threads-and-expunge ()
6182 ;; This function takes the dependencies already made by
6183 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go
6184 ;; through the dependencies in the hash table and finds all the
6185 ;; roots. Roots do not refer back to any valid articles.
6186 (gnus-message 6 "Threading...")
6187 (let ((default (or gnus-summary-default-score 0))
6188 (below gnus-summary-expunge-below)
6189 roots article new-roots)
6190 (and gnus-fetch-old-headers
6191 (eq gnus-headers-retrieved-by 'nov)
6192 (gnus-build-old-threads))
6193 (mapatoms
6194 (lambda (refs)
6195 (if (not (car (symbol-value refs)))
6196 ;; These articles do not refer back to any other articles -
6197 ;; they are roots.
6198 (let ((headers (cdr (symbol-value refs))))
6199 ;; We weed out the low-scored articles.
6200 (while headers
6201 (if (not (< (or (cdr (assq (mail-header-number (car headers))
6202 gnus-newsgroup-scored)) default)
6203 below))
6204 ;; It is over.
6205 (setq roots (cons (car headers) roots))
6206 ;; It is below, so we mark it as read.
6207 (setq gnus-newsgroup-unreads
6208 (delq (mail-header-number (car headers))
6209 gnus-newsgroup-unreads))
6210 (setq gnus-newsgroup-reads
6211 (cons (cons (mail-header-number (car headers))
6212 gnus-low-score-mark)
6213 gnus-newsgroup-reads)))
6214 (setq headers (cdr headers))))
6215 ;; Ok, these refer back to valid articles, but if
6216 ;; `gnus-thread-ignore-subject' is nil, we have to check that
6217 ;; the root has the same subject as its children. The children
6218 ;; that do not are made into roots and removed from the list
6219 ;; of children.
6220 (or gnus-thread-ignore-subject
6221 (let* ((prev (symbol-value refs))
6222 (subject (gnus-simplify-subject-re
6223 (mail-header-subject (car prev))))
6224 (headers (cdr prev)))
6225 (while headers
6226 (if (not (string= subject
6227 (gnus-simplify-subject-re
6228 (mail-header-subject (car headers)))))
6229 (progn
6230 (if (not (< (or (cdr (assq (mail-header-number
6231 (car headers))
6232 gnus-newsgroup-scored))
6233 default) below))
6234 (setq new-roots (cons (car headers) new-roots))
6235 (setq gnus-newsgroup-unreads
6236 (delq (mail-header-number (car headers))
6237 gnus-newsgroup-unreads))
6238 (setq gnus-newsgroup-reads
6239 (cons (cons (mail-header-number (car headers))
6240 gnus-low-score-mark)
6241 gnus-newsgroup-reads)))
6242 (setcdr prev (cdr headers)))
6243 (setq prev headers))
6244 (setq headers (cdr headers)))))
6245 ;; If this article is expunged, some of the children might be
6246 ;; roots.
6247 (if (< (or (cdr (assq (mail-header-number (car (symbol-value refs)))
6248 gnus-newsgroup-scored)) default)
6249 below)
6250 (let* ((prev (symbol-value refs))
6251 (headers (cdr prev)))
6252 (while headers
6253 (setq article (mail-header-number (car headers)))
6254 (if (not (< (or (cdr (assq article gnus-newsgroup-scored))
6255 default) below))
6256 (progn (setq new-roots (cons (car headers) new-roots))
6257 (setq prev headers))
6258 (setq gnus-newsgroup-unreads
6259 (delq article gnus-newsgroup-unreads))
6260 (setq gnus-newsgroup-reads
6261 (cons (cons article gnus-low-score-mark)
6262 gnus-newsgroup-reads))
6263 (setcdr prev (cdr headers)))
6264 (setq headers (cdr headers))))
6265 ;; It was not expunged, but we look at expunged children.
6266 (let* ((prev (symbol-value refs))
6267 (headers (cdr prev))
6268 article)
6269 (while headers
6270 (setq article (mail-header-number (car headers)))
6271 (if (not (< (or (cdr (assq article gnus-newsgroup-scored))
6272 default) below))
6273 (setq prev headers)
6274 (setq gnus-newsgroup-unreads
6275 (delq article gnus-newsgroup-unreads))
6276 (setq gnus-newsgroup-reads
6277 (cons (cons article gnus-low-score-mark)
6278 gnus-newsgroup-reads))
6279 (setcdr prev (cdr headers)))
6280 (setq headers (cdr headers)))))))
6281 gnus-newsgroup-dependencies)
6283 ;; We enter the new roots into the dependencies structure to
6284 ;; ensure that any possible later thread-regeneration will be
6285 ;; possible.
6286 (let ((r new-roots))
6287 (while r
6288 (gnus-sethash (concat (mail-header-id (car r)) ".boo")
6289 (list nil (car r)) gnus-newsgroup-dependencies)
6290 (setq r (cdr r))))
6292 (setq roots (nconc new-roots roots))
6294 (prog1
6295 (mapcar 'gnus-trim-thread
6296 (apply 'append
6297 (mapcar 'gnus-cut-thread
6298 (mapcar 'gnus-make-sub-thread roots))))
6299 (gnus-message 6 "Threading...done"))))
6302 (defun gnus-cut-thread (thread)
6303 ;; Remove leaf dormant or ancient articles from THREAD.
6304 (let ((head (car thread))
6305 (tail (apply 'append (mapcar 'gnus-cut-thread (cdr thread)))))
6306 (if (and (null tail)
6307 (let ((number (mail-header-number head)))
6308 (or (memq number gnus-newsgroup-ancient)
6309 (memq number gnus-newsgroup-dormant)
6310 (and gnus-summary-expunge-below
6311 (eq gnus-fetch-old-headers 'some)
6312 (< (or (cdr (assq number gnus-newsgroup-scored))
6313 gnus-summary-default-score 0)
6314 gnus-summary-expunge-below)
6315 (progn
6316 (setq gnus-newsgroup-unreads
6317 (delq number gnus-newsgroup-unreads))
6318 (setq gnus-newsgroup-reads
6319 (cons (cons number gnus-low-score-mark)
6320 gnus-newsgroup-reads))
6321 t)))))
6323 (list (cons head tail)))))
6325 (defun gnus-trim-thread (thread)
6326 ;; Remove root ancient articles with only one child from THREAD.
6327 (if (and (eq gnus-fetch-old-headers 'some)
6328 (memq (mail-header-number (car thread)) gnus-newsgroup-ancient)
6329 (= (length thread) 2))
6330 (gnus-trim-thread (nth 1 thread))
6331 thread))
6333 (defun gnus-make-sub-thread (root)
6334 ;; This function makes a sub-tree for a node in the tree.
6335 (let ((children (reverse (cdr (gnus-gethash (downcase (mail-header-id root))
6336 gnus-newsgroup-dependencies)))))
6337 (cons root (mapcar 'gnus-make-sub-thread children))))
6339 (defun gnus-build-old-threads ()
6340 ;; Look at all the articles that refer back to old articles, and
6341 ;; fetch the headers for the articles that aren't there. This will
6342 ;; build complete threads - if the roots haven't been expired by the
6343 ;; server, that is.
6344 (let (id heads)
6345 (mapatoms
6346 (lambda (refs)
6347 (if (not (car (symbol-value refs)))
6348 (progn
6349 (setq heads (cdr (symbol-value refs)))
6350 (while heads
6351 (if (not (memq (mail-header-number (car heads))
6352 gnus-newsgroup-dormant))
6353 (progn
6354 (setq id (symbol-name refs))
6355 (while (and (setq id (gnus-build-get-header id))
6356 (not (car (gnus-gethash
6357 id gnus-newsgroup-dependencies)))))
6358 (setq heads nil))
6359 (setq heads (cdr heads)))))))
6360 gnus-newsgroup-dependencies)))
6362 (defun gnus-build-get-header (id)
6363 ;; Look through the buffer of NOV lines and find the header to
6364 ;; ID. Enter this line into the dependencies hash table, and return
6365 ;; the id of the parent article (if any).
6366 (let ((deps gnus-newsgroup-dependencies)
6367 found header)
6368 (prog1
6369 (save-excursion
6370 (set-buffer nntp-server-buffer)
6371 (goto-char (point-min))
6372 (while (and (not found) (search-forward id nil t))
6373 (beginning-of-line)
6374 (setq found (looking-at
6375 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
6376 (regexp-quote id))))
6377 (or found (beginning-of-line 2)))
6378 (if found
6379 (let (ref)
6380 (beginning-of-line)
6381 (and
6382 (setq header (gnus-nov-parse-line
6383 (read (current-buffer)) deps))
6384 (setq ref (mail-header-references header))
6385 (string-match "\\(<[^>]+>\\) *$" ref)
6386 (substring ref (match-beginning 1) (match-end 1))))))
6387 (and header
6388 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers)
6389 gnus-newsgroup-ancient (cons (mail-header-number header)
6390 gnus-newsgroup-ancient))))))
6392 ;; Re-build the thread containing ID.
6393 (defun gnus-rebuild-thread (id)
6394 (let ((dep gnus-newsgroup-dependencies)
6395 (buffer-read-only nil)
6396 parent headers refs thread art)
6397 (while (and id (setq headers
6398 (car (setq art (gnus-gethash (downcase id) dep)))))
6399 (setq parent art)
6400 (setq id (and (setq refs (mail-header-references headers))
6401 (string-match "\\(<[^>]+>\\) *$" refs)
6402 (substring refs (match-beginning 1) (match-end 1)))))
6403 (setq thread (gnus-make-sub-thread (car parent)))
6404 (gnus-rebuild-remove-articles thread)
6405 (let ((beg (point)))
6406 (gnus-summary-prepare-threads (list thread))
6407 (gnus-summary-update-lines beg (point)))))
6409 ;; Delete all lines in the summary buffer that correspond to articles
6410 ;; in this thread.
6411 (defun gnus-rebuild-remove-articles (thread)
6412 (and (gnus-summary-goto-subject (mail-header-number (car thread)))
6413 (gnus-delete-line))
6414 (mapcar (lambda (th) (gnus-rebuild-remove-articles th)) (cdr thread)))
6416 (defun gnus-sort-threads (threads)
6417 ;; Sort threads as specified in `gnus-thread-sort-functions'.
6418 (let ((fun gnus-thread-sort-functions))
6419 (while fun
6420 (gnus-message 6 "Sorting with %S..." fun)
6421 (setq threads (sort threads (car fun))
6422 fun (cdr fun))))
6423 (if gnus-thread-sort-functions
6424 (gnus-message 6 "Sorting...done"))
6425 threads)
6427 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
6428 (defmacro gnus-thread-header (thread)
6429 ;; Return header of first article in THREAD.
6430 ;; Note that THREAD must never, evr be anything else than a variable -
6431 ;; using some other form will lead to serious barfage.
6432 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
6433 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
6434 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
6435 (vector thread) 2))
6437 (defun gnus-thread-sort-by-number (h1 h2)
6438 "Sort threads by root article number."
6439 (< (mail-header-number (gnus-thread-header h1))
6440 (mail-header-number (gnus-thread-header h2))))
6442 (defun gnus-thread-sort-by-author (h1 h2)
6443 "Sort threads by root author."
6444 (string-lessp
6445 (let ((extract (funcall
6446 gnus-extract-address-components
6447 (mail-header-from (gnus-thread-header h1)))))
6448 (or (car extract) (cdr extract)))
6449 (let ((extract (funcall
6450 gnus-extract-address-components
6451 (mail-header-from (gnus-thread-header h2)))))
6452 (or (car extract) (cdr extract)))))
6454 (defun gnus-thread-sort-by-subject (h1 h2)
6455 "Sort threads by root subject."
6456 (string-lessp
6457 (downcase (gnus-simplify-subject-re
6458 (mail-header-subject (gnus-thread-header h1))))
6459 (downcase (gnus-simplify-subject-re
6460 (mail-header-subject (gnus-thread-header h2))))))
6462 (defun gnus-thread-sort-by-date (h1 h2)
6463 "Sort threads by root article date."
6464 (string-lessp
6465 (gnus-sortable-date (mail-header-date (gnus-thread-header h1)))
6466 (gnus-sortable-date (mail-header-date (gnus-thread-header h2)))))
6468 (defun gnus-thread-sort-by-score (h1 h2)
6469 "Sort threads by root article score.
6470 Unscored articles will be counted as having a score of zero."
6471 (> (or (cdr (assq (mail-header-number (gnus-thread-header h1))
6472 gnus-newsgroup-scored))
6473 gnus-summary-default-score 0)
6474 (or (cdr (assq (mail-header-number (gnus-thread-header h2))
6475 gnus-newsgroup-scored))
6476 gnus-summary-default-score 0)))
6478 (defun gnus-thread-sort-by-total-score (h1 h2)
6479 "Sort threads by the sum of all scores in the thread.
6480 Unscored articles will be counted as having a score of zero."
6481 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
6483 (defun gnus-thread-total-score (thread)
6484 ;; This function find the total score of THREAD.
6485 (if (consp thread)
6486 (if (stringp (car thread))
6487 (apply gnus-thread-score-function 0
6488 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
6489 (gnus-thread-total-score-1 thread))
6490 (gnus-thread-total-score-1 (list thread))))
6492 (defun gnus-thread-total-score-1 (root)
6493 ;; This function find the total score of the thread below ROOT.
6494 (setq root (car root))
6495 (apply gnus-thread-score-function
6496 (or (cdr (assq (mail-header-number root) gnus-newsgroup-scored))
6497 gnus-summary-default-score 0)
6498 (mapcar 'gnus-thread-total-score
6499 (cdr (gnus-gethash (downcase (mail-header-id root))
6500 gnus-newsgroup-dependencies)))))
6502 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
6503 (defvar gnus-tmp-prev-subject "")
6505 (defun gnus-summary-prepare-threads (threads &optional cull)
6506 "Prepare summary buffer from THREADS and indentation LEVEL.
6507 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
6508 or a straight list of headers."
6509 (gnus-message 5 "Generating summary...")
6510 (let ((level 0)
6511 thread header number subject stack state gnus-tmp-gathered)
6512 (if (vectorp (car threads))
6513 ;; If this is a straight (sic) list of headers, then a
6514 ;; threaded summary display isn't required, so we just create
6515 ;; an unthreaded one.
6516 (gnus-summary-prepare-unthreaded threads cull)
6518 ;; Do the threaded display.
6520 (while (or threads stack)
6522 (if threads
6523 ;; If there are some threads, we do them before the
6524 ;; threads on the stack.
6525 (setq thread threads
6526 header (car (car thread)))
6527 ;; There were no current threads, so we pop something off
6528 ;; the stack.
6529 (setq state (car stack)
6530 level (car state)
6531 thread (cdr state)
6532 stack (cdr stack)
6533 header (car (car thread))))
6535 (if (stringp header)
6536 (progn
6537 ;; The header is a dummy root.
6538 (cond
6539 ((eq gnus-summary-make-false-root 'adopt)
6540 ;; We let the first article adopt the rest.
6541 (let ((th (car (cdr (car thread)))))
6542 (while (cdr th)
6543 (setq th (cdr th)))
6544 (setcdr th (cdr (cdr (car thread))))
6545 (setq gnus-tmp-gathered
6546 (nconc (mapcar
6547 (lambda (h) (mail-header-number (car h)))
6548 (cdr (cdr (car thread))))
6549 gnus-tmp-gathered))
6550 (setcdr (cdr (car thread)) nil))
6551 (setq level -1))
6552 ((eq gnus-summary-make-false-root 'empty)
6553 ;; We print adopted articles with empty subject fields.
6554 (setq gnus-tmp-gathered
6555 (nconc (mapcar
6556 (lambda (h) (mail-header-number (car h)))
6557 (cdr (cdr (car thread))))
6558 gnus-tmp-gathered))
6559 (setq level -1))
6560 ((eq gnus-summary-make-false-root 'dummy)
6561 ;; We output a dummy root.
6562 (gnus-summary-insert-dummy-line
6563 nil header (mail-header-number
6564 (car (car (cdr (car thread)))))))
6566 ;; We do not make a root for the gathered
6567 ;; sub-threads at all.
6568 (setq level -1))))
6570 (setq number (mail-header-number header)
6571 subject (mail-header-subject header))
6573 ;; Do the async thing.
6574 (and gnus-newsgroup-async
6575 (setq gnus-newsgroup-threads
6576 (cons (cons number (mail-header-lines header))
6577 gnus-newsgroup-threads)))
6579 ;; We may have to root out some bad articles...
6580 (and cull
6581 (= level 0)
6582 (cond ((and (memq (setq number (mail-header-number header))
6583 gnus-newsgroup-dormant)
6584 (null thread))
6585 (setq header nil))
6586 ((and gnus-summary-expunge-below
6587 (< (or (cdr (assq number gnus-newsgroup-scored))
6588 gnus-summary-default-score 0)
6589 gnus-summary-expunge-below))
6590 (setq header nil)
6591 (setq gnus-newsgroup-unreads
6592 (delq number gnus-newsgroup-unreads))
6593 (setq gnus-newsgroup-reads
6594 (cons (cons number gnus-low-score-mark)
6595 gnus-newsgroup-reads)))))
6597 (and
6598 header
6599 (progn
6600 (inline
6601 (gnus-summary-insert-line
6602 nil header level nil
6603 (cond
6604 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
6605 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
6606 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
6607 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
6608 (t (or (cdr (assq number gnus-newsgroup-reads))
6609 gnus-ancient-mark)))
6610 (memq number gnus-newsgroup-replied)
6611 (memq number gnus-newsgroup-expirable)
6612 (cond
6613 ((and gnus-thread-ignore-subject
6614 (not (string=
6615 (gnus-simplify-subject-re gnus-tmp-prev-subject)
6616 (gnus-simplify-subject-re subject))))
6617 subject)
6618 ((zerop level)
6619 (if (and (eq gnus-summary-make-false-root 'empty)
6620 (memq number gnus-tmp-gathered))
6621 gnus-summary-same-subject
6622 subject))
6623 (t gnus-summary-same-subject))
6624 (and (eq gnus-summary-make-false-root 'adopt)
6625 (memq number gnus-tmp-gathered))
6626 (cdr (assq number gnus-newsgroup-scored))
6627 (memq number gnus-newsgroup-processable))
6629 (setq gnus-tmp-prev-subject subject)))))
6631 (if (nth 1 thread)
6632 (setq stack (cons (cons (max 0 level) (nthcdr 1 thread)) stack)))
6633 (setq level (1+ level))
6634 (setq threads (cdr (car thread))))))
6635 (gnus-message 5 "Generating summary...done"))
6639 (defun gnus-summary-prepare-unthreaded (headers &optional cull)
6640 (let (header number)
6642 ;; Do the async thing, if that is required.
6643 (if gnus-newsgroup-async
6644 (setq gnus-newsgroup-threads
6645 (mapcar (lambda (h)
6646 (cons (mail-header-number h) (mail-header-lines h)))
6647 headers)))
6649 (while headers
6650 (setq header (car headers)
6651 headers (cdr headers)
6652 number (mail-header-number header))
6654 ;; We may have to root out some bad articles...
6655 (cond
6656 ((and cull
6657 (memq (setq number (mail-header-number header))
6658 gnus-newsgroup-dormant)))
6659 ((and cull gnus-summary-expunge-below
6660 (< (or (cdr (assq number gnus-newsgroup-scored))
6661 gnus-summary-default-score 0)
6662 gnus-summary-expunge-below))
6663 (setq gnus-newsgroup-unreads
6664 (delq number gnus-newsgroup-unreads))
6665 (setq gnus-newsgroup-reads
6666 (cons (cons number gnus-low-score-mark)
6667 gnus-newsgroup-reads)))
6669 (gnus-summary-insert-line
6670 nil header 0 nil
6671 (cond ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
6672 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
6673 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
6674 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
6675 (t (or (cdr (assq number gnus-newsgroup-reads))
6676 gnus-ancient-mark)))
6677 (memq number gnus-newsgroup-replied)
6678 (memq number gnus-newsgroup-expirable)
6679 (mail-header-subject header) nil
6680 (cdr (assq number gnus-newsgroup-scored))
6681 (memq number gnus-newsgroup-processable)))))))
6683 (defun gnus-select-newsgroup (group &optional read-all)
6684 "Select newsgroup GROUP.
6685 If READ-ALL is non-nil, all articles in the group are selected."
6686 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
6687 (info (nth 2 entry))
6688 articles)
6690 (or (gnus-check-server
6691 (setq gnus-current-select-method (gnus-find-method-for-group group)))
6692 (error "Couldn't open server"))
6694 (or (and entry (not (eq (car entry) t))) ; Either it's active...
6695 (gnus-activate-group group) ; Or we can activate it...
6696 (progn ; Or we bug out.
6697 (kill-buffer (current-buffer))
6698 (error "Couldn't request group %s: %s"
6699 group (gnus-status-message group))))
6701 (setq gnus-newsgroup-name group)
6702 (setq gnus-newsgroup-unselected nil)
6703 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
6705 (and gnus-asynchronous
6706 (gnus-check-backend-function
6707 'request-asynchronous gnus-newsgroup-name)
6708 (setq gnus-newsgroup-async
6709 (gnus-request-asynchronous gnus-newsgroup-name)))
6711 (setq articles (gnus-articles-to-read group read-all))
6713 (cond
6714 ((null articles)
6715 (gnus-message 3 "Couldn't select newsgroup")
6716 'quit)
6717 ((eq articles 0) nil)
6719 ;; Init the dependencies hash table.
6720 (setq gnus-newsgroup-dependencies
6721 (gnus-make-hashtable (length articles)))
6722 ;; Retrieve the headers and read them in.
6723 (gnus-message 5 "Fetching headers...")
6724 (setq gnus-newsgroup-headers
6725 (if (eq 'nov (setq gnus-headers-retrieved-by
6726 ;; This is a naughty hack. To get the
6727 ;; retrieval of old headers to work, we
6728 ;; set `nntp-nov-gap' to nil (locally),
6729 ;; and then just retrieve the headers.
6730 ;; Mucho magic.
6731 (if gnus-fetch-old-headers
6732 (let (nntp-nov-gap)
6733 (gnus-retrieve-headers
6734 (if (not (eq 1 (car articles)))
6735 (cons 1 articles)
6736 articles)
6737 gnus-newsgroup-name))
6738 (gnus-retrieve-headers
6739 articles gnus-newsgroup-name))))
6740 (progn
6741 (gnus-get-newsgroup-headers-xover articles))
6742 ;; If we were to fetch old headers, but the backend didn't
6743 ;; support XOVER, then it is possible we fetched one article
6744 ;; that we shouldn't have. If that's the case, we remove it.
6745 (if (or (not gnus-fetch-old-headers)
6746 (eq 1 (car articles)))
6748 (save-excursion
6749 (set-buffer nntp-server-buffer)
6750 (goto-char (point-min))
6751 (and
6752 (looking-at "[0-9]+[ \t]+1[ \t]") ; This is not a NOV line.
6753 (delete-region ; So we delete this head.
6754 (point)
6755 (search-forward "\n.\n" nil t)))))
6756 (gnus-get-newsgroup-headers)))
6757 (gnus-message 5 "Fetching headers...done")
6758 ;; Remove canceled articles from the list of unread articles.
6759 (setq gnus-newsgroup-unreads
6760 (gnus-set-sorted-intersection
6761 gnus-newsgroup-unreads
6762 (mapcar (lambda (headers) (mail-header-number headers))
6763 gnus-newsgroup-headers)))
6764 ;; Adjust and set lists of article marks.
6765 (and info
6766 (let (marked)
6767 (gnus-adjust-marked-articles info)
6768 (setq gnus-newsgroup-marked
6769 (copy-sequence
6770 (cdr (assq 'tick (setq marked (nth 3 info))))))
6771 (setq gnus-newsgroup-replied
6772 (copy-sequence (cdr (assq 'reply marked))))
6773 (setq gnus-newsgroup-expirable
6774 (copy-sequence (cdr (assq 'expire marked))))
6775 (setq gnus-newsgroup-killed
6776 (copy-sequence (cdr (assq 'killed marked))))
6777 (setq gnus-newsgroup-bookmarks
6778 (copy-sequence (cdr (assq 'bookmark marked))))
6779 (setq gnus-newsgroup-dormant
6780 (copy-sequence (cdr (assq 'dormant marked))))
6781 (setq gnus-newsgroup-scored
6782 (copy-sequence (cdr (assq 'score marked))))
6783 (setq gnus-newsgroup-processable nil)))
6784 ;; Check whether auto-expire is to be done in this group.
6785 (setq gnus-newsgroup-auto-expire
6786 (or (and (stringp gnus-auto-expirable-newsgroups)
6787 (string-match gnus-auto-expirable-newsgroups group))
6788 (memq 'auto-expire (nth 5 info))))
6789 ;; First and last article in this newsgroup.
6790 (and gnus-newsgroup-headers
6791 (setq gnus-newsgroup-begin
6792 (mail-header-number (car gnus-newsgroup-headers)))
6793 (setq gnus-newsgroup-end
6794 (mail-header-number
6795 (gnus-last-element gnus-newsgroup-headers))))
6796 (setq gnus-reffed-article-number -1)
6797 ;; GROUP is successfully selected.
6798 (or gnus-newsgroup-headers t)))))
6800 (defun gnus-articles-to-read (group read-all)
6801 ;; Find out what articles the user wants to read.
6802 (let* ((articles
6803 ;; Select all articles if `read-all' is non-nil, or if all the
6804 ;; unread articles are dormant articles.
6805 (if (or read-all
6806 (= (length gnus-newsgroup-unreads)
6807 (length gnus-newsgroup-dormant)))
6808 (gnus-uncompress-range
6809 (gnus-gethash group gnus-active-hashtb))
6810 gnus-newsgroup-unreads))
6811 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
6812 (scored (length scored-list))
6813 (number (length articles))
6814 (marked (+ (length gnus-newsgroup-marked)
6815 (length gnus-newsgroup-dormant)))
6816 (select
6817 (cond
6818 ((numberp read-all)
6819 read-all)
6821 (condition-case ()
6822 (cond ((and (or (<= scored marked)
6823 (= scored number))
6824 (numberp gnus-large-newsgroup)
6825 (> number gnus-large-newsgroup))
6826 (let ((input
6827 (read-string
6828 (format
6829 "How many articles from %s (default %d): "
6830 gnus-newsgroup-name number))))
6831 (if (string-match "^[ \t]*$" input)
6832 number input)))
6833 ((and (> scored marked) (< scored number))
6834 (let ((input
6835 (read-string
6836 (format
6837 "%s %s (%d scored, %d total): "
6838 "How many articles from"
6839 group scored number))))
6840 (if (string-match "^[ \t]*$" input)
6841 number input)))
6842 (t number))
6843 (quit nil))))))
6844 (setq select (if (stringp select) (string-to-number select) select))
6845 (if (or (null select) (zerop select))
6846 select
6847 (if (and (not (zerop scored)) (<= (abs select) scored))
6848 (progn
6849 (setq articles (sort scored-list '<))
6850 (setq number (length articles)))
6851 (setq articles (copy-sequence articles)))
6853 (if (< (abs select) number)
6854 (if (< select 0)
6855 ;; Select the N oldest articles.
6856 (setcdr (nthcdr (1- (abs select)) articles) nil)
6857 ;; Select the N most recent articles.
6858 (setq articles (nthcdr (- number select) articles))))
6859 (setq gnus-newsgroup-unselected
6860 (gnus-sorted-intersection
6861 gnus-newsgroup-unreads
6862 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
6863 articles)))
6865 (defun gnus-killed-articles (killed articles)
6866 (let (out)
6867 (while articles
6868 (if (inline (gnus-member-of-range (car articles) killed))
6869 (setq out (cons (car articles) out)))
6870 (setq articles (cdr articles)))
6871 out))
6873 (defun gnus-adjust-marked-articles (info &optional active)
6874 "Remove all marked articles that are no longer legal."
6875 (let ((marked-lists (nth 3 info))
6876 (active (or active (gnus-gethash (car info) gnus-active-hashtb)))
6877 m prev)
6878 ;; There are many types of marked articles.
6879 (while marked-lists
6880 (setq m (cdr (setq prev (car marked-lists))))
6881 (cond ((or (eq 'tick (car prev)) (eq 'dormant (car prev)))
6882 ;; Make sure that all ticked articles are a subset of the
6883 ;; unread/unselected articles.
6884 ;;(while m
6885 ;; (if (or (memq (car m) gnus-newsgroup-unreads)
6886 ;; (memq (car m) gnus-newsgroup-unselected))
6887 ;; (setq prev m)
6888 ;; (setcdr prev (cdr m)))
6889 ;; (setq m (cdr m)))
6891 ((eq 'score (car prev))
6892 ;; Scored articles should be a subset of
6893 ;; unread/unselected articles.
6894 (while m
6895 (if (or (memq (car (car m)) gnus-newsgroup-unreads)
6896 (memq (car (car m)) gnus-newsgroup-unreads))
6897 (setq prev m)
6898 (setcdr prev (cdr m)))
6899 (setq m (cdr m))))
6900 ((eq 'bookmark (car prev))
6901 ;; Bookmarks should be a subset of active articles.
6902 (while m
6903 (if (< (car (car m)) (car active))
6904 (setcdr prev (cdr m))
6905 (setq prev m))
6906 (setq m (cdr m))))
6907 ((eq 'killed (car prev))
6908 ;; Articles that have been through the kill process are
6909 ;; to be a subset of active articles.
6910 (while (and m (< (or (and (numberp (car m)) (car m))
6911 (cdr (car m)))
6912 (car active)))
6913 (setcdr prev (cdr m))
6914 (setq m (cdr m)))
6915 (if (and m (< (or (and (numberp (car m)) (car m))
6916 (car (car m)))
6917 (car active)))
6918 (setcar (if (numberp (car m)) m (car m)) (car active))))
6919 ((or (eq 'reply (car prev)) (eq 'expire (car prev)))
6920 ;; The replied and expirable articles have to be articles
6921 ;; that are active.
6922 (while m
6923 (if (< (car m) (car active))
6924 (setcdr prev (cdr m))
6925 (setq prev m))
6926 (setq m (cdr m)))))
6927 (setq marked-lists (cdr marked-lists)))
6928 ;; Remove all lists that are empty.
6929 (setq marked-lists (nth 3 info))
6930 (if marked-lists
6931 (progn
6932 (while (= 1 (length (car marked-lists)))
6933 (setq marked-lists (cdr marked-lists)))
6934 (setq m (cdr (setq prev marked-lists)))
6935 (while m
6936 (if (= 1 (length (car m)))
6937 (setcdr prev (cdr m))
6938 (setq prev m))
6939 (setq m (cdr m)))
6940 (setcar (nthcdr 3 info) marked-lists)))
6941 ;; Finally, if there are no marked lists at all left, and if there
6942 ;; are no elements after the lists in the info list, we just chop
6943 ;; the info list off before the marked lists.
6944 (and (null marked-lists)
6945 (not (nthcdr 4 info))
6946 (setcdr (nthcdr 2 info) nil)))
6947 info)
6949 (defun gnus-set-marked-articles
6950 (info ticked replied expirable killed dormant bookmark score)
6951 "Enter the various lists of marked articles into the newsgroup info list."
6952 (let (newmarked)
6953 (and ticked (setq newmarked (cons (cons 'tick ticked) nil)))
6954 (and replied (setq newmarked (cons (cons 'reply replied) newmarked)))
6955 (and expirable (setq newmarked (cons (cons 'expire expirable)
6956 newmarked)))
6957 (and killed (setq newmarked (cons (cons 'killed killed) newmarked)))
6958 (and dormant (setq newmarked (cons (cons 'dormant dormant) newmarked)))
6959 (and bookmark (setq newmarked (cons (cons 'bookmark bookmark)
6960 newmarked)))
6961 (and score (setq newmarked (cons (cons 'score score) newmarked)))
6962 (if (nthcdr 3 info)
6963 (progn
6964 (setcar (nthcdr 3 info) newmarked)
6965 (and (not newmarked)
6966 (not (nthcdr 4 info))
6967 (setcdr (nthcdr 2 info) nil)))
6968 (if newmarked
6969 (setcdr (nthcdr 2 info) (list newmarked))))))
6971 (defun gnus-add-marked-articles (group type articles &optional info force)
6972 ;; Add ARTICLES of TYPE to the info of GROUP.
6973 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
6974 ;; add, but replace marked articles of TYPE with ARTICLES.
6975 (let ((info (or info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
6976 marked m)
6977 (or (not info)
6978 (and (not (setq marked (nthcdr 3 info)))
6979 (setcdr (nthcdr 2 info) (list (list (cons type articles)))))
6980 (and (not (setq m (assq type (car marked))))
6981 (setcar marked (cons (cons type articles) (car marked))))
6982 (if force
6983 (setcdr m articles)
6984 (nconc m articles)))))
6986 (defun gnus-set-mode-line (where)
6987 "This function sets the mode line of the article or summary buffers.
6988 If WHERE is `summary', the summary mode line format will be used."
6989 (if (memq where gnus-updated-mode-lines)
6990 (let (mode-string)
6991 (save-excursion
6992 (set-buffer gnus-summary-buffer)
6993 (let* ((mformat (if (eq where 'article)
6994 gnus-article-mode-line-format-spec
6995 gnus-summary-mode-line-format-spec))
6996 (buffer-name (if (eq where 'article)
6997 (buffer-name
6998 (get-buffer gnus-article-buffer))
6999 (buffer-name)))
7000 (group-name gnus-newsgroup-name)
7001 (article-number (or gnus-current-article 0))
7002 (unread (- (length gnus-newsgroup-unreads)
7003 (length gnus-newsgroup-dormant)))
7004 (unread-and-unticked
7005 (- unread (length gnus-newsgroup-marked)))
7006 (unselected (length gnus-newsgroup-unselected))
7007 (unread-and-unselected
7008 (cond ((and (zerop unread-and-unticked)
7009 (zerop unselected)) "")
7010 ((zerop unselected)
7011 (format "{%d more}" unread-and-unticked))
7012 (t (format "{%d(+%d) more}"
7013 unread-and-unticked unselected))))
7014 (subject
7015 (if gnus-current-headers
7016 (mail-header-subject gnus-current-headers) ""))
7017 (max-len (and gnus-mode-non-string-length
7018 (- (frame-width) gnus-mode-non-string-length)))
7019 header);; passed as argument to any user-format-funcs
7020 (setq mode-string (eval mformat))
7021 (or (numberp max-len)
7022 (setq max-len (length mode-string)))
7023 (if (< max-len 4) (setq max-len 4))
7024 (if (> (length mode-string) max-len)
7025 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
7026 ;; function `substring' might cut on a middle
7027 ;; of multi-octet character.
7028 (setq mode-string
7029 (concat (gnus-truncate-string mode-string (- max-len 3))
7030 "...")))
7031 (setq mode-string (format (format "%%-%ds" max-len)
7032 mode-string))))
7033 (setq mode-line-buffer-identification mode-string)
7034 (set-buffer-modified-p t))))
7036 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
7037 "Go through the HEADERS list and add all Xrefs to a hash table.
7038 The resulting hash table is returned, or nil if no Xrefs were found."
7039 (let* ((from-method (gnus-find-method-for-group from-newsgroup))
7040 (prefix (if (and
7041 (gnus-group-foreign-p from-newsgroup)
7042 (not (memq 'virtual
7043 (assoc (symbol-name (car from-method))
7044 gnus-valid-select-methods))))
7045 (gnus-group-real-prefix from-newsgroup)))
7046 (xref-hashtb (make-vector 63 0))
7047 start group entry number xrefs header)
7048 (while headers
7049 (setq header (car headers))
7050 (if (and (setq xrefs (mail-header-xref header))
7051 (not (memq (mail-header-number header) unreads)))
7052 (progn
7053 (setq start 0)
7054 (while (string-match "\\([^ ]+\\):\\([0-9]+\\)" xrefs start)
7055 (setq start (match-end 0))
7056 (setq group (concat prefix (substring xrefs (match-beginning 1)
7057 (match-end 1))))
7058 (setq number
7059 (string-to-int (substring xrefs (match-beginning 2)
7060 (match-end 2))))
7061 (if (setq entry (gnus-gethash group xref-hashtb))
7062 (setcdr entry (cons number (cdr entry)))
7063 (gnus-sethash group (cons number nil) xref-hashtb)))))
7064 (setq headers (cdr headers)))
7065 (if start xref-hashtb nil)))
7067 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads expirable)
7068 "Look through all the headers and mark the Xrefs as read."
7069 (let ((virtual (memq 'virtual
7070 (assoc (symbol-name (car (gnus-find-method-for-group
7071 from-newsgroup)))
7072 gnus-valid-select-methods)))
7073 name entry info xref-hashtb idlist method
7074 nth4)
7075 (save-excursion
7076 (set-buffer gnus-group-buffer)
7077 (if (setq xref-hashtb
7078 (gnus-create-xref-hashtb from-newsgroup headers unreads))
7079 (mapatoms
7080 (lambda (group)
7081 (if (string= from-newsgroup (setq name (symbol-name group)))
7083 (setq idlist (symbol-value group))
7084 ;; Dead groups are not updated.
7085 (if (and (prog1
7086 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
7087 info (nth 2 entry))
7088 (if (stringp (setq nth4 (nth 4 info)))
7089 (setq nth4 (gnus-server-to-method nth4))))
7090 ;; Only do the xrefs if the group has the same
7091 ;; select method as the group we have just read.
7092 (or (gnus-methods-equal-p
7093 nth4 (gnus-find-method-for-group from-newsgroup))
7094 virtual
7095 (equal nth4
7096 (setq method (gnus-find-method-for-group
7097 from-newsgroup)))
7098 (and (equal (car nth4) (car method))
7099 (equal (nth 1 nth4) (nth 1 method))))
7100 gnus-use-cross-reference
7101 (or (not (eq gnus-use-cross-reference t))
7102 virtual
7103 ;; Only do cross-references on subscribed
7104 ;; groups, if that is what is wanted.
7105 (<= (nth 1 info) gnus-level-subscribed)))
7106 (gnus-group-make-articles-read name idlist expirable))))
7107 xref-hashtb)))))
7109 (defun gnus-group-make-articles-read (group articles expirable)
7110 (let* ((num 0)
7111 (entry (gnus-gethash group gnus-newsrc-hashtb))
7112 (info (nth 2 entry))
7113 (active (gnus-gethash group gnus-active-hashtb))
7114 exps expirable range)
7115 ;; First peel off all illegal article numbers.
7116 (if active
7117 (let ((ids articles)
7118 (ticked (cdr (assq 'tick (nth 3 info))))
7119 (dormant (cdr (assq 'dormant (nth 3 info))))
7120 id first)
7121 (setq exps nil)
7122 (while ids
7123 (setq id (car ids))
7124 (if (and first (> id (cdr active)))
7125 (progn
7126 ;; We'll end up in this situation in one particular
7127 ;; obscure situation. If you re-scan a group and get
7128 ;; a new article that is cross-posted to a different
7129 ;; group that has not been re-scanned, you might get
7130 ;; crossposted article that has a higher number than
7131 ;; Gnus believes possible. So we re-activate this
7132 ;; group as well. This might mean doing the
7133 ;; crossposting thingy will *increase* the number
7134 ;; of articles in some groups. Tsk, tsk.
7135 (setq active (or (gnus-activate-group group) active))))
7136 (if (or (> id (cdr active))
7137 (< id (car active))
7138 (memq id ticked)
7139 (memq id dormant))
7140 (setq articles (delq id articles)))
7141 (and (memq id expirable)
7142 (setq exps (cons id exps)))
7143 (setq ids (cdr ids)))))
7144 ;; Update expirable articles.
7145 (gnus-add-marked-articles nil 'expirable exps info)
7146 (and active
7147 (null (nth 2 info))
7148 (> (car active) 1)
7149 (setcar (nthcdr 2 info) (cons 1 (1- (car active)))))
7150 (setcar (nthcdr 2 info)
7151 (setq range
7152 (gnus-add-to-range
7153 (nth 2 info)
7154 (setq articles (sort articles '<)))))
7155 ;; Then we have to re-compute how many unread
7156 ;; articles there are in this group.
7157 (if active
7158 (progn
7159 (cond
7160 ((not range)
7161 (setq num (- (1+ (cdr active)) (car active))))
7162 ((not (listp (cdr range)))
7163 (setq num (- (cdr active) (- (1+ (cdr range))
7164 (car range)))))
7166 (while range
7167 (if (numberp (car range))
7168 (setq num (1+ num))
7169 (setq num (+ num (- (1+ (cdr (car range)))
7170 (car (car range))))))
7171 (setq range (cdr range)))
7172 (setq num (- (cdr active) num))))
7173 ;; Update the number of unread articles.
7174 (setcar
7175 entry
7176 (max 0 (- num
7177 (length (cdr (assq 'tick (nth 3 info))))
7178 (length
7179 (cdr (assq 'dormant (nth 3 info)))))))
7180 ;; Update the group buffer.
7181 (gnus-group-update-group group t)))))
7183 (defun gnus-methods-equal-p (m1 m2)
7184 (let ((m1 (or m1 gnus-select-method))
7185 (m2 (or m2 gnus-select-method)))
7186 (or (equal m1 m2)
7187 (and (eq (car m1) (car m2))
7188 (or (not (memq 'address (assoc (symbol-name (car m1))
7189 gnus-valid-select-methods)))
7190 (equal (nth 1 m1) (nth 1 m2)))))))
7192 (defsubst gnus-header-value ()
7193 (buffer-substring (match-end 0) (gnus-point-at-eol)))
7195 (defvar gnus-newsgroup-none-id 0)
7197 (defun gnus-get-newsgroup-headers ()
7198 (setq gnus-article-internal-prepare-hook nil)
7199 (let ((cur nntp-server-buffer)
7200 (dependencies gnus-newsgroup-dependencies)
7201 headers id dep end ref)
7202 (save-excursion
7203 (set-buffer nntp-server-buffer)
7204 ;; Allow the user to mangle the headers before parsing them.
7205 (run-hooks 'gnus-parse-headers-hook)
7206 (goto-char (point-min))
7207 ;; Search to the beginning of the next header. Error messages
7208 ;; do not begin with 2 or 3.
7209 (while (re-search-forward "^[23][0-9]+ " nil t)
7210 (let ((header (make-vector 9 nil))
7211 (case-fold-search t)
7212 (p (point))
7213 in-reply-to)
7214 (setq id nil
7215 ref nil)
7216 (mail-header-set-number header (read cur))
7217 ;; This implementation of this function, with nine
7218 ;; search-forwards instead of the one re-search-forward and
7219 ;; a case (which basically was the old function) is actually
7220 ;; about twice as fast, even though it looks messier. You
7221 ;; can't have everything, I guess. Speed and elegance
7222 ;; doesn't always come hand in hand.
7223 (save-restriction
7224 (narrow-to-region (point) (or (save-excursion
7225 (search-forward "\n.\n" nil t))
7226 (point)))
7227 (if (search-forward "\nfrom: " nil t)
7228 (mail-header-set-from header (gnus-header-value))
7229 (mail-header-set-from header "(nobody)"))
7230 (goto-char p)
7231 (if (search-forward "\nsubject: " nil t)
7232 (mail-header-set-subject header (gnus-header-value))
7233 (mail-header-set-subject header "(none)"))
7234 (goto-char p)
7235 (and (search-forward "\nxref: " nil t)
7236 (mail-header-set-xref header (gnus-header-value)))
7237 (goto-char p)
7238 (or (numberp (and (search-forward "\nlines: " nil t)
7239 (mail-header-set-lines header (read cur))))
7240 (mail-header-set-lines header 0))
7241 (goto-char p)
7242 (and (search-forward "\ndate: " nil t)
7243 (mail-header-set-date header (gnus-header-value)))
7244 (goto-char p)
7245 (if (search-forward "\nmessage-id: " nil t)
7246 (mail-header-set-id header (setq id (gnus-header-value)))
7247 ;; If there was no message-id, we just fake one to make
7248 ;; subsequent routines simpler.
7249 (mail-header-set-id
7250 header
7251 (setq id (concat "none+"
7252 (int-to-string
7253 (setq gnus-newsgroup-none-id
7254 (1+ gnus-newsgroup-none-id)))))))
7255 (goto-char p)
7256 (if (search-forward "\nreferences: " nil t)
7257 (progn
7258 (mail-header-set-references header (gnus-header-value))
7259 (setq end (match-end 0))
7260 (save-excursion
7261 (setq ref
7262 (downcase
7263 (buffer-substring
7264 (progn
7265 (end-of-line)
7266 (search-backward ">" end t)
7267 (1+ (point)))
7268 (progn
7269 (search-backward "<" end t)
7270 (point)))))))
7271 ;; Get the references from the in-reply-to header if there
7272 ;; ware no references and the in-reply-to header looks
7273 ;; promising.
7274 (if (and (search-forward "\nin-reply-to: " nil t)
7275 (setq in-reply-to (gnus-header-value))
7276 (string-match "<[^>]+>" in-reply-to))
7277 (progn
7278 (mail-header-set-references
7279 header
7280 (setq ref (substring in-reply-to (match-beginning 0)
7281 (match-end 0))))
7282 (setq ref (downcase ref)))
7283 (setq ref "none")))
7284 ;; We do some threading while we read the headers. The
7285 ;; message-id and the last reference are both entered into
7286 ;; the same hash table. Some tippy-toeing around has to be
7287 ;; done in case an article has arrived before the article
7288 ;; which it refers to.
7289 (if (boundp (setq dep (intern (downcase id) dependencies)))
7290 (if (car (symbol-value dep))
7291 ;; An article with this Message-ID has already
7292 ;; been seen, so we ignore this one, except we add
7293 ;; any additional Xrefs (in case the two articles
7294 ;; came from different servers.
7295 (progn
7296 (mail-header-set-xref
7297 (car (symbol-value dep))
7298 (concat (or (mail-header-xref
7299 (car (symbol-value dep))) "")
7300 (or (mail-header-xref header) "")))
7301 (setq header nil))
7302 (setcar (symbol-value dep) header))
7303 (set dep (list header)))
7304 (if header
7305 (progn
7306 (if (boundp (setq dep (intern ref dependencies)))
7307 (setcdr (symbol-value dep)
7308 (cons header (cdr (symbol-value dep))))
7309 (set dep (list nil header)))
7310 (setq headers (cons header headers))))
7311 (goto-char (point-max))))))
7312 (nreverse headers)))
7314 ;; The following macros and functions were written by Felix Lee
7315 ;; <flee@cse.psu.edu>.
7317 (defmacro gnus-nov-read-integer ()
7318 '(prog1
7319 (if (= (following-char) ?\t)
7321 (let ((num (condition-case nil (read buffer) (error nil))))
7322 (if (numberp num) num 0)))
7323 (or (eobp) (forward-char 1))))
7325 (defmacro gnus-nov-skip-field ()
7326 '(search-forward "\t" eol 'move))
7328 (defmacro gnus-nov-field ()
7329 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
7331 ;; Goes through the xover lines and returns a list of vectors
7332 (defun gnus-get-newsgroup-headers-xover (sequence)
7333 "Parse the news overview data in the server buffer, and return a
7334 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
7335 ;; Get the Xref when the users reads the articles since most/some
7336 ;; NNTP servers do not include Xrefs when using XOVER.
7337 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
7338 (let ((cur nntp-server-buffer)
7339 (dependencies gnus-newsgroup-dependencies)
7340 number headers header)
7341 (save-excursion
7342 (set-buffer nntp-server-buffer)
7343 ;; Allow the user to mangle the headers before parsing them.
7344 (run-hooks 'gnus-parse-headers-hook)
7345 (goto-char (point-min))
7346 (while (and sequence (not (eobp)))
7347 (setq number (read cur))
7348 (while (and sequence (< (car sequence) number))
7349 (setq sequence (cdr sequence)))
7350 (and sequence
7351 (eq number (car sequence))
7352 (progn
7353 (setq sequence (cdr sequence))
7354 (if (setq header
7355 (inline (gnus-nov-parse-line number dependencies)))
7356 (setq headers (cons header headers)))))
7357 (forward-line 1))
7358 (setq headers (nreverse headers)))
7359 headers))
7361 ;; This function has to be called with point after the article number
7362 ;; on the beginning of the line.
7363 (defun gnus-nov-parse-line (number dependencies)
7364 (let ((none 0)
7365 (eol (gnus-point-at-eol))
7366 (buffer (current-buffer))
7367 header ref id dep)
7369 ;; overview: [num subject from date id refs chars lines misc]
7370 (narrow-to-region (point) eol)
7371 (or (eobp) (forward-char))
7373 (condition-case nil
7374 (setq header
7375 (vector
7376 number ; number
7377 (gnus-nov-field) ; subject
7378 (gnus-nov-field) ; from
7379 (gnus-nov-field) ; date
7380 (setq id (or (gnus-nov-field)
7381 (concat "none+"
7382 (int-to-string
7383 (setq none (1+ none)))))) ; id
7384 (progn
7385 (save-excursion
7386 (let ((beg (point)))
7387 (search-forward "\t" eol)
7388 (if (search-backward ">" beg t)
7389 (setq ref
7390 (downcase
7391 (buffer-substring
7392 (1+ (point))
7393 (progn
7394 (search-backward "<" beg t)
7395 (point)))))
7396 (setq ref nil))))
7397 (gnus-nov-field)) ; refs
7398 (gnus-nov-read-integer) ; chars
7399 (gnus-nov-read-integer) ; lines
7400 (if (= (following-char) ?\n)
7402 (gnus-nov-field)) ; misc
7404 (error (progn
7405 (ding)
7406 (message "Strange nov line.")
7407 (setq header nil)
7408 (goto-char eol))))
7410 (widen)
7412 ;; We build the thread tree.
7413 (and header
7414 (if (boundp (setq dep (intern (downcase id) dependencies)))
7415 (if (car (symbol-value dep))
7416 ;; An article with this Message-ID has already been seen,
7417 ;; so we ignore this one, except we add any additional
7418 ;; Xrefs (in case the two articles came from different
7419 ;; servers.
7420 (progn
7421 (mail-header-set-xref
7422 (car (symbol-value dep))
7423 (concat (or (mail-header-xref (car (symbol-value dep))) "")
7424 (or (mail-header-xref header) "")))
7425 (setq header nil))
7426 (setcar (symbol-value dep) header))
7427 (set dep (list header))))
7428 (if header
7429 (progn
7430 (if (boundp (setq dep (intern (or ref "none")
7431 dependencies)))
7432 (setcdr (symbol-value dep)
7433 (cons header (cdr (symbol-value dep))))
7434 (set dep (list nil header)))))
7435 header))
7437 (defun gnus-article-get-xrefs ()
7438 "Fill in the Xref value in `gnus-current-headers', if necessary.
7439 This is meant to be called in `gnus-article-internal-prepare-hook'."
7440 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
7441 gnus-current-headers)))
7442 (or (not gnus-use-cross-reference)
7443 (not headers)
7444 (and (mail-header-xref headers)
7445 (not (string= (mail-header-xref headers) "")))
7446 (let ((case-fold-search t)
7447 xref)
7448 (save-restriction
7449 (gnus-narrow-to-headers)
7450 (goto-char (point-min))
7451 (if (or (and (eq (downcase (following-char)) ?x)
7452 (looking-at "Xref:"))
7453 (search-forward "\nXref:" nil t))
7454 (progn
7455 (goto-char (1+ (match-end 0)))
7456 (setq xref (buffer-substring (point)
7457 (progn (end-of-line) (point))))
7458 (mail-header-set-xref headers xref))))))))
7460 (defalias 'gnus-find-header-by-number 'gnus-get-header-by-number)
7461 (make-obsolete 'gnus-find-header-by-number 'gnus-get-header-by-number)
7463 (defun gnus-make-headers-hashtable-by-number ()
7464 "Make hashtable for the variable gnus-newsgroup-headers by number."
7465 (save-excursion
7466 (set-buffer gnus-summary-buffer)
7467 (let ((headers gnus-newsgroup-headers)
7468 header)
7469 (setq gnus-newsgroup-headers-hashtb-by-number
7470 (gnus-make-hashtable (length headers)))
7471 (while headers
7472 (setq header (car headers))
7473 (gnus-sethash (int-to-string (mail-header-number header))
7474 header gnus-newsgroup-headers-hashtb-by-number)
7475 (setq headers (cdr headers))))))
7477 (defun gnus-more-header-backward ()
7478 "Find new header backward."
7479 (let ((first (car (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
7480 (artnum gnus-newsgroup-begin)
7481 (header nil))
7482 (while (and (not header)
7483 (> artnum first))
7484 (setq artnum (1- artnum))
7485 (setq header (gnus-read-header artnum)))
7486 header))
7488 (defun gnus-more-header-forward (&optional backward)
7489 "Find new header forward.
7490 If BACKWARD, find new header backward instead."
7491 (if backward
7492 (gnus-more-header-backward)
7493 (let ((last (cdr (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
7494 (artnum gnus-newsgroup-end)
7495 (header nil))
7496 (while (and (not header)
7497 (< artnum last))
7498 (setq artnum (1+ artnum))
7499 (setq header (gnus-read-header artnum)))
7500 header)))
7502 (defun gnus-extend-newsgroup (header &optional backward)
7503 "Extend newsgroup selection with HEADER.
7504 Optional argument BACKWARD means extend toward backward."
7505 (if header
7506 (let ((artnum (mail-header-number header)))
7507 (setq gnus-newsgroup-headers
7508 (if backward
7509 (cons header gnus-newsgroup-headers)
7510 (nconc gnus-newsgroup-headers (list header))))
7511 (setq gnus-newsgroup-unselected
7512 (delq artnum gnus-newsgroup-unselected))
7513 (setq gnus-newsgroup-begin (min gnus-newsgroup-begin artnum))
7514 (setq gnus-newsgroup-end (max gnus-newsgroup-end artnum)))))
7516 (defun gnus-summary-work-articles (n)
7517 "Return a list of articles to be worked upon. The prefix argument,
7518 the list of process marked articles, and the current article will be
7519 taken into consideration."
7520 (let (articles)
7521 (if (and n (numberp n))
7522 (let ((backward (< n 0))
7523 (n (abs n)))
7524 (save-excursion
7525 (while (and (> n 0)
7526 (setq articles (cons (gnus-summary-article-number)
7527 articles))
7528 (gnus-summary-search-forward nil nil backward))
7529 (setq n (1- n))))
7530 (sort articles (function <)))
7531 (or (reverse gnus-newsgroup-processable)
7532 (list (gnus-summary-article-number))))))
7534 (defun gnus-summary-search-group (&optional backward use-level)
7535 "Search for next unread newsgroup.
7536 If optional argument BACKWARD is non-nil, search backward instead."
7537 (save-excursion
7538 (set-buffer gnus-group-buffer)
7539 (if (gnus-group-search-forward
7540 backward nil (if use-level (gnus-group-group-level) nil))
7541 (gnus-group-group-name))))
7543 (defun gnus-summary-best-group (&optional exclude-group)
7544 "Find the name of the best unread group.
7545 If EXCLUDE-GROUP, do not go to this group."
7546 (save-excursion
7547 (set-buffer gnus-group-buffer)
7548 (save-excursion
7549 (gnus-group-best-unread-group exclude-group))))
7551 (defun gnus-subject-equal (s1 s2)
7552 (cond
7553 ((null gnus-summary-gather-subject-limit)
7554 (equal (gnus-simplify-subject-re s1)
7555 (gnus-simplify-subject-re s2)))
7556 ((eq gnus-summary-gather-subject-limit 'fuzzy)
7557 (equal (gnus-simplify-subject-fuzzy s1)
7558 (gnus-simplify-subject-fuzzy s2)))
7559 ((numberp gnus-summary-gather-subject-limit)
7560 (equal (gnus-limit-string s1 gnus-summary-gather-subject-limit)
7561 (gnus-limit-string s2 gnus-summary-gather-subject-limit)))
7563 (equal s1 s2))))
7565 (defun gnus-summary-search-subject (&optional backward unread subject)
7566 "Search for article forward.
7567 If BACKWARD is non-nil, search backward.
7568 If UNREAD is non-nil, only unread articles are selected.
7569 If SUBJECT is non-nil, the article which has the same subject will be
7570 searched for."
7571 (let ((func (if backward 'previous-single-property-change
7572 'next-single-property-change))
7573 (beg (point))
7574 (did t)
7575 pos psubject)
7576 (beginning-of-line)
7577 (and gnus-summary-check-current unread
7578 (eq (get-text-property (point) 'gnus-mark) gnus-unread-mark)
7579 (setq did nil))
7580 (if (not did)
7582 (forward-char (if backward (if (bobp) 0 -1) (if (eobp) 0 1)))
7583 (while
7584 (and
7585 (setq pos (funcall func (point) 'gnus-number))
7586 (goto-char (if backward (1- pos) pos))
7587 (setq did
7588 (not (and
7589 (or (not unread)
7590 (eq (get-text-property (point) 'gnus-mark)
7591 gnus-unread-mark))
7592 (or (not subject)
7593 (and (setq psubject
7594 (inline (gnus-summary-subject-string)))
7595 (inline
7596 (gnus-subject-equal subject psubject)))))))
7597 (if backward (if (bobp) nil (forward-char -1) t)
7598 (if (eobp) nil (forward-char 1) t)))))
7599 (if did
7600 (progn (goto-char beg) nil)
7601 (prog1
7602 (get-text-property (point) 'gnus-number)
7603 (gnus-summary-show-thread)
7604 (gnus-summary-position-cursor)))))
7606 (defun gnus-summary-pseudo-article ()
7607 "The thread level of the article on the current line."
7608 (get-text-property (gnus-point-at-bol) 'gnus-pseudo))
7610 (defalias 'gnus-summary-score 'gnus-summary-article-score)
7611 (make-obsolete 'gnus-summary-score 'gnus-summary-article-score)
7612 (defun gnus-summary-article-score ()
7613 "Return current article score."
7614 (or (cdr (assq (gnus-summary-article-number) gnus-newsgroup-scored))
7615 gnus-summary-default-score 0))
7617 (defun gnus-summary-recenter ()
7618 "Center point in the summary window.
7619 If `gnus-auto-center-summary' is nil, or the article buffer isn't
7620 displayed, no centering will be performed."
7621 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
7622 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
7623 (let* ((top (cond ((< (window-height) 4) 0)
7624 ((< (window-height) 7) 1)
7625 (t 2)))
7626 (height (1- (window-height)))
7627 (bottom (save-excursion (goto-char (point-max))
7628 (forward-line (- height))
7629 (point)))
7630 (window (get-buffer-window (current-buffer))))
7631 (and
7632 ;; The user has to want it,
7633 gnus-auto-center-summary
7634 ;; the article buffer must be displayed,
7635 (get-buffer-window gnus-article-buffer)
7636 ;; Set the window start to either `bottom', which is the biggest
7637 ;; possible valid number, or the second line from the top,
7638 ;; whichever is the least.
7639 (set-window-start
7640 window (min bottom (save-excursion (forward-line (- top)) (point)))))))
7642 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
7643 (defun gnus-short-group-name (group &optional levels)
7644 "Collapse GROUP name LEVELS."
7645 (let* ((name "") (foreign "") (depth -1) (skip 1)
7646 (levels (or levels
7647 (progn
7648 (while (string-match "\\." group skip)
7649 (setq skip (match-end 0)
7650 depth (+ depth 1)))
7651 depth))))
7652 (if (string-match ":" group)
7653 (setq foreign (substring group 0 (match-end 0))
7654 group (substring group (match-end 0))))
7655 (while group
7656 (if (and (string-match "\\." group) (> levels 0))
7657 (setq name (concat name (substring group 0 1))
7658 group (substring group (match-end 0))
7659 levels (- levels 1)
7660 name (concat name "."))
7661 (setq name (concat foreign name group)
7662 group nil)))
7663 name))
7665 (defun gnus-summary-jump-to-group (newsgroup)
7666 "Move point to NEWSGROUP in group mode buffer."
7667 ;; Keep update point of group mode buffer if visible.
7668 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
7669 (save-window-excursion
7670 ;; Take care of tree window mode.
7671 (if (get-buffer-window gnus-group-buffer)
7672 (pop-to-buffer gnus-group-buffer))
7673 (gnus-group-jump-to-group newsgroup))
7674 (save-excursion
7675 ;; Take care of tree window mode.
7676 (if (get-buffer-window gnus-group-buffer)
7677 (pop-to-buffer gnus-group-buffer)
7678 (set-buffer gnus-group-buffer))
7679 (gnus-group-jump-to-group newsgroup))))
7681 ;; This function returns a list of article numbers based on the
7682 ;; difference between the ranges of read articles in this group and
7683 ;; the range of active articles.
7684 (defun gnus-list-of-unread-articles (group)
7685 (let* ((read (nth 2 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
7686 (active (gnus-gethash group gnus-active-hashtb))
7687 (last (cdr active))
7688 first nlast unread)
7689 ;; If none are read, then all are unread.
7690 (if (not read)
7691 (setq first (car active))
7692 ;; If the range of read articles is a single range, then the
7693 ;; first unread article is the article after the last read
7694 ;; article. Sounds logical, doesn't it?
7695 (if (not (listp (cdr read)))
7696 (setq first (1+ (cdr read)))
7697 ;; `read' is a list of ranges.
7698 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
7699 (car (car read)))) 1)
7700 (setq first 1))
7701 (while read
7702 (if first
7703 (while (< first nlast)
7704 (setq unread (cons first unread))
7705 (setq first (1+ first))))
7706 (setq first (1+ (if (atom (car read)) (car read) (cdr (car read)))))
7707 (setq nlast (if (atom (car (cdr read)))
7708 (car (cdr read))
7709 (car (car (cdr read)))))
7710 (setq read (cdr read)))))
7711 ;; And add the last unread articles.
7712 (while (<= first last)
7713 (setq unread (cons first unread))
7714 (setq first (1+ first)))
7715 ;; Return the list of unread articles.
7716 (nreverse unread)))
7718 (defun gnus-list-of-read-articles (group)
7719 (let ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
7720 (active (gnus-gethash group gnus-active-hashtb)))
7721 (and info active
7722 (gnus-sorted-complement
7723 (gnus-uncompress-range active)
7724 (gnus-list-of-unread-articles group)))))
7726 ;; Various summary commands
7728 (defun gnus-summary-universal-argument ()
7729 "Perform any operation on all articles marked with the process mark."
7730 (interactive)
7731 (gnus-set-global-variables)
7732 (let ((articles (reverse gnus-newsgroup-processable))
7733 func)
7734 (or articles (error "No articles marked"))
7735 (or (setq func (key-binding (read-key-sequence "C-c C-u")))
7736 (error "Undefined key"))
7737 (while articles
7738 (gnus-summary-goto-subject (car articles))
7739 (command-execute func)
7740 (gnus-summary-remove-process-mark (car articles))
7741 (setq articles (cdr articles)))))
7743 (defun gnus-summary-toggle-truncation (&optional arg)
7744 "Toggle truncation of summary lines.
7745 With arg, turn line truncation on iff arg is positive."
7746 (interactive "P")
7747 (setq truncate-lines
7748 (if (null arg) (not truncate-lines)
7749 (> (prefix-numeric-value arg) 0)))
7750 (redraw-display))
7752 (defun gnus-summary-reselect-current-group (&optional all)
7753 "Once exit and then reselect the current newsgroup.
7754 The prefix argument ALL means to select all articles."
7755 (interactive "P")
7756 (gnus-set-global-variables)
7757 (let ((current-subject (gnus-summary-article-number))
7758 (group gnus-newsgroup-name))
7759 (setq gnus-newsgroup-begin nil)
7760 (gnus-summary-exit t)
7761 ;; We have to adjust the point of group mode buffer because the
7762 ;; current point was moved to the next unread newsgroup by
7763 ;; exiting.
7764 (gnus-summary-jump-to-group group)
7765 (gnus-group-read-group all t)
7766 (gnus-summary-goto-subject current-subject)))
7768 (defun gnus-summary-rescan-group (&optional all)
7769 "Exit the newsgroup, ask for new articles, and select the newsgroup."
7770 (interactive "P")
7771 (gnus-set-global-variables)
7772 ;; Fix by Ilja Weis <kult@uni-paderborn.de>.
7773 (let ((group gnus-newsgroup-name))
7774 (gnus-summary-exit)
7775 (gnus-summary-jump-to-group group)
7776 (save-excursion
7777 (set-buffer gnus-group-buffer)
7778 (gnus-group-get-new-news-this-group 1))
7779 (gnus-summary-jump-to-group group)
7780 (gnus-group-read-group all)))
7782 (defun gnus-summary-update-info ()
7783 (let* ((group gnus-newsgroup-name))
7784 (if gnus-newsgroup-kill-headers
7785 (setq gnus-newsgroup-killed
7786 (gnus-compress-sequence
7787 (nconc
7788 (gnus-set-sorted-intersection
7789 (gnus-uncompress-range gnus-newsgroup-killed)
7790 (setq gnus-newsgroup-unselected
7791 (sort gnus-newsgroup-unselected '<)))
7792 (setq gnus-newsgroup-unreads
7793 (sort gnus-newsgroup-unreads '<))) t)))
7794 (or (listp (cdr gnus-newsgroup-killed))
7795 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
7796 (let ((headers gnus-newsgroup-headers))
7797 (gnus-close-group group)
7798 (run-hooks 'gnus-exit-group-hook)
7799 (gnus-update-read-articles
7800 group gnus-newsgroup-unreads gnus-newsgroup-unselected
7801 gnus-newsgroup-marked
7802 t gnus-newsgroup-replied gnus-newsgroup-expirable
7803 gnus-newsgroup-killed gnus-newsgroup-dormant
7804 gnus-newsgroup-bookmarks
7805 (and gnus-save-score gnus-newsgroup-scored))
7806 (and gnus-use-cross-reference
7807 (gnus-mark-xrefs-as-read
7808 group headers gnus-newsgroup-unreads gnus-newsgroup-expirable))
7809 ;; Do adaptive scoring, and possibly save score files.
7810 (and gnus-newsgroup-adaptive
7811 (gnus-score-adaptive))
7812 (and gnus-use-scoring
7813 (fboundp 'gnus-score-save)
7814 (funcall 'gnus-score-save))
7815 ;; Do not switch windows but change the buffer to work.
7816 (set-buffer gnus-group-buffer)
7817 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
7818 (gnus-group-update-group group)))))
7820 (defun gnus-summary-exit (&optional temporary)
7821 "Exit reading current newsgroup, and then return to group selection mode.
7822 gnus-exit-group-hook is called with no arguments if that value is non-nil."
7823 (interactive)
7824 (gnus-set-global-variables)
7825 (gnus-kill-save-kill-buffer)
7826 (let* ((group gnus-newsgroup-name)
7827 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
7828 (mode major-mode)
7829 (buf (current-buffer)))
7830 (run-hooks 'gnus-summary-prepare-exit-hook)
7831 ;; Make all changes in this group permanent.
7832 (gnus-summary-update-info)
7833 (set-buffer buf)
7834 (and gnus-use-cache (gnus-cache-possibly-remove-articles))
7835 ;; Make sure where I was, and go to next newsgroup.
7836 (set-buffer gnus-group-buffer)
7837 (or quit-config
7838 (progn
7839 (gnus-group-jump-to-group group)
7840 (gnus-group-next-unread-group 1)))
7841 (if temporary
7842 nil ;Nothing to do.
7843 ;; We set all buffer-local variables to nil. It is unclear why
7844 ;; this is needed, but if we don't, buffer-local variables are
7845 ;; not garbage-collected, it seems. This would the lead to en
7846 ;; ever-growing Emacs.
7847 (set-buffer buf)
7848 (gnus-summary-clear-local-variables)
7849 ;; We clear the global counterparts of the buffer-local
7850 ;; variables as well, just to be on the safe side.
7851 (gnus-configure-windows 'group 'force)
7852 (gnus-summary-clear-local-variables)
7853 ;; Return to group mode buffer.
7854 (if (eq mode 'gnus-summary-mode)
7855 (gnus-kill-buffer buf))
7856 (if (get-buffer gnus-article-buffer)
7857 (bury-buffer gnus-article-buffer))
7858 (setq gnus-current-select-method gnus-select-method)
7859 (pop-to-buffer gnus-group-buffer)
7860 (if (not quit-config)
7861 (progn
7862 (gnus-group-jump-to-group group)
7863 (gnus-group-next-unread-group 1))
7864 (if (not (buffer-name (car quit-config)))
7865 (gnus-configure-windows 'group 'force)
7866 (set-buffer (car quit-config))
7867 (and (eq major-mode 'gnus-summary-mode)
7868 (gnus-set-global-variables))
7869 (gnus-configure-windows (cdr quit-config))))
7870 (run-hooks 'gnus-summary-exit-hook))))
7872 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
7873 (defun gnus-summary-exit-no-update (&optional no-questions)
7874 "Quit reading current newsgroup without updating read article info."
7875 (interactive)
7876 (gnus-set-global-variables)
7877 (let* ((group gnus-newsgroup-name)
7878 (quit-config (gnus-group-quit-config group)))
7879 (if (or no-questions
7880 gnus-expert-user
7881 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
7882 (progn
7883 (gnus-close-group group)
7884 (gnus-summary-clear-local-variables)
7885 (set-buffer gnus-group-buffer)
7886 (gnus-summary-clear-local-variables)
7887 ;; Return to group selection mode.
7888 (gnus-configure-windows 'group 'force)
7889 (if (get-buffer gnus-summary-buffer)
7890 (kill-buffer gnus-summary-buffer))
7891 (if (get-buffer gnus-article-buffer)
7892 (bury-buffer gnus-article-buffer))
7893 (if (equal (gnus-group-group-name) group)
7894 (gnus-group-next-unread-group 1))
7895 (if quit-config
7896 (progn
7897 (if (not (buffer-name (car quit-config)))
7898 (gnus-configure-windows 'group 'force)
7899 (set-buffer (car quit-config))
7900 (and (eq major-mode 'gnus-summary-mode)
7901 (gnus-set-global-variables))
7902 (gnus-configure-windows (cdr quit-config)))))))))
7904 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
7905 (defun gnus-summary-fetch-faq (group)
7906 "Fetch the FAQ for the current group."
7907 (interactive (list gnus-newsgroup-name))
7908 (let (gnus-faq-buffer)
7909 (and (setq gnus-faq-buffer (gnus-group-fetch-faq group))
7910 (gnus-configure-windows 'summary-faq))))
7912 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7913 (defun gnus-summary-describe-group (&optional force)
7914 "Describe the current newsgroup."
7915 (interactive "P")
7916 (gnus-group-describe-group force gnus-newsgroup-name))
7918 (defun gnus-summary-describe-briefly ()
7919 "Describe summary mode commands briefly."
7920 (interactive)
7921 (gnus-message 6
7922 (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")))
7924 ;; Walking around group mode buffer from summary mode.
7926 (defun gnus-summary-next-group (&optional no-article target-group backward)
7927 "Exit current newsgroup and then select next unread newsgroup.
7928 If prefix argument NO-ARTICLE is non-nil, no article is selected
7929 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
7930 previous group instead."
7931 (interactive "P")
7932 (gnus-set-global-variables)
7933 (let ((current-group gnus-newsgroup-name)
7934 (current-buffer (current-buffer))
7935 entered)
7936 ;; First we semi-exit this group to update Xrefs and all variables.
7937 ;; We can't do a real exit, because the window conf must remain
7938 ;; the same in case the user is prompted for info, and we don't
7939 ;; want the window conf to change before that...
7940 (gnus-summary-exit t)
7941 (while (not entered)
7942 ;; Then we find what group we are supposed to enter.
7943 (set-buffer gnus-group-buffer)
7944 (gnus-group-jump-to-group current-group)
7945 (setq target-group
7946 (or target-group
7947 (if (eq gnus-keep-same-level 'best)
7948 (gnus-summary-best-group gnus-newsgroup-name)
7949 (gnus-summary-search-group backward gnus-keep-same-level))))
7950 (if (not target-group)
7951 ;; There are no further groups, so we return to the group
7952 ;; buffer.
7953 (progn
7954 (gnus-message 5 "Returning to the group buffer")
7955 (setq entered t)
7956 (set-buffer current-buffer)
7957 (gnus-summary-exit))
7958 ;; We try to enter the target group.
7959 (gnus-group-jump-to-group target-group)
7960 (let ((unreads (gnus-group-group-unread)))
7961 (if (and (or (eq t unreads)
7962 (and unreads (not (zerop unreads))))
7963 (gnus-summary-read-group
7964 target-group nil no-article current-buffer))
7965 (setq entered t)
7966 (setq current-group target-group
7967 target-group nil)))))))
7969 (defun gnus-summary-next-group-old (&optional no-article group backward)
7970 "Exit current newsgroup and then select next unread newsgroup.
7971 If prefix argument NO-ARTICLE is non-nil, no article is selected initially.
7972 If BACKWARD, go to previous group instead."
7973 (interactive "P")
7974 (gnus-set-global-variables)
7975 (let ((ingroup gnus-newsgroup-name)
7976 (sumbuf (current-buffer))
7977 num)
7978 (set-buffer gnus-group-buffer)
7979 (if (and group
7980 (or (and (numberp (setq num (car (gnus-gethash
7981 group gnus-newsrc-hashtb))))
7982 (< num 1))
7983 (null num)))
7984 (progn
7985 (gnus-group-jump-to-group group)
7986 (setq group nil))
7987 (gnus-group-jump-to-group ingroup))
7988 (gnus-summary-search-group backward)
7989 (let ((group (or group (gnus-summary-search-group backward))))
7990 (set-buffer sumbuf)
7991 (gnus-summary-exit t) ;Update all information.
7992 (if (null group)
7993 (gnus-summary-exit-no-update t)
7994 (gnus-group-jump-to-group ingroup)
7995 (setq group (gnus-summary-search-group backward))
7996 (gnus-message 5 "Selecting %s..." group)
7997 (set-buffer gnus-group-buffer)
7998 ;; We are now in group mode buffer.
7999 ;; Make sure group mode buffer point is on GROUP.
8000 (gnus-group-jump-to-group group)
8001 (if (not (eq gnus-auto-select-next 'quietly))
8002 (progn
8003 (gnus-summary-read-group group nil no-article sumbuf)
8004 (and (string= gnus-newsgroup-name ingroup)
8005 (bufferp sumbuf) (buffer-name sumbuf)
8006 (progn
8007 (set-buffer (setq gnus-summary-buffer sumbuf))
8008 (gnus-summary-exit-no-update t))))
8009 (let ((prevgroup group))
8010 (gnus-group-jump-to-group ingroup)
8011 (setq group (gnus-summary-search-group backward))
8012 (gnus-summary-read-group group nil no-article sumbuf)
8013 (while (and (string= gnus-newsgroup-name ingroup)
8014 (bufferp sumbuf)
8015 (buffer-name sumbuf)
8016 (not (string= prevgroup (gnus-group-group-name))))
8017 (set-buffer gnus-group-buffer)
8018 (gnus-summary-read-group
8019 (setq prevgroup (gnus-group-group-name))
8020 nil no-article sumbuf))
8021 (and (string= prevgroup (gnus-group-group-name))
8022 ;; We have reached the final group in the group
8023 ;; buffer.
8024 (progn
8025 (if (buffer-name sumbuf)
8026 (progn
8027 (set-buffer sumbuf)
8028 (gnus-summary-exit)))))))))))
8030 (defun gnus-summary-prev-group (&optional no-article)
8031 "Exit current newsgroup and then select previous unread newsgroup.
8032 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
8033 (interactive "P")
8034 (gnus-summary-next-group no-article nil t))
8036 ;; Walking around summary lines.
8038 (defun gnus-summary-first-subject (&optional unread)
8039 "Go to the first unread subject.
8040 If UNREAD is non-nil, go to the first unread article.
8041 Returns nil if there are no unread articles."
8042 (interactive "P")
8043 (prog1
8044 (cond ((not unread)
8045 (goto-char (point-min)))
8046 ((gnus-goto-char
8047 (text-property-any
8048 (point-min) (point-max) 'gnus-mark gnus-unread-mark))
8051 ;; There are no unread articles.
8052 (gnus-message 3 "No more unread articles")
8053 nil))
8054 (gnus-summary-position-cursor)))
8056 (defun gnus-summary-next-subject (n &optional unread dont-display)
8057 "Go to next N'th summary line.
8058 If N is negative, go to the previous N'th subject line.
8059 If UNREAD is non-nil, only unread articles are selected.
8060 The difference between N and the actual number of steps taken is
8061 returned."
8062 (interactive "p")
8063 (let ((backward (< n 0))
8064 (n (abs n)))
8065 (while (and (> n 0)
8066 (gnus-summary-search-forward unread nil backward))
8067 (setq n (1- n)))
8068 (if (/= 0 n) (gnus-message 7 "No more%s articles"
8069 (if unread " unread" "")))
8070 (or dont-display
8071 (progn
8072 (gnus-summary-recenter)
8073 (gnus-summary-position-cursor)))
8076 (defun gnus-summary-next-unread-subject (n)
8077 "Go to next N'th unread summary line."
8078 (interactive "p")
8079 (gnus-summary-next-subject n t))
8081 (defun gnus-summary-prev-subject (n &optional unread)
8082 "Go to previous N'th summary line.
8083 If optional argument UNREAD is non-nil, only unread article is selected."
8084 (interactive "p")
8085 (gnus-summary-next-subject (- n) unread))
8087 (defun gnus-summary-prev-unread-subject (n)
8088 "Go to previous N'th unread summary line."
8089 (interactive "p")
8090 (gnus-summary-next-subject (- n) t))
8092 (defun gnus-summary-goto-subject (article)
8093 "Go the subject line of ARTICLE."
8094 (interactive
8095 (list
8096 (string-to-int
8097 (completing-read "Article number: "
8098 (mapcar
8099 (lambda (headers)
8100 (list
8101 (int-to-string (mail-header-number headers))))
8102 gnus-newsgroup-headers)
8103 nil 'require-match))))
8104 (or article (error "No article number"))
8105 (let ((b (point)))
8106 (if (not (gnus-goto-char (text-property-any (point-min) (point-max)
8107 'gnus-number article)))
8109 (gnus-summary-show-thread)
8110 ;; Skip dummy articles.
8111 (if (eq (gnus-summary-article-mark) gnus-dummy-mark)
8112 (forward-line 1))
8113 (prog1
8114 (if (not (eobp))
8115 article
8116 (goto-char b)
8117 nil)
8118 (gnus-summary-position-cursor)))))
8120 ;; Walking around summary lines with displaying articles.
8122 (defun gnus-summary-expand-window (&optional arg)
8123 "Make the summary buffer take up the entire Emacs frame.
8124 Given a prefix, will force an `article' buffer configuration."
8125 (interactive "P")
8126 (gnus-set-global-variables)
8127 (if arg
8128 (gnus-configure-windows 'article 'force)
8129 (gnus-configure-windows 'summary 'force)))
8131 (defun gnus-summary-display-article (article &optional all-header)
8132 "Display ARTICLE in article buffer."
8133 (gnus-set-global-variables)
8134 (if (null article)
8136 (prog1
8137 (gnus-article-prepare article all-header)
8138 (gnus-summary-show-thread)
8139 (if (eq (gnus-summary-article-mark) gnus-dummy-mark)
8140 (progn
8141 (forward-line 1)
8142 (gnus-summary-position-cursor)))
8143 (run-hooks 'gnus-select-article-hook)
8144 (gnus-summary-recenter)
8145 (gnus-summary-goto-subject article)
8146 ;; Successfully display article.
8147 (gnus-summary-update-line)
8148 (gnus-article-set-window-start
8149 (cdr (assq article gnus-newsgroup-bookmarks)))
8150 t)))
8152 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
8153 "Select the current article.
8154 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
8155 non-nil, the article will be re-fetched even if it already present in
8156 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
8157 be displayed."
8158 (and (not pseudo) (gnus-summary-pseudo-article)
8159 (error "This is a pseudo-article."))
8160 (let ((article (or article (gnus-summary-article-number)))
8161 (all-headers (not (not all-headers))) ;Must be T or NIL.
8162 did)
8163 (prog1
8164 (save-excursion
8165 (set-buffer gnus-summary-buffer)
8166 (if (or (null gnus-current-article)
8167 (null gnus-article-current)
8168 (null (get-buffer gnus-article-buffer))
8169 (not (eq article (cdr gnus-article-current)))
8170 (not (equal (car gnus-article-current) gnus-newsgroup-name))
8171 force)
8172 ;; The requested article is different from the current article.
8173 (progn
8174 (gnus-summary-display-article article all-headers)
8175 (setq did article))
8176 (if (or all-headers gnus-show-all-headers)
8177 (gnus-article-show-all-headers))
8178 nil))
8179 (if did
8180 (gnus-article-set-window-start
8181 (cdr (assq article gnus-newsgroup-bookmarks)))))))
8183 (defun gnus-summary-set-current-mark (&optional current-mark)
8184 "Obsolete function."
8185 nil)
8187 (defun gnus-summary-next-article (&optional unread subject backward)
8188 "Select the next article.
8189 If UNREAD, only unread articles are selected.
8190 If SUBJECT, only articles with SUBJECT are selected.
8191 If BACKWARD, the previous article is selected instead of the next."
8192 (interactive "P")
8193 (gnus-set-global-variables)
8194 (let (header)
8195 (cond
8196 ;; Is there such an article?
8197 ((and (gnus-summary-search-forward unread subject backward)
8198 (or (gnus-summary-display-article (gnus-summary-article-number))
8199 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
8200 (gnus-summary-position-cursor))
8201 ;; If not, we try the first unread, if that is wanted.
8202 ((and subject
8203 gnus-auto-select-same
8204 (or (gnus-summary-first-unread-article)
8205 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
8206 (gnus-summary-position-cursor)
8207 (gnus-message 6 "Wrapped"))
8208 ;; Try to get next/previous article not displayed in this group.
8209 ((and gnus-auto-extend-newsgroup
8210 (not unread) (not subject)
8211 (setq header (gnus-more-header-forward backward)))
8212 (gnus-extend-newsgroup header backward)
8213 (let ((buffer-read-only nil))
8214 (goto-char (if backward (point-min) (point-max)))
8215 (gnus-summary-prepare-threads (list header)))
8216 (gnus-summary-goto-article (if backward gnus-newsgroup-begin
8217 gnus-newsgroup-end)))
8218 ;; Go to next/previous group.
8220 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
8221 (gnus-summary-jump-to-group gnus-newsgroup-name))
8222 (let ((cmd last-command-char)
8223 (group
8224 (if (eq gnus-keep-same-level 'best)
8225 (gnus-summary-best-group gnus-newsgroup-name)
8226 (gnus-summary-search-group backward gnus-keep-same-level))))
8227 ;; For some reason, the group window gets selected. We change
8228 ;; it back.
8229 (select-window (get-buffer-window (current-buffer)))
8230 ;; Keep just the event type of CMD.
8231 ;(and (listp cmd) (setq cmd (car cmd)))
8232 ;; Select next unread newsgroup automagically.
8233 (cond
8234 ((not gnus-auto-select-next)
8235 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
8236 ((eq gnus-auto-select-next 'quietly)
8237 ;; Select quietly.
8238 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
8239 (gnus-summary-exit)
8240 (gnus-message 7 "No more%s articles (%s)..."
8241 (if unread " unread" "")
8242 (if group (concat "selecting " group)
8243 "exiting"))
8244 (gnus-summary-next-group nil group backward)))
8246 (let ((keystrokes '(?\C-n ?\C-p))
8247 key)
8248 (while (or (null key) (memq key keystrokes))
8249 (gnus-message
8250 7 "No more%s articles%s" (if unread " unread" "")
8251 (if (and group
8252 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
8253 (format " (Type %s for %s [%s])"
8254 (single-key-description cmd) group
8255 (car (gnus-gethash group gnus-newsrc-hashtb)))
8256 (format " (Type %s to exit %s)"
8257 (single-key-description cmd)
8258 gnus-newsgroup-name)))
8259 ;; Confirm auto selection.
8260 (let* ((event (read-char)))
8261 (setq key (if (listp event) (car event) event))
8262 (if (memq key keystrokes)
8263 (let ((obuf (current-buffer)))
8264 (switch-to-buffer gnus-group-buffer)
8265 (and group
8266 (gnus-group-jump-to-group group))
8267 (condition-case ()
8268 (execute-kbd-macro (char-to-string key))
8269 (error (ding) nil))
8270 (setq group (gnus-group-group-name))
8271 (switch-to-buffer obuf)))))
8272 (if (equal key cmd)
8273 (if (or (not group)
8274 (gnus-ephemeral-group-p gnus-newsgroup-name))
8275 (gnus-summary-exit)
8276 (gnus-summary-next-group nil group backward))
8277 (execute-kbd-macro (char-to-string key)))))))))))
8279 (defun gnus-summary-next-unread-article ()
8280 "Select unread article after current one."
8281 (interactive)
8282 (gnus-summary-next-article t (and gnus-auto-select-same
8283 (gnus-summary-subject-string))))
8285 (defun gnus-summary-prev-article (&optional unread subject)
8286 "Select the article after the current one.
8287 If UNREAD is non-nil, only unread articles are selected."
8288 (interactive "P")
8289 (gnus-summary-next-article unread subject t))
8291 (defun gnus-summary-prev-unread-article ()
8292 "Select unred article before current one."
8293 (interactive)
8294 (gnus-summary-prev-article t (and gnus-auto-select-same
8295 (gnus-summary-subject-string))))
8297 (defun gnus-summary-next-page (&optional lines circular)
8298 "Show next page of selected article.
8299 If end of article, select next article.
8300 Argument LINES specifies lines to be scrolled up.
8301 If CIRCULAR is non-nil, go to the start of the article instead of
8302 instead of selecting the next article when reaching the end of the
8303 current article."
8304 (interactive "P")
8305 (setq gnus-summary-buffer (current-buffer))
8306 (gnus-set-global-variables)
8307 (let ((article (gnus-summary-article-number))
8308 (endp nil))
8309 (gnus-configure-windows 'article)
8310 (if (or (null gnus-current-article)
8311 (null gnus-article-current)
8312 (/= article (cdr gnus-article-current))
8313 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
8314 ;; Selected subject is different from current article's.
8315 (gnus-summary-display-article article)
8316 (gnus-eval-in-buffer-window
8317 gnus-article-buffer
8318 (setq endp (gnus-article-next-page lines)))
8319 (if endp
8320 (cond (circular
8321 (gnus-summary-beginning-of-article))
8322 (lines
8323 (gnus-message 3 "End of message"))
8324 ((null lines)
8325 (gnus-summary-next-unread-article)))))
8326 (gnus-summary-recenter)
8327 (gnus-summary-position-cursor)))
8329 (defun gnus-summary-prev-page (&optional lines)
8330 "Show previous page of selected article.
8331 Argument LINES specifies lines to be scrolled down."
8332 (interactive "P")
8333 (gnus-set-global-variables)
8334 (let ((article (gnus-summary-article-number)))
8335 (gnus-configure-windows 'article)
8336 (if (or (null gnus-current-article)
8337 (null gnus-article-current)
8338 (/= article (cdr gnus-article-current))
8339 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
8340 ;; Selected subject is different from current article's.
8341 (gnus-summary-display-article article)
8342 (gnus-summary-recenter)
8343 (gnus-eval-in-buffer-window gnus-article-buffer
8344 (gnus-article-prev-page lines))))
8345 (gnus-summary-position-cursor))
8347 (defun gnus-summary-scroll-up (lines)
8348 "Scroll up (or down) one line current article.
8349 Argument LINES specifies lines to be scrolled up (or down if negative)."
8350 (interactive "p")
8351 (gnus-set-global-variables)
8352 (gnus-configure-windows 'article)
8353 (or (gnus-summary-select-article nil nil 'pseudo)
8354 (gnus-eval-in-buffer-window
8355 gnus-article-buffer
8356 (cond ((> lines 0)
8357 (if (gnus-article-next-page lines)
8358 (gnus-message 3 "End of message")))
8359 ((< lines 0)
8360 (gnus-article-prev-page (- lines))))))
8361 (gnus-summary-recenter)
8362 (gnus-summary-position-cursor))
8364 (defun gnus-summary-next-same-subject ()
8365 "Select next article which has the same subject as current one."
8366 (interactive)
8367 (gnus-set-global-variables)
8368 (gnus-summary-next-article nil (gnus-summary-subject-string)))
8370 (defun gnus-summary-prev-same-subject ()
8371 "Select previous article which has the same subject as current one."
8372 (interactive)
8373 (gnus-set-global-variables)
8374 (gnus-summary-prev-article nil (gnus-summary-subject-string)))
8376 (defun gnus-summary-next-unread-same-subject ()
8377 "Select next unread article which has the same subject as current one."
8378 (interactive)
8379 (gnus-set-global-variables)
8380 (gnus-summary-next-article t (gnus-summary-subject-string)))
8382 (defun gnus-summary-prev-unread-same-subject ()
8383 "Select previous unread article which has the same subject as current one."
8384 (interactive)
8385 (gnus-set-global-variables)
8386 (gnus-summary-prev-article t (gnus-summary-subject-string)))
8388 (defun gnus-summary-first-unread-article ()
8389 "Select the first unread article.
8390 Return nil if there are no unread articles."
8391 (interactive)
8392 (gnus-set-global-variables)
8393 (prog1
8394 (if (gnus-summary-first-subject t)
8395 (progn
8396 (gnus-summary-show-thread)
8397 (gnus-summary-first-subject t)
8398 (gnus-summary-display-article (gnus-summary-article-number))))
8399 (gnus-summary-position-cursor)))
8401 (defun gnus-summary-best-unread-article ()
8402 "Select the unread article with the highest score."
8403 (interactive)
8404 (gnus-set-global-variables)
8405 (let ((best -1000000)
8406 article score)
8407 (save-excursion
8408 (or (gnus-summary-first-subject t)
8409 (error "No unread articles"))
8410 (while
8411 (and
8412 (progn
8413 (and (> (setq score (gnus-summary-article-score)) best)
8414 (setq best score
8415 article (gnus-summary-article-number)))
8417 (gnus-summary-search-subject nil t))))
8418 (if (not article)
8419 (error "No unread articles")
8420 (gnus-summary-goto-article article))
8421 (gnus-summary-position-cursor)))
8423 (defun gnus-summary-goto-article (article &optional all-headers)
8424 "Fetch ARTICLE and display it if it exists.
8425 If ALL-HEADERS is non-nil, no header lines are hidden."
8426 (interactive
8427 (list
8428 (string-to-int
8429 (completing-read
8430 "Article number: "
8431 (mapcar (lambda (headers)
8432 (list (int-to-string (mail-header-number headers))))
8433 gnus-newsgroup-headers)
8434 nil 'require-match))))
8435 (prog1
8436 (and (gnus-summary-goto-subject article)
8437 (gnus-summary-display-article article all-headers))
8438 (gnus-summary-position-cursor)))
8440 (defun gnus-summary-goto-last-article ()
8441 "Go to the previously read article."
8442 (interactive)
8443 (prog1
8444 (and gnus-last-article
8445 (gnus-summary-goto-article gnus-last-article))
8446 (gnus-summary-position-cursor)))
8448 (defun gnus-summary-pop-article (number)
8449 "Pop one article off the history and go to the previous.
8450 NUMBER articles will be popped off."
8451 (interactive "p")
8452 (let (to)
8453 (setq gnus-newsgroup-history
8454 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
8455 (if to
8456 (gnus-summary-goto-article (car to))
8457 (error "Article history empty")))
8458 (gnus-summary-position-cursor))
8460 ;; Summary article oriented commands
8462 (defun gnus-summary-refer-parent-article (n)
8463 "Refer parent article N times.
8464 The difference between N and the number of articles fetched is returned."
8465 (interactive "p")
8466 (gnus-set-global-variables)
8467 (while
8468 (and
8469 (> n 0)
8470 (let ((ref (mail-header-references (gnus-get-header-by-num
8471 (gnus-summary-article-number)))))
8472 (if (and ref (not (equal ref ""))
8473 (string-match "<[^<>]*>[ \t]*$" ref))
8474 (gnus-summary-refer-article
8475 (substring ref (match-beginning 0) (match-end 0)))
8476 (gnus-message 1 "No references in article %d"
8477 (gnus-summary-article-number))
8478 nil)))
8479 (setq n (1- n)))
8480 (gnus-summary-position-cursor)
8483 (defun gnus-summary-refer-article (message-id)
8484 "Refer article specified by MESSAGE-ID.
8485 NOTE: This command only works with newsgroups that use real or simulated NNTP."
8486 (interactive "sMessage-ID: ")
8487 (if (or (not (stringp message-id))
8488 (zerop (length message-id)))
8490 ;; Construct the correct Message-ID if necessary.
8491 ;; Suggested by tale@pawl.rpi.edu.
8492 (or (string-match "^<" message-id)
8493 (setq message-id (concat "<" message-id)))
8494 (or (string-match ">$" message-id)
8495 (setq message-id (concat message-id ">")))
8496 (let ((header (car (gnus-gethash (downcase message-id)
8497 gnus-newsgroup-dependencies))))
8498 (if header
8499 (or (gnus-summary-goto-article (mail-header-number header))
8500 ;; The header has been read, but the article had been
8501 ;; expunged, so we insert it again.
8502 (progn
8503 (gnus-summary-insert-line
8504 nil header 0 nil gnus-read-mark nil nil
8505 (mail-header-subject header))
8506 (forward-line -1)
8507 (mail-header-number header)))
8508 (let ((gnus-override-method gnus-refer-article-method)
8509 (gnus-ancient-mark gnus-read-mark)
8510 (tmp-point (window-start
8511 (get-buffer-window gnus-article-buffer)))
8512 number tmp-buf)
8513 (and gnus-refer-article-method
8514 (gnus-check-server gnus-refer-article-method))
8515 ;; Save the old article buffer.
8516 (save-excursion
8517 (set-buffer (gnus-article-setup-buffer))
8518 (gnus-kill-buffer " *temp Article*")
8519 (setq tmp-buf (rename-buffer " *temp Article*")))
8520 (prog1
8521 (if (gnus-article-prepare
8522 message-id nil (gnus-read-header message-id))
8523 (progn
8524 (setq number (mail-header-number gnus-current-headers))
8525 (gnus-rebuild-thread message-id)
8526 (gnus-summary-goto-subject number)
8527 (if (null gnus-use-full-window)
8528 (progn
8529 (delete-windows-on tmp-buf)
8530 (gnus-configure-windows 'article 'force)))
8531 (gnus-summary-recenter)
8532 (gnus-article-set-window-start
8533 (cdr (assq number gnus-newsgroup-bookmarks)))
8534 (and gnus-visual
8535 (run-hooks 'gnus-visual-mark-article-hook))
8536 message-id)
8537 ;; We restore the old article buffer.
8538 (save-excursion
8539 (kill-buffer gnus-article-buffer)
8540 (set-buffer tmp-buf)
8541 (rename-buffer gnus-article-buffer)
8542 (let ((buffer-read-only nil))
8543 (and tmp-point
8544 (set-window-start (get-buffer-window (current-buffer))
8545 tmp-point)))))))))))
8547 (defun gnus-summary-enter-digest-group ()
8548 "Enter a digest group based on the current article."
8549 (interactive)
8550 (gnus-set-global-variables)
8551 (gnus-summary-select-article)
8552 ;; We do not want a narrowed article.
8553 (gnus-summary-stop-page-breaking)
8554 (let ((name (format "%s-%d"
8555 (gnus-group-prefixed-name
8556 gnus-newsgroup-name (list 'nndoc ""))
8557 gnus-current-article))
8558 (ogroup gnus-newsgroup-name)
8559 (buf (current-buffer)))
8560 (if (gnus-group-read-ephemeral-group
8561 name (list 'nndoc name
8562 (list 'nndoc-address (get-buffer gnus-article-buffer))
8563 '(nndoc-article-type digest))
8565 (setcdr (nthcdr 4 (nth 2 (gnus-gethash name gnus-newsrc-hashtb)))
8566 (list (list (cons 'to-group ogroup))))
8567 (switch-to-buffer buf)
8568 (gnus-set-global-variables)
8569 (gnus-configure-windows 'summary)
8570 (gnus-message 3 "Article not a digest?"))))
8572 (defun gnus-summary-isearch-article ()
8573 "Do incremental search forward on current article."
8574 (interactive)
8575 (gnus-set-global-variables)
8576 (gnus-summary-select-article)
8577 (gnus-eval-in-buffer-window
8578 gnus-article-buffer (isearch-forward)))
8580 (defun gnus-summary-search-article-forward (regexp &optional backward)
8581 "Search for an article containing REGEXP forward.
8582 If BACKWARD, search backward instead."
8583 (interactive
8584 (list (read-string
8585 (format "Search article %s (regexp%s): "
8586 (if current-prefix-arg "backward" "forward")
8587 (if gnus-last-search-regexp
8588 (concat ", default " gnus-last-search-regexp)
8589 "")))
8590 current-prefix-arg))
8591 (gnus-set-global-variables)
8592 (if (string-equal regexp "")
8593 (setq regexp (or gnus-last-search-regexp ""))
8594 (setq gnus-last-search-regexp regexp))
8595 (if (gnus-summary-search-article regexp backward)
8596 (gnus-article-set-window-start
8597 (cdr (assq (gnus-summary-article-number) gnus-newsgroup-bookmarks)))
8598 (error "Search failed: \"%s\"" regexp)))
8600 (defun gnus-summary-search-article-backward (regexp)
8601 "Search for an article containing REGEXP backward."
8602 (interactive
8603 (list (read-string
8604 (format "Search article backward (regexp%s): "
8605 (if gnus-last-search-regexp
8606 (concat ", default " gnus-last-search-regexp)
8607 "")))))
8608 (gnus-summary-search-article-forward regexp 'backward))
8610 (defun gnus-summary-search-article (regexp &optional backward)
8611 "Search for an article containing REGEXP.
8612 Optional argument BACKWARD means do search for backward.
8613 gnus-select-article-hook is not called during the search."
8614 (let ((gnus-select-article-hook nil) ;Disable hook.
8615 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8616 (re-search
8617 (if backward
8618 (function re-search-backward) (function re-search-forward)))
8619 (found nil)
8620 (last nil))
8621 ;; Hidden thread subtrees must be searched for ,too.
8622 (gnus-summary-show-all-threads)
8623 (if (eobp) (forward-line -1))
8624 ;; First of all, search current article.
8625 ;; We don't want to read article again from NNTP server nor reset
8626 ;; current point.
8627 (gnus-summary-select-article)
8628 (gnus-message 9 "Searching article: %d..." gnus-current-article)
8629 (setq last gnus-current-article)
8630 (gnus-eval-in-buffer-window
8631 gnus-article-buffer
8632 (save-restriction
8633 (widen)
8634 ;; Begin search from current point.
8635 (setq found (funcall re-search regexp nil t))))
8636 ;; Then search next articles.
8637 (while (and (not found)
8638 (gnus-summary-display-article
8639 (gnus-summary-search-subject backward nil nil)))
8640 (gnus-message 9 "Searching article: %d..." gnus-current-article)
8641 (gnus-eval-in-buffer-window
8642 gnus-article-buffer
8643 (save-restriction
8644 (widen)
8645 (goto-char (if backward (point-max) (point-min)))
8646 (setq found (funcall re-search regexp nil t)))))
8647 (message "")
8648 ;; Adjust article pointer.
8649 (or (eq last gnus-current-article)
8650 (setq gnus-last-article last))
8651 ;; Return T if found such article.
8652 found))
8654 (defun gnus-summary-execute-command (header regexp command &optional backward)
8655 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8656 If HEADER is an empty string (or nil), the match is done on the entire
8657 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8658 (interactive
8659 (list (let ((completion-ignore-case t))
8660 (completing-read
8661 "Header name: "
8662 (mapcar (lambda (string) (list string))
8663 '("Number" "Subject" "From" "Lines" "Date"
8664 "Message-ID" "Xref" "References"))
8665 nil 'require-match))
8666 (read-string "Regexp: ")
8667 (read-key-sequence "Command: ")
8668 current-prefix-arg))
8669 (gnus-set-global-variables)
8670 ;; Hidden thread subtrees must be searched as well.
8671 (gnus-summary-show-all-threads)
8672 ;; We don't want to change current point nor window configuration.
8673 (save-excursion
8674 (save-window-excursion
8675 (gnus-message 6 "Executing %s..." (key-description command))
8676 ;; We'd like to execute COMMAND interactively so as to give arguments.
8677 (gnus-execute header regexp
8678 (` (lambda ()
8679 (call-interactively '(, (key-binding command)))))
8680 backward)
8681 (gnus-message 6 "Executing %s...done" (key-description command)))))
8683 (defun gnus-summary-beginning-of-article ()
8684 "Scroll the article back to the beginning."
8685 (interactive)
8686 (gnus-set-global-variables)
8687 (gnus-summary-select-article)
8688 (gnus-configure-windows 'article)
8689 (gnus-eval-in-buffer-window
8690 gnus-article-buffer
8691 (widen)
8692 (goto-char (point-min))
8693 (and gnus-break-pages (gnus-narrow-to-page))))
8695 (defun gnus-summary-end-of-article ()
8696 "Scroll to the end of the article."
8697 (interactive)
8698 (gnus-set-global-variables)
8699 (gnus-summary-select-article)
8700 (gnus-configure-windows 'article)
8701 (gnus-eval-in-buffer-window
8702 gnus-article-buffer
8703 (widen)
8704 (goto-char (point-max))
8705 (recenter -3)
8706 (and gnus-break-pages (gnus-narrow-to-page))))
8708 (defun gnus-summary-show-article ()
8709 "Force re-fetching of the current article."
8710 (interactive)
8711 (gnus-set-global-variables)
8712 (gnus-summary-select-article nil 'force)
8713 (gnus-configure-windows 'article)
8714 (gnus-summary-position-cursor))
8716 (defun gnus-summary-verbose-headers (&optional arg)
8717 "Toggle permanent full header display.
8718 If ARG is a positive number, turn header display on.
8719 If ARG is a negative number, turn header display off."
8720 (interactive "P")
8721 (gnus-set-global-variables)
8722 (gnus-summary-toggle-header arg)
8723 (setq gnus-show-all-headers
8724 (cond ((or (not (numberp arg))
8725 (zerop arg))
8726 (not gnus-show-all-headers))
8727 ((natnump arg)
8728 t))))
8730 (defun gnus-summary-toggle-header (&optional arg)
8731 "Show the headers if they are hidden, or hide them if they are shown.
8732 If ARG is a positive number, show the entire header.
8733 If ARG is a negative number, hide the unwanted header lines."
8734 (interactive "P")
8735 (gnus-set-global-variables)
8736 (save-excursion
8737 (set-buffer gnus-article-buffer)
8738 (let ((buffer-read-only nil))
8739 (if (numberp arg)
8740 (if (> arg 0) (remove-text-properties (point-min) (point-max)
8741 gnus-hidden-properties)
8742 (if (< arg 0) (run-hooks 'gnus-article-display-hook)))
8743 (if (text-property-any (point-min) (point-max) 'invisible t)
8744 (remove-text-properties
8745 (point-min) (point-max) gnus-hidden-properties)
8746 ;; We hide the headers. This song and dance act below is
8747 ;; done because `gnus-have-all-headers' is buffer-local to
8748 ;; the summary buffer, and we only want to temporarily
8749 ;; change it in that buffer. Ugh.
8750 (let ((have gnus-have-all-headers))
8751 (save-excursion
8752 (set-buffer gnus-summary-buffer)
8753 (setq gnus-have-all-headers nil)
8754 (save-excursion
8755 (set-buffer gnus-article-buffer)
8756 (run-hooks 'gnus-article-display-hook))
8757 (setq gnus-have-all-headers have)))))
8758 (set-window-point (get-buffer-window (current-buffer)) (point-min)))))
8760 (defun gnus-summary-show-all-headers ()
8761 "Make all header lines visible."
8762 (interactive)
8763 (gnus-set-global-variables)
8764 (gnus-article-show-all-headers))
8766 (defun gnus-summary-toggle-mime (&optional arg)
8767 "Toggle MIME processing.
8768 If ARG is a positive number, turn MIME processing on."
8769 (interactive "P")
8770 (gnus-set-global-variables)
8771 (setq gnus-show-mime
8772 (if (null arg) (not gnus-show-mime)
8773 (> (prefix-numeric-value arg) 0)))
8774 (gnus-summary-select-article t 'force))
8776 (defun gnus-summary-caesar-message (&optional arg)
8777 "Caesar rotate the current article by 13.
8778 The numerical prefix specifies how manu places to rotate each letter
8779 forward."
8780 (interactive "P")
8781 (gnus-set-global-variables)
8782 (gnus-summary-select-article)
8783 (let ((mail-header-separator ""))
8784 (gnus-eval-in-buffer-window
8785 gnus-article-buffer
8786 (save-restriction
8787 (widen)
8788 (let ((start (window-start)))
8789 (news-caesar-buffer-body arg)
8790 (set-window-start (get-buffer-window (current-buffer)) start))))))
8792 (defun gnus-summary-stop-page-breaking ()
8793 "Stop page breaking in the current article."
8794 (interactive)
8795 (gnus-set-global-variables)
8796 (gnus-summary-select-article)
8797 (gnus-eval-in-buffer-window gnus-article-buffer (widen)))
8799 ;; Suggested by Brian Edmonds <bedmonds@prodigy.bc.ca>.
8801 (defun gnus-summary-move-article (&optional n to-newsgroup select-method)
8802 "Move the current article to a different newsgroup.
8803 If N is a positive number, move the N next articles.
8804 If N is a negative number, move the N previous articles.
8805 If N is nil and any articles have been marked with the process mark,
8806 move those articles instead.
8807 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8808 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
8809 re-spool using this method.
8810 For this function to work, both the current newsgroup and the
8811 newsgroup that you want to move to have to support the `request-move'
8812 and `request-accept' functions. (Ie. mail newsgroups at present.)"
8813 (interactive "P")
8814 (gnus-set-global-variables)
8815 (or (gnus-check-backend-function 'request-move-article gnus-newsgroup-name)
8816 (error "The current newsgroup does not support article moving"))
8817 (let ((articles (gnus-summary-work-articles n))
8818 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
8819 art-group to-method sel-met)
8820 (if (and (not to-newsgroup) (not select-method))
8821 (setq to-newsgroup
8822 (completing-read
8823 (format "Where do you want to move %s? %s"
8824 (if (> (length articles) 1)
8825 (format "these %d articles" (length articles))
8826 "this article")
8827 (if gnus-current-move-group
8828 (format "(%s default) " gnus-current-move-group)
8829 ""))
8830 gnus-active-hashtb nil nil prefix)))
8831 (if to-newsgroup
8832 (progn
8833 (if (or (string= to-newsgroup "") (string= to-newsgroup prefix))
8834 (setq to-newsgroup (or gnus-current-move-group "")))
8835 (or (gnus-gethash to-newsgroup gnus-active-hashtb)
8836 (gnus-activate-group to-newsgroup)
8837 (error "No such group: %s" to-newsgroup))
8838 (setq gnus-current-move-group to-newsgroup)))
8839 (setq to-method (if select-method (list select-method "")
8840 (gnus-find-method-for-group to-newsgroup)))
8841 (or (gnus-check-backend-function 'request-accept-article (car to-method))
8842 (error "%s does not support article copying" (car to-method)))
8843 (or (gnus-check-server to-method)
8844 (error "Can't open server %s" (car to-method)))
8845 (gnus-message 6 "Moving to %s: %s..."
8846 (or select-method to-newsgroup) articles)
8847 (while articles
8848 (if (setq art-group
8849 (gnus-request-move-article
8850 (car articles) ; Article to move
8851 gnus-newsgroup-name ; From newsgroup
8852 (nth 1 (gnus-find-method-for-group
8853 gnus-newsgroup-name)) ; Server
8854 (list 'gnus-request-accept-article
8855 (if select-method
8856 (list 'quote select-method)
8857 to-newsgroup)
8858 (not (cdr articles))) ; Accept form
8859 (not (cdr articles)))) ; Only save nov last time
8860 (let* ((buffer-read-only nil)
8861 (entry
8863 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
8864 (gnus-gethash
8865 (gnus-group-prefixed-name
8866 (car art-group)
8867 (if select-method (list select-method "")
8868 (gnus-find-method-for-group to-newsgroup)))
8869 gnus-newsrc-hashtb)))
8870 (info (nth 2 entry))
8871 (article (car articles)))
8872 (gnus-summary-goto-subject article)
8873 (beginning-of-line)
8874 (delete-region (point) (progn (forward-line 1) (point)))
8875 ;; Update the group that has been moved to.
8876 (if (not info)
8877 () ; This group does not exist yet.
8878 (if (not (memq article gnus-newsgroup-unreads))
8879 (setcar (cdr (cdr info))
8880 (gnus-add-to-range (nth 2 info)
8881 (list (cdr art-group)))))
8882 ;; Copy any marks over to the new group.
8883 (let ((marks '((tick . gnus-newsgroup-marked)
8884 (dormant . gnus-newsgroup-dormant)
8885 (expire . gnus-newsgroup-expirable)
8886 (bookmark . gnus-newsgroup-bookmarks)
8887 (reply . gnus-newsgroup-replied)))
8888 (to-article (cdr art-group)))
8889 (while marks
8890 (if (memq article (symbol-value (cdr (car marks))))
8891 (gnus-add-marked-articles
8892 (car info) (car (car marks)) (list to-article) info))
8893 (setq marks (cdr marks)))))
8894 ;; Update marks.
8895 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8896 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8897 (setq gnus-newsgroup-dormant
8898 (delq article gnus-newsgroup-dormant))
8899 (setq gnus-newsgroup-reads
8900 (cons (cons article gnus-canceled-mark)
8901 gnus-newsgroup-reads)))
8902 (gnus-message 1 "Couldn't move article %s" (car articles)))
8903 (gnus-summary-remove-process-mark (car articles))
8904 (setq articles (cdr articles)))
8905 (gnus-set-mode-line 'summary)))
8907 (defun gnus-summary-respool-article (&optional n respool-method)
8908 "Respool the current article.
8909 The article will be squeezed through the mail spooling process again,
8910 which means that it will be put in some mail newsgroup or other
8911 depending on `nnmail-split-methods'.
8912 If N is a positive number, respool the N next articles.
8913 If N is a negative number, respool the N previous articles.
8914 If N is nil and any articles have been marked with the process mark,
8915 respool those articles instead.
8917 Respooling can be done both from mail groups and \"real\" newsgroups.
8918 In the former case, the articles in question will be moved from the
8919 current group into whatever groups they are destined to. In the
8920 latter case, they will be copied into the relevant groups."
8921 (interactive "P")
8922 (gnus-set-global-variables)
8923 (let ((respool-methods (gnus-methods-using 'respool))
8924 (methname
8925 (symbol-name (car (gnus-find-method-for-group gnus-newsgroup-name)))))
8926 (or respool-method
8927 (setq respool-method
8928 (completing-read
8929 "What method do you want to use when respooling? "
8930 respool-methods nil t methname)))
8931 (or (string= respool-method "")
8932 (if (assoc (symbol-name
8933 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8934 respool-methods)
8935 (gnus-summary-move-article n nil (intern respool-method))
8936 (gnus-summary-copy-article n nil (intern respool-method))))))
8938 ;; Suggested by gregj@unidata.com (Gregory J. Grubbs).
8939 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
8940 "Move the current article to a different newsgroup.
8941 If N is a positive number, move the N next articles.
8942 If N is a negative number, move the N previous articles.
8943 If N is nil and any articles have been marked with the process mark,
8944 move those articles instead.
8945 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8946 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
8947 re-spool using this method.
8948 For this function to work, the newsgroup that you want to move to have
8949 to support the `request-move' and `request-accept'
8950 functions. (Ie. mail newsgroups at present.)"
8951 (interactive "P")
8952 (gnus-set-global-variables)
8953 (let ((articles (gnus-summary-work-articles n))
8954 (copy-buf (get-buffer-create "*copy work*"))
8955 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
8956 art-group to-method)
8957 (buffer-disable-undo copy-buf)
8958 (if (and (not to-newsgroup) (not select-method))
8959 (setq to-newsgroup
8960 (completing-read
8961 (format "Where do you want to copy %s? %s"
8962 (if (> (length articles) 1)
8963 (format "these %d articles" (length articles))
8964 "this article")
8965 (if gnus-current-move-group
8966 (format "(%s default) " gnus-current-move-group)
8967 ""))
8968 gnus-active-hashtb nil nil prefix)))
8969 (if to-newsgroup
8970 (progn
8971 (if (or (string= to-newsgroup "") (string= to-newsgroup prefix))
8972 (setq to-newsgroup (or gnus-current-move-group "")))
8973 (or (gnus-gethash to-newsgroup gnus-active-hashtb)
8974 (gnus-activate-group to-newsgroup)
8975 (error "No such group: %s" to-newsgroup))
8976 (setq gnus-current-move-group to-newsgroup)))
8977 (setq to-method (if select-method (list select-method "")
8978 (gnus-find-method-for-group to-newsgroup)))
8979 (or (gnus-check-backend-function 'request-accept-article (car to-method))
8980 (error "%s does not support article copying" (car to-method)))
8981 (or (gnus-check-server to-method)
8982 (error "Can't open server %s" (car to-method)))
8983 (while articles
8984 (gnus-message 6 "Copying to %s: %s..."
8985 (or select-method to-newsgroup) articles)
8986 (if (setq art-group
8987 (save-excursion
8988 (set-buffer copy-buf)
8989 (gnus-request-article-this-buffer
8990 (car articles) gnus-newsgroup-name)
8991 (gnus-request-accept-article
8992 (if select-method (list 'quote select-method) to-newsgroup)
8993 (not (cdr articles)))))
8994 (let* ((entry
8996 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
8997 (gnus-gethash
8998 (gnus-group-prefixed-name
8999 (car art-group)
9000 (if select-method (list select-method "")
9001 (gnus-find-method-for-group to-newsgroup)))
9002 gnus-newsrc-hashtb)))
9003 (info (nth 2 entry))
9004 (article (car articles)))
9005 ;; We copy the info over to the new group.
9006 (if (not info)
9007 () ; This group does not exist (yet).
9008 (if (not (memq article gnus-newsgroup-unreads))
9009 (setcar (cdr (cdr info))
9010 (gnus-add-to-range (nth 2 info)
9011 (list (cdr art-group)))))
9012 ;; Copy any marks over to the new group.
9013 (let ((marks '((tick . gnus-newsgroup-marked)
9014 (dormant . gnus-newsgroup-dormant)
9015 (expire . gnus-newsgroup-expirable)
9016 (bookmark . gnus-newsgroup-bookmarks)
9017 (reply . gnus-newsgroup-replied)))
9018 (to-article (cdr art-group)))
9019 (while marks
9020 (if (memq article (symbol-value (cdr (car marks))))
9021 (gnus-add-marked-articles
9022 (car info) (car (car marks)) (list to-article) info))
9023 (setq marks (cdr marks))))))
9024 (gnus-message 1 "Couldn't copy article %s" (car articles)))
9025 (gnus-summary-remove-process-mark (car articles))
9026 (setq articles (cdr articles)))
9027 (kill-buffer copy-buf)))
9029 (defun gnus-summary-import-article (file)
9030 "Import a random file into a mail newsgroup."
9031 (interactive "fImport file: ")
9032 (let ((group gnus-newsgroup-name)
9033 atts)
9034 (or (gnus-check-backend-function 'request-accept-article group)
9035 (error "%s does not support article importing" group))
9036 (or (file-readable-p file)
9037 (not (file-regular-p file))
9038 (error "Can't read %s" file))
9039 (save-excursion
9040 (set-buffer (get-buffer-create " *import file*"))
9041 (buffer-disable-undo (current-buffer))
9042 (erase-buffer)
9043 (insert-file-contents file)
9044 (goto-char (point-min))
9045 (if (nnheader-article-p)
9047 (setq atts (file-attributes file))
9048 (insert "From: " (read-string "From: ") "\n"
9049 "Subject: " (read-string "Subject: ") "\n"
9050 "Date: " (current-time-string (nth 5 atts)) "\n"
9051 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
9052 (gnus-request-accept-article group t)
9053 (kill-buffer (current-buffer)))))
9055 (defun gnus-summary-expire-articles ()
9056 "Expire all articles that are marked as expirable in the current group."
9057 (interactive)
9058 (if (not (gnus-check-backend-function
9059 'request-expire-articles gnus-newsgroup-name))
9061 (let* ((info (nth 2 (gnus-gethash gnus-newsgroup-name
9062 gnus-newsrc-hashtb)))
9063 (total (memq 'total-expire (nth 5 info)))
9064 (expirable (if total
9065 (gnus-list-of-read-articles gnus-newsgroup-name)
9066 (setq gnus-newsgroup-expirable
9067 (sort gnus-newsgroup-expirable '<))))
9069 (if (not expirable)
9071 (gnus-message 6 "Expiring articles...")
9072 ;; The list of articles that weren't expired is returned.
9073 (setq es (gnus-request-expire-articles expirable gnus-newsgroup-name))
9074 (or total (setq gnus-newsgroup-expirable es))
9075 ;; We go through the old list of expirable, and mark all
9076 ;; really expired articles as nonexistent.
9077 (or (eq es expirable) ;If nothing was expired, we don't mark.
9078 (let ((gnus-use-cache nil))
9079 (while expirable
9080 (or (memq (car expirable) es)
9081 (gnus-summary-mark-article
9082 (car expirable) gnus-canceled-mark))
9083 (setq expirable (cdr expirable)))))
9084 (gnus-message 6 "Expiring articles...done")))))
9086 (defun gnus-summary-expire-articles-now ()
9087 "Expunge all expirable articles in the current group.
9088 This means that *all* articles that are marked as expirable will be
9089 deleted forever, right now."
9090 (interactive)
9091 (or gnus-expert-user
9092 (gnus-y-or-n-p
9093 "Are you really, really, really sure you want to expunge? ")
9094 (error "Phew!"))
9095 (let ((nnmail-expiry-wait -1)
9096 (nnmail-expiry-wait-function nil))
9097 (gnus-summary-expire-articles)))
9099 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
9100 (defun gnus-summary-delete-article (&optional n)
9101 "Delete the N next (mail) articles.
9102 This command actually deletes articles. This is not a marking
9103 command. The article will disappear forever from you life, never to
9104 return.
9105 If N is negative, delete backwards.
9106 If N is nil and articles have been marked with the process mark,
9107 delete these instead."
9108 (interactive "P")
9109 (or (gnus-check-backend-function 'request-expire-articles
9110 gnus-newsgroup-name)
9111 (error "The current newsgroup does not support article deletion."))
9112 ;; Compute the list of articles to delete.
9113 (let ((articles (gnus-summary-work-articles n))
9114 not-deleted)
9115 (if (and gnus-novice-user
9116 (not (gnus-y-or-n-p
9117 (format "Do you really want to delete %s forever? "
9118 (if (> (length articles) 1) "these articles"
9119 "this article")))))
9121 ;; Delete the articles.
9122 (setq not-deleted (gnus-request-expire-articles
9123 articles gnus-newsgroup-name 'force))
9124 (while articles
9125 (gnus-summary-remove-process-mark (car articles))
9126 ;; The backend might not have been able to delete the article
9127 ;; after all.
9128 (or (memq (car articles) not-deleted)
9129 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
9130 (setq articles (cdr articles))))
9131 (gnus-summary-position-cursor)
9132 (gnus-set-mode-line 'summary)
9133 not-deleted))
9135 (defun gnus-summary-edit-article (&optional force)
9136 "Enter into a buffer and edit the current article.
9137 This will have permanent effect only in mail groups.
9138 If FORCE is non-nil, allow editing of articles even in read-only
9139 groups."
9140 (interactive "P")
9141 (or force
9142 (not (gnus-group-read-only-p))
9143 (error "The current newsgroup does not support article editing."))
9144 (gnus-summary-select-article t)
9145 (gnus-configure-windows 'article)
9146 (select-window (get-buffer-window gnus-article-buffer))
9147 (gnus-message 6 "C-c C-c to end edits")
9148 (setq buffer-read-only nil)
9149 (text-mode)
9150 (use-local-map (copy-keymap (current-local-map)))
9151 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
9152 (buffer-enable-undo)
9153 (widen)
9154 (goto-char (point-min))
9155 (search-forward "\n\n" nil t))
9157 (defun gnus-summary-edit-article-done ()
9158 "Make edits to the current article permanent."
9159 (interactive)
9160 (if (gnus-group-read-only-p)
9161 (progn
9162 (gnus-summary-edit-article-postpone)
9163 (message "The current newsgroup does not support article editing.")
9164 (ding))
9165 (let ((buf (buffer-substring-no-properties (point-min) (point-max))))
9166 (erase-buffer)
9167 (insert buf)
9168 (if (not (gnus-request-replace-article
9169 (cdr gnus-article-current) (car gnus-article-current)
9170 (current-buffer)))
9171 (error "Couldn't replace article.")
9172 (gnus-article-mode)
9173 (use-local-map gnus-article-mode-map)
9174 (setq buffer-read-only t)
9175 (buffer-disable-undo (current-buffer))
9176 (gnus-configure-windows 'summary))
9177 (and gnus-visual (run-hooks 'gnus-visual-mark-article-hook)))))
9179 (defun gnus-summary-edit-article-postpone ()
9180 "Postpone changes to the current article."
9181 (interactive)
9182 (gnus-article-mode)
9183 (use-local-map gnus-article-mode-map)
9184 (setq buffer-read-only t)
9185 (buffer-disable-undo (current-buffer))
9186 (gnus-configure-windows 'summary)
9187 (and gnus-visual (run-hooks 'gnus-visual-mark-article-hook)))
9189 (defun gnus-summary-fancy-query ()
9190 "Query where the fancy respool algorithm would put this article."
9191 (interactive)
9192 (gnus-summary-select-article)
9193 (save-excursion
9194 (set-buffer gnus-article-buffer)
9195 (save-restriction
9196 (goto-char (point-min))
9197 (search-forward "\n\n")
9198 (narrow-to-region (point-min) (point))
9199 (pp-eval-expression (list 'quote (nnmail-split-fancy))))))
9201 ;; Summary score commands.
9203 ;; Suggested by boubaker@cenatls.cena.dgac.fr.
9205 (defun gnus-summary-raise-score (n)
9206 "Raise the score of the current article by N."
9207 (interactive "p")
9208 (gnus-summary-set-score (+ (gnus-summary-article-score) n)))
9210 (defun gnus-summary-set-score (n)
9211 "Set the score of the current article to N."
9212 (interactive "p")
9213 ;; Skip dummy header line.
9214 (save-excursion
9215 (gnus-summary-show-thread)
9216 (if (eq (gnus-summary-article-mark) gnus-dummy-mark)
9217 (forward-line 1))
9218 (let ((buffer-read-only nil))
9219 ;; Set score.
9220 (gnus-summary-update-mark
9221 (if (= n (or gnus-summary-default-score 0)) ?
9222 (if (< n (or gnus-summary-default-score 0))
9223 gnus-score-below-mark gnus-score-over-mark)) 'score))
9224 (let* ((article (gnus-summary-article-number))
9225 (score (assq article gnus-newsgroup-scored)))
9226 (if score (setcdr score n)
9227 (setq gnus-newsgroup-scored
9228 (cons (cons article n) gnus-newsgroup-scored))))
9229 (gnus-summary-update-line)))
9231 (defun gnus-summary-current-score ()
9232 "Return the score of the current article."
9233 (interactive)
9234 (message "%s" (gnus-summary-article-score)))
9236 ;; Summary marking commands.
9238 (defun gnus-summary-raise-same-subject-and-select (score)
9239 "Raise articles which has the same subject with SCORE and select the next."
9240 (interactive "p")
9241 (let ((subject (gnus-summary-subject-string)))
9242 (gnus-summary-raise-score score)
9243 (while (gnus-summary-search-subject nil nil subject)
9244 (gnus-summary-raise-score score))
9245 (gnus-summary-next-article t)))
9247 (defun gnus-summary-raise-same-subject (score)
9248 "Raise articles which has the same subject with SCORE."
9249 (interactive "p")
9250 (let ((subject (gnus-summary-subject-string)))
9251 (gnus-summary-raise-score score)
9252 (while (gnus-summary-search-subject nil nil subject)
9253 (gnus-summary-raise-score score))
9254 (gnus-summary-next-subject 1 t)))
9256 (defun gnus-score-default (level)
9257 (if level (prefix-numeric-value level)
9258 gnus-score-interactive-default-score))
9260 (defun gnus-summary-raise-thread (&optional score)
9261 "Raise the score of the articles in the current thread with SCORE."
9262 (interactive "P")
9263 (setq score (gnus-score-default score))
9264 (let (e)
9265 (save-excursion
9266 (let ((level (gnus-summary-thread-level)))
9267 (gnus-summary-raise-score score)
9268 (while (and (zerop (gnus-summary-next-subject 1 nil t))
9269 (> (gnus-summary-thread-level) level))
9270 (gnus-summary-raise-score score))
9271 (setq e (point))))
9272 (let ((gnus-summary-check-current t))
9273 (or (zerop (gnus-summary-next-subject 1 t))
9274 (goto-char e))))
9275 (gnus-summary-recenter)
9276 (gnus-summary-position-cursor)
9277 (gnus-set-mode-line 'summary))
9279 (defun gnus-summary-lower-same-subject-and-select (score)
9280 "Raise articles which has the same subject with SCORE and select the next."
9281 (interactive "p")
9282 (gnus-summary-raise-same-subject-and-select (- score)))
9284 (defun gnus-summary-lower-same-subject (score)
9285 "Raise articles which has the same subject with SCORE."
9286 (interactive "p")
9287 (gnus-summary-raise-same-subject (- score)))
9289 (defun gnus-summary-lower-thread (&optional score)
9290 "Lower score of articles in the current thread with SCORE."
9291 (interactive "P")
9292 (gnus-summary-raise-thread (- (1- (gnus-score-default score)))))
9294 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9295 "Mark articles which has the same subject as read, and then select the next.
9296 If UNMARK is positive, remove any kind of mark.
9297 If UNMARK is negative, tick articles."
9298 (interactive "P")
9299 (if unmark
9300 (setq unmark (prefix-numeric-value unmark)))
9301 (let ((count
9302 (gnus-summary-mark-same-subject
9303 (gnus-summary-subject-string) unmark)))
9304 ;; Select next unread article. If auto-select-same mode, should
9305 ;; select the first unread article.
9306 (gnus-summary-next-article t (and gnus-auto-select-same
9307 (gnus-summary-subject-string)))
9308 (gnus-message 7 "%d article%s marked as %s"
9309 count (if (= count 1) " is" "s are")
9310 (if unmark "unread" "read"))))
9312 (defun gnus-summary-kill-same-subject (&optional unmark)
9313 "Mark articles which has the same subject as read.
9314 If UNMARK is positive, remove any kind of mark.
9315 If UNMARK is negative, tick articles."
9316 (interactive "P")
9317 (if unmark
9318 (setq unmark (prefix-numeric-value unmark)))
9319 (let ((count
9320 (gnus-summary-mark-same-subject
9321 (gnus-summary-subject-string) unmark)))
9322 ;; If marked as read, go to next unread subject.
9323 (if (null unmark)
9324 ;; Go to next unread subject.
9325 (gnus-summary-next-subject 1 t))
9326 (gnus-message 7 "%d articles are marked as %s"
9327 count (if unmark "unread" "read"))))
9329 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9330 "Mark articles with same SUBJECT as read, and return marked number.
9331 If optional argument UNMARK is positive, remove any kinds of marks.
9332 If optional argument UNMARK is negative, mark articles as unread instead."
9333 (let ((count 1))
9334 (save-excursion
9335 (cond
9336 ((null unmark) ; Mark as read.
9337 (while (and
9338 (progn
9339 (gnus-summary-mark-article-as-read gnus-killed-mark)
9340 (gnus-summary-show-thread) t)
9341 (gnus-summary-search-forward nil subject))
9342 (setq count (1+ count))))
9343 ((> unmark 0) ; Tick.
9344 (while (and
9345 (progn
9346 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9347 (gnus-summary-show-thread) t)
9348 (gnus-summary-search-forward nil subject))
9349 (setq count (1+ count))))
9350 (t ; Mark as unread.
9351 (while (and
9352 (progn
9353 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9354 (gnus-summary-show-thread) t)
9355 (gnus-summary-search-forward nil subject))
9356 (setq count (1+ count)))))
9357 (gnus-set-mode-line 'summary)
9358 ;; Return the number of marked articles.
9359 count)))
9361 (defun gnus-summary-mark-as-processable (n &optional unmark)
9362 "Set the process mark on the next N articles.
9363 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9364 the process mark instead. The difference between N and the actual
9365 number of articles marked is returned."
9366 (interactive "p")
9367 (let ((backward (< n 0))
9368 (n (abs n)))
9369 (while (and
9370 (> n 0)
9371 (if unmark
9372 (gnus-summary-remove-process-mark
9373 (gnus-summary-article-number))
9374 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9375 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9376 (setq n (1- n)))
9377 (if (/= 0 n) (gnus-message 7 "No more articles"))
9378 (gnus-summary-recenter)
9379 (gnus-summary-position-cursor)
9382 (defun gnus-summary-unmark-as-processable (n)
9383 "Remove the process mark from the next N articles.
9384 If N is negative, mark backward instead. The difference between N and
9385 the actual number of articles marked is returned."
9386 (interactive "p")
9387 (gnus-summary-mark-as-processable n t))
9389 (defun gnus-summary-unmark-all-processable ()
9390 "Remove the process mark from all articles."
9391 (interactive)
9392 (save-excursion
9393 (while gnus-newsgroup-processable
9394 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9395 (gnus-summary-position-cursor))
9397 (defun gnus-summary-mark-as-expirable (n)
9398 "Mark N articles forward as expirable.
9399 If N is negative, mark backward instead. The difference between N and
9400 the actual number of articles marked is returned."
9401 (interactive "p")
9402 (gnus-summary-mark-forward n gnus-expirable-mark))
9404 (defun gnus-summary-mark-article-as-replied (article)
9405 "Mark ARTICLE replied and update the summary line."
9406 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
9407 (let ((buffer-read-only nil))
9408 (if (gnus-summary-goto-subject article)
9409 (progn
9410 (gnus-summary-update-mark gnus-replied-mark 'replied)
9411 t))))
9413 (defun gnus-summary-set-bookmark (article)
9414 "Set a bookmark in current article."
9415 (interactive (list (gnus-summary-article-number)))
9416 (if (or (not (get-buffer gnus-article-buffer))
9417 (not gnus-current-article)
9418 (not gnus-article-current)
9419 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9420 (error "No current article selected"))
9421 ;; Remove old bookmark, if one exists.
9422 (let ((old (assq article gnus-newsgroup-bookmarks)))
9423 (if old (setq gnus-newsgroup-bookmarks
9424 (delq old gnus-newsgroup-bookmarks))))
9425 ;; Set the new bookmark, which is on the form
9426 ;; (article-number . line-number-in-body).
9427 (setq gnus-newsgroup-bookmarks
9428 (cons
9429 (cons article
9430 (save-excursion
9431 (set-buffer gnus-article-buffer)
9432 (count-lines
9433 (min (point)
9434 (save-excursion
9435 (goto-char (point-min))
9436 (search-forward "\n\n" nil t)
9437 (point)))
9438 (point))))
9439 gnus-newsgroup-bookmarks))
9440 (gnus-message 6 "A bookmark has been added to the current article."))
9442 (defun gnus-summary-remove-bookmark (article)
9443 "Remove the bookmark from the current article."
9444 (interactive (list (gnus-summary-article-number)))
9445 ;; Remove old bookmark, if one exists.
9446 (let ((old (assq article gnus-newsgroup-bookmarks)))
9447 (if old
9448 (progn
9449 (setq gnus-newsgroup-bookmarks
9450 (delq old gnus-newsgroup-bookmarks))
9451 (gnus-message 6 "Removed bookmark."))
9452 (gnus-message 6 "No bookmark in current article."))))
9454 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9455 (defun gnus-summary-mark-as-dormant (n)
9456 "Mark N articles forward as dormant.
9457 If N is negative, mark backward instead. The difference between N and
9458 the actual number of articles marked is returned."
9459 (interactive "p")
9460 (gnus-summary-mark-forward n gnus-dormant-mark))
9462 (defun gnus-summary-set-process-mark (article)
9463 "Set the process mark on ARTICLE and update the summary line."
9464 (setq gnus-newsgroup-processable
9465 (cons article
9466 (delq article gnus-newsgroup-processable)))
9467 (let ((buffer-read-only nil))
9468 (if (gnus-summary-goto-subject article)
9469 (progn
9470 (gnus-summary-show-thread)
9471 (and (eq (gnus-summary-article-mark) gnus-dummy-mark)
9472 (forward-line 1))
9473 (gnus-summary-update-mark gnus-process-mark 'replied)
9474 t))))
9476 (defun gnus-summary-remove-process-mark (article)
9477 "Remove the process mark from ARTICLE and update the summary line."
9478 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9479 (let ((buffer-read-only nil))
9480 (if (gnus-summary-goto-subject article)
9481 (progn
9482 (gnus-summary-show-thread)
9483 (and (eq (gnus-summary-article-mark) gnus-dummy-mark)
9484 (forward-line 1))
9485 (gnus-summary-update-mark ? 'replied)
9486 (if (memq article gnus-newsgroup-replied)
9487 (gnus-summary-update-mark gnus-replied-mark 'replied))
9488 t))))
9490 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9491 "Mark N articles as read forwards.
9492 If N is negative, mark backwards instead.
9493 Mark with MARK. If MARK is ? , ?! or ??, articles will be
9494 marked as unread.
9495 The difference between N and the actual number of articles marked is
9496 returned."
9497 (interactive "p")
9498 (gnus-set-global-variables)
9499 (let ((backward (< n 0))
9500 (gnus-summary-goto-unread
9501 (and gnus-summary-goto-unread
9502 (not (memq mark (list gnus-unread-mark
9503 gnus-ticked-mark gnus-dormant-mark)))))
9504 (n (abs n))
9505 (mark (or mark gnus-del-mark)))
9506 (while (and (> n 0)
9507 (gnus-summary-mark-article nil mark no-expire)
9508 (zerop (gnus-summary-next-subject
9509 (if backward -1 1) gnus-summary-goto-unread t)))
9510 (setq n (1- n)))
9511 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9512 (gnus-summary-recenter)
9513 (gnus-summary-position-cursor)
9514 (gnus-set-mode-line 'summary)
9517 (defun gnus-summary-mark-article-as-read (mark)
9518 "Mark the current article quickly as read with MARK."
9519 (let ((article (gnus-summary-article-number)))
9520 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9521 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9522 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9523 (setq gnus-newsgroup-reads
9524 (cons (cons article mark) gnus-newsgroup-reads))
9525 ;; Possibly remove from cache, if that is used.
9526 (and gnus-use-cache (gnus-cache-enter-remove-article article))
9527 (and gnus-newsgroup-auto-expire
9528 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
9529 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
9530 (= mark gnus-read-mark))
9531 (progn
9532 (setq mark gnus-expirable-mark)
9533 (setq gnus-newsgroup-expirable
9534 (cons article gnus-newsgroup-expirable))))
9535 (while (eq (gnus-summary-article-mark) gnus-dummy-mark)
9536 (forward-line 1))
9537 ;; Fix the mark.
9538 (gnus-summary-update-mark mark 'unread)
9541 (defun gnus-summary-mark-article-as-unread (mark)
9542 "Mark the current article quickly as unread with MARK."
9543 (let ((article (gnus-summary-article-number)))
9544 (or (memq article gnus-newsgroup-unreads)
9545 (setq gnus-newsgroup-unreads (cons article gnus-newsgroup-unreads)))
9546 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9547 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9548 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9549 (setq gnus-newsgroup-reads
9550 (delq (assq article gnus-newsgroup-reads)
9551 gnus-newsgroup-reads))
9552 (if (= mark gnus-ticked-mark)
9553 (setq gnus-newsgroup-marked (cons article gnus-newsgroup-marked)))
9554 (if (= mark gnus-dormant-mark)
9555 (setq gnus-newsgroup-dormant (cons article gnus-newsgroup-dormant)))
9557 ;; See whether the article is to be put in the cache.
9558 (and gnus-use-cache
9559 (vectorp (gnus-get-header-by-num article))
9560 (save-excursion
9561 (gnus-cache-possibly-enter-article
9562 gnus-newsgroup-name article
9563 (gnus-get-header-by-num article)
9564 (= mark gnus-ticked-mark)
9565 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9567 (while (eq (gnus-summary-article-mark) gnus-dummy-mark)
9568 (forward-line 1))
9569 ;; Fix the mark.
9570 (gnus-summary-update-mark mark 'unread)
9573 (defun gnus-summary-mark-article (&optional article mark no-expire)
9574 "Mark ARTICLE with MARK. MARK can be any character.
9575 Four MARK strings are reserved: `? ' (unread), `?!' (ticked), `??'
9576 (dormant) and `?E' (expirable).
9577 If MARK is nil, then the default character `?D' is used.
9578 If ARTICLE is nil, then the article on the current line will be
9579 marked."
9580 (and (stringp mark)
9581 (setq mark (aref mark 0)))
9582 ;; If no mark is given, then we check auto-expiring.
9583 (and (not no-expire)
9584 gnus-newsgroup-auto-expire
9585 (or (not mark)
9586 (and (numberp mark)
9587 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
9588 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
9589 (= mark gnus-read-mark))))
9590 (setq mark gnus-expirable-mark))
9591 (let* ((mark (or mark gnus-del-mark))
9592 (article (or article (gnus-summary-article-number))))
9593 (or article (error "No article on current line"))
9594 (if (or (= mark gnus-unread-mark)
9595 (= mark gnus-ticked-mark)
9596 (= mark gnus-dormant-mark))
9597 (gnus-mark-article-as-unread article mark)
9598 (gnus-mark-article-as-read article mark))
9600 ;; See whether the article is to be put in the cache.
9601 (and gnus-use-cache
9602 (not (= mark gnus-canceled-mark))
9603 (vectorp (gnus-get-header-by-num article))
9604 (save-excursion
9605 (gnus-cache-possibly-enter-article
9606 gnus-newsgroup-name article
9607 (gnus-get-header-by-num article)
9608 (= mark gnus-ticked-mark)
9609 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9611 (if (gnus-summary-goto-subject article)
9612 (let ((buffer-read-only nil))
9613 (gnus-summary-show-thread)
9614 (and (eq (gnus-summary-article-mark) gnus-dummy-mark)
9615 (forward-line 1))
9616 ;; Fix the mark.
9617 (gnus-summary-update-mark mark 'unread)
9618 t))))
9620 (defun gnus-summary-update-mark (mark type)
9621 (beginning-of-line)
9622 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
9623 (buffer-read-only nil)
9624 plist)
9625 (if (not forward)
9627 (forward-char forward)
9628 (setq plist (text-properties-at (point)))
9629 (delete-char 1)
9630 (insert mark)
9631 (and plist (add-text-properties (1- (point)) (point) plist))
9632 (and (eq type 'unread)
9633 (progn
9634 (add-text-properties (1- (point)) (point) (list 'gnus-mark mark))
9635 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
9637 (defun gnus-mark-article-as-read (article &optional mark)
9638 "Enter ARTICLE in the pertinent lists and remove it from others."
9639 ;; Make the article expirable.
9640 (let ((mark (or mark gnus-del-mark)))
9641 (if (= mark gnus-expirable-mark)
9642 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
9643 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
9644 ;; Remove from unread and marked lists.
9645 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9646 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9647 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9648 (setq gnus-newsgroup-reads
9649 (cons (cons article mark) gnus-newsgroup-reads))
9650 ;; Possibly remove from cache, if that is used.
9651 (and gnus-use-cache (gnus-cache-enter-remove-article article))))
9653 (defun gnus-mark-article-as-unread (article &optional mark)
9654 "Enter ARTICLE in the pertinent lists and remove it from others."
9655 (let ((mark (or mark gnus-ticked-mark)))
9656 ;; Add to unread list.
9657 (or (memq article gnus-newsgroup-unreads)
9658 (setq gnus-newsgroup-unreads (cons article gnus-newsgroup-unreads)))
9659 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9660 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9661 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9662 (setq gnus-newsgroup-reads
9663 (delq (assq article gnus-newsgroup-reads)
9664 gnus-newsgroup-reads))
9665 (if (= mark gnus-ticked-mark)
9666 (setq gnus-newsgroup-marked (cons article gnus-newsgroup-marked)))
9667 (if (= mark gnus-dormant-mark)
9668 (setq gnus-newsgroup-dormant (cons article gnus-newsgroup-dormant)))))
9670 (defalias 'gnus-summary-mark-as-unread-forward
9671 'gnus-summary-tick-article-forward)
9672 (make-obsolete 'gnus-summary-mark-as-unread-forward
9673 'gnus-summary-tick-article-forward)
9674 (defun gnus-summary-tick-article-forward (n)
9675 "Tick N articles forwards.
9676 If N is negative, tick backwards instead.
9677 The difference between N and the number of articles ticked is returned."
9678 (interactive "p")
9679 (gnus-summary-mark-forward n gnus-ticked-mark))
9681 (defalias 'gnus-summary-mark-as-unread-backward
9682 'gnus-summary-tick-article-backward)
9683 (make-obsolete 'gnus-summary-mark-as-unread-backward
9684 'gnus-summary-tick-article-backward)
9685 (defun gnus-summary-tick-article-backward (n)
9686 "Tick N articles backwards.
9687 The difference between N and the number of articles ticked is returned."
9688 (interactive "p")
9689 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
9691 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9692 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9693 (defun gnus-summary-tick-article (&optional article clear-mark)
9694 "Mark current article as unread.
9695 Optional 1st argument ARTICLE specifies article number to be marked as unread.
9696 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
9697 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
9698 gnus-ticked-mark)))
9700 (defun gnus-summary-mark-as-read-forward (n)
9701 "Mark N articles as read forwards.
9702 If N is negative, mark backwards instead.
9703 The difference between N and the actual number of articles marked is
9704 returned."
9705 (interactive "p")
9706 (gnus-summary-mark-forward n gnus-del-mark t))
9708 (defun gnus-summary-mark-as-read-backward (n)
9709 "Mark the N articles as read backwards.
9710 The difference between N and the actual number of articles marked is
9711 returned."
9712 (interactive "p")
9713 (gnus-summary-mark-forward (- n) gnus-del-mark t))
9715 (defun gnus-summary-mark-as-read (&optional article mark)
9716 "Mark current article as read.
9717 ARTICLE specifies the article to be marked as read.
9718 MARK specifies a string to be inserted at the beginning of the line."
9719 (gnus-summary-mark-article article mark))
9721 (defun gnus-summary-clear-mark-forward (n)
9722 "Clear marks from N articles forward.
9723 If N is negative, clear backward instead.
9724 The difference between N and the number of marks cleared is returned."
9725 (interactive "p")
9726 (gnus-summary-mark-forward n gnus-unread-mark))
9728 (defun gnus-summary-clear-mark-backward (n)
9729 "Clear marks from N articles backward.
9730 The difference between N and the number of marks cleared is returned."
9731 (interactive "p")
9732 (gnus-summary-mark-forward (- n) gnus-unread-mark))
9734 (defun gnus-summary-mark-unread-as-read ()
9735 "Intended to be used by `gnus-summary-mark-article-hook'."
9736 (or (memq gnus-current-article gnus-newsgroup-marked)
9737 (memq gnus-current-article gnus-newsgroup-dormant)
9738 (memq gnus-current-article gnus-newsgroup-expirable)
9739 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
9741 (defun gnus-summary-mark-region-as-read (point mark all)
9742 "Mark all unread articles between point and mark as read.
9743 If given a prefix, mark all articles between point and mark as read,
9744 even ticked and dormant ones."
9745 (interactive "r\nP")
9746 (save-excursion
9747 (goto-char point)
9748 (beginning-of-line)
9749 (while (and
9750 (< (point) mark)
9751 (progn
9752 (and
9753 (or all
9754 (and
9755 (not (memq (gnus-summary-article-number)
9756 gnus-newsgroup-marked))
9757 (not (memq (gnus-summary-article-number)
9758 gnus-newsgroup-dormant))))
9759 (gnus-summary-mark-article
9760 (gnus-summary-article-number) gnus-del-mark))
9762 (zerop (forward-line 1))))))
9764 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
9765 (defalias 'gnus-summary-delete-marked-as-read
9766 'gnus-summary-remove-lines-marked-as-read)
9767 (make-obsolete 'gnus-summary-delete-marked-as-read
9768 'gnus-summary-remove-lines-marked-as-read)
9769 (defun gnus-summary-remove-lines-marked-as-read ()
9770 "Remove lines that are marked as read."
9771 (interactive)
9772 (gnus-summary-remove-lines-marked-with
9773 (concat (mapconcat
9774 (lambda (char) (char-to-string (symbol-value char)))
9775 '(gnus-del-mark gnus-read-mark gnus-ancient-mark
9776 gnus-killed-mark gnus-kill-file-mark
9777 gnus-low-score-mark gnus-expirable-mark
9778 gnus-canceled-mark gnus-catchup-mark)
9779 ""))))
9781 (defalias 'gnus-summary-delete-marked-with
9782 'gnus-summary-remove-lines-marked-with)
9783 (make-obsolete 'gnus-summary-delete-marked-with
9784 'gnus-summary-remove-lines-marked-with)
9785 ;; Rewrite by Daniel Quinlan <quinlan@best.com>.
9786 (defun gnus-summary-remove-lines-marked-with (marks)
9787 "Remove lines that are marked with MARKS (e.g. \"DK\")."
9788 (interactive "sMarks: ")
9789 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
9790 (gnus-set-global-variables)
9791 (let ((buffer-read-only nil)
9792 (orig-article
9793 (let ((gnus-summary-check-current t))
9794 (gnus-summary-search-forward t)
9795 (gnus-summary-article-number)))
9796 (marks (concat "^[" marks "]")))
9797 (goto-char (point-min))
9798 (if gnus-newsgroup-adaptive
9799 (gnus-score-remove-lines-adaptive marks)
9800 (while (re-search-forward marks nil t)
9801 (gnus-delete-line)))
9802 ;; If we use dummy roots, we have to do an additional sweep over
9803 ;; the buffer.
9804 (if (not (eq gnus-summary-make-false-root 'dummy))
9806 (goto-char (point-min))
9807 (setq marks (concat "^[" (char-to-string gnus-dummy-mark) "]"))
9808 (while (re-search-forward marks nil t)
9809 (if (gnus-subject-equal
9810 (gnus-summary-subject-string)
9811 (progn
9812 (forward-line 1)
9813 (gnus-summary-subject-string)))
9815 (forward-line -1)
9816 (gnus-delete-line))))
9817 (or (zerop (buffer-size))
9818 (gnus-summary-goto-subject orig-article)
9819 (if (eobp)
9820 (gnus-summary-prev-subject 1)
9821 (gnus-summary-position-cursor)))))
9823 (defun gnus-summary-expunge-below (&optional score)
9824 "Remove articles with score less than SCORE."
9825 (interactive "P")
9826 (gnus-set-global-variables)
9827 (setq score (if score
9828 (prefix-numeric-value score)
9829 (or gnus-summary-default-score 0)))
9830 (save-excursion
9831 (set-buffer gnus-summary-buffer)
9832 (goto-char (point-min))
9833 (let ((buffer-read-only nil)
9834 beg)
9835 (while (not (eobp))
9836 (if (< (gnus-summary-article-score) score)
9837 (progn
9838 (setq beg (point))
9839 (forward-line 1)
9840 (delete-region beg (point)))
9841 (forward-line 1)))
9842 ;; Adjust point.
9843 (or (zerop (buffer-size))
9844 (if (eobp)
9845 (gnus-summary-prev-subject 1)
9846 (gnus-summary-position-cursor))))))
9848 (defun gnus-summary-mark-below (score mark)
9849 "Mark articles with score less than SCORE with MARK."
9850 (interactive "P\ncMark: ")
9851 (gnus-set-global-variables)
9852 (setq score (if score
9853 (prefix-numeric-value score)
9854 (or gnus-summary-default-score 0)))
9855 (save-excursion
9856 (set-buffer gnus-summary-buffer)
9857 (goto-char (point-min))
9858 (while (not (eobp))
9859 (and (< (gnus-summary-article-score) score)
9860 (gnus-summary-mark-article nil mark))
9861 (forward-line 1))))
9863 (defun gnus-summary-kill-below (&optional score)
9864 "Mark articles with score below SCORE as read."
9865 (interactive "P")
9866 (gnus-set-global-variables)
9867 (gnus-summary-mark-below score gnus-killed-mark))
9869 (defun gnus-summary-clear-above (&optional score)
9870 "Clear all marks from articles with score above SCORE."
9871 (interactive "P")
9872 (gnus-set-global-variables)
9873 (gnus-summary-mark-above score gnus-unread-mark))
9875 (defun gnus-summary-tick-above (&optional score)
9876 "Tick all articles with score above SCORE."
9877 (interactive "P")
9878 (gnus-set-global-variables)
9879 (gnus-summary-mark-above score gnus-ticked-mark))
9881 (defun gnus-summary-mark-above (score mark)
9882 "Mark articles with score over SCORE with MARK."
9883 (interactive "P\ncMark: ")
9884 (gnus-set-global-variables)
9885 (setq score (if score
9886 (prefix-numeric-value score)
9887 (or gnus-summary-default-score 0)))
9888 (save-excursion
9889 (set-buffer gnus-summary-buffer)
9890 (goto-char (point-min))
9891 (while (not (eobp))
9892 (if (> (gnus-summary-article-score) score)
9893 (progn
9894 (gnus-summary-mark-article nil mark)
9895 (forward-line 1))
9896 (forward-line 1)))))
9898 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9899 (defun gnus-summary-show-all-expunged ()
9900 "Display all the hidden articles that were expunged for low scores."
9901 (interactive)
9902 (gnus-set-global-variables)
9903 (let ((buffer-read-only nil))
9904 (let ((scored gnus-newsgroup-scored)
9905 headers h)
9906 (while scored
9907 (or (gnus-summary-goto-subject (car (car scored)))
9908 (and (setq h (gnus-get-header-by-num (car (car scored))))
9909 (< (cdr (car scored)) gnus-summary-expunge-below)
9910 (setq headers (cons h headers))))
9911 (setq scored (cdr scored)))
9912 (or headers (error "No expunged articles hidden."))
9913 (goto-char (point-min))
9914 (save-excursion
9915 (gnus-summary-update-lines
9916 (point)
9917 (progn
9918 (gnus-summary-prepare-unthreaded (nreverse headers))
9919 (point)))))
9920 (goto-char (point-min))
9921 (gnus-summary-position-cursor)))
9923 (defun gnus-summary-show-all-dormant ()
9924 "Display all the hidden articles that are marked as dormant."
9925 (interactive)
9926 (gnus-set-global-variables)
9927 (let ((buffer-read-only nil))
9928 (let ((dormant gnus-newsgroup-dormant)
9929 headers h)
9930 (while dormant
9931 (or (gnus-summary-goto-subject (car dormant))
9932 (and (setq h (gnus-get-header-by-num (car dormant)))
9933 (setq headers (cons h headers))))
9934 (setq dormant (cdr dormant)))
9935 (or headers (error "No dormant articles hidden."))
9936 (goto-char (point-min))
9937 (save-excursion
9938 (gnus-summary-update-lines
9939 (point)
9940 (progn
9941 (gnus-summary-prepare-unthreaded (nreverse headers))
9942 (point)))))
9943 (goto-char (point-min))
9944 (gnus-summary-position-cursor)))
9946 (defun gnus-summary-hide-all-dormant ()
9947 "Hide all dormant articles."
9948 (interactive)
9949 (gnus-set-global-variables)
9950 (gnus-summary-remove-lines-marked-with (char-to-string gnus-dormant-mark))
9951 (gnus-summary-position-cursor))
9953 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
9954 "Mark all articles not marked as unread in this newsgroup as read.
9955 If prefix argument ALL is non-nil, all articles are marked as read.
9956 If QUIETLY is non-nil, no questions will be asked.
9957 If TO-HERE is non-nil, it should be a point in the buffer. All
9958 articles before this point will be marked as read.
9959 The number of articles marked as read is returned."
9960 (interactive "P")
9961 (gnus-set-global-variables)
9962 (prog1
9963 (if (or quietly
9964 (not gnus-interactive-catchup) ;Without confirmation?
9965 gnus-expert-user
9966 (gnus-y-or-n-p
9967 (if all
9968 "Mark absolutely all articles as read? "
9969 "Mark all unread articles as read? ")))
9970 (if (and not-mark
9971 (not gnus-newsgroup-adaptive)
9972 (not gnus-newsgroup-auto-expire))
9973 (progn
9974 (and all (setq gnus-newsgroup-marked nil
9975 gnus-newsgroup-dormant nil))
9976 (setq gnus-newsgroup-unreads
9977 (append gnus-newsgroup-marked gnus-newsgroup-dormant)))
9978 ;; We actually mark all articles as canceled, which we
9979 ;; have to do when using auto-expiry or adaptive scoring.
9980 (gnus-summary-show-all-threads)
9981 (if (gnus-summary-first-subject (not all))
9982 (while (and
9983 (if to-here (< (point) to-here) t)
9984 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9985 (gnus-summary-search-subject nil (not all)))))
9986 (or to-here
9987 (setq gnus-newsgroup-unreads
9988 (append gnus-newsgroup-marked
9989 gnus-newsgroup-dormant)))))
9990 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
9991 (if (and (not to-here) (eq 'nnvirtual (car method)))
9992 (nnvirtual-catchup-group
9993 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
9994 (gnus-summary-position-cursor)))
9996 (defun gnus-summary-catchup-to-here (&optional all)
9997 "Mark all unticked articles before the current one as read.
9998 If ALL is non-nil, also mark ticked and dormant articles as read."
9999 (interactive "P")
10000 (gnus-set-global-variables)
10001 (save-excursion
10002 (and (zerop (forward-line -1))
10003 (progn
10004 (end-of-line)
10005 (gnus-summary-catchup all t (point))
10006 (gnus-set-mode-line 'summary))))
10007 (gnus-summary-position-cursor))
10009 (defun gnus-summary-catchup-all (&optional quietly)
10010 "Mark all articles in this newsgroup as read."
10011 (interactive "P")
10012 (gnus-set-global-variables)
10013 (gnus-summary-catchup t quietly))
10015 (defun gnus-summary-catchup-and-exit (&optional all quietly)
10016 "Mark all articles not marked as unread in this newsgroup as read, then exit.
10017 If prefix argument ALL is non-nil, all articles are marked as read."
10018 (interactive "P")
10019 (gnus-set-global-variables)
10020 (gnus-summary-catchup all quietly nil 'fast)
10021 ;; Select next newsgroup or exit.
10022 (if (and (eq gnus-auto-select-next 'quietly)
10023 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
10024 (gnus-summary-next-group nil)
10025 (gnus-summary-exit)))
10027 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
10028 "Mark all articles in this newsgroup as read, and then exit."
10029 (interactive "P")
10030 (gnus-set-global-variables)
10031 (gnus-summary-catchup-and-exit t quietly))
10033 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
10034 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
10035 "Mark all articles in this group as read and select the next group.
10036 If given a prefix, mark all articles, unread as well as ticked, as
10037 read."
10038 (interactive "P")
10039 (gnus-set-global-variables)
10040 (gnus-summary-catchup all)
10041 (gnus-summary-next-group))
10043 ;; Thread-based commands.
10045 (defun gnus-summary-toggle-threads (&optional arg)
10046 "Toggle showing conversation threads.
10047 If ARG is positive number, turn showing conversation threads on."
10048 (interactive "P")
10049 (gnus-set-global-variables)
10050 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
10051 (setq gnus-show-threads
10052 (if (null arg) (not gnus-show-threads)
10053 (> (prefix-numeric-value arg) 0)))
10054 (gnus-summary-prepare)
10055 (gnus-summary-goto-subject current)
10056 (gnus-summary-position-cursor)))
10058 (defun gnus-summary-show-all-threads ()
10059 "Show all threads."
10060 (interactive)
10061 (gnus-set-global-variables)
10062 (save-excursion
10063 (let ((buffer-read-only nil))
10064 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10065 (gnus-summary-position-cursor))
10067 (defun gnus-summary-show-thread ()
10068 "Show thread subtrees.
10069 Returns nil if no thread was there to be shown."
10070 (interactive)
10071 (gnus-set-global-variables)
10072 (let ((buffer-read-only nil)
10073 (orig (prog1 (point) (gnus-summary-hide-thread)))
10074 ;; first goto end then to beg, to have point at beg after let
10075 (end (progn (end-of-line) (point)))
10076 (beg (progn (beginning-of-line) (point))))
10077 (prog1
10078 ;; Any hidden lines here?
10079 (search-forward "\r" end t)
10080 (subst-char-in-region beg end ?\^M ?\n t)
10081 (goto-char orig)
10082 (gnus-summary-position-cursor))))
10084 (defun gnus-summary-hide-all-threads ()
10085 "Hide all thread subtrees."
10086 (interactive)
10087 (gnus-set-global-variables)
10088 (save-excursion
10089 (goto-char (point-min))
10090 (gnus-summary-hide-thread)
10091 (while (and (not (eobp)) (zerop (forward-line 1)))
10092 (gnus-summary-hide-thread)))
10093 (gnus-summary-position-cursor))
10095 (defun gnus-summary-hide-thread ()
10096 "Hide thread subtrees.
10097 Returns nil if no threads were there to be hidden."
10098 (interactive)
10099 (gnus-set-global-variables)
10100 (let ((buffer-read-only nil)
10101 (start (point))
10102 (level (gnus-summary-thread-level))
10103 (end (point)))
10104 ;; Go forward until either the buffer ends or the subthread
10105 ;; ends.
10106 (if (eobp)
10108 (while (and (zerop (forward-line 1))
10109 (> (gnus-summary-thread-level) level))
10110 (setq end (point)))
10111 (prog1
10112 (save-excursion
10113 (goto-char end)
10114 (search-backward "\n" start t))
10115 (subst-char-in-region start end ?\n ?\^M t)
10116 (forward-line -1)
10117 (gnus-summary-position-cursor)))))
10119 (defun gnus-summary-go-to-next-thread (&optional previous)
10120 "Go to the same level (or less) next thread.
10121 If PREVIOUS is non-nil, go to previous thread instead.
10122 Return the article number moved to, or nil if moving was impossible."
10123 (let ((level (gnus-summary-thread-level))
10124 (article (gnus-summary-article-number)))
10125 (if previous
10126 (while (and (zerop (forward-line -1))
10127 (> (gnus-summary-thread-level) level)))
10128 (while (and (save-excursion
10129 (forward-line 1)
10130 (not (eobp)))
10131 (zerop (forward-line 1))
10132 (> (gnus-summary-thread-level) level))))
10133 (gnus-summary-recenter)
10134 (gnus-summary-position-cursor)
10135 (let ((oart (gnus-summary-article-number)))
10136 (and (/= oart article) oart))))
10138 (defun gnus-summary-next-thread (n)
10139 "Go to the same level next N'th thread.
10140 If N is negative, search backward instead.
10141 Returns the difference between N and the number of skips actually
10142 done."
10143 (interactive "p")
10144 (gnus-set-global-variables)
10145 (let ((backward (< n 0))
10146 (n (abs n)))
10147 (while (and (> n 0)
10148 (gnus-summary-go-to-next-thread backward))
10149 (setq n (1- n)))
10150 (gnus-summary-position-cursor)
10151 (if (/= 0 n) (gnus-message 7 "No more threads"))
10154 (defun gnus-summary-prev-thread (n)
10155 "Go to the same level previous N'th thread.
10156 Returns the difference between N and the number of skips actually
10157 done."
10158 (interactive "p")
10159 (gnus-set-global-variables)
10160 (gnus-summary-next-thread (- n)))
10162 (defun gnus-summary-go-down-thread (&optional same)
10163 "Go down one level in the current thread.
10164 If SAME is non-nil, also move to articles of the same level."
10165 (let ((level (gnus-summary-thread-level))
10166 (start (point)))
10167 (if (and (zerop (forward-line 1))
10168 (> (gnus-summary-thread-level) level))
10170 (goto-char start)
10171 nil)))
10173 (defun gnus-summary-go-up-thread ()
10174 "Go up one level in the current thread."
10175 (let ((level (gnus-summary-thread-level))
10176 (start (point)))
10177 (while (and (zerop (forward-line -1))
10178 (>= (gnus-summary-thread-level) level)))
10179 (if (>= (gnus-summary-thread-level) level)
10180 (progn
10181 (goto-char start)
10182 nil)
10183 t)))
10185 (defun gnus-summary-down-thread (n)
10186 "Go down thread N steps.
10187 If N is negative, go up instead.
10188 Returns the difference between N and how many steps down that were
10189 taken."
10190 (interactive "p")
10191 (gnus-set-global-variables)
10192 (let ((up (< n 0))
10193 (n (abs n)))
10194 (while (and (> n 0)
10195 (if up (gnus-summary-go-up-thread)
10196 (gnus-summary-go-down-thread)))
10197 (setq n (1- n)))
10198 (gnus-summary-position-cursor)
10199 (if (/= 0 n) (gnus-message 7 "Can't go further"))
10202 (defun gnus-summary-up-thread (n)
10203 "Go up thread N steps.
10204 If N is negative, go up instead.
10205 Returns the difference between N and how many steps down that were
10206 taken."
10207 (interactive "p")
10208 (gnus-set-global-variables)
10209 (gnus-summary-down-thread (- n)))
10211 (defun gnus-summary-kill-thread (&optional unmark)
10212 "Mark articles under current thread as read.
10213 If the prefix argument is positive, remove any kinds of marks.
10214 If the prefix argument is negative, tick articles instead."
10215 (interactive "P")
10216 (gnus-set-global-variables)
10217 (if unmark
10218 (setq unmark (prefix-numeric-value unmark)))
10219 (let ((killing t)
10220 (level (gnus-summary-thread-level)))
10221 (save-excursion
10222 ;; Expand the thread.
10223 (gnus-summary-show-thread)
10224 (while killing
10225 ;; Mark the article...
10226 (cond ((null unmark) (gnus-summary-mark-article-as-read
10227 gnus-killed-mark))
10228 ((> unmark 0) (gnus-summary-mark-article-as-unread
10229 gnus-unread-mark))
10230 (t (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10231 ;; ...and go forward until either the buffer ends or the subtree
10232 ;; ends.
10233 (if (not (and (zerop (forward-line 1))
10234 (> (gnus-summary-thread-level) level)))
10235 (setq killing nil))))
10236 ;; Hide killed subtrees.
10237 (and (null unmark)
10238 gnus-thread-hide-killed
10239 (gnus-summary-hide-thread))
10240 ;; If marked as read, go to next unread subject.
10241 (if (null unmark)
10242 ;; Go to next unread subject.
10243 (gnus-summary-next-subject 1 t)))
10244 (gnus-set-mode-line 'summary))
10246 ;; Summary sorting commands
10248 (defun gnus-summary-sort-by-number (&optional reverse)
10249 "Sort summary buffer by article number.
10250 Argument REVERSE means reverse order."
10251 (interactive "P")
10252 (gnus-set-global-variables)
10253 (gnus-summary-sort
10254 ;; `gnus-summary-article-number' is a macro, and `sort-subr' wants
10255 ;; a function, so we wrap it.
10256 (cons (lambda () (gnus-summary-article-number))
10257 'gnus-thread-sort-by-number) reverse))
10259 (defun gnus-summary-sort-by-author (&optional reverse)
10260 "Sort summary buffer by author name alphabetically.
10261 If case-fold-search is non-nil, case of letters is ignored.
10262 Argument REVERSE means reverse order."
10263 (interactive "P")
10264 (gnus-set-global-variables)
10265 (gnus-summary-sort
10266 (cons
10267 (lambda ()
10268 (let* ((header (gnus-get-header-by-num (gnus-summary-article-number)))
10269 extract)
10270 (if (not (vectorp header))
10272 (setq extract (funcall gnus-extract-address-components
10273 (mail-header-from header)))
10274 (concat (or (car extract) (cdr extract))
10275 "\r" (int-to-string (mail-header-number header))
10276 "\r" (mail-header-subject header)))))
10277 'gnus-thread-sort-by-author)
10278 reverse))
10280 (defun gnus-summary-sort-by-subject (&optional reverse)
10281 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
10282 If case-fold-search is non-nil, case of letters is ignored.
10283 Argument REVERSE means reverse order."
10284 (interactive "P")
10285 (gnus-set-global-variables)
10286 (gnus-summary-sort
10287 (cons
10288 (lambda ()
10289 (let* ((header (gnus-get-header-by-num (gnus-summary-article-number)))
10290 extract)
10291 (if (not (vectorp header))
10293 (setq extract (funcall gnus-extract-address-components
10294 (mail-header-from header)))
10295 (concat
10296 (downcase (gnus-simplify-subject (gnus-summary-subject-string) t))
10297 "\r" (int-to-string (mail-header-number header))
10298 "\r" (or (car extract) (cdr extract))))))
10299 'gnus-thread-sort-by-subject)
10300 reverse))
10302 (defun gnus-summary-sort-by-date (&optional reverse)
10303 "Sort summary buffer by date.
10304 Argument REVERSE means reverse order."
10305 (interactive "P")
10306 (gnus-set-global-variables)
10307 (gnus-summary-sort
10308 (cons
10309 (lambda ()
10310 (gnus-sortable-date
10311 (mail-header-date
10312 (gnus-get-header-by-num (gnus-summary-article-number)))))
10313 'gnus-thread-sort-by-date)
10314 reverse))
10316 (defun gnus-summary-sort-by-score (&optional reverse)
10317 "Sort summary buffer by score.
10318 Argument REVERSE means reverse order."
10319 (interactive "P")
10320 (gnus-set-global-variables)
10321 (gnus-summary-sort
10322 (cons (lambda () (gnus-summary-article-score))
10323 'gnus-thread-sort-by-score)
10324 (not reverse)))
10326 (defvar gnus-summary-already-sorted nil)
10327 (defun gnus-summary-sort (predicate reverse)
10328 ;; Sort summary buffer by PREDICATE. REVERSE means reverse order.
10329 (if gnus-summary-already-sorted
10331 (let (buffer-read-only)
10332 (if (not gnus-show-threads)
10333 ;; We do untreaded sorting...
10334 (progn
10335 (goto-char (point-min))
10336 (sort-subr reverse 'forward-line 'end-of-line (car predicate)))
10337 ;; ... or we do threaded sorting.
10338 (let ((gnus-thread-sort-functions (list (cdr predicate)))
10339 (gnus-summary-prepare-hook nil)
10340 (gnus-summary-already-sorted nil))
10341 ;; We do that by simply regenerating the threads.
10342 (gnus-summary-prepare)
10343 (and gnus-show-threads
10344 gnus-thread-hide-subtree
10345 (gnus-summary-hide-all-threads))
10346 ;; If in async mode, we send some info to the backend.
10347 (and gnus-newsgroup-async
10348 (setq gnus-newsgroup-threads (nreverse gnus-newsgroup-threads))
10349 (gnus-request-asynchronous
10350 gnus-newsgroup-name
10351 (if (and gnus-asynchronous-article-function
10352 (fboundp gnus-asynchronous-article-function))
10353 (funcall gnus-asynchronous-article-function
10354 gnus-newsgroup-threads)
10355 gnus-newsgroup-threads))))))))
10358 (defun gnus-sortable-date (date)
10359 "Make sortable string by string-lessp from DATE.
10360 Timezone package is used."
10361 (let* ((date (timezone-fix-time date nil nil)) ;[Y M D H M S]
10362 (year (aref date 0))
10363 (month (aref date 1))
10364 (day (aref date 2)))
10365 (timezone-make-sortable-date
10366 year month day
10367 (timezone-make-time-string
10368 (aref date 3) (aref date 4) (aref date 5)))))
10371 ;; Summary saving commands.
10373 (defun gnus-summary-save-article (&optional n)
10374 "Save the current article using the default saver function.
10375 If N is a positive number, save the N next articles.
10376 If N is a negative number, save the N previous articles.
10377 If N is nil and any articles have been marked with the process mark,
10378 save those articles instead.
10379 The variable `gnus-default-article-saver' specifies the saver function."
10380 (interactive "P")
10381 (gnus-set-global-variables)
10382 (let ((articles (gnus-summary-work-articles n)))
10383 (while articles
10384 (let ((header (gnus-get-header-by-num (car articles))))
10385 (if (vectorp header)
10386 (progn
10387 (save-window-excursion
10388 (gnus-summary-select-article t nil nil (car articles)))
10389 (or gnus-save-all-headers
10390 (gnus-article-hide-headers t))
10391 ;; Remove any X-Gnus lines.
10392 (save-excursion
10393 (save-restriction
10394 (set-buffer gnus-article-buffer)
10395 (let ((buffer-read-only nil))
10396 (goto-char (point-min))
10397 (narrow-to-region (point) (or (search-forward "\n\n" nil t)
10398 (point-max)))
10399 (while (re-search-forward "^X-Gnus" nil t)
10400 (beginning-of-line)
10401 (delete-region (point)
10402 (progn (forward-line 1) (point))))
10403 (widen))))
10404 (save-window-excursion
10405 (if gnus-default-article-saver
10406 (funcall gnus-default-article-saver)
10407 (error "No default saver is defined."))))
10408 (if (assq 'name header)
10409 (gnus-copy-file (cdr (assq 'name header)))
10410 (gnus-message 1 "Article %d is unsavable" (car articles)))))
10411 (gnus-summary-remove-process-mark (car articles))
10412 (setq articles (cdr articles)))
10413 (gnus-summary-position-cursor)
10416 (defun gnus-summary-pipe-output (&optional arg)
10417 "Pipe the current article to a subprocess.
10418 If N is a positive number, pipe the N next articles.
10419 If N is a negative number, pipe the N previous articles.
10420 If N is nil and any articles have been marked with the process mark,
10421 pipe those articles instead."
10422 (interactive "P")
10423 (gnus-set-global-variables)
10424 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
10425 (gnus-summary-save-article arg))
10426 (gnus-configure-windows 'pipe))
10428 (defun gnus-summary-save-article-mail (&optional arg)
10429 "Append the current article to an mail file.
10430 If N is a positive number, save the N next articles.
10431 If N is a negative number, save the N previous articles.
10432 If N is nil and any articles have been marked with the process mark,
10433 save those articles instead."
10434 (interactive "P")
10435 (gnus-set-global-variables)
10436 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
10437 (gnus-summary-save-article arg)))
10439 (defun gnus-summary-save-article-rmail (&optional arg)
10440 "Append the current article to an rmail file.
10441 If N is a positive number, save the N next articles.
10442 If N is a negative number, save the N previous articles.
10443 If N is nil and any articles have been marked with the process mark,
10444 save those articles instead."
10445 (interactive "P")
10446 (gnus-set-global-variables)
10447 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
10448 (gnus-summary-save-article arg)))
10450 (defun gnus-summary-save-article-file (&optional arg)
10451 "Append the current article to a file.
10452 If N is a positive number, save the N next articles.
10453 If N is a negative number, save the N previous articles.
10454 If N is nil and any articles have been marked with the process mark,
10455 save those articles instead."
10456 (interactive "P")
10457 (gnus-set-global-variables)
10458 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
10459 (gnus-summary-save-article arg)))
10461 (defun gnus-read-save-file-name (prompt default-name)
10462 (let ((methods gnus-split-methods)
10463 split-name)
10464 (if (not gnus-split-methods)
10466 (save-excursion
10467 (set-buffer gnus-article-buffer)
10468 (gnus-narrow-to-headers)
10469 (while methods
10470 (goto-char (point-min))
10471 (and (condition-case ()
10472 (re-search-forward (car (car methods)) nil t)
10473 (error nil))
10474 (setq split-name (cons (nth 1 (car methods)) split-name)))
10475 (setq methods (cdr methods)))
10476 (widen)))
10477 (cond ((null split-name)
10478 (read-file-name
10479 (concat prompt " (default "
10480 (file-name-nondirectory default-name) ") ")
10481 (file-name-directory default-name)
10482 default-name))
10483 ((= 1 (length split-name))
10484 (read-file-name
10485 (concat prompt " (default " (car split-name) ") ")
10486 gnus-article-save-directory
10487 (concat gnus-article-save-directory (car split-name))))
10489 (setq split-name (mapcar (lambda (el) (list el))
10490 (nreverse split-name)))
10491 (let ((result (completing-read
10492 (concat prompt " ")
10493 split-name nil nil)))
10494 (concat gnus-article-save-directory
10495 (if (string= result "")
10496 (car (car split-name))
10497 result)))))))
10499 (defun gnus-summary-save-in-rmail (&optional filename)
10500 "Append this article to Rmail file.
10501 Optional argument FILENAME specifies file name.
10502 Directory to save to is default to `gnus-article-save-directory' which
10503 is initialized from the SAVEDIR environment variable."
10504 (interactive)
10505 (gnus-set-global-variables)
10506 (let ((default-name
10507 (funcall gnus-rmail-save-name gnus-newsgroup-name
10508 gnus-current-headers gnus-newsgroup-last-rmail)))
10509 (or filename
10510 (setq filename (gnus-read-save-file-name
10511 "Save in rmail file:" default-name)))
10512 (gnus-make-directory (file-name-directory filename))
10513 (gnus-eval-in-buffer-window
10514 gnus-article-buffer
10515 (save-excursion
10516 (save-restriction
10517 (widen)
10518 (gnus-output-to-rmail filename))))
10519 ;; Remember the directory name to save articles
10520 (setq gnus-newsgroup-last-rmail filename)))
10522 (defun gnus-summary-save-in-mail (&optional filename)
10523 "Append this article to Unix mail file.
10524 Optional argument FILENAME specifies file name.
10525 Directory to save to is default to `gnus-article-save-directory' which
10526 is initialized from the SAVEDIR environment variable."
10527 (interactive)
10528 (gnus-set-global-variables)
10529 (let ((default-name
10530 (funcall gnus-mail-save-name gnus-newsgroup-name
10531 gnus-current-headers gnus-newsgroup-last-mail)))
10532 (or filename
10533 (setq filename (gnus-read-save-file-name
10534 "Save in Unix mail file:" default-name)))
10535 (setq filename
10536 (expand-file-name filename
10537 (and default-name
10538 (file-name-directory default-name))))
10539 (gnus-make-directory (file-name-directory filename))
10540 (gnus-eval-in-buffer-window
10541 gnus-article-buffer
10542 (save-excursion
10543 (save-restriction
10544 (widen)
10545 (if (and (file-readable-p filename) (mail-file-babyl-p filename))
10546 (gnus-output-to-rmail filename)
10547 (rmail-output filename 1 t t)))))
10548 ;; Remember the directory name to save articles.
10549 (setq gnus-newsgroup-last-mail filename)))
10551 (defun gnus-summary-save-in-file (&optional filename)
10552 "Append this article to file.
10553 Optional argument FILENAME specifies file name.
10554 Directory to save to is default to `gnus-article-save-directory' which
10555 is initialized from the SAVEDIR environment variable."
10556 (interactive)
10557 (gnus-set-global-variables)
10558 (let ((default-name
10559 (funcall gnus-file-save-name gnus-newsgroup-name
10560 gnus-current-headers gnus-newsgroup-last-file)))
10561 (or filename
10562 (setq filename (gnus-read-save-file-name
10563 "Save in file:" default-name)))
10564 (gnus-make-directory (file-name-directory filename))
10565 (gnus-eval-in-buffer-window
10566 gnus-article-buffer
10567 (save-excursion
10568 (save-restriction
10569 (widen)
10570 (gnus-output-to-file filename))))
10571 ;; Remember the directory name to save articles.
10572 (setq gnus-newsgroup-last-file filename)))
10574 (defun gnus-summary-save-in-pipe (&optional command)
10575 "Pipe this article to subprocess."
10576 (interactive)
10577 (gnus-set-global-variables)
10578 (let ((command (read-string "Shell command on article: "
10579 gnus-last-shell-command)))
10580 (if (string-equal command "")
10581 (setq command gnus-last-shell-command))
10582 (gnus-eval-in-buffer-window
10583 gnus-article-buffer
10584 (save-restriction
10585 (widen)
10586 (shell-command-on-region (point-min) (point-max) command nil)))
10587 (setq gnus-last-shell-command command)))
10589 ;; Summary extract commands
10591 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
10592 (let ((buffer-read-only nil)
10593 (article (gnus-summary-article-number))
10595 (or (gnus-summary-goto-subject article)
10596 (error (format "No such article: %d" article)))
10597 (gnus-summary-position-cursor)
10598 ;; If all commands are to be bunched up on one line, we collect
10599 ;; them here.
10600 (if gnus-view-pseudos-separately
10602 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
10603 files action)
10604 (while ps
10605 (setq action (cdr (assq 'action (car ps))))
10606 (setq files (list (cdr (assq 'name (car ps)))))
10607 (while (and ps (cdr ps)
10608 (string= (or action "1")
10609 (or (cdr (assq 'action (car (cdr ps)))) "2")))
10610 (setq files (cons (cdr (assq 'name (car (cdr ps)))) files))
10611 (setcdr ps (cdr (cdr ps))))
10612 (if (not files)
10614 (if (not (string-match "%s" action))
10615 (setq files (cons " " files)))
10616 (setq files (cons " " files))
10617 (and (assq 'execute (car ps))
10618 (setcdr (assq 'execute (car ps))
10619 (funcall (if (string-match "%s" action)
10620 'format 'concat)
10621 action
10622 (mapconcat (lambda (f) f) files " ")))))
10623 (setq ps (cdr ps)))))
10624 (if (and gnus-view-pseudos (not not-view))
10625 (while pslist
10626 (and (assq 'execute (car pslist))
10627 (gnus-execute-command (cdr (assq 'execute (car pslist)))
10628 (eq gnus-view-pseudos 'not-confirm)))
10629 (setq pslist (cdr pslist)))
10630 (save-excursion
10631 (while pslist
10632 (gnus-summary-goto-subject (or (cdr (assq 'article (car pslist)))
10633 (gnus-summary-article-number)))
10634 (forward-line 1)
10635 (setq b (point))
10636 (insert " " (file-name-nondirectory
10637 (cdr (assq 'name (car pslist))))
10638 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
10639 (add-text-properties
10640 b (1+ b) (list 'gnus-number gnus-reffed-article-number
10641 'gnus-mark gnus-unread-mark
10642 'gnus-level 0
10643 'gnus-pseudo (car pslist)))
10644 (forward-line -1)
10645 (gnus-sethash (int-to-string gnus-reffed-article-number)
10646 (car pslist) gnus-newsgroup-headers-hashtb-by-number)
10647 (setq gnus-newsgroup-unreads
10648 (cons gnus-reffed-article-number gnus-newsgroup-unreads))
10649 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
10650 (setq pslist (cdr pslist)))))))
10652 (defun gnus-pseudos< (p1 p2)
10653 (let ((c1 (cdr (assq 'action p1)))
10654 (c2 (cdr (assq 'action p2))))
10655 (and c1 c2 (string< c1 c2))))
10657 (defun gnus-request-pseudo-article (props)
10658 (cond ((assq 'execute props)
10659 (gnus-execute-command (cdr (assq 'execute props)))))
10660 (let ((gnus-current-article (gnus-summary-article-number)))
10661 (run-hooks 'gnus-mark-article-hook)))
10663 (defun gnus-execute-command (command &optional automatic)
10664 (save-excursion
10665 (gnus-article-setup-buffer)
10666 (set-buffer gnus-article-buffer)
10667 (let ((command (if automatic command (read-string "Command: " command)))
10668 (buffer-read-only nil))
10669 (erase-buffer)
10670 (insert "$ " command "\n\n")
10671 (if gnus-view-pseudo-asynchronously
10672 (start-process "gnus-execute" nil "sh" "-c" command)
10673 (call-process "sh" nil t nil "-c" command)))))
10675 (defun gnus-copy-file (file &optional to)
10676 "Copy FILE to TO."
10677 (interactive
10678 (list (read-file-name "Copy file: " default-directory)
10679 (read-file-name "Copy file to: " default-directory)))
10680 (gnus-set-global-variables)
10681 (or to (setq to (read-file-name "Copy file to: " default-directory)))
10682 (and (file-directory-p to)
10683 (setq to (concat (file-name-as-directory to)
10684 (file-name-nondirectory file))))
10685 (copy-file file to))
10687 ;; Summary kill commands.
10689 (defun gnus-summary-edit-global-kill (article)
10690 "Edit the \"global\" kill file."
10691 (interactive (list (gnus-summary-article-number)))
10692 (gnus-set-global-variables)
10693 (gnus-group-edit-global-kill article))
10695 (defun gnus-summary-edit-local-kill ()
10696 "Edit a local kill file applied to the current newsgroup."
10697 (interactive)
10698 (gnus-set-global-variables)
10699 (setq gnus-current-headers
10700 (gnus-gethash
10701 (int-to-string (gnus-summary-article-number))
10702 gnus-newsgroup-headers-hashtb-by-number))
10703 (gnus-set-global-variables)
10704 (gnus-group-edit-local-kill
10705 (gnus-summary-article-number) gnus-newsgroup-name))
10709 ;;; Gnus article mode
10712 (put 'gnus-article-mode 'mode-class 'special)
10714 (defvar gnus-bugaboo nil)
10716 (if gnus-article-mode-map
10718 (setq gnus-article-mode-map (make-keymap))
10719 (suppress-keymap gnus-article-mode-map)
10720 (define-key gnus-article-mode-map " " 'gnus-article-next-page)
10721 (define-key gnus-article-mode-map "\177" 'gnus-article-prev-page)
10722 (define-key gnus-article-mode-map "\C-c^" 'gnus-article-refer-article)
10723 (define-key gnus-article-mode-map "h" 'gnus-article-show-summary)
10724 (define-key gnus-article-mode-map "s" 'gnus-article-show-summary)
10725 (define-key gnus-article-mode-map "\C-c\C-m" 'gnus-article-mail)
10726 (define-key gnus-article-mode-map "?" 'gnus-article-describe-briefly)
10727 (define-key gnus-article-mode-map gnus-mouse-2 'gnus-article-push-button)
10728 (define-key gnus-article-mode-map "\r" 'gnus-article-press-button)
10729 (define-key gnus-article-mode-map "\t" 'gnus-article-next-button)
10730 (define-key gnus-article-mode-map "\C-c\C-b" 'gnus-bug)
10732 ;; Duplicate almost all summary keystrokes in the article mode map.
10733 (let ((commands
10734 (list
10735 "p" "N" "P" "\M-\C-n" "\M-\C-p"
10736 "\M-n" "\M-p" "." "," "\M-s" "\M-r" "<" ">" "j"
10737 "u" "!" "U" "d" "D" "E" "\M-u" "\M-U" "k" "\C-k" "\M-\C-k"
10738 "\M-\C-l" "e" "#" "\M-#" "\M-\C-t" "\M-\C-s" "\M-\C-h"
10739 "\M-\C-f" "\M-\C-b" "\M-\C-u" "\M-\C-d" "&" "\C-w"
10740 "\C-t" "?" "\C-c\M-\C-s" "\C-c\C-s\C-n" "\C-c\C-s\C-a"
10741 "\C-c\C-s\C-s" "\C-c\C-s\C-d" "\C-c\C-s\C-i" "\C-x\C-s"
10742 "\M-g" "w" "\C-c\C-r" "\M-t" "C"
10743 "o" "\C-o" "|" "\M-k" "\M-K" "V" "\C-c\C-d"
10744 "\C-c\C-i" "x" "X" "t" "g" "?" "l"
10745 "\C-c\C-v\C-v" "\C-d" "v"
10746 ;; "Mt" "M!" "Md" "Mr"
10747 ;; "Mc" "M " "Me" "Mx" "M?" "Mb" "MB" "M#" "M\M-#" "M\M-r"
10748 ;; "M\M-\C-r" "MD" "M\M-D" "MS" "MC" "MH" "M\C-c" "Mk" "MK"
10749 ;; "Ms" "Mc" "Mu" "Mm" "Mk" "Gn" "Gp" "GN" "GP" "G\C-n" "G\C-p"
10750 ;; "G\M-n" "G\M-p" "Gf" "Gb" "Gg" "Gl" "Gp" "Tk" "Tl" "Ti" "TT"
10751 ;; "Ts" "TS" "Th" "TH" "Tn" "Tp" "Tu" "Td" "T#" "A " "An" "A\177" "Ap"
10752 ;; "A\r" "A<" "A>" "Ab" "Ae" "A^" "Ar" "Aw" "Ac" "Ag" "At" "Am"
10753 ;; "As" "Wh" "Ws" "Wc" "Wo" "Ww" "Wd" "Wq" "Wf" "Wt" "W\C-t"
10754 ;; "WT" "WA" "Wa" "WH" "WC" "WS" "Wb" "Hv" "Hf" "Hd" "Hh" "Hi"
10755 ;; "Be" "B\177" "Bm" "Br" "Bw" "Bc" "Bq" "Bi" "Oo" "Om" "Or"
10756 ;; "Of" "Oh" "Ov" "Op" "Vu" "V\C-s" "V\C-r" "Vr" "V&" "VT" "Ve"
10757 ;; "VD" "Vk" "VK" "Vsn" "Vsa" "Vss" "Vsd" "Vsi"
10759 (while (and gnus-bugaboo commands) ; disabled
10760 (define-key gnus-article-mode-map (car commands)
10761 'gnus-article-summary-command)
10762 (setq commands (cdr commands))))
10764 (let ((commands (list "q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
10765 ;; "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
10766 "=" "n" "^" "\M-^")))
10767 (while (and gnus-bugaboo commands) ; disabled
10768 (define-key gnus-article-mode-map (car commands)
10769 'gnus-article-summary-command-nosave)
10770 (setq commands (cdr commands)))))
10773 (defun gnus-article-mode ()
10774 "Major mode for displaying an article.
10776 All normal editing commands are switched off.
10778 The following commands are available:
10780 \\<gnus-article-mode-map>
10781 \\[gnus-article-next-page]\t Scroll the article one page forwards
10782 \\[gnus-article-prev-page]\t Scroll the article one page backwards
10783 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
10784 \\[gnus-article-show-summary]\t Display the summary buffer
10785 \\[gnus-article-mail]\t Send a reply to the address near point
10786 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
10787 \\[gnus-info-find-node]\t Go to the Gnus info node"
10788 (interactive)
10789 (if gnus-visual (gnus-article-make-menu-bar))
10790 (kill-all-local-variables)
10791 (gnus-simplify-mode-line)
10792 (setq mode-name "Article")
10793 (setq major-mode 'gnus-article-mode)
10794 (make-local-variable 'minor-mode-alist)
10795 (or (assq 'gnus-show-mime minor-mode-alist)
10796 (setq minor-mode-alist
10797 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
10798 (use-local-map gnus-article-mode-map)
10799 (make-local-variable 'page-delimiter)
10800 (setq page-delimiter gnus-page-delimiter)
10801 (buffer-disable-undo (current-buffer))
10802 (setq buffer-read-only t) ;Disable modification
10803 (run-hooks 'gnus-article-mode-hook))
10805 (defun gnus-article-setup-buffer ()
10806 "Initialize article mode buffer."
10807 ;; Returns the article buffer.
10808 (if (get-buffer gnus-article-buffer)
10809 (save-excursion
10810 (set-buffer gnus-article-buffer)
10811 (buffer-disable-undo (current-buffer))
10812 (setq buffer-read-only t)
10813 (gnus-add-current-to-buffer-list)
10814 (or (eq major-mode 'gnus-article-mode)
10815 (gnus-article-mode))
10816 (current-buffer))
10817 (save-excursion
10818 (set-buffer (get-buffer-create gnus-article-buffer))
10819 (gnus-add-current-to-buffer-list)
10820 (gnus-article-mode)
10821 (current-buffer))))
10823 ;; Set article window start at LINE, where LINE is the number of lines
10824 ;; from the head of the article.
10825 (defun gnus-article-set-window-start (&optional line)
10826 (set-window-start
10827 (get-buffer-window gnus-article-buffer)
10828 (save-excursion
10829 (set-buffer gnus-article-buffer)
10830 (goto-char (point-min))
10831 (if (not line)
10832 (point-min)
10833 (gnus-message 6 "Moved to bookmark")
10834 (search-forward "\n\n" nil t)
10835 (forward-line line)
10836 (point)))))
10838 (defun gnus-request-article-this-buffer (article group)
10839 "Get an article and insert it into this buffer."
10840 (setq group (or group gnus-newsgroup-name))
10842 ;; Open server if it has closed.
10843 (gnus-check-server (gnus-find-method-for-group group))
10845 ;; Using `gnus-request-article' directly will insert the article into
10846 ;; `nntp-server-buffer' - so we'll save some time by not having to
10847 ;; copy it from the server buffer into the article buffer.
10849 ;; We only request an article by message-id when we do not have the
10850 ;; headers for it, so we'll have to get those.
10851 (and (stringp article)
10852 (let ((gnus-override-method gnus-refer-article-method))
10853 (gnus-read-header article)))
10855 ;; If the article number is negative, that means that this article
10856 ;; doesn't belong in this newsgroup (possibly), so we find its
10857 ;; message-id and request it by id instead of number.
10858 (if (not (numberp article))
10860 (save-excursion
10861 (set-buffer gnus-summary-buffer)
10862 (let ((header (gnus-get-header-by-num article)))
10863 (if (< article 0)
10864 (if (vectorp header)
10865 ;; It's a real article.
10866 (setq article (mail-header-id header))
10867 ;; It is an extracted pseudo-article.
10868 (setq article 'pseudo)
10869 (gnus-request-pseudo-article header)))
10871 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
10872 (if (not (eq (car method) 'nneething))
10874 (let ((dir (concat (file-name-as-directory (nth 1 method))
10875 (mail-header-subject header))))
10876 (if (file-directory-p dir)
10877 (progn
10878 (setq article 'nneething)
10879 (gnus-group-enter-directory dir)))))))))
10881 ;; Check the cache.
10882 (if (and gnus-use-cache
10883 (numberp article)
10884 (gnus-cache-request-article article group))
10885 'article
10886 ;; Get the article and put into the article buffer.
10887 (if (or (stringp article) (numberp article))
10888 (progn
10889 (erase-buffer)
10890 ;; There may be some overlays that we have to kill...
10891 (insert "i")
10892 (let ((overlays (and (fboundp 'overlays-at)
10893 (overlays-at (point-min)))))
10894 (while overlays
10895 (delete-overlay (car overlays))
10896 (setq overlays (cdr overlays))))
10897 (erase-buffer)
10898 (let ((gnus-override-method
10899 (and (stringp article) gnus-refer-article-method)))
10900 (and (gnus-request-article article group (current-buffer))
10901 'article)))
10902 article)))
10904 (defun gnus-read-header (id)
10905 "Read the headers of article ID and enter them into the Gnus system."
10906 (let (header)
10907 (if (not (setq header
10908 (car (if (let ((gnus-nov-is-evil t))
10909 (gnus-retrieve-headers
10910 (list id) gnus-newsgroup-name))
10911 (gnus-get-newsgroup-headers)))))
10913 (if (stringp id)
10914 (mail-header-set-number header gnus-reffed-article-number))
10915 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers))
10916 (gnus-sethash (int-to-string (mail-header-number header)) header
10917 gnus-newsgroup-headers-hashtb-by-number)
10918 (if (stringp id)
10919 (setq gnus-reffed-article-number (1- gnus-reffed-article-number)))
10920 (setq gnus-current-headers header)
10921 header)))
10923 (defun gnus-article-prepare (article &optional all-headers header)
10924 "Prepare ARTICLE in article mode buffer.
10925 ARTICLE should either be an article number or a Message-ID.
10926 If ARTICLE is an id, HEADER should be the article headers.
10927 If ALL-HEADERS is non-nil, no headers are hidden."
10928 (save-excursion
10929 ;; Make sure we start in a summary buffer.
10930 (or (eq major-mode 'gnus-summary-mode)
10931 (set-buffer gnus-summary-buffer))
10932 (setq gnus-summary-buffer (current-buffer))
10933 ;; Make sure the connection to the server is alive.
10934 (or (gnus-server-opened (gnus-find-method-for-group gnus-newsgroup-name))
10935 (progn
10936 (gnus-check-server
10937 (gnus-find-method-for-group gnus-newsgroup-name))
10938 (gnus-request-group gnus-newsgroup-name t)))
10939 (let* ((article (if header (mail-header-number header) article))
10940 (summary-buffer (current-buffer))
10941 (internal-hook gnus-article-internal-prepare-hook)
10942 (group gnus-newsgroup-name)
10943 result)
10944 (save-excursion
10945 (gnus-article-setup-buffer)
10946 (set-buffer gnus-article-buffer)
10947 (if (not (setq result (let ((buffer-read-only nil))
10948 (gnus-request-article-this-buffer
10949 article group))))
10950 ;; There is no such article.
10951 (save-excursion
10952 (if (not (numberp article))
10954 (setq gnus-article-current
10955 (cons gnus-newsgroup-name article))
10956 (set-buffer gnus-summary-buffer)
10957 (setq gnus-current-article article)
10958 (gnus-summary-mark-article article gnus-canceled-mark))
10959 (gnus-message 1 "No such article (may be canceled)")
10960 (ding)
10961 nil)
10962 (if (or (eq result 'pseudo) (eq result 'nneething))
10963 (progn
10964 (save-excursion
10965 (set-buffer summary-buffer)
10966 (setq gnus-last-article gnus-current-article
10967 gnus-newsgroup-history (cons gnus-current-article
10968 gnus-newsgroup-history)
10969 gnus-current-article 0
10970 gnus-current-headers nil
10971 gnus-article-current nil)
10972 (if (eq result 'nneething)
10973 (gnus-configure-windows 'summary)
10974 (gnus-configure-windows 'article))
10975 (gnus-set-global-variables))
10976 (gnus-set-mode-line 'article))
10977 ;; The result from the `request' was an actual article -
10978 ;; or at least some text that is now displayed in the
10979 ;; article buffer.
10980 (if (and (numberp article)
10981 (not (eq article gnus-current-article)))
10982 ;; Seems like a new article has been selected.
10983 ;; `gnus-current-article' must be an article number.
10984 (save-excursion
10985 (set-buffer summary-buffer)
10986 (setq gnus-last-article gnus-current-article
10987 gnus-newsgroup-history (cons gnus-current-article
10988 gnus-newsgroup-history)
10989 gnus-current-article article
10990 gnus-current-headers
10991 (gnus-get-header-by-num gnus-current-article)
10992 gnus-article-current
10993 (cons gnus-newsgroup-name gnus-current-article))
10994 (gnus-summary-show-thread)
10995 (run-hooks 'gnus-mark-article-hook)
10996 (gnus-set-mode-line 'summary)
10997 (and gnus-visual
10998 (run-hooks 'gnus-visual-mark-article-hook))
10999 ;; Set the global newsgroup variables here.
11000 ;; Suggested by Jim Sisolak
11001 ;; <sisolak@trans4.neep.wisc.edu>.
11002 (gnus-set-global-variables)
11003 (setq gnus-have-all-headers
11004 (or all-headers gnus-show-all-headers))
11005 (and gnus-use-cache
11006 (vectorp (gnus-get-header-by-number article))
11007 (gnus-cache-possibly-enter-article
11008 group article
11009 (gnus-get-header-by-number article)
11010 (memq article gnus-newsgroup-marked)
11011 (memq article gnus-newsgroup-dormant)
11012 (memq article gnus-newsgroup-unreads)))))
11013 ;; Hooks for getting information from the article.
11014 ;; This hook must be called before being narrowed.
11015 (let (buffer-read-only)
11016 (run-hooks 'internal-hook)
11017 (run-hooks 'gnus-article-prepare-hook)
11018 ;; Decode MIME message.
11019 (if (and gnus-show-mime
11020 (or (not gnus-strict-mime)
11021 (gnus-fetch-field "Mime-Version")))
11022 (funcall gnus-show-mime-method))
11023 ;; Perform the article display hooks.
11024 (run-hooks 'gnus-article-display-hook))
11025 ;; Do page break.
11026 (goto-char (point-min))
11027 (and gnus-break-pages (gnus-narrow-to-page))
11028 (gnus-set-mode-line 'article)
11029 (gnus-configure-windows 'article)
11030 (goto-char (point-min))
11031 t))))))
11033 (defun gnus-article-show-all-headers ()
11034 "Show all article headers in article mode buffer."
11035 (save-excursion
11036 (gnus-article-setup-buffer)
11037 (set-buffer gnus-article-buffer)
11038 (let ((buffer-read-only nil))
11039 (remove-text-properties (point-min) (point-max)
11040 gnus-hidden-properties))))
11042 (defun gnus-article-hide-headers-if-wanted ()
11043 "Hide unwanted headers if `gnus-have-all-headers' is nil.
11044 Provided for backwards compatibility."
11045 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
11046 (gnus-article-hide-headers)))
11048 (defun gnus-article-hide-headers (&optional delete)
11049 "Hide unwanted headers and possibly sort them as well."
11050 (interactive "P")
11051 (save-excursion
11052 (set-buffer gnus-article-buffer)
11053 (save-restriction
11054 (let ((sorted gnus-sorted-header-list)
11055 (buffer-read-only nil)
11056 want-list beg want-l)
11057 ;; First we narrow to just the headers.
11058 (widen)
11059 (goto-char (point-min))
11060 ;; Hide any "From " lines at the beginning of (mail) articles.
11061 (while (looking-at "From ")
11062 (forward-line 1))
11063 (or (bobp)
11064 (add-text-properties (point-min) (point) gnus-hidden-properties))
11065 ;; Then treat the rest of the header lines.
11066 (narrow-to-region
11067 (point)
11068 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
11069 ;; Then we use the two regular expressions
11070 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
11071 ;; select which header lines is to remain visible in the
11072 ;; article buffer.
11073 (goto-char (point-min))
11074 (while (re-search-forward "^[^ \t]*:" nil t)
11075 (beginning-of-line)
11076 ;; We add the headers we want to keep to a list and delete
11077 ;; them from the buffer.
11078 (if (or (and (stringp gnus-visible-headers)
11079 (looking-at gnus-visible-headers))
11080 (and (not (stringp gnus-visible-headers))
11081 (stringp gnus-ignored-headers)
11082 (not (looking-at gnus-ignored-headers))))
11083 (progn
11084 (setq beg (point))
11085 (forward-line 1)
11086 ;; Be sure to get multi-line headers...
11087 (re-search-forward "^[^ \t]*:" nil t)
11088 (beginning-of-line)
11089 (setq want-list
11090 (cons (buffer-substring beg (point)) want-list))
11091 (delete-region beg (point))
11092 (goto-char beg))
11093 (forward-line 1)))
11094 ;; Next we perform the sorting by looking at
11095 ;; `gnus-sorted-header-list'.
11096 (goto-char (point-min))
11097 (while (and sorted want-list)
11098 (setq want-l want-list)
11099 (while (and want-l
11100 (not (string-match (car sorted) (car want-l))))
11101 (setq want-l (cdr want-l)))
11102 (if want-l
11103 (progn
11104 (insert (car want-l))
11105 (setq want-list (delq (car want-l) want-list))))
11106 (setq sorted (cdr sorted)))
11107 ;; Any headers that were not matched by the sorted list we
11108 ;; just tack on the end of the visible header list.
11109 (while want-list
11110 (insert (car want-list))
11111 (setq want-list (cdr want-list)))
11112 ;; And finally we make the unwanted headers invisible.
11113 (if delete
11114 (delete-region (point) (point-max))
11115 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
11116 (add-text-properties (point) (point-max) gnus-hidden-properties))))))
11118 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
11119 (defun gnus-article-treat-overstrike ()
11120 "Translate overstrikes into bold text."
11121 (interactive)
11122 (save-excursion
11123 (set-buffer gnus-article-buffer)
11124 (let ((buffer-read-only nil))
11125 (while (search-forward "\b" nil t)
11126 (let ((next (following-char))
11127 (previous (char-after (- (point) 2))))
11128 (cond ((eq next previous)
11129 (put-text-property (- (point) 2) (point)
11130 'invisible t)
11131 (put-text-property (point) (1+ (point))
11132 'face 'bold))
11133 ((eq next ?_)
11134 (put-text-property (1- (point)) (1+ (point))
11135 'invisible t)
11136 (put-text-property (1- (point)) (point)
11137 'face 'underline))
11138 ((eq previous ?_)
11139 (put-text-property (- (point) 2) (point)
11140 'invisible t)
11141 (put-text-property (point) (1+ (point))
11142 'face 'underline))))))))
11144 (defun gnus-article-word-wrap ()
11145 "Format too long lines."
11146 (interactive)
11147 (save-excursion
11148 (set-buffer gnus-article-buffer)
11149 (let ((buffer-read-only nil))
11150 (goto-char (point-min))
11151 (search-forward "\n\n" nil t)
11152 (end-of-line 1)
11153 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
11154 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
11155 (adaptive-fill-mode t))
11156 (while (not (eobp))
11157 (and (>= (current-column) (min fill-column (window-width)))
11158 (/= (preceding-char) ?:)
11159 (fill-paragraph nil))
11160 (end-of-line 2))))))
11162 (defun gnus-article-remove-cr ()
11163 "Remove carriage returns from an article."
11164 (interactive)
11165 (save-excursion
11166 (set-buffer gnus-article-buffer)
11167 (let ((buffer-read-only nil))
11168 (goto-char (point-min))
11169 (while (search-forward "\r" nil t)
11170 (replace-match "" t t)))))
11172 (defun gnus-article-display-x-face (&optional force)
11173 "Look for an X-Face header and display it if present."
11174 (interactive (list 'force))
11175 (save-excursion
11176 (set-buffer gnus-article-buffer)
11177 (let ((inhibit-point-motion-hooks t)
11178 (case-fold-search nil)
11179 from)
11180 (save-restriction
11181 (goto-char (point-min))
11182 (search-forward "\n\n")
11183 (narrow-to-region (point-min) (point))
11184 (goto-char (point-min))
11185 (setq from (mail-fetch-field "from"))
11186 (if (not (and gnus-article-x-face-command
11187 (or force
11188 (not gnus-article-x-face-too-ugly)
11189 (and gnus-article-x-face-too-ugly from
11190 (not (string-match gnus-article-x-face-too-ugly
11191 from))))
11192 (progn
11193 (goto-char (point-min))
11194 (re-search-forward "^X-Face: " nil t))))
11196 (let ((beg (point))
11197 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
11198 (if (symbolp gnus-article-x-face-command)
11199 (and (or (fboundp gnus-article-x-face-command)
11200 (error "%s is not a function"
11201 gnus-article-x-face-command))
11202 (funcall gnus-article-x-face-command beg end))
11203 (call-process-region beg end "sh" nil 0 nil
11204 "-c" gnus-article-x-face-command))))))))
11206 (defun gnus-article-de-quoted-unreadable (&optional force)
11207 "Do a naive translation of a quoted-printable-encoded article.
11208 This is in no way, shape or form meant as a replacement for real MIME
11209 processing, but is simply a stop-gap measure until MIME support is
11210 written.
11211 If FORCE, decode the article whether it is marked as quoted-printable
11212 or not."
11213 (interactive (list 'force))
11214 (save-excursion
11215 (set-buffer gnus-article-buffer)
11216 (let ((case-fold-search t)
11217 (buffer-read-only nil)
11218 (type (gnus-fetch-field "content-transfer-encoding")))
11219 (if (or force (and type (string-match "quoted-printable" type)))
11220 (progn
11221 (goto-char (point-min))
11222 (search-forward "\n\n" nil 'move)
11223 (gnus-mime-decode-quoted-printable (point) (point-max)))))))
11225 (defun gnus-mime-decode-quoted-printable (from to)
11226 ;; Decode quoted-printable from region between FROM and TO.
11227 (save-excursion
11228 (goto-char from)
11229 (while (search-forward "=" to t)
11230 (cond ((eq (following-char) ?\n)
11231 (delete-char -1)
11232 (delete-char 1))
11233 ((looking-at "[0-9A-F][0-9A-F]")
11234 (delete-char -1)
11235 (insert (hexl-hex-string-to-integer
11236 (buffer-substring (point) (+ 2 (point)))))
11237 (delete-char 2))
11238 ((looking-at "=")
11239 (delete-char 1))
11240 ((gnus-message 3 "Malformed MIME quoted-printable message"))))))
11242 (defvar gnus-article-time-units
11243 (list (cons 'year (* 365.25 24 60 60))
11244 (cons 'week (* 7 24 60 60))
11245 (cons 'day (* 24 60 60))
11246 (cons 'hour (* 60 60))
11247 (cons 'minute 60)
11248 (cons 'second 1)))
11250 (defun gnus-article-date-ut (&optional type)
11251 "Convert DATE date to universal time in the current article.
11252 If TYPE is `local', convert to local time; if it is `lapsed', output
11253 how much time has lapsed since DATE."
11254 (interactive (list 'ut))
11255 (let ((date (mail-header-date (or gnus-current-headers
11256 (gnus-get-header-by-number
11257 (gnus-summary-article-number))"")))
11258 (date-regexp "^Date: \\|^X-Sent: "))
11259 (if (or (not date)
11260 (string= date ""))
11262 (save-excursion
11263 (set-buffer gnus-article-buffer)
11264 (let ((buffer-read-only nil))
11265 (goto-char (point-min))
11266 (if (and (re-search-forward date-regexp nil t)
11267 (progn
11268 (beginning-of-line)
11269 (looking-at date-regexp)))
11270 (delete-region (gnus-point-at-bol)
11271 (progn (end-of-line) (1+ (point))))
11272 (goto-char (point-min))
11273 (goto-char (- (search-forward "\n\n") 2)))
11274 (insert
11275 (cond
11276 ((eq type 'local)
11277 (concat "Date: " (condition-case ()
11278 (timezone-make-date-arpa-standard date)
11279 (error date))
11280 "\n"))
11281 ((eq type 'ut)
11282 (concat "Date: "
11283 (condition-case ()
11284 (timezone-make-date-arpa-standard date nil "UT")
11285 (error date))
11286 "\n"))
11287 ((eq type 'lapsed)
11288 ;; If the date is seriously mangled, the timezone
11289 ;; functions are liable to bug out, so we condition-case
11290 ;; the entire thing.
11291 (let* ((real-sec (condition-case ()
11292 (- (gnus-seconds-since-epoch
11293 (timezone-make-date-arpa-standard
11294 (current-time-string)
11295 (current-time-zone) "UT"))
11296 (gnus-seconds-since-epoch
11297 (timezone-make-date-arpa-standard
11298 date nil "UT")))
11299 (error 0)))
11300 (sec (abs real-sec))
11301 num prev)
11302 (if (zerop sec)
11303 "X-Sent: Now\n"
11304 (concat
11305 "X-Sent: "
11306 (mapconcat
11307 (lambda (unit)
11308 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
11310 (setq sec (- sec (* num (cdr unit))))
11311 (prog1
11312 (concat (if prev ", " "") (int-to-string
11313 (floor num))
11314 " " (symbol-name (car unit))
11315 (if (> num 1) "s" ""))
11316 (setq prev t))))
11317 gnus-article-time-units "")
11318 (if (> real-sec 0)
11319 " ago\n"
11320 " in the future\n")))))
11322 (error "Unknown conversion type: %s" type)))))))))
11324 (defun gnus-article-date-local ()
11325 "Convert the current article date to the local timezone."
11326 (interactive)
11327 (gnus-article-date-ut 'local))
11329 (defun gnus-article-date-lapsed ()
11330 "Convert the current article date to time lapsed since it was sent."
11331 (interactive)
11332 (gnus-article-date-ut 'lapsed))
11334 (defun gnus-article-maybe-highlight ()
11335 "Do some article highlighting if `gnus-visual' is non-nil."
11336 (if gnus-visual (gnus-article-highlight-some)))
11338 ;; Article savers.
11340 (defun gnus-output-to-rmail (file-name)
11341 "Append the current article to an Rmail file named FILE-NAME."
11342 (require 'rmail)
11343 ;; Most of these codes are borrowed from rmailout.el.
11344 (setq file-name (expand-file-name file-name))
11345 (setq rmail-default-rmail-file file-name)
11346 (let ((artbuf (current-buffer))
11347 (tmpbuf (get-buffer-create " *Gnus-output*")))
11348 (save-excursion
11349 (or (get-file-buffer file-name)
11350 (file-exists-p file-name)
11351 (if (gnus-yes-or-no-p
11352 (concat "\"" file-name "\" does not exist, create it? "))
11353 (let ((file-buffer (create-file-buffer file-name)))
11354 (save-excursion
11355 (set-buffer file-buffer)
11356 (rmail-insert-rmail-file-header)
11357 (let ((require-final-newline nil))
11358 (write-region (point-min) (point-max) file-name t 1)))
11359 (kill-buffer file-buffer))
11360 (error "Output file does not exist")))
11361 (set-buffer tmpbuf)
11362 (buffer-disable-undo (current-buffer))
11363 (erase-buffer)
11364 (insert-buffer-substring artbuf)
11365 (gnus-convert-article-to-rmail)
11366 ;; Decide whether to append to a file or to an Emacs buffer.
11367 (let ((outbuf (get-file-buffer file-name)))
11368 (if (not outbuf)
11369 (append-to-file (point-min) (point-max) file-name)
11370 ;; File has been visited, in buffer OUTBUF.
11371 (set-buffer outbuf)
11372 (let ((buffer-read-only nil)
11373 (msg (and (boundp 'rmail-current-message)
11374 (symbol-value 'rmail-current-message))))
11375 ;; If MSG is non-nil, buffer is in RMAIL mode.
11376 (if msg
11377 (progn (widen)
11378 (narrow-to-region (point-max) (point-max))))
11379 (insert-buffer-substring tmpbuf)
11380 (if msg
11381 (progn
11382 (goto-char (point-min))
11383 (widen)
11384 (search-backward "\^_")
11385 (narrow-to-region (point) (point-max))
11386 (goto-char (1+ (point-min)))
11387 (rmail-count-new-messages t)
11388 (rmail-show-message msg)))))))
11389 (kill-buffer tmpbuf)))
11391 (defun gnus-output-to-file (file-name)
11392 "Append the current article to a file named FILE-NAME."
11393 (setq file-name (expand-file-name file-name))
11394 (let ((artbuf (current-buffer))
11395 (tmpbuf (get-buffer-create " *Gnus-output*")))
11396 (save-excursion
11397 (set-buffer tmpbuf)
11398 (buffer-disable-undo (current-buffer))
11399 (erase-buffer)
11400 (insert-buffer-substring artbuf)
11401 ;; Append newline at end of the buffer as separator, and then
11402 ;; save it to file.
11403 (goto-char (point-max))
11404 (insert "\n")
11405 (append-to-file (point-min) (point-max) file-name))
11406 (kill-buffer tmpbuf)))
11408 (defun gnus-convert-article-to-rmail ()
11409 "Convert article in current buffer to Rmail message format."
11410 (let ((buffer-read-only nil))
11411 ;; Convert article directly into Babyl format.
11412 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
11413 (goto-char (point-min))
11414 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
11415 (while (search-forward "\n\^_" nil t) ;single char
11416 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
11417 (goto-char (point-max))
11418 (insert "\^_")))
11420 (defun gnus-narrow-to-page (&optional arg)
11421 "Make text outside current page invisible except for page delimiter.
11422 A numeric arg specifies to move forward or backward by that many pages,
11423 thus showing a page other than the one point was originally in."
11424 (interactive "P")
11425 (setq arg (if arg (prefix-numeric-value arg) 0))
11426 (save-excursion
11427 (forward-page -1) ;Beginning of current page.
11428 (widen)
11429 (if (> arg 0)
11430 (forward-page arg)
11431 (if (< arg 0)
11432 (forward-page (1- arg))))
11433 ;; Find the end of the page.
11434 (forward-page)
11435 ;; If we stopped due to end of buffer, stay there.
11436 ;; If we stopped after a page delimiter, put end of restriction
11437 ;; at the beginning of that line.
11438 ;; These are commented out.
11439 ;; (if (save-excursion (beginning-of-line)
11440 ;; (looking-at page-delimiter))
11441 ;; (beginning-of-line))
11442 (narrow-to-region (point)
11443 (progn
11444 ;; Find the top of the page.
11445 (forward-page -1)
11446 ;; If we found beginning of buffer, stay there.
11447 ;; If extra text follows page delimiter on same line,
11448 ;; include it.
11449 ;; Otherwise, show text starting with following line.
11450 (if (and (eolp) (not (bobp)))
11451 (forward-line 1))
11452 (point)))))
11454 (defun gnus-gmt-to-local ()
11455 "Rewrite Date header described in GMT to local in current buffer.
11456 Intended to be used with gnus-article-prepare-hook."
11457 (save-excursion
11458 (save-restriction
11459 (widen)
11460 (goto-char (point-min))
11461 (narrow-to-region (point-min)
11462 (progn (search-forward "\n\n" nil 'move) (point)))
11463 (goto-char (point-min))
11464 (if (re-search-forward "^Date:[ \t]\\(.*\\)$" nil t)
11465 (let ((buffer-read-only nil)
11466 (date (buffer-substring-no-properties
11467 (match-beginning 1) (match-end 1))))
11468 (delete-region (match-beginning 1) (match-end 1))
11469 (insert
11470 (timezone-make-date-arpa-standard
11471 date nil (current-time-zone))))))))
11474 ;; Article mode commands
11476 (defun gnus-article-next-page (&optional lines)
11477 "Show next page of current article.
11478 If end of article, return non-nil. Otherwise return nil.
11479 Argument LINES specifies lines to be scrolled up."
11480 (interactive "P")
11481 (move-to-window-line -1)
11482 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
11483 (if (save-excursion
11484 (end-of-line)
11485 (and (pos-visible-in-window-p) ;Not continuation line.
11486 (eobp)))
11487 ;; Nothing in this page.
11488 (if (or (not gnus-break-pages)
11489 (save-excursion
11490 (save-restriction
11491 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
11492 t ;Nothing more.
11493 (gnus-narrow-to-page 1) ;Go to next page.
11494 nil)
11495 ;; More in this page.
11496 (condition-case ()
11497 (scroll-up lines)
11498 (end-of-buffer
11499 ;; Long lines may cause an end-of-buffer error.
11500 (goto-char (point-max))))
11501 nil))
11503 (defun gnus-article-prev-page (&optional lines)
11504 "Show previous page of current article.
11505 Argument LINES specifies lines to be scrolled down."
11506 (interactive "P")
11507 (move-to-window-line 0)
11508 (if (and gnus-break-pages
11509 (bobp)
11510 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
11511 (progn
11512 (gnus-narrow-to-page -1) ;Go to previous page.
11513 (goto-char (point-max))
11514 (recenter -1))
11515 (scroll-down lines)))
11517 (defun gnus-article-refer-article ()
11518 "Read article specified by message-id around point."
11519 (interactive)
11520 (search-forward ">" nil t) ;Move point to end of "<....>".
11521 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
11522 (let ((message-id
11523 (buffer-substring (match-beginning 1) (match-end 1))))
11524 (set-buffer gnus-summary-buffer)
11525 (gnus-summary-refer-article message-id))
11526 (error "No references around point")))
11528 (defun gnus-article-show-summary ()
11529 "Reconfigure windows to show summary buffer."
11530 (interactive)
11531 (gnus-configure-windows 'article)
11532 (gnus-summary-goto-subject gnus-current-article))
11534 (defun gnus-article-describe-briefly ()
11535 "Describe article mode commands briefly."
11536 (interactive)
11537 (gnus-message 6
11538 (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")))
11540 (defun gnus-article-summary-command ()
11541 "Execute the last keystroke in the summary buffer."
11542 (interactive)
11543 (let ((obuf (current-buffer))
11544 (owin (current-window-configuration))
11545 func)
11546 (switch-to-buffer gnus-summary-buffer 'norecord)
11547 (setq func (lookup-key (current-local-map) (this-command-keys)))
11548 (call-interactively func)
11549 (set-buffer obuf)
11550 (set-window-configuration owin)
11551 (set-window-point (get-buffer-window (current-buffer)) (point))))
11553 (defun gnus-article-summary-command-nosave ()
11554 "Execute the last keystroke in the summary buffer."
11555 (interactive)
11556 (let (func)
11557 (pop-to-buffer gnus-summary-buffer 'norecord)
11558 (setq func (lookup-key (current-local-map) (this-command-keys)))
11559 (call-interactively func)))
11562 ;; Basic ideas by emv@math.lsa.umich.edu (Edward Vielmetti)
11564 ;;;###autoload
11565 (defalias 'gnus-batch-kill 'gnus-batch-score)
11566 ;;;###autoload
11567 (defun gnus-batch-score ()
11568 "Run batched scoring.
11569 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
11570 Newsgroups is a list of strings in Bnews format. If you want to score
11571 the comp hierarchy, you'd say \"comp.all\". If you would not like to
11572 score the alt hierarchy, you'd say \"!alt.all\"."
11573 (interactive)
11574 (let* ((yes-and-no
11575 (gnus-newsrc-parse-options
11576 (apply (function concat)
11577 (mapcar (lambda (g) (concat g " "))
11578 command-line-args-left))))
11579 (gnus-expert-user t)
11580 (nnmail-spool-file nil)
11581 (gnus-use-dribble-file nil)
11582 (yes (car yes-and-no))
11583 (no (cdr yes-and-no))
11584 group newsrc entry
11585 ;; Disable verbose message.
11586 gnus-novice-user gnus-large-newsgroup)
11587 ;; Eat all arguments.
11588 (setq command-line-args-left nil)
11589 ;; Start Gnus.
11590 (gnus)
11591 ;; Apply kills to specified newsgroups in command line arguments.
11592 (setq newsrc (cdr gnus-newsrc-alist))
11593 (while newsrc
11594 (setq group (car (car newsrc)))
11595 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
11596 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
11597 (and (car entry)
11598 (or (eq (car entry) t)
11599 (not (zerop (car entry)))))
11600 (if yes (string-match yes group) t)
11601 (or (null no) (not (string-match no group))))
11602 (progn
11603 (gnus-summary-read-group group nil t)
11604 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
11605 (gnus-summary-exit))))
11606 (setq newsrc (cdr newsrc)))
11607 ;; Exit Emacs.
11608 (switch-to-buffer gnus-group-buffer)
11609 (gnus-group-save-newsrc)))
11611 (defun gnus-apply-kill-file ()
11612 "Apply a kill file to the current newsgroup.
11613 Returns the number of articles marked as read."
11614 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
11615 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
11616 (gnus-apply-kill-file-internal)
11619 (defun gnus-kill-save-kill-buffer ()
11620 (save-excursion
11621 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
11622 (if (get-file-buffer file)
11623 (progn
11624 (set-buffer (get-file-buffer file))
11625 (and (buffer-modified-p) (save-buffer))
11626 (kill-buffer (current-buffer)))))))
11628 (defvar gnus-kill-file-name "KILL"
11629 "Suffix of the kill files.")
11631 (defun gnus-newsgroup-kill-file (newsgroup)
11632 "Return the name of a kill file name for NEWSGROUP.
11633 If NEWSGROUP is nil, return the global kill file name instead."
11634 (cond ((or (null newsgroup)
11635 (string-equal newsgroup ""))
11636 ;; The global KILL file is placed at top of the directory.
11637 (expand-file-name gnus-kill-file-name
11638 (or gnus-kill-files-directory "~/News")))
11639 ((gnus-use-long-file-name 'not-kill)
11640 ;; Append ".KILL" to newsgroup name.
11641 (expand-file-name (concat (gnus-newsgroup-savable-name newsgroup)
11642 "." gnus-kill-file-name)
11643 (or gnus-kill-files-directory "~/News")))
11645 ;; Place "KILL" under the hierarchical directory.
11646 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
11647 "/" gnus-kill-file-name)
11648 (or gnus-kill-files-directory "~/News")))))
11652 ;;; Dribble file
11655 (defvar gnus-dribble-ignore nil)
11656 (defvar gnus-dribble-eval-file nil)
11658 (defun gnus-dribble-file-name ()
11659 (concat gnus-current-startup-file "-dribble"))
11661 (defun gnus-dribble-enter (string)
11662 (if (and (not gnus-dribble-ignore)
11663 gnus-dribble-buffer
11664 (buffer-name gnus-dribble-buffer))
11665 (let ((obuf (current-buffer)))
11666 (set-buffer gnus-dribble-buffer)
11667 (insert string "\n")
11668 (set-window-point (get-buffer-window (current-buffer)) (point-max))
11669 (set-buffer obuf))))
11671 (defun gnus-dribble-read-file ()
11672 (let ((dribble-file (gnus-dribble-file-name)))
11673 (save-excursion
11674 (set-buffer (setq gnus-dribble-buffer
11675 (get-buffer-create
11676 (file-name-nondirectory dribble-file))))
11677 (gnus-add-current-to-buffer-list)
11678 (erase-buffer)
11679 (set-visited-file-name dribble-file)
11680 (buffer-disable-undo (current-buffer))
11681 (bury-buffer (current-buffer))
11682 (set-buffer-modified-p nil)
11683 (let ((auto (make-auto-save-file-name))
11684 (gnus-dribble-ignore t))
11685 (if (or (file-exists-p auto) (file-exists-p dribble-file))
11686 (progn
11687 (if (file-newer-than-file-p auto dribble-file)
11688 (setq dribble-file auto))
11689 (insert-file-contents dribble-file)
11690 (if (not (zerop (buffer-size)))
11691 (set-buffer-modified-p t))
11692 (if (gnus-y-or-n-p
11693 "Auto-save file exists. Do you want to read it? ")
11694 (setq gnus-dribble-eval-file t))))))))
11696 (defun gnus-dribble-eval-file ()
11697 (if (not gnus-dribble-eval-file)
11699 (setq gnus-dribble-eval-file nil)
11700 (save-excursion
11701 (let ((gnus-dribble-ignore t))
11702 (set-buffer gnus-dribble-buffer)
11703 (eval-buffer (current-buffer))))))
11705 (defun gnus-dribble-delete-file ()
11706 (if (file-exists-p (gnus-dribble-file-name))
11707 (delete-file (gnus-dribble-file-name)))
11708 (if gnus-dribble-buffer
11709 (save-excursion
11710 (set-buffer gnus-dribble-buffer)
11711 (let ((auto (make-auto-save-file-name)))
11712 (if (file-exists-p auto)
11713 (delete-file auto))
11714 (erase-buffer)
11715 (set-buffer-modified-p nil)))))
11717 (defun gnus-dribble-save ()
11718 (if (and gnus-dribble-buffer
11719 (buffer-name gnus-dribble-buffer))
11720 (save-excursion
11721 (set-buffer gnus-dribble-buffer)
11722 (save-buffer))))
11724 (defun gnus-dribble-clear ()
11725 (save-excursion
11726 (if (gnus-buffer-exists-p gnus-dribble-buffer)
11727 (progn
11728 (set-buffer gnus-dribble-buffer)
11729 (erase-buffer)
11730 (set-buffer-modified-p nil)
11731 (setq buffer-saved-size (buffer-size))))))
11734 ;;; Server Communication
11737 (defun gnus-start-news-server (&optional confirm)
11738 "Open a method for getting news.
11739 If CONFIRM is non-nil, the user will be asked for an NNTP server."
11740 (let (how)
11741 (if gnus-current-select-method
11742 ;; Stream is already opened.
11744 ;; Open NNTP server.
11745 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
11746 (if confirm
11747 (progn
11748 ;; Read server name with completion.
11749 (setq gnus-nntp-server
11750 (completing-read "NNTP server: "
11751 (mapcar (lambda (server) (list server))
11752 (cons (list gnus-nntp-server)
11753 gnus-secondary-servers))
11754 nil nil gnus-nntp-server))))
11756 (if (and gnus-nntp-server
11757 (stringp gnus-nntp-server)
11758 (not (string= gnus-nntp-server "")))
11759 (setq gnus-select-method
11760 (cond ((or (string= gnus-nntp-server "")
11761 (string= gnus-nntp-server "::"))
11762 (list 'nnspool (system-name)))
11763 ((string-match "^:" gnus-nntp-server)
11764 (list 'nnmh gnus-nntp-server
11765 (list 'nnmh-directory
11766 (file-name-as-directory
11767 (expand-file-name
11768 (concat "~/" (substring
11769 gnus-nntp-server 1)))))
11770 (list 'nnmh-get-new-mail nil)))
11772 (list 'nntp gnus-nntp-server)))))
11774 (setq how (car gnus-select-method))
11775 (cond ((eq how 'nnspool)
11776 (require 'nnspool)
11777 (gnus-message 5 "Looking up local news spool..."))
11778 ((eq how 'nnmh)
11779 (require 'nnmh)
11780 (gnus-message 5 "Looking up mh spool..."))
11782 (require 'nntp)))
11783 (setq gnus-current-select-method gnus-select-method)
11784 (run-hooks 'gnus-open-server-hook)
11785 (or
11786 ;; gnus-open-server-hook might have opened it
11787 (gnus-server-opened gnus-select-method)
11788 (gnus-open-server gnus-select-method)
11789 (gnus-y-or-n-p
11790 (format
11791 "%s open error: '%s'. Continue? "
11792 (nth 1 gnus-select-method)
11793 (gnus-status-message gnus-select-method)))
11794 (progn
11795 (gnus-message 1 "Couldn't open server on %s"
11796 (nth 1 gnus-select-method))
11797 (ding)
11798 nil)))))
11800 (defun gnus-check-server (&optional method)
11801 "If the news server is down, start it up again."
11802 (let ((method (if method method gnus-select-method)))
11803 (and (stringp method)
11804 (setq method (gnus-server-to-method method)))
11805 (if (gnus-server-opened method)
11806 ;; Stream is already opened.
11808 ;; Open server.
11809 (gnus-message 5 "Opening server %s on %s..." (car method) (nth 1 method))
11810 (run-hooks 'gnus-open-server-hook)
11811 (prog1
11812 (gnus-open-server method)
11813 (message "")))))
11815 (defun gnus-nntp-message (&optional message)
11816 "Check the status of the NNTP server.
11817 If the status of the server is clear and MESSAGE is non-nil, MESSAGE
11818 is returned insted of the status string."
11819 (let ((status (gnus-status-message (gnus-find-method-for-group
11820 gnus-newsgroup-name)))
11821 (message (or message "")))
11822 (if (and (stringp status) (> (length status) 0))
11823 status message)))
11825 (defun gnus-get-function (method function)
11826 (and (stringp method)
11827 (setq method (gnus-server-to-method method)))
11828 (let ((func (intern (format "%s-%s" (car method) function))))
11829 (if (not (fboundp func))
11830 (progn
11831 (require (car method))
11832 (if (not (fboundp func))
11833 (error "No such function: %s" func))))
11834 func))
11836 ;;; Interface functions to the backends.
11838 (defun gnus-open-server (method)
11839 (funcall (gnus-get-function method 'open-server)
11840 (nth 1 method) (nthcdr 2 method)))
11842 (defun gnus-close-server (method)
11843 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
11845 (defun gnus-request-list (method)
11846 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
11848 (defun gnus-request-list-newsgroups (method)
11849 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
11851 (defun gnus-request-newgroups (date method)
11852 (funcall (gnus-get-function method 'request-newgroups)
11853 date (nth 1 method)))
11855 (defun gnus-server-opened (method)
11856 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
11858 (defun gnus-status-message (method)
11859 (let ((method (if (stringp method) (gnus-find-method-for-group method)
11860 method)))
11861 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
11863 (defun gnus-request-group (group &optional dont-check)
11864 (let ((method (gnus-find-method-for-group group)))
11865 (funcall (gnus-get-function method 'request-group)
11866 (gnus-group-real-name group) (nth 1 method) dont-check)))
11868 (defun gnus-request-asynchronous (group &optional articles)
11869 (let ((method (gnus-find-method-for-group group)))
11870 (funcall (gnus-get-function method 'request-asynchronous)
11871 (gnus-group-real-name group) (nth 1 method) articles)))
11873 (defun gnus-list-active-group (group)
11874 (let ((method (gnus-find-method-for-group group))
11875 (func 'list-active-group))
11876 (and (gnus-check-backend-function func group)
11877 (funcall (gnus-get-function method func)
11878 (gnus-group-real-name group) (nth 1 method)))))
11880 (defun gnus-request-group-description (group)
11881 (let ((method (gnus-find-method-for-group group))
11882 (func 'request-group-description))
11883 (and (gnus-check-backend-function func group)
11884 (funcall (gnus-get-function method func)
11885 (gnus-group-real-name group) (nth 1 method)))))
11887 (defun gnus-close-group (group)
11888 (let ((method (gnus-find-method-for-group group)))
11889 (funcall (gnus-get-function method 'close-group)
11890 (gnus-group-real-name group) (nth 1 method))))
11892 (defun gnus-retrieve-headers (articles group)
11893 (let ((method (gnus-find-method-for-group group)))
11894 (if (and gnus-use-cache (numberp (car articles)))
11895 (gnus-cache-retrieve-headers articles group)
11896 (funcall (gnus-get-function method 'retrieve-headers)
11897 articles (gnus-group-real-name group) (nth 1 method)))))
11899 (defun gnus-retrieve-groups (groups method)
11900 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
11902 (defun gnus-request-article (article group &optional buffer)
11903 (let ((method (gnus-find-method-for-group group)))
11904 (funcall (gnus-get-function method 'request-article)
11905 article (gnus-group-real-name group) (nth 1 method) buffer)))
11907 (defun gnus-request-head (article group)
11908 (let ((method (gnus-find-method-for-group group)))
11909 (funcall (gnus-get-function method 'request-head)
11910 article (gnus-group-real-name group) (nth 1 method))))
11912 (defun gnus-request-body (article group)
11913 (let ((method (gnus-find-method-for-group group)))
11914 (funcall (gnus-get-function method 'request-body)
11915 article (gnus-group-real-name group) (nth 1 method))))
11917 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
11918 (defun gnus-request-post-buffer (post group subject header artbuf
11919 info follow-to respect-poster)
11920 (let* ((info (or info (and group (nth 2 (gnus-gethash
11921 group gnus-newsrc-hashtb)))))
11922 (method
11923 (if (and gnus-post-method
11924 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
11925 (memq 'post (assoc
11926 (format "%s" (car (gnus-find-method-for-group
11927 gnus-newsgroup-name)))
11928 gnus-valid-select-methods)))
11929 gnus-post-method
11930 (gnus-find-method-for-group gnus-newsgroup-name))))
11931 (or (gnus-check-server method)
11932 (error "Can't open server %s:%s" (car method) (nth 1 method)))
11933 (let ((mail-self-blind nil)
11934 (mail-archive-file-name nil))
11935 (funcall (gnus-get-function method 'request-post-buffer)
11936 post group subject header artbuf info follow-to
11937 respect-poster))))
11939 (defun gnus-request-post (method &optional force)
11940 (and (stringp method)
11941 (setq method (gnus-server-to-method method)))
11942 (and (not force) gnus-post-method
11943 (memq 'post (assoc (format "%s" (car method))
11944 gnus-valid-select-methods))
11945 (setq method gnus-post-method))
11946 (funcall (gnus-get-function method 'request-post)
11947 (nth 1 method)))
11949 (defun gnus-request-expire-articles (articles group &optional force)
11950 (let ((method (gnus-find-method-for-group group)))
11951 (funcall (gnus-get-function method 'request-expire-articles)
11952 articles (gnus-group-real-name group) (nth 1 method)
11953 force)))
11955 (defun gnus-request-move-article
11956 (article group server accept-function &optional last)
11957 (let ((method (gnus-find-method-for-group group)))
11958 (funcall (gnus-get-function method 'request-move-article)
11959 article (gnus-group-real-name group)
11960 (nth 1 method) accept-function last)))
11962 (defun gnus-request-accept-article (group &optional last)
11963 (goto-char (point-max))
11964 (or (bolp) (insert "\n"))
11965 (let ((func (if (symbolp group) group
11966 (car (gnus-find-method-for-group group)))))
11967 (funcall (intern (format "%s-request-accept-article" func))
11968 (if (stringp group) (gnus-group-real-name group) group)
11969 last)))
11971 (defun gnus-request-replace-article (article group buffer)
11972 (let ((func (car (gnus-find-method-for-group group))))
11973 (funcall (intern (format "%s-request-replace-article" func))
11974 article (gnus-group-real-name group) buffer)))
11976 (defun gnus-request-create-group (group)
11977 (let ((method (gnus-find-method-for-group group)))
11978 (funcall (gnus-get-function method 'request-create-group)
11979 (gnus-group-real-name group) (nth 1 method))))
11981 (defun gnus-member-of-valid (symbol group)
11982 (memq symbol (assoc
11983 (format "%s" (car (gnus-find-method-for-group group)))
11984 gnus-valid-select-methods)))
11986 (defun gnus-secondary-method-p (method)
11987 (let ((methods gnus-secondary-select-methods)
11988 (gmethod (gnus-server-get-method nil method)))
11989 (while (and methods
11990 (not (equal (gnus-server-get-method nil (car methods))
11991 gmethod)))
11992 (setq methods (cdr methods)))
11993 methods))
11995 (defun gnus-find-method-for-group (group &optional info)
11996 (or gnus-override-method
11997 (and (not group)
11998 gnus-select-method)
11999 (let ((info (or info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
12000 method)
12001 (if (or (not info)
12002 (not (setq method (nth 4 info))))
12003 (setq method gnus-select-method)
12004 (setq method
12005 (cond ((stringp method)
12006 (gnus-server-to-method method))
12007 ((stringp (car method))
12008 (gnus-server-extend-method group method))
12010 method))))
12011 (gnus-server-add-address method))))
12013 (defun gnus-check-backend-function (func group)
12014 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
12015 group)))
12016 (fboundp (intern (format "%s-%s" method func)))))
12018 (defun gnus-methods-using (method)
12019 (let ((valids gnus-valid-select-methods)
12020 outs)
12021 (while valids
12022 (if (memq method (car valids))
12023 (setq outs (cons (car valids) outs)))
12024 (setq valids (cdr valids)))
12025 outs))
12027 ;;;
12028 ;;; Active & Newsrc File Handling
12031 ;; Newsrc related functions.
12032 ;; Gnus internal format of gnus-newsrc-alist:
12033 ;; (("alt.general" 3 (1 . 1))
12034 ;; ("alt.misc" 3 ((1 . 10) (12 . 15)))
12035 ;; ("alt.test" 7 (1 . 99) (45 57 93)) ...)
12036 ;; The first item is the group name; the second is the subscription
12037 ;; level; the third is either a range of a list of ranges of read
12038 ;; articles, the optional fourth element is a list of marked articles,
12039 ;; the optional fifth element is the select method.
12041 ;; Gnus internal format of gnus-newsrc-hashtb:
12042 ;; (95 ("alt.general" 3 (1 . 1)) ("alt.misc" 3 ((1 . 10) (12 . 15))) ...)
12043 ;; This is the entry for "alt.misc". The first element is the number
12044 ;; of unread articles in "alt.misc". The cdr of this entry is the
12045 ;; element *before* "alt.misc" in gnus-newsrc-alist, which makes is
12046 ;; trivial to remove or add new elements into gnus-newsrc-alist
12047 ;; without scanning the entire list. So, to get the actual information
12048 ;; of "alt.misc", you'd say something like
12049 ;; (nth 2 (gnus-gethash "alt.misc" gnus-newsrc-hashtb))
12051 ;; Gnus internal format of gnus-active-hashtb:
12052 ;; ((1 . 1))
12053 ;; (5 . 10))
12054 ;; (67 . 99)) ...)
12055 ;; The only element in each entry in this hash table is a range of
12056 ;; (possibly) available articles. (Articles in this range may have
12057 ;; been expired or canceled.)
12059 ;; Gnus internal format of gnus-killed-list and gnus-zombie-list:
12060 ;; ("alt.misc" "alt.test" "alt.general" ...)
12062 (defun gnus-setup-news (&optional rawfile level)
12063 "Setup news information.
12064 If RAWFILE is non-nil, the .newsrc file will also be read.
12065 If LEVEL is non-nil, the news will be set up at level LEVEL."
12066 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
12067 ;; Clear some variables to re-initialize news information.
12068 (if init (setq gnus-newsrc-alist nil
12069 gnus-active-hashtb nil))
12071 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
12072 (if init (gnus-read-newsrc-file rawfile))
12074 ;; If we don't read the complete active file, we fill in the
12075 ;; hashtb here.
12076 (if (or (null gnus-read-active-file)
12077 (eq gnus-read-active-file 'some))
12078 (gnus-update-active-hashtb-from-killed))
12080 ;; Read the active file and create `gnus-active-hashtb'.
12081 ;; If `gnus-read-active-file' is nil, then we just create an empty
12082 ;; hash table. The partial filling out of the hash table will be
12083 ;; done in `gnus-get-unread-articles'.
12084 (and gnus-read-active-file
12085 (not level)
12086 (gnus-read-active-file))
12088 (or gnus-active-hashtb
12089 (setq gnus-active-hashtb (make-vector 4095 0)))
12091 ;; Possibly eval the dribble file.
12092 (and init gnus-use-dribble-file (gnus-dribble-eval-file))
12094 (gnus-update-format-specifications)
12096 ;; Find new newsgroups and treat them.
12097 (if (and init gnus-check-new-newsgroups gnus-read-active-file (not level)
12098 (gnus-check-server gnus-select-method))
12099 (gnus-find-new-newsgroups))
12101 ;; Find the number of unread articles in each non-dead group.
12102 (let ((gnus-read-active-file (and (not level) gnus-read-active-file)))
12103 (gnus-get-unread-articles (or level (1+ gnus-level-subscribed))))
12105 (if (and init gnus-check-bogus-newsgroups
12106 gnus-read-active-file (not level)
12107 (gnus-server-opened gnus-select-method))
12108 (gnus-check-bogus-newsgroups))))
12110 (defun gnus-find-new-newsgroups ()
12111 "Search for new newsgroups and add them.
12112 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
12113 The `-n' option line from .newsrc is respected."
12114 (interactive)
12115 (or (gnus-check-first-time-used)
12116 (if (or (consp gnus-check-new-newsgroups)
12117 (eq gnus-check-new-newsgroups 'ask-server))
12118 (gnus-ask-server-for-new-groups)
12119 (let ((groups 0)
12120 group new-newsgroups)
12121 (gnus-message 5 "Looking for new newsgroups...")
12122 (or gnus-have-read-active-file (gnus-read-active-file))
12123 (setq gnus-newsrc-last-checked-date (current-time-string))
12124 (if (not gnus-killed-hashtb) (gnus-make-hashtable-from-killed))
12125 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
12126 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
12127 (mapatoms
12128 (lambda (sym)
12129 (if (or (null (setq group (symbol-name sym)))
12130 (null (symbol-value sym))
12131 (gnus-gethash group gnus-killed-hashtb)
12132 (gnus-gethash group gnus-newsrc-hashtb))
12134 (let ((do-sub (gnus-matches-options-n group)))
12135 (cond
12136 ((eq do-sub 'subscribe)
12137 (setq groups (1+ groups))
12138 (gnus-sethash group group gnus-killed-hashtb)
12139 (funcall gnus-subscribe-options-newsgroup-method group))
12140 ((eq do-sub 'ignore)
12141 nil)
12143 (setq groups (1+ groups))
12144 (gnus-sethash group group gnus-killed-hashtb)
12145 (if gnus-subscribe-hierarchical-interactive
12146 (setq new-newsgroups (cons group new-newsgroups))
12147 (funcall gnus-subscribe-newsgroup-method group)))))))
12148 gnus-active-hashtb)
12149 (if new-newsgroups
12150 (gnus-subscribe-hierarchical-interactive new-newsgroups))
12151 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
12152 (if (> groups 0)
12153 (gnus-message 6 "%d new newsgroup%s arrived."
12154 groups (if (> groups 1) "s have" " has"))
12155 (gnus-message 6 "No new newsgroups."))))))
12157 (defun gnus-matches-options-n (group)
12158 ;; Returns `subscribe' if the group is to be unconditionally
12159 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
12160 ;; no match for the group.
12162 ;; First we check the two user variables.
12163 (cond
12164 ((and gnus-options-subscribe
12165 (string-match gnus-options-subscribe group))
12166 'subscribe)
12167 ((and gnus-options-not-subscribe
12168 (string-match gnus-options-not-subscribe group))
12169 'ignore)
12170 ;; Then we go through the list that was retrieved from the .newsrc
12171 ;; file. This list has elements on the form
12172 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
12173 ;; is in the reverse order of the options line) is returned.
12175 (let ((regs gnus-newsrc-options-n))
12176 (while (and regs
12177 (not (string-match (car (car regs)) group)))
12178 (setq regs (cdr regs)))
12179 (and regs (cdr (car regs)))))))
12181 (defun gnus-ask-server-for-new-groups ()
12182 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
12183 (methods (cons gnus-select-method
12184 (append
12185 (and (consp gnus-check-new-newsgroups)
12186 gnus-check-new-newsgroups)
12187 gnus-secondary-select-methods)))
12188 (groups 0)
12189 (new-date (current-time-string))
12190 (hashtb (gnus-make-hashtable 100))
12191 group new-newsgroups got-new method)
12192 ;; Go through both primary and secondary select methods and
12193 ;; request new newsgroups.
12194 (while methods
12195 (setq method (gnus-server-get-method nil (car methods)))
12196 (and (gnus-check-server method)
12197 (gnus-request-newgroups date method)
12198 (save-excursion
12199 (setq got-new t)
12200 (set-buffer nntp-server-buffer)
12201 ;; Enter all the new groups in a hashtable.
12202 (gnus-active-to-gnus-format method hashtb 'ignore)))
12203 (setq methods (cdr methods)))
12204 (and got-new (setq gnus-newsrc-last-checked-date new-date))
12205 ;; Now all new groups from all select methods are in `hashtb'.
12206 (mapatoms
12207 (lambda (group-sym)
12208 (setq group (symbol-name group-sym))
12209 (if (or (null group)
12210 (null (symbol-value group-sym))
12211 (gnus-gethash group gnus-newsrc-hashtb)
12212 (member group gnus-zombie-list)
12213 (member group gnus-killed-list))
12214 ;; The group is already known.
12216 (and (symbol-value group-sym)
12217 (gnus-sethash group (symbol-value group-sym) gnus-active-hashtb))
12218 (let ((do-sub (gnus-matches-options-n group)))
12219 (cond ((eq do-sub 'subscribe)
12220 (setq groups (1+ groups))
12221 (gnus-sethash group group gnus-killed-hashtb)
12222 (funcall
12223 gnus-subscribe-options-newsgroup-method group))
12224 ((eq do-sub 'ignore)
12225 nil)
12227 (setq groups (1+ groups))
12228 (gnus-sethash group group gnus-killed-hashtb)
12229 (if gnus-subscribe-hierarchical-interactive
12230 (setq new-newsgroups (cons group new-newsgroups))
12231 (funcall gnus-subscribe-newsgroup-method group)))))))
12232 hashtb)
12233 (if new-newsgroups
12234 (gnus-subscribe-hierarchical-interactive new-newsgroups))
12235 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
12236 (if (> groups 0)
12237 (gnus-message 6 "%d new newsgroup%s arrived."
12238 groups (if (> groups 1) "s have" " has")))
12239 got-new))
12241 (defun gnus-check-first-time-used ()
12242 (if (or (> (length gnus-newsrc-alist) 1)
12243 (file-exists-p gnus-startup-file)
12244 (file-exists-p (concat gnus-startup-file ".el"))
12245 (file-exists-p (concat gnus-startup-file ".eld")))
12247 (gnus-message 6 "First time user; subscribing you to default groups")
12248 (or gnus-have-read-active-file (gnus-read-active-file))
12249 (setq gnus-newsrc-last-checked-date (current-time-string))
12250 (let ((groups gnus-default-subscribed-newsgroups)
12251 group)
12252 (if (eq groups t)
12254 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
12255 (mapatoms
12256 (lambda (sym)
12257 (if (null (setq group (symbol-name sym)))
12259 (let ((do-sub (gnus-matches-options-n group)))
12260 (cond
12261 ((eq do-sub 'subscribe)
12262 (gnus-sethash group group gnus-killed-hashtb)
12263 (funcall gnus-subscribe-options-newsgroup-method group))
12264 ((eq do-sub 'ignore)
12265 nil)
12267 (setq gnus-killed-list (cons group gnus-killed-list)))))))
12268 gnus-active-hashtb)
12269 (while groups
12270 (if (gnus-gethash (car groups) gnus-active-hashtb)
12271 (gnus-group-change-level
12272 (car groups) gnus-level-default-subscribed gnus-level-killed))
12273 (setq groups (cdr groups)))
12274 (gnus-group-make-help-group)
12275 (and gnus-novice-user
12276 (gnus-message 7 "`A k' to list killed groups"))))))
12278 (defun gnus-subscribe-group (group previous &optional method)
12279 (gnus-group-change-level
12280 (if method
12281 (list t group gnus-level-default-subscribed nil nil method)
12282 group)
12283 gnus-level-default-subscribed gnus-level-killed previous t))
12285 ;; `gnus-group-change-level' is the fundamental function for changing
12286 ;; subscription levels of newsgroups. This might mean just changing
12287 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
12288 ;; again, which subscribes/unsubscribes a group, which is equally
12289 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
12290 ;; from 8-9 to 1-7 means that you remove the group from the list of
12291 ;; killed (or zombie) groups and add them to the (kinda) subscribed
12292 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
12293 ;; which is trivial.
12294 ;; ENTRY can either be a string (newsgroup name) or a list (if
12295 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
12296 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
12297 ;; entries.
12298 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
12299 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
12300 ;; after.
12301 (defun gnus-group-change-level (entry level &optional oldlevel
12302 previous fromkilled)
12303 (let (group info active num)
12304 ;; Glean what info we can from the arguments
12305 (if (consp entry)
12306 (if fromkilled (setq group (nth 1 entry))
12307 (setq group (car (nth 2 entry))))
12308 (setq group entry))
12309 (if (and (stringp entry)
12310 oldlevel
12311 (< oldlevel gnus-level-zombie))
12312 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
12313 (if (and (not oldlevel)
12314 (consp entry))
12315 (setq oldlevel (car (cdr (nth 2 entry)))))
12316 (if (stringp previous)
12317 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
12319 (if (and (>= oldlevel gnus-level-zombie)
12320 (gnus-gethash group gnus-newsrc-hashtb))
12321 ;; We are trying to subscribe a group that is already
12322 ;; subscribed.
12323 () ; Do nothing.
12325 (or (gnus-ephemeral-group-p group)
12326 (gnus-dribble-enter
12327 (format "(gnus-group-change-level %S %S %S %S %S)"
12328 group level oldlevel (car (nth 2 previous)) fromkilled)))
12330 ;; Then we remove the newgroup from any old structures, if needed.
12331 ;; If the group was killed, we remove it from the killed or zombie
12332 ;; list. If not, and it is in fact going to be killed, we remove
12333 ;; it from the newsrc hash table and assoc.
12334 (cond ((>= oldlevel gnus-level-zombie)
12335 (if (= oldlevel gnus-level-zombie)
12336 (setq gnus-zombie-list (delete group gnus-zombie-list))
12337 (setq gnus-killed-list (delete group gnus-killed-list))))
12339 (if (and (>= level gnus-level-zombie)
12340 entry)
12341 (progn
12342 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb)
12343 (if (nth 3 entry)
12344 (setcdr (gnus-gethash (car (nth 3 entry))
12345 gnus-newsrc-hashtb)
12346 (cdr entry)))
12347 (setcdr (cdr entry) (cdr (cdr (cdr entry))))))))
12349 ;; Finally we enter (if needed) the list where it is supposed to
12350 ;; go, and change the subscription level. If it is to be killed,
12351 ;; we enter it into the killed or zombie list.
12352 (cond ((>= level gnus-level-zombie)
12353 ;; Remove from the hash table.
12354 (gnus-sethash group nil gnus-newsrc-hashtb)
12355 (or (gnus-group-foreign-p group)
12356 ;; We do not enter foreign groups into the list of dead
12357 ;; groups.
12358 (if (= level gnus-level-zombie)
12359 (setq gnus-zombie-list (cons group gnus-zombie-list))
12360 (setq gnus-killed-list (cons group gnus-killed-list)))))
12362 ;; If the list is to be entered into the newsrc assoc, and
12363 ;; it was killed, we have to create an entry in the newsrc
12364 ;; hashtb format and fix the pointers in the newsrc assoc.
12365 (if (>= oldlevel gnus-level-zombie)
12366 (progn
12367 (if (listp entry)
12368 (progn
12369 (setq info (cdr entry))
12370 (setq num (car entry)))
12371 (setq active (gnus-gethash group gnus-active-hashtb))
12372 (setq num
12373 (if active (- (1+ (cdr active)) (car active)) t))
12374 ;; Check whether the group is foreign. If so, the
12375 ;; foreign select method has to be entered into the
12376 ;; info.
12377 (let ((method (gnus-group-method-name group)))
12378 (if (eq method gnus-select-method)
12379 (setq info (list group level nil))
12380 (setq info (list group level nil nil method)))))
12381 (or previous
12382 (setq previous
12383 (let ((p gnus-newsrc-alist))
12384 (while (cdr (cdr p))
12385 (setq p (cdr p)))
12386 p)))
12387 (setq entry (cons info (cdr (cdr previous))))
12388 (if (cdr previous)
12389 (progn
12390 (setcdr (cdr previous) entry)
12391 (gnus-sethash group (cons num (cdr previous))
12392 gnus-newsrc-hashtb))
12393 (setcdr previous entry)
12394 (gnus-sethash group (cons num previous)
12395 gnus-newsrc-hashtb))
12396 (if (cdr entry)
12397 (setcdr (gnus-gethash (car (car (cdr entry)))
12398 gnus-newsrc-hashtb)
12399 entry)))
12400 ;; It was alive, and it is going to stay alive, so we
12401 ;; just change the level and don't change any pointers or
12402 ;; hash table entries.
12403 (setcar (cdr (car (cdr (cdr entry)))) level)))))))
12405 (defun gnus-kill-newsgroup (newsgroup)
12406 "Obsolete function. Kills a newsgroup."
12407 (gnus-group-change-level
12408 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
12410 (defun gnus-check-bogus-newsgroups (&optional confirm)
12411 "Remove bogus newsgroups.
12412 If CONFIRM is non-nil, the user has to confirm the deletion of every
12413 newsgroup."
12414 (let ((newsrc (cdr gnus-newsrc-alist))
12415 bogus group entry)
12416 (gnus-message 5 "Checking bogus newsgroups...")
12417 (or gnus-have-read-active-file (gnus-read-active-file))
12418 ;; Find all bogus newsgroup that are subscribed.
12419 (while newsrc
12420 (setq group (car (car newsrc)))
12421 (if (or (gnus-gethash group gnus-active-hashtb) ; Active
12422 (nth 4 (car newsrc)) ; Foreign
12423 (and confirm
12424 (not (gnus-y-or-n-p
12425 (format "Remove bogus newsgroup: %s " group)))))
12426 ;; Don't remove.
12428 ;; Found a bogus newsgroup.
12429 (setq bogus (cons group bogus)))
12430 (setq newsrc (cdr newsrc)))
12431 ;; Remove all bogus subscribed groups by first killing them, and
12432 ;; then removing them from the list of killed groups.
12433 (while bogus
12434 (and (setq entry (gnus-gethash (car bogus) gnus-newsrc-hashtb))
12435 (progn
12436 (gnus-group-change-level entry gnus-level-killed)
12437 (setq gnus-killed-list (delete (car bogus) gnus-killed-list))))
12438 (setq bogus (cdr bogus)))
12439 ;; Then we remove all bogus groups from the list of killed and
12440 ;; zombie groups. They are are removed without confirmation.
12441 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
12442 killed)
12443 (while dead-lists
12444 (setq killed (symbol-value (car dead-lists)))
12445 (while killed
12446 (setq group (car killed))
12447 (or (gnus-gethash group gnus-active-hashtb)
12448 ;; The group is bogus.
12449 (set (car dead-lists)
12450 (delete group (symbol-value (car dead-lists)))))
12451 (setq killed (cdr killed)))
12452 (setq dead-lists (cdr dead-lists))))
12453 (gnus-message 5 "Checking bogus newsgroups...done")))
12455 (defun gnus-check-duplicate-killed-groups ()
12456 "Remove duplicates from the list of killed groups."
12457 (interactive)
12458 (let ((killed gnus-killed-list))
12459 (while killed
12460 (gnus-message 9 "%d" (length killed))
12461 (setcdr killed (delete (car killed) (cdr killed)))
12462 (setq killed (cdr killed)))))
12464 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
12465 ;; and compute how many unread articles there are in each group.
12466 (defun gnus-get-unread-articles (&optional level)
12467 (let* ((newsrc (cdr gnus-newsrc-alist))
12468 (level (or level (1+ gnus-level-subscribed)))
12469 (foreign-level
12470 (min
12471 (cond ((and gnus-activate-foreign-newsgroups
12472 (not (numberp gnus-activate-foreign-newsgroups)))
12473 (1+ gnus-level-subscribed))
12474 ((numberp gnus-activate-foreign-newsgroups)
12475 gnus-activate-foreign-newsgroups)
12476 (t 0))
12477 level))
12478 info group active virtuals method)
12479 (gnus-message 5 "Checking new news...")
12481 (while newsrc
12482 (setq info (car newsrc)
12483 group (car info)
12484 active (gnus-gethash group gnus-active-hashtb))
12486 ;; Check newsgroups. If the user doesn't want to check them, or
12487 ;; they can't be checked (for instance, if the news server can't
12488 ;; be reached) we just set the number of unread articles in this
12489 ;; newsgroup to t. This means that Gnus thinks that there are
12490 ;; unread articles, but it has no idea how many.
12491 (if (and (setq method (nth 4 info))
12492 (not (gnus-server-equal gnus-select-method
12493 (gnus-server-get-method nil method)))
12494 (not (gnus-secondary-method-p method)))
12495 ;; These groups are foreign. Check the level.
12496 (if (<= (nth 1 info) foreign-level)
12497 (if (eq (car (if (stringp method)
12498 (gnus-server-to-method method)
12499 (nth 4 info))) 'nnvirtual)
12500 ;; We have to activate the virtual groups after all
12501 ;; the others, so we just pop them on a list for
12502 ;; now.
12503 (setq virtuals (cons info virtuals))
12504 (and (setq active (gnus-activate-group (car info)))
12505 ;; Close the groups as we look at them!
12506 (gnus-close-group group))))
12508 ;; These groups are native or secondary.
12509 (if (and (not gnus-read-active-file)
12510 (<= (nth 1 info) level))
12511 (progn
12512 (or gnus-read-active-file (gnus-check-server method))
12513 (setq active (gnus-activate-group (car info))))))
12515 (if active
12516 (gnus-get-unread-articles-in-group info active)
12517 ;; The group couldn't be reached, so we nix out the number of
12518 ;; unread articles and stuff.
12519 (gnus-sethash group nil gnus-active-hashtb)
12520 (setcar (gnus-gethash group gnus-newsrc-hashtb) t))
12522 (setq newsrc (cdr newsrc)))
12524 ;; Activate the virtual groups. This has to be done after all the
12525 ;; other groups.
12526 ;; !!! If one virtual group contains another virtual group, even
12527 ;; doing it this way might cause problems.
12528 (while virtuals
12529 (and (setq active (gnus-activate-group (car (car virtuals))))
12530 (gnus-get-unread-articles-in-group (car virtuals) active))
12531 (setq virtuals (cdr virtuals)))
12533 (gnus-message 5 "Checking new news...done")))
12535 ;; Create a hash table out of the newsrc alist. The `car's of the
12536 ;; alist elements are used as keys.
12537 (defun gnus-make-hashtable-from-newsrc-alist ()
12538 (let ((alist gnus-newsrc-alist)
12539 (ohashtb gnus-newsrc-hashtb)
12540 prev)
12541 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
12542 (setq alist
12543 (setq prev (setq gnus-newsrc-alist
12544 (if (equal (car (car gnus-newsrc-alist))
12545 "dummy.group")
12546 gnus-newsrc-alist
12547 (cons (list "dummy.group" 0 nil) alist)))))
12548 (while alist
12549 (gnus-sethash (car (car alist))
12550 (cons (and ohashtb (car (gnus-gethash
12551 (car (car alist)) ohashtb)))
12552 prev) gnus-newsrc-hashtb)
12553 (setq prev alist
12554 alist (cdr alist)))))
12556 (defun gnus-make-hashtable-from-killed ()
12557 "Create a hash table from the killed and zombie lists."
12558 (let ((lists '(gnus-killed-list gnus-zombie-list))
12559 list)
12560 (setq gnus-killed-hashtb
12561 (gnus-make-hashtable
12562 (+ (length gnus-killed-list) (length gnus-zombie-list))))
12563 (while lists
12564 (setq list (symbol-value (car lists)))
12565 (setq lists (cdr lists))
12566 (while list
12567 (gnus-sethash (car list) (car list) gnus-killed-hashtb)
12568 (setq list (cdr list))))))
12570 (defun gnus-get-unread-articles-in-group (info active)
12571 (let* ((range (nth 2 info))
12572 (num 0)
12573 (marked (nth 3 info)))
12574 ;; If a cache is present, we may have to alter the active info.
12575 (and gnus-use-cache
12576 (gnus-cache-possibly-alter-active (car info) active))
12577 ;; Modify the list of read articles according to what articles
12578 ;; are available; then tally the unread articles and add the
12579 ;; number to the group hash table entry.
12580 (cond
12581 ((zerop (cdr active))
12582 (setq num 0))
12583 ((not range)
12584 (setq num (- (1+ (cdr active)) (car active))))
12585 ((not (listp (cdr range)))
12586 ;; Fix a single (num . num) range according to the
12587 ;; active hash table.
12588 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
12589 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
12590 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
12591 ;; Compute number of unread articles.
12592 (setq num (max 0 (- (cdr active) (- (1+ (cdr range)) (car range))))))
12594 ;; The read list is a list of ranges. Fix them according to
12595 ;; the active hash table.
12596 ;; First peel off any elements that are below the lower
12597 ;; active limit.
12598 (while (and (cdr range)
12599 (>= (car active)
12600 (or (and (atom (car (cdr range))) (car (cdr range)))
12601 (car (car (cdr range))))))
12602 (if (numberp (car range))
12603 (setcar range
12604 (cons (car range)
12605 (or (and (numberp (car (cdr range)))
12606 (car (cdr range)))
12607 (cdr (car (cdr range))))))
12608 (setcdr (car range)
12609 (or (and (numberp (nth 1 range)) (nth 1 range))
12610 (cdr (car (cdr range))))))
12611 (setcdr range (cdr (cdr range))))
12612 ;; Adjust the first element to be the same as the lower limit.
12613 (if (and (not (atom (car range)))
12614 (< (cdr (car range)) (car active)))
12615 (setcdr (car range) (1- (car active))))
12616 ;; Then we want to peel off any elements that are higher
12617 ;; than the upper active limit.
12618 (let ((srange range))
12619 ;; Go past all legal elements.
12620 (while (and (cdr srange)
12621 (<= (or (and (atom (car (cdr srange)))
12622 (car (cdr srange)))
12623 (car (car (cdr srange)))) (cdr active)))
12624 (setq srange (cdr srange)))
12625 (if (cdr srange)
12626 ;; Nuke all remaining illegal elements.
12627 (setcdr srange nil))
12629 ;; Adjust the final element.
12630 (if (and (not (atom (car srange)))
12631 (> (cdr (car srange)) (cdr active)))
12632 (setcdr (car srange) (cdr active))))
12633 ;; Compute the number of unread articles.
12634 (while range
12635 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
12636 (cdr (car range))))
12637 (or (and (atom (car range)) (car range))
12638 (car (car range))))))
12639 (setq range (cdr range)))
12640 (setq num (max 0 (- (cdr active) num)))))
12641 (and info
12642 (progn
12643 (and (assq 'tick marked)
12644 (inline (gnus-remove-illegal-marked-articles
12645 (assq 'tick marked) (nth 2 info))))
12646 (and (assq 'dormant marked)
12647 (inline (gnus-remove-illegal-marked-articles
12648 (assq 'dormant marked) (nth 2 info))))
12649 (setcar
12650 (gnus-gethash (car info) gnus-newsrc-hashtb)
12651 (setq num (max 0 (- num (length (cdr (assq 'tick marked)))
12652 (length (cdr (assq 'dormant marked)))))))))
12653 num))
12655 (defun gnus-remove-illegal-marked-articles (marked ranges)
12656 (let ((m (cdr marked)))
12657 ;; Make sure that all ticked articles are a subset of the unread
12658 ;; articles.
12659 (while m
12660 (if (gnus-member-of-range (car m) ranges)
12661 (setcdr marked (cdr m))
12662 (setq marked m))
12663 (setq m (cdr m)))))
12665 (defun gnus-activate-group (group)
12666 ;; Check whether a group has been activated or not.
12667 (let ((method (gnus-find-method-for-group group))
12668 active)
12669 (and (gnus-check-server method)
12670 ;; We escape all bugs and quit here to make it possible to
12671 ;; continue if a group is so out-there that it reports bugs
12672 ;; and stuff.
12673 (condition-case ()
12674 (gnus-request-group group)
12675 (error nil)
12676 (quit nil))
12677 (save-excursion
12678 (set-buffer nntp-server-buffer)
12679 (goto-char (point-min))
12680 ;; Parse the result we got from `gnus-request-group'.
12681 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
12682 (progn
12683 (goto-char (match-beginning 1))
12684 (gnus-sethash
12685 group (setq active (cons (read (current-buffer))
12686 (read (current-buffer))))
12687 gnus-active-hashtb))
12688 ;; Return the new active info.
12689 active)))))
12691 (defun gnus-update-read-articles
12692 (group unread unselected ticked &optional domarks replied expirable killed
12693 dormant bookmark score)
12694 "Update the list of read and ticked articles in GROUP using the
12695 UNREAD and TICKED lists.
12696 Note: UNSELECTED has to be sorted over `<'.
12697 Returns whether the updating was successful."
12698 (let* ((active (or gnus-newsgroup-active
12699 (gnus-gethash group gnus-active-hashtb)))
12700 (entry (gnus-gethash group gnus-newsrc-hashtb))
12701 (info (nth 2 entry))
12702 (marked (nth 3 info))
12703 (prev 1)
12704 (unread (sort (copy-sequence unread) (function <)))
12705 read)
12706 (if (or (not info) (not active))
12707 ;; There is no info on this group if it was, in fact,
12708 ;; killed. Gnus stores no information on killed groups, so
12709 ;; there's nothing to be done.
12710 ;; One could store the information somewhere temporarily,
12711 ;; perhaps... Hmmm...
12713 ;; Remove any negative articles numbers.
12714 (while (and unread (< (car unread) 0))
12715 (setq unread (cdr unread)))
12716 ;; Remove any expired article numbers
12717 (while (and unread (< (car unread) (car active)))
12718 (setq unread (cdr unread)))
12719 (while (and ticked (< (car ticked) (car active)))
12720 (setq ticked (cdr ticked)))
12721 (while (and dormant (< (car dormant) (car active)))
12722 (setq dormant (cdr dormant)))
12723 (setq unread (sort (append unselected unread) '<))
12724 ;; Weed out duplicates.
12725 (let ((un unread))
12726 (while (cdr un)
12727 (if (eq (car un) (car (cdr un)))
12728 (setcdr un (cdr (cdr un)))
12729 (setq un (cdr un)))))
12730 ;; Compute the ranges of read articles by looking at the list of
12731 ;; unread articles.
12732 (while unread
12733 (if (/= (car unread) prev)
12734 (setq read (cons (if (= prev (1- (car unread))) prev
12735 (cons prev (1- (car unread)))) read)))
12736 (setq prev (1+ (car unread)))
12737 (setq unread (cdr unread)))
12738 (if (<= prev (cdr active))
12739 (setq read (cons (cons prev (cdr active)) read)))
12740 ;; Enter this list into the group info.
12741 (setcar (cdr (cdr info))
12742 (if (> (length read) 1) (nreverse read) read))
12743 ;; Enter the list of ticked articles.
12744 (gnus-set-marked-articles
12745 info ticked
12746 (if domarks replied (cdr (assq 'reply marked)))
12747 (if domarks expirable (cdr (assq 'expire marked)))
12748 (if domarks killed (cdr (assq 'killed marked)))
12749 (if domarks dormant (cdr (assq 'dormant marked)))
12750 (if domarks bookmark (cdr (assq 'bookmark marked)))
12751 (if domarks score (cdr (assq 'score marked))))
12752 ;; Set the number of unread articles in gnus-newsrc-hashtb.
12753 (gnus-get-unread-articles-in-group
12754 info (gnus-gethash group gnus-active-hashtb))
12755 t)))
12757 (defun gnus-make-articles-unread (group articles)
12758 "Mark ARTICLES in GROUP as unread."
12759 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
12760 (gnus-gethash (gnus-group-real-name group)
12761 gnus-newsrc-hashtb))))
12762 (ranges (nth 2 info))
12763 news)
12764 (while articles
12765 (and (gnus-member-of-range (car articles) ranges)
12766 (setq news (cons (car articles) news)))
12767 (setq articles (cdr articles)))
12768 (if (not news)
12770 (setcar (nthcdr 2 info)
12771 (gnus-remove-from-range (nth 2 info) (nreverse news)))
12772 (gnus-group-update-group group t))))
12774 ;; Enter all dead groups into the hashtb.
12775 (defun gnus-update-active-hashtb-from-killed ()
12776 (let ((hashtb (setq gnus-active-hashtb (make-vector 4095 0)))
12777 (lists (list gnus-killed-list gnus-zombie-list))
12778 killed)
12779 (while lists
12780 (setq killed (car lists))
12781 (while killed
12782 (gnus-sethash (car killed) nil hashtb)
12783 (setq killed (cdr killed)))
12784 (setq lists (cdr lists)))))
12786 ;; Get the active file(s) from the backend(s).
12787 (defun gnus-read-active-file ()
12788 (gnus-group-set-mode-line)
12789 (let ((methods (if (gnus-check-server gnus-select-method)
12790 ;; The native server is available.
12791 (cons gnus-select-method gnus-secondary-select-methods)
12792 ;; The native server is down, so we just do the
12793 ;; secondary ones.
12794 gnus-secondary-select-methods))
12795 list-type)
12796 (setq gnus-have-read-active-file nil)
12797 (save-excursion
12798 (set-buffer nntp-server-buffer)
12799 (while methods
12800 (let* ((method (gnus-server-get-method nil (car methods)))
12801 (where (nth 1 method))
12802 (mesg (format "Reading active file%s via %s..."
12803 (if (and where (not (zerop (length where))))
12804 (concat " from " where) "")
12805 (car method))))
12806 (gnus-message 5 mesg)
12807 (if (not (gnus-check-server method))
12809 (cond
12810 ((and (eq gnus-read-active-file 'some)
12811 (gnus-check-backend-function 'retrieve-groups (car method)))
12812 (let ((newsrc (cdr gnus-newsrc-alist))
12813 (gmethod (gnus-server-get-method nil method))
12814 groups)
12815 (while newsrc
12816 (and (gnus-server-equal
12817 (gnus-find-method-for-group
12818 (car (car newsrc)) (car newsrc))
12819 gmethod)
12820 (setq groups (cons (gnus-group-real-name
12821 (car (car newsrc))) groups)))
12822 (setq newsrc (cdr newsrc)))
12823 (gnus-check-server method)
12824 (setq list-type (gnus-retrieve-groups groups method))
12825 (cond
12826 ((not list-type)
12827 (gnus-message
12828 1 "Cannot read partial active file from %s server."
12829 (car method))
12830 (ding)
12831 (sit-for 2))
12832 ((eq list-type 'active)
12833 (gnus-active-to-gnus-format method gnus-active-hashtb))
12835 (gnus-groups-to-gnus-format method gnus-active-hashtb)))))
12837 (if (not (gnus-request-list method))
12838 (progn
12839 (gnus-message 1 "Cannot read active file from %s server."
12840 (car method))
12841 (ding))
12842 (gnus-active-to-gnus-format method)
12843 ;; We mark this active file as read.
12844 (setq gnus-have-read-active-file
12845 (cons method gnus-have-read-active-file))
12846 (gnus-message 5 "%sdone" mesg))))))
12847 (setq methods (cdr methods))))))
12849 ;; Read an active file and place the results in `gnus-active-hashtb'.
12850 (defun gnus-active-to-gnus-format (method &optional hashtb ignore-errors)
12851 (let ((cur (current-buffer))
12852 (hashtb (or hashtb
12853 (if (and gnus-active-hashtb
12854 (not (equal method gnus-select-method)))
12855 gnus-active-hashtb
12856 (setq gnus-active-hashtb
12857 (if (equal method gnus-select-method)
12858 (gnus-make-hashtable
12859 (count-lines (point-min) (point-max)))
12860 (gnus-make-hashtable 4096))))))
12861 (flag-hashtb (gnus-make-hashtable 60)))
12862 ;; Delete unnecessary lines.
12863 (goto-char (point-min))
12864 (while (search-forward "\nto." nil t)
12865 (delete-region (1+ (match-beginning 0))
12866 (progn (forward-line 1) (point))))
12867 (or (string= gnus-ignored-newsgroups "")
12868 (progn
12869 (goto-char (point-min))
12870 (delete-matching-lines gnus-ignored-newsgroups)))
12871 ;; Make the group names readable as a lisp expression even if they
12872 ;; contain special characters.
12873 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
12874 (goto-char (point-max))
12875 (while (re-search-backward "[][';?()#]" nil t)
12876 (insert ?\\))
12877 ;; If these are groups from a foreign select method, we insert the
12878 ;; group prefix in front of the group names.
12879 (and method (not (gnus-server-equal
12880 (gnus-server-get-method nil method)
12881 (gnus-server-get-method nil gnus-select-method)))
12882 (let ((prefix (gnus-group-prefixed-name "" method)))
12883 (goto-char (point-min))
12884 (while (and (not (eobp))
12885 (progn (insert prefix)
12886 (zerop (forward-line 1)))))))
12887 ;; Store the active file in a hash table.
12888 (goto-char (point-min))
12889 (if (string-match "%[oO]" gnus-group-line-format)
12890 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
12891 ;; If we want information on moderated groups, we use this
12892 ;; loop...
12893 (let* ((mod-hashtb (make-vector 7 0))
12894 (m (intern "m" mod-hashtb))
12895 group max min)
12896 (while (not (eobp))
12897 (condition-case nil
12898 (progn
12899 (narrow-to-region (point) (gnus-point-at-eol))
12900 (setq group (let ((obarray hashtb)) (read cur)))
12901 (if (and (numberp (setq max (read cur)))
12902 (numberp (setq min (read cur)))
12903 (progn
12904 (skip-chars-forward " \t")
12905 (not
12906 (or (= (following-char) ?=)
12907 (= (following-char) ?x)
12908 (= (following-char) ?j)))))
12909 (set group (cons min max))
12910 (set group nil))
12911 ;; Enter moderated groups into a list.
12912 (if (eq (let ((obarray mod-hashtb)) (read cur)) m)
12913 (setq gnus-moderated-list
12914 (cons (symbol-name group) gnus-moderated-list))))
12915 (error
12916 (and group
12917 (symbolp group)
12918 (set group nil))))
12919 (widen)
12920 (forward-line 1)))
12921 ;; And if we do not care about moderation, we use this loop,
12922 ;; which is faster.
12923 (let (group max min)
12924 (while (not (eobp))
12925 (condition-case ()
12926 (progn
12927 (narrow-to-region (point) (gnus-point-at-eol))
12928 ;; group gets set to a symbol interned in the hash table
12929 ;; (what a hack!!) - jwz
12930 (setq group (let ((obarray hashtb)) (read cur)))
12931 (if (and (numberp (setq max (read cur)))
12932 (numberp (setq min (read cur)))
12933 (progn
12934 (skip-chars-forward " \t")
12935 (not
12936 (or (= (following-char) ?=)
12937 (= (following-char) ?x)
12938 (= (following-char) ?j)))))
12939 (set group (cons min max))
12940 (set group nil)))
12941 (error
12942 (progn
12943 (and group
12944 (symbolp group)
12945 (set group nil))
12946 (or ignore-errors
12947 (gnus-message 3 "Warning - illegal active: %s"
12948 (buffer-substring
12949 (gnus-point-at-bol) (gnus-point-at-eol)))))))
12950 (widen)
12951 (forward-line 1))))))
12953 (defun gnus-groups-to-gnus-format (method &optional hashtb)
12954 ;; Parse a "groups" active file.
12955 (let ((cur (current-buffer))
12956 (hashtb (or hashtb
12957 (if (and method gnus-active-hashtb)
12958 gnus-active-hashtb
12959 (setq gnus-active-hashtb
12960 (gnus-make-hashtable
12961 (count-lines (point-min) (point-max)))))))
12962 (prefix (and method
12963 (not (gnus-server-equal
12964 (gnus-server-get-method nil method)
12965 (gnus-server-get-method nil gnus-select-method)))
12966 (gnus-group-prefixed-name "" method))))
12968 (goto-char (point-min))
12969 ;; We split this into to separate loops, one with the prefix
12970 ;; and one without to speed the reading up somewhat.
12971 (if prefix
12972 (let (min max opoint group)
12973 (while (not (eobp))
12974 (condition-case ()
12975 (progn
12976 (read cur) (read cur)
12977 (setq min (read cur)
12978 max (read cur)
12979 opoint (point))
12980 (skip-chars-forward " \t")
12981 (insert prefix)
12982 (goto-char opoint)
12983 (set (let ((obarray hashtb)) (read cur))
12984 (cons min max)))
12985 (error (and group (symbolp group) (set group nil))))
12986 (forward-line 1)))
12987 (let (min max group)
12988 (while (not (eobp))
12989 (condition-case ()
12990 (if (= (following-char) ?2)
12991 (progn
12992 (read cur) (read cur)
12993 (setq min (read cur)
12994 max (read cur))
12995 (set (setq group (let ((obarray hashtb)) (read cur)))
12996 (cons min max))))
12997 (error (and group (symbolp group) (set group nil))))
12998 (forward-line 1))))))
13000 (defun gnus-read-newsrc-file (&optional force)
13001 "Read startup file.
13002 If FORCE is non-nil, the .newsrc file is read."
13003 ;; Reset variables that might be defined in the .newsrc.eld file.
13004 (let ((variables gnus-variable-list))
13005 (while variables
13006 (set (car variables) nil)
13007 (setq variables (cdr variables))))
13008 (let* ((newsrc-file gnus-current-startup-file)
13009 (quick-file (concat newsrc-file ".el")))
13010 (save-excursion
13011 ;; We always load the .newsrc.eld file. If always contains
13012 ;; much information that can not be gotten from the .newsrc
13013 ;; file (ticked articles, killed groups, foreign methods, etc.)
13014 (gnus-read-newsrc-el-file quick-file)
13016 (if (or force
13017 (and (file-newer-than-file-p newsrc-file quick-file)
13018 (file-newer-than-file-p newsrc-file
13019 (concat quick-file "d")))
13020 (not gnus-newsrc-alist))
13021 ;; We read the .newsrc file. Note that if there if a
13022 ;; .newsrc.eld file exists, it has already been read, and
13023 ;; the `gnus-newsrc-hashtb' has been created. While reading
13024 ;; the .newsrc file, Gnus will only use the information it
13025 ;; can find there for changing the data already read -
13026 ;; ie. reading the .newsrc file will not trash the data
13027 ;; already read (except for read articles).
13028 (save-excursion
13029 (gnus-message 5 "Reading %s..." newsrc-file)
13030 (set-buffer (find-file-noselect newsrc-file))
13031 (buffer-disable-undo (current-buffer))
13032 (gnus-newsrc-to-gnus-format)
13033 (kill-buffer (current-buffer))
13034 (gnus-message 5 "Reading %s...done" newsrc-file))))))
13036 (defun gnus-read-newsrc-el-file (file)
13037 (let ((ding-file (concat file "d")))
13038 ;; We always, always read the .eld file.
13039 (gnus-message 5 "Reading %s..." ding-file)
13040 (let (gnus-newsrc-assoc)
13041 (condition-case nil
13042 (load ding-file t t t)
13043 (error nil))
13044 (and gnus-newsrc-assoc (setq gnus-newsrc-alist gnus-newsrc-assoc)))
13045 (let ((inhibit-quit t))
13046 (gnus-uncompress-newsrc-alist))
13047 (gnus-make-hashtable-from-newsrc-alist)
13048 (if (not (file-newer-than-file-p file ding-file))
13050 ;; Old format quick file
13051 (gnus-message 5 "Reading %s..." file)
13052 ;; The .el file is newer than the .eld file, so we read that one
13053 ;; as well.
13054 (gnus-read-old-newsrc-el-file file))))
13056 ;; Parse the old-style quick startup file
13057 (defun gnus-read-old-newsrc-el-file (file)
13058 (let (newsrc killed marked group m)
13059 (prog1
13060 (let ((gnus-killed-assoc nil)
13061 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
13062 (prog1
13063 (condition-case nil
13064 (load file t t t)
13065 (error nil))
13066 (setq newsrc gnus-newsrc-assoc
13067 killed gnus-killed-assoc
13068 marked gnus-marked-assoc)))
13069 (setq gnus-newsrc-alist nil)
13070 (while newsrc
13071 (setq group (car newsrc))
13072 (let ((info (nth 2 (gnus-gethash (car group) gnus-newsrc-hashtb))))
13073 (if info
13074 (progn
13075 (setcar (nthcdr 2 info) (cdr (cdr group)))
13076 (setcar (cdr info)
13077 (if (nth 1 group) gnus-level-default-subscribed
13078 gnus-level-default-unsubscribed))
13079 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
13080 (setq gnus-newsrc-alist
13081 (cons
13082 (setq info
13083 (list (car group)
13084 (if (nth 1 group) gnus-level-default-subscribed
13085 gnus-level-default-unsubscribed)
13086 (cdr (cdr group))))
13087 gnus-newsrc-alist)))
13088 (if (setq m (assoc (car group) marked))
13089 (setcdr (cdr (cdr info))
13090 (cons (list (cons 'tick (cdr m))) nil))))
13091 (setq newsrc (cdr newsrc)))
13092 (setq newsrc killed)
13093 (while newsrc
13094 (setcar newsrc (car (car newsrc)))
13095 (setq newsrc (cdr newsrc)))
13096 (setq gnus-killed-list killed))
13097 ;; The .el file version of this variable does not begin with
13098 ;; "options", while the .eld version does, so we just add it if it
13099 ;; isn't there.
13100 (and
13101 gnus-newsrc-options
13102 (progn
13103 (and (not (string-match "^ *options" gnus-newsrc-options))
13104 (setq gnus-newsrc-options (concat "options " gnus-newsrc-options)))
13105 (and (not (string-match "\n$" gnus-newsrc-options))
13106 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n")))
13107 ;; Finally, if we read some options lines, we parse them.
13108 (or (string= gnus-newsrc-options "")
13109 (gnus-newsrc-parse-options gnus-newsrc-options))))
13111 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
13112 (gnus-make-hashtable-from-newsrc-alist)))
13114 (defun gnus-make-newsrc-file (file)
13115 "Make server dependent file name by catenating FILE and server host name."
13116 (let* ((file (expand-file-name file nil))
13117 (real-file (concat file "-" (nth 1 gnus-select-method))))
13118 (if (or (file-exists-p real-file)
13119 (file-exists-p (concat real-file ".el"))
13120 (file-exists-p (concat real-file ".eld")))
13121 real-file file)))
13123 (defun gnus-uncompress-newsrc-alist ()
13124 ;; Uncompress all lists of marked articles in the newsrc assoc.
13125 (let ((newsrc gnus-newsrc-alist)
13126 marked)
13127 (while newsrc
13128 (if (not (setq marked (nth 3 (car newsrc))))
13130 (while marked
13131 (or (eq 'score (car (car marked)))
13132 (eq 'bookmark (car (car marked)))
13133 (eq 'killed (car (car marked)))
13134 (setcdr (car marked) (gnus-uncompress-range (cdr (car marked)))))
13135 (setq marked (cdr marked))))
13136 (setq newsrc (cdr newsrc)))))
13138 (defun gnus-compress-newsrc-alist ()
13139 ;; Compress all lists of marked articles in the newsrc assoc.
13140 (let ((newsrc gnus-newsrc-alist)
13141 marked)
13142 (while newsrc
13143 (if (not (setq marked (nth 3 (car newsrc))))
13145 (while marked
13146 (or (eq 'score (car (car marked)))
13147 (eq 'bookmark (car (car marked)))
13148 (eq 'killed (car (car marked)))
13149 (setcdr (car marked)
13150 (condition-case ()
13151 (gnus-compress-sequence
13152 (sort (cdr (car marked)) '<) t)
13153 (error (cdr (car marked))))))
13154 (setq marked (cdr marked))))
13155 (setq newsrc (cdr newsrc)))))
13157 (defun gnus-newsrc-to-gnus-format ()
13158 (setq gnus-newsrc-options "")
13159 (setq gnus-newsrc-options-n nil)
13161 (or gnus-active-hashtb
13162 (setq gnus-active-hashtb (make-vector 4095 0)))
13163 (let ((buf (current-buffer))
13164 (already-read (> (length gnus-newsrc-alist) 1))
13165 group subscribed options-symbol newsrc Options-symbol
13166 symbol reads num1)
13167 (goto-char (point-min))
13168 ;; We intern the symbol `options' in the active hashtb so that we
13169 ;; can `eq' against it later.
13170 (set (setq options-symbol (intern "options" gnus-active-hashtb)) nil)
13171 (set (setq Options-symbol (intern "Options" gnus-active-hashtb)) nil)
13173 (while (not (eobp))
13174 ;; We first read the first word on the line by narrowing and
13175 ;; then reading into `gnus-active-hashtb'. Most groups will
13176 ;; already exist in that hashtb, so this will save some string
13177 ;; space.
13178 (narrow-to-region
13179 (point)
13180 (progn (skip-chars-forward "^ \t!:\n") (point)))
13181 (goto-char (point-min))
13182 (setq symbol
13183 (and (/= (point-min) (point-max))
13184 (let ((obarray gnus-active-hashtb)) (read buf))))
13185 (widen)
13186 ;; Now, the symbol we have read is either `options' or a group
13187 ;; name. If it is an options line, we just add it to a string.
13188 (cond
13189 ((or (eq symbol options-symbol)
13190 (eq symbol Options-symbol))
13191 (setq gnus-newsrc-options
13192 ;; This concating is quite inefficient, but since our
13193 ;; thorough studies show that approx 99.37% of all
13194 ;; .newsrc files only contain a single options line, we
13195 ;; don't give a damn, frankly, my dear.
13196 (concat gnus-newsrc-options
13197 (buffer-substring
13198 (gnus-point-at-bol)
13199 ;; Options may continue on the next line.
13200 (or (and (re-search-forward "^[^ \t]" nil 'move)
13201 (progn (beginning-of-line) (point)))
13202 (point)))))
13203 (forward-line -1))
13204 (symbol
13205 (or (boundp symbol) (set symbol nil))
13206 ;; It was a group name.
13207 (setq subscribed (= (following-char) ?:)
13208 group (symbol-name symbol)
13209 reads nil)
13210 (if (eolp)
13211 ;; If the line ends here, this is clearly a buggy line, so
13212 ;; we put point a the beginning of line and let the cond
13213 ;; below do the error handling.
13214 (beginning-of-line)
13215 ;; We skip to the beginning of the ranges.
13216 (skip-chars-forward "!: \t"))
13217 ;; We are now at the beginning of the list of read articles.
13218 ;; We read them range by range.
13219 (while
13220 (cond
13221 ((looking-at "[0-9]+")
13222 ;; We narrow and read a number instead of buffer-substring/
13223 ;; string-to-int because it's faster. narrow/widen is
13224 ;; faster than save-restriction/narrow, and save-restriction
13225 ;; produces a garbage object.
13226 (setq num1 (progn
13227 (narrow-to-region (match-beginning 0) (match-end 0))
13228 (read buf)))
13229 (widen)
13230 ;; If the next character is a dash, then this is a range.
13231 (if (= (following-char) ?-)
13232 (progn
13233 ;; We read the upper bound of the range.
13234 (forward-char 1)
13235 (if (not (looking-at "[0-9]+"))
13236 ;; This is a buggy line, by we pretend that
13237 ;; it's kinda OK. Perhaps the user should be
13238 ;; dinged?
13239 (setq reads (cons num1 reads))
13240 (setq reads
13241 (cons
13242 (cons num1
13243 (progn
13244 (narrow-to-region (match-beginning 0)
13245 (match-end 0))
13246 (read buf)))
13247 reads))
13248 (widen)))
13249 ;; It was just a simple number, so we add it to the
13250 ;; list of ranges.
13251 (setq reads (cons num1 reads)))
13252 ;; If the next char in ?\n, then we have reached the end
13253 ;; of the line and return nil.
13254 (/= (following-char) ?\n))
13255 ((= (following-char) ?\n)
13256 ;; End of line, so we end.
13257 nil)
13259 ;; Not numbers and not eol, so this might be a buggy
13260 ;; line...
13261 (or (eobp)
13262 ;; If it was eob instead of ?\n, we allow it.
13263 (progn
13264 ;; The line was buggy.
13265 (setq group nil)
13266 (gnus-message 3 "Mangled line: %s"
13267 (buffer-substring (gnus-point-at-bol)
13268 (gnus-point-at-eol)))
13269 (ding)
13270 (sit-for 1)))
13271 nil))
13272 ;; Skip past ", ". Spaces are illegal in these ranges, but
13273 ;; we allow them, because it's a common mistake to put a
13274 ;; space after the comma.
13275 (skip-chars-forward ", "))
13277 ;; We have already read .newsrc.eld, so we gently update the
13278 ;; data in the hash table with the information we have just
13279 ;; read.
13280 (if (not group)
13282 (let ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
13283 level)
13284 (if info
13285 ;; There is an entry for this file in the alist.
13286 (progn
13287 (setcar (nthcdr 2 info) (nreverse reads))
13288 ;; We update the level very gently. In fact, we
13289 ;; only change it if there's been a status change
13290 ;; from subscribed to unsubscribed, or vice versa.
13291 (setq level (nth 1 info))
13292 (cond ((and (<= level gnus-level-subscribed)
13293 (not subscribed))
13294 (setq level (if reads
13295 gnus-level-default-unsubscribed
13296 (1+ gnus-level-default-unsubscribed))))
13297 ((and (> level gnus-level-subscribed) subscribed)
13298 (setq level gnus-level-default-subscribed)))
13299 (setcar (cdr info) level))
13300 ;; This is a new group.
13301 (setq info (list group
13302 (if subscribed
13303 gnus-level-default-subscribed
13304 (if reads
13305 (1+ gnus-level-subscribed)
13306 gnus-level-default-unsubscribed))
13307 (nreverse reads))))
13308 (setq newsrc (cons info newsrc))))))
13309 (forward-line 1))
13311 (setq newsrc (nreverse newsrc))
13313 (if (not already-read)
13315 ;; We now have two newsrc lists - `newsrc', which is what we
13316 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
13317 ;; what we've read from .newsrc.eld. We have to merge these
13318 ;; lists. We do this by "attaching" any (foreign) groups in the
13319 ;; gnus-newsrc-alist to the (native) group that precedes them.
13320 (let ((rc (cdr gnus-newsrc-alist))
13321 (prev gnus-newsrc-alist)
13322 entry mentry)
13323 (while rc
13324 (or (null (nth 4 (car rc))) ; It's a native group.
13325 (assoc (car (car rc)) newsrc) ; It's already in the alist.
13326 (if (setq entry (assoc (car (car prev)) newsrc))
13327 (setcdr (setq mentry (memq entry newsrc))
13328 (cons (car rc) (cdr mentry)))
13329 (setq newsrc (cons (car rc) newsrc))))
13330 (setq prev rc
13331 rc (cdr rc)))))
13333 (setq gnus-newsrc-alist newsrc)
13334 ;; We make the newsrc hashtb.
13335 (gnus-make-hashtable-from-newsrc-alist)
13337 ;; Finally, if we read some options lines, we parse them.
13338 (or (string= gnus-newsrc-options "")
13339 (gnus-newsrc-parse-options gnus-newsrc-options))))
13341 ;; Parse options lines to find "options -n !all rec.all" and stuff.
13342 ;; The return value will be a list on the form
13343 ;; ((regexp1 . ignore)
13344 ;; (regexp2 . subscribe)...)
13345 ;; When handling new newsgroups, groups that match a `ignore' regexp
13346 ;; will be ignored, and groups that match a `subscribe' regexp will be
13347 ;; subscribed. A line like
13348 ;; options -n !all rec.all
13349 ;; will lead to a list that looks like
13350 ;; (("^rec\\..+" . subscribe)
13351 ;; ("^.+" . ignore))
13352 ;; So all "rec.*" groups will be subscribed, while all the other
13353 ;; groups will be ignored. Note that "options -n !all rec.all" is very
13354 ;; different from "options -n rec.all !all".
13355 (defun gnus-newsrc-parse-options (options)
13356 (let (out eol)
13357 (save-excursion
13358 (gnus-set-work-buffer)
13359 (insert (regexp-quote options))
13360 ;; First we treat all continuation lines.
13361 (goto-char (point-min))
13362 (while (re-search-forward "\n[ \t]+" nil t)
13363 (replace-match " " t t))
13364 ;; Then we transform all "all"s into ".+"s.
13365 (goto-char (point-min))
13366 (while (re-search-forward "\\ball\\b" nil t)
13367 (replace-match ".+" t t))
13368 (goto-char (point-min))
13369 ;; We remove all other options than the "-n" ones.
13370 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
13371 (replace-match " ")
13372 (forward-char -1))
13373 (goto-char (point-min))
13375 ;; We are only interested in "options -n" lines - we
13376 ;; ignore the other option lines.
13377 (while (re-search-forward "[ \t]-n" nil t)
13378 (setq eol
13379 (or (save-excursion
13380 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
13381 (- (point) 2)))
13382 (gnus-point-at-eol)))
13383 ;; Search for all "words"...
13384 (while (re-search-forward "[^ \t,\n]+" eol t)
13385 (if (= (char-after (match-beginning 0)) ?!)
13386 ;; If the word begins with a bang (!), this is a "not"
13387 ;; spec. We put this spec (minus the bang) and the
13388 ;; symbol `ignore' into the list.
13389 (setq out (cons (cons (concat
13390 "^" (buffer-substring
13391 (1+ (match-beginning 0))
13392 (match-end 0)))
13393 'ignore) out))
13394 ;; There was no bang, so this is a "yes" spec.
13395 (setq out (cons (cons (concat
13396 "^" (buffer-substring (match-beginning 0)
13397 (match-end 0)))
13398 'subscribe) out)))))
13400 (setq gnus-newsrc-options-n out))))
13403 (defun gnus-save-newsrc-file ()
13404 "Save .newsrc file."
13405 ;; Note: We cannot save .newsrc file if all newsgroups are removed
13406 ;; from the variable gnus-newsrc-alist.
13407 (and (or gnus-newsrc-alist gnus-killed-list)
13408 gnus-current-startup-file
13409 (progn
13410 (run-hooks 'gnus-save-newsrc-hook)
13411 (save-excursion
13412 (if (and gnus-use-dribble-file
13413 (or (not gnus-dribble-buffer)
13414 (not (buffer-name gnus-dribble-buffer))
13415 (zerop (save-excursion
13416 (set-buffer gnus-dribble-buffer)
13417 (buffer-size)))))
13418 (gnus-message 4 "(No changes need to be saved)")
13419 (if gnus-save-newsrc-file
13420 (progn
13421 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
13422 ;; Make backup file of master newsrc.
13423 (gnus-gnus-to-newsrc-format)
13424 (gnus-message 5 "Saving %s...done"
13425 gnus-current-startup-file)))
13426 ;; Quickly loadable .newsrc.
13427 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
13428 (make-local-variable 'version-control)
13429 (setq version-control 'never)
13430 (setq buffer-file-name (concat gnus-current-startup-file ".eld"))
13431 (gnus-add-current-to-buffer-list)
13432 (buffer-disable-undo (current-buffer))
13433 (erase-buffer)
13434 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
13435 (gnus-gnus-to-quick-newsrc-format)
13436 (save-buffer)
13437 (kill-buffer (current-buffer))
13438 (gnus-message 5 "Saving %s.eld...done" gnus-current-startup-file)
13439 (gnus-dribble-delete-file))))))
13441 (defun gnus-gnus-to-quick-newsrc-format ()
13442 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
13443 (insert ";; Gnus startup file.\n")
13444 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
13445 (insert ";; to read .newsrc.\n")
13446 (insert "(setq gnus-newsrc-file-version "
13447 (prin1-to-string gnus-version) ")\n")
13448 (let ((variables gnus-variable-list)
13449 (inhibit-quit t)
13450 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
13451 variable)
13452 ;; insert lisp expressions.
13453 (gnus-compress-newsrc-alist)
13454 (while variables
13455 (setq variable (car variables))
13456 (and (boundp variable)
13457 (symbol-value variable)
13458 (or gnus-save-killed-list (not (eq variable 'gnus-killed-list)))
13459 (insert "(setq " (symbol-name variable) " '"
13460 (prin1-to-string (symbol-value variable))
13461 ")\n"))
13462 (setq variables (cdr variables)))
13463 (gnus-uncompress-newsrc-alist)))
13466 (defun gnus-gnus-to-newsrc-format ()
13467 ;; Generate and save the .newsrc file.
13468 (let ((newsrc (cdr gnus-newsrc-alist))
13469 info ranges range)
13470 (save-excursion
13471 (set-buffer (create-file-buffer gnus-current-startup-file))
13472 (setq buffer-file-name gnus-current-startup-file)
13473 (buffer-disable-undo (current-buffer))
13474 (erase-buffer)
13475 ;; Write options.
13476 (if gnus-newsrc-options (insert gnus-newsrc-options))
13477 ;; Write subscribed and unsubscribed.
13478 (while newsrc
13479 (setq info (car newsrc))
13480 (if (not (nth 4 info)) ;Don't write foreign groups to .newsrc.
13481 (progn
13482 (insert (car info) (if (> (nth 1 info) gnus-level-subscribed)
13483 "!" ":"))
13484 (if (setq ranges (nth 2 info))
13485 (progn
13486 (insert " ")
13487 (if (not (listp (cdr ranges)))
13488 (if (= (car ranges) (cdr ranges))
13489 (insert (int-to-string (car ranges)))
13490 (insert (int-to-string (car ranges)) "-"
13491 (int-to-string (cdr ranges))))
13492 (while ranges
13493 (setq range (car ranges)
13494 ranges (cdr ranges))
13495 (if (or (atom range) (= (car range) (cdr range)))
13496 (insert (int-to-string
13497 (or (and (atom range) range)
13498 (car range))))
13499 (insert (int-to-string (car range)) "-"
13500 (int-to-string (cdr range))))
13501 (if ranges (insert ","))))))
13502 (insert "\n")))
13503 (setq newsrc (cdr newsrc)))
13504 (make-local-variable 'version-control)
13505 (setq version-control 'never)
13506 ;; It has been reported that sometime the modtime on the .newsrc
13507 ;; file seems to be off. We really do want to overwrite it, so
13508 ;; we clear the modtime here before saving. It's a bit odd,
13509 ;; though...
13510 ;; sometimes the modtime clear isn't sufficient. most brute force:
13511 ;; delete the silly thing entirely first. but this fails to provide
13512 ;; such niceties as .newsrc~ creation.
13513 (if gnus-modtime-botch
13514 (delete-file gnus-startup-file)
13515 (clear-visited-file-modtime))
13516 (save-buffer)
13517 (kill-buffer (current-buffer)))))
13519 (defun gnus-read-all-descriptions-files ()
13520 (let ((methods (cons gnus-select-method gnus-secondary-select-methods)))
13521 (while methods
13522 (gnus-read-descriptions-file (car methods))
13523 (setq methods (cdr methods)))
13526 (defun gnus-read-descriptions-file (&optional method)
13527 (let ((method (or method gnus-select-method)))
13528 ;; We create the hashtable whether we manage to read the desc file
13529 ;; to avoid trying to re-read after a failed read.
13530 (or gnus-description-hashtb
13531 (setq gnus-description-hashtb
13532 (gnus-make-hashtable (length gnus-active-hashtb))))
13533 ;; Mark this method's desc file as read.
13534 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read"
13535 gnus-description-hashtb)
13537 (gnus-message 5 "Reading descriptions file via %s..." (car method))
13538 (cond
13539 ((not (gnus-check-server method))
13540 (gnus-message 1 "Couldn't open server")
13541 nil)
13542 ((not (gnus-request-list-newsgroups method))
13543 (gnus-message 1 "Couldn't read newsgroups descriptions")
13544 nil)
13546 (let (group)
13547 (save-excursion
13548 (save-restriction
13549 (set-buffer nntp-server-buffer)
13550 (goto-char (point-min))
13551 (if (or (search-forward "\n.\n" nil t)
13552 (goto-char (point-max)))
13553 (progn
13554 (beginning-of-line)
13555 (narrow-to-region (point-min) (point))))
13556 (goto-char (point-min))
13557 (while (not (eobp))
13558 ;; If we get an error, we set group to 0, which is not a
13559 ;; symbol...
13560 (setq group
13561 (condition-case ()
13562 (let ((obarray gnus-description-hashtb))
13563 ;; Group is set to a symbol interned in this
13564 ;; hash table.
13565 (read nntp-server-buffer))
13566 (error 0)))
13567 (skip-chars-forward " \t")
13568 ;; ... which leads to this line being effectively ignored.
13569 (and (symbolp group)
13570 (set group (buffer-substring
13571 (point) (progn (end-of-line) (point)))))
13572 (forward-line 1))))
13573 (gnus-message 5 "Reading descriptions file...done")
13574 t)))))
13576 (defun gnus-group-get-description (group)
13577 ;; Get the description of a group by sending XGTITLE to the server.
13578 (and (gnus-request-group-description group)
13579 (save-excursion
13580 (set-buffer nntp-server-buffer)
13581 (goto-char (point-min))
13582 (and (looking-at "[^ \t]+[ \t]+\\(.*\\)")
13583 (buffer-substring (match-beginning 1) (match-end 1))))))
13586 ;;; Server
13589 (defvar gnus-server-mode-hook nil
13590 "Hook run in `gnus-server-mode' buffers.")
13592 (defconst gnus-server-line-format " {%(%h:%w%)}\n"
13593 "Format of server lines.
13594 It works along the same lines as a normal formatting string,
13595 with some simple extensions.")
13597 (defvar gnus-server-mode-line-format "Gnus List of servers"
13598 "The format specification for the server mode line.")
13600 (defconst gnus-server-line-format-alist
13601 (list (list ?h 'how ?s)
13602 (list ?n 'name ?s)
13603 (list ?w 'where ?s)
13606 (defconst gnus-server-mode-line-format-alist
13607 (list (list ?S 'news-server ?s)
13608 (list ?M 'news-method ?s)
13609 (list ?u 'user-defined ?s)))
13611 (defvar gnus-server-line-format-spec nil)
13612 (defvar gnus-server-mode-line-format-spec nil)
13613 (defvar gnus-server-killed-servers nil)
13615 (defvar gnus-server-mode-map nil)
13616 (put 'gnus-server-mode 'mode-class 'special)
13618 (if gnus-server-mode-map
13620 (setq gnus-server-mode-map (make-sparse-keymap))
13621 (suppress-keymap gnus-server-mode-map)
13622 (define-key gnus-server-mode-map " " 'gnus-server-read-server)
13623 (define-key gnus-server-mode-map "\r" 'gnus-server-read-server)
13624 (define-key gnus-server-mode-map gnus-mouse-2 'gnus-server-pick-server)
13625 (define-key gnus-server-mode-map "q" 'gnus-server-exit)
13626 (define-key gnus-server-mode-map "l" 'gnus-server-list-servers)
13627 (define-key gnus-server-mode-map "k" 'gnus-server-kill-server)
13628 (define-key gnus-server-mode-map "y" 'gnus-server-yank-server)
13629 (define-key gnus-server-mode-map "c" 'gnus-server-copy-server)
13630 (define-key gnus-server-mode-map "a" 'gnus-server-add-server)
13631 (define-key gnus-server-mode-map "e" 'gnus-server-edit-server))
13633 (defun gnus-server-mode ()
13634 "Major mode for listing and editing servers.
13636 All normal editing commands are switched off.
13637 \\<gnus-server-mode-map>
13639 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
13641 The following commands are available:
13643 \\{gnus-server-mode-map}"
13644 (interactive)
13645 (if gnus-visual (gnus-server-make-menu-bar))
13646 (kill-all-local-variables)
13647 (gnus-simplify-mode-line)
13648 (setq major-mode 'gnus-server-mode)
13649 (setq mode-name "Server")
13650 ; (gnus-group-set-mode-line)
13651 (setq mode-line-process nil)
13652 (use-local-map gnus-server-mode-map)
13653 (buffer-disable-undo (current-buffer))
13654 (setq truncate-lines t)
13655 (setq buffer-read-only t)
13656 (run-hooks 'gnus-server-mode-hook))
13658 (defun gnus-server-insert-server-line (sformat name method)
13659 (let* ((sformat (or sformat gnus-server-line-format-spec))
13660 (how (car method))
13661 (where (nth 1 method))
13663 (beginning-of-line)
13664 (setq b (point))
13665 ;; Insert the text.
13666 (insert (eval sformat))
13667 (add-text-properties b (1+ b) (list 'gnus-server (intern name)))))
13669 (defun gnus-server-setup-buffer ()
13670 (if (get-buffer gnus-server-buffer)
13672 (save-excursion
13673 (set-buffer (get-buffer-create gnus-server-buffer))
13674 (gnus-server-mode)
13675 (and gnus-carpal (gnus-carpal-setup-buffer 'server)))))
13677 (defun gnus-server-prepare ()
13678 (setq gnus-server-mode-line-format-spec
13679 (gnus-parse-format gnus-server-mode-line-format
13680 gnus-server-mode-line-format-alist))
13681 (setq gnus-server-line-format-spec
13682 (gnus-parse-format gnus-server-line-format
13683 gnus-server-line-format-alist))
13684 (let ((alist gnus-server-alist)
13685 (buffer-read-only nil))
13686 (erase-buffer)
13687 (while alist
13688 (gnus-server-insert-server-line nil (car (car alist)) (cdr (car alist)))
13689 (setq alist (cdr alist))))
13690 (goto-char (point-min))
13691 (gnus-server-position-cursor))
13693 (defun gnus-server-server-name ()
13694 (let ((server (get-text-property (gnus-point-at-bol) 'gnus-server)))
13695 (and server (symbol-name server))))
13697 (defalias 'gnus-server-position-cursor 'gnus-goto-colon)
13699 (defconst gnus-server-edit-buffer "*Gnus edit server*")
13701 (defun gnus-server-update-server (server)
13702 (save-excursion
13703 (set-buffer gnus-server-buffer)
13704 (let ((buffer-read-only nil)
13705 (info (cdr (assoc server gnus-server-alist))))
13706 (gnus-dribble-enter
13707 (concat "(gnus-server-set-info \"" server "\" '"
13708 (prin1-to-string info) ")"))
13709 ;; Buffer may be narrowed.
13710 (save-restriction
13711 (widen)
13712 (if (gnus-server-goto-server server)
13713 (delete-region (progn (beginning-of-line) (point))
13714 (progn (forward-line 1) (point))))
13715 (let ((entry (assoc server gnus-server-alist)))
13716 (gnus-server-insert-server-line nil (car entry) (cdr entry))
13717 (gnus-server-position-cursor))))))
13719 (defun gnus-server-set-info (server info)
13720 ;; Enter a select method into the virtual server alist.
13721 (gnus-dribble-enter
13722 (concat "(gnus-server-set-info \"" server "\" '"
13723 (prin1-to-string info) ")"))
13724 (let* ((server (nth 1 info))
13725 (entry (assoc server gnus-server-alist)))
13726 (if entry (setcdr entry info)
13727 (setq gnus-server-alist
13728 (nconc gnus-server-alist (list (cons server info)))))))
13730 (defun gnus-server-to-method (server)
13731 ;; Map virtual server names to select methods.
13732 (or (and (equal server "native") gnus-select-method)
13733 (cdr (assoc server gnus-server-alist))))
13735 (defun gnus-server-extend-method (group method)
13736 ;; This function "extends" a virtual server. If the server is
13737 ;; "hello", and the select method is ("hello" (my-var "something"))
13738 ;; in the group "alt.alt", this will result in a new virtual server
13739 ;; called "helly+alt.alt".
13740 (let ((entry
13741 (gnus-copy-sequence
13742 (if (equal (car method) "native") gnus-select-method
13743 (cdr (assoc (car method) gnus-server-alist))))))
13744 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
13745 (nconc entry (cdr method))))
13747 (defun gnus-server-get-method (group method)
13748 ;; Input either a server name, and extended server name, or a
13749 ;; select method, and return a select method.
13750 (cond ((stringp method)
13751 (gnus-server-to-method method))
13752 ((and (stringp (car method)) group)
13753 (gnus-server-extend-method group method))
13755 (gnus-server-add-address method))))
13757 (defun gnus-server-add-address (method)
13758 (let ((method-name (symbol-name (car method))))
13759 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
13760 (not (assq (intern (concat method-name "-address")) method)))
13761 (append method (list (list (intern (concat method-name "-address"))
13762 (nth 1 method))))
13763 method)))
13765 (defun gnus-server-equal (s1 s2)
13766 (or (equal s1 s2)
13767 (and (= (length s1) (length s2))
13768 (progn
13769 (while (and s1 (member (car s1) s2))
13770 (setq s1 (cdr s1)))
13771 (null s1)))))
13773 ;;; Interactive server functions.
13775 (defun gnus-server-kill-server (server)
13776 "Kill the server on the current line."
13777 (interactive (list (gnus-server-server-name)))
13778 (or (gnus-server-goto-server server)
13779 (if server (error "No such server: %s" server)
13780 (error "No server on the current line")))
13781 (gnus-dribble-enter "")
13782 (let ((buffer-read-only nil))
13783 (delete-region (progn (beginning-of-line) (point))
13784 (progn (forward-line 1) (point))))
13785 (setq gnus-server-killed-servers
13786 (cons (assoc server gnus-server-alist) gnus-server-killed-servers))
13787 (setq gnus-server-alist (delq (car gnus-server-killed-servers)
13788 gnus-server-alist))
13789 (gnus-server-position-cursor))
13791 (defun gnus-server-yank-server ()
13792 "Yank the previously killed server."
13793 (interactive)
13794 (or gnus-server-killed-servers
13795 (error "No killed servers to be yanked"))
13796 (let ((alist gnus-server-alist)
13797 (server (gnus-server-server-name))
13798 (killed (car gnus-server-killed-servers)))
13799 (if (not server)
13800 (setq gnus-server-alist (nconc gnus-server-alist (list killed)))
13801 (if (string= server (car (car gnus-server-alist)))
13802 (setq gnus-server-alist (cons killed gnus-server-alist))
13803 (while (and (cdr alist)
13804 (not (string= server (car (car (cdr alist))))))
13805 (setq alist (cdr alist)))
13806 (setcdr alist (cons killed (cdr alist)))))
13807 (gnus-server-update-server (car killed))
13808 (setq gnus-server-killed-servers (cdr gnus-server-killed-servers))
13809 (gnus-server-position-cursor)))
13811 (defun gnus-server-exit ()
13812 "Return to the group buffer."
13813 (interactive)
13814 (kill-buffer (current-buffer))
13815 (switch-to-buffer gnus-group-buffer))
13817 (defun gnus-server-list-servers ()
13818 "List all available servers."
13819 (interactive)
13820 (let ((cur (gnus-server-server-name)))
13821 (gnus-server-prepare)
13822 (if cur (gnus-server-goto-server cur)
13823 (goto-char (point-max))
13824 (forward-line -1))
13825 (gnus-server-position-cursor)))
13827 (defun gnus-server-copy-server (from to)
13828 (interactive
13829 (list
13830 (or (gnus-server-server-name)
13831 (error "No server on the current line"))
13832 (read-string "Copy to: ")))
13833 (or from (error "No server on current line"))
13834 (or (and to (not (string= to ""))) (error "No name to copy to"))
13835 (and (assoc to gnus-server-alist) (error "%s already exists" to))
13836 (or (assoc from gnus-server-alist)
13837 (error "%s: no such server" from))
13838 (let ((to-entry (gnus-copy-sequence (assoc from gnus-server-alist))))
13839 (setcar to-entry to)
13840 (setcar (nthcdr 2 to-entry) to)
13841 (setq gnus-server-killed-servers
13842 (cons to-entry gnus-server-killed-servers))
13843 (gnus-server-yank-server)))
13845 (defun gnus-server-add-server (how where)
13846 (interactive
13847 (list (intern (completing-read "Server method: "
13848 gnus-valid-select-methods nil t))
13849 (read-string "Server name: ")))
13850 (setq gnus-server-killed-servers
13851 (cons (list where how where) gnus-server-killed-servers))
13852 (gnus-server-yank-server))
13854 (defun gnus-server-goto-server (server)
13855 "Jump to a server line."
13856 (interactive
13857 (list (completing-read "Goto server: " gnus-server-alist nil t)))
13858 (let ((to (text-property-any (point-min) (point-max)
13859 'gnus-server (intern server))))
13860 (and to
13861 (progn
13862 (goto-char to)
13863 (gnus-server-position-cursor)))))
13865 (defun gnus-server-edit-server (server)
13866 "Edit the server on the current line."
13867 (interactive (list (gnus-server-server-name)))
13868 (or server
13869 (error "No server on current line"))
13870 (let ((winconf (current-window-configuration)))
13871 (get-buffer-create gnus-server-edit-buffer)
13872 (gnus-configure-windows 'edit-server)
13873 (gnus-add-current-to-buffer-list)
13874 (emacs-lisp-mode)
13875 (make-local-variable 'gnus-prev-winconf)
13876 (setq gnus-prev-winconf winconf)
13877 (use-local-map (copy-keymap (current-local-map)))
13878 (let ((done-func '(lambda ()
13879 "Exit editing mode and update the information."
13880 (interactive)
13881 (gnus-server-edit-server-done 'group))))
13882 (setcar (cdr (nth 4 done-func)) server)
13883 (local-set-key "\C-c\C-c" done-func))
13884 (erase-buffer)
13885 (insert ";; Type `C-c C-c' after you have edited the server.\n\n")
13886 (insert (pp-to-string (cdr (assoc server gnus-server-alist))))))
13888 (defun gnus-server-edit-server-done (server)
13889 (interactive)
13890 (set-buffer (get-buffer-create gnus-server-edit-buffer))
13891 (goto-char (point-min))
13892 (let ((form (read (current-buffer)))
13893 (winconf gnus-prev-winconf))
13894 (gnus-server-set-info server form)
13895 (kill-buffer (current-buffer))
13896 (and winconf (set-window-configuration winconf))
13897 (set-buffer gnus-server-buffer)
13898 (gnus-server-update-server (gnus-server-server-name))
13899 (gnus-server-list-servers)
13900 (gnus-server-position-cursor)))
13902 (defun gnus-server-read-server (server)
13903 "Browse a server."
13904 (interactive (list (gnus-server-server-name)))
13905 (gnus-browse-foreign-server (gnus-server-to-method server) (current-buffer)))
13907 (defun gnus-mouse-pick-server (e)
13908 (interactive "e")
13909 (mouse-set-point e)
13910 (gnus-server-read-server (gnus-server-server-name)))
13913 ;;; entry points into gnus-score.el
13916 ;;; Finding score files.
13918 (defvar gnus-global-score-files nil
13919 "*List of global score files and directories.
13920 Set this variable if you want to use people's score files. One entry
13921 for each score file or each score file directory. Gnus will decide
13922 by itself what score files are applicable to which group.
13924 Say you want to use the single score file
13925 \"/ftp.ifi.uio.no@ftp:/pub/larsi/ding/score/soc.motss.SCORE\" and all
13926 score files in the \"/ftp.some-where:/pub/score\" directory.
13928 (setq gnus-global-score-files
13929 '(\"/ftp.ifi.uio.no:/pub/larsi/ding/score/soc.motss.SCORE\"
13930 \"/ftp.some-where:/pub/score\"))")
13932 (defun gnus-score-score-files (group)
13933 "Return a list of all possible score files."
13934 ;; Search and set any global score files.
13935 (and gnus-global-score-files
13936 (or gnus-internal-global-score-files
13937 (gnus-score-search-global-directories gnus-global-score-files)))
13938 ;; Fix the kill-file dir variable.
13939 (setq gnus-kill-files-directory
13940 (file-name-as-directory
13941 (or gnus-kill-files-directory "~/News/")))
13942 ;; If we can't read it, there are no score files.
13943 (if (not (file-exists-p (expand-file-name gnus-kill-files-directory)))
13944 (setq gnus-score-file-list nil)
13945 (if (gnus-use-long-file-name 'not-score)
13946 ;; We want long file names.
13947 (if (or (not gnus-score-file-list)
13948 (not (car gnus-score-file-list))
13949 (gnus-file-newer-than gnus-kill-files-directory
13950 (car gnus-score-file-list)))
13951 (setq gnus-score-file-list
13952 (cons (nth 5 (file-attributes gnus-kill-files-directory))
13953 (nreverse
13954 (directory-files
13955 gnus-kill-files-directory t
13956 (gnus-score-file-regexp))))))
13957 ;; We do not use long file names, so we have to do some
13958 ;; directory traversing.
13959 (let ((mdir (length (expand-file-name gnus-kill-files-directory)))
13960 (suffixes (list gnus-score-file-suffix gnus-adaptive-file-suffix))
13961 dir files suffix)
13962 (while suffixes
13963 (setq dir (expand-file-name
13964 (concat gnus-kill-files-directory
13965 (gnus-replace-chars-in-string group ?. ?/))))
13966 (setq dir (gnus-replace-chars-in-string dir ?: ?/))
13967 (setq suffix (car suffixes)
13968 suffixes (cdr suffixes))
13969 (if (file-exists-p (concat dir "/" suffix))
13970 (setq files (cons (concat dir "/" suffix) files)))
13971 (while (>= (1+ (length dir)) mdir)
13972 (and (file-exists-p (concat dir "/all/" suffix))
13973 (setq files (cons (concat dir "/all/" suffix) files)))
13974 (string-match "/[^/]*$" dir)
13975 (setq dir (substring dir 0 (match-beginning 0)))))
13976 (setq gnus-score-file-list
13977 (cons nil (nreverse files)))))
13978 (cdr gnus-score-file-list)))
13980 (defun gnus-score-file-regexp ()
13981 (concat "\\(" gnus-score-file-suffix
13982 "\\|" gnus-adaptive-file-suffix "\\)$"))
13984 (defun gnus-score-find-bnews (group)
13985 "Return a list of score files for GROUP.
13986 The score files are those files in the ~/News directory which matches
13987 GROUP using BNews sys file syntax."
13988 (let* ((sfiles (append (gnus-score-score-files group)
13989 gnus-internal-global-score-files))
13990 (kill-dir (file-name-as-directory
13991 (expand-file-name gnus-kill-files-directory)))
13992 (klen (length kill-dir))
13993 ofiles not-match regexp)
13994 (save-excursion
13995 (set-buffer (get-buffer-create "*gnus score files*"))
13996 (buffer-disable-undo (current-buffer))
13997 ;; Go through all score file names and create regexp with them
13998 ;; as the source.
13999 (while sfiles
14000 (erase-buffer)
14001 (insert (car sfiles))
14002 (goto-char (point-min))
14003 ;; First remove the suffix itself.
14004 (re-search-forward (concat "." (gnus-score-file-regexp)))
14005 (replace-match "" t t)
14006 (goto-char (point-min))
14007 (if (looking-at (regexp-quote kill-dir))
14008 ;; If the file name was just "SCORE", `klen' is one character
14009 ;; too much.
14010 (delete-char (min (1- (point-max)) klen))
14011 (goto-char (point-max))
14012 (search-backward "/")
14013 (delete-region (1+ (point)) (point-min)))
14014 ;; If short file names were used, we have to translate slashes.
14015 (goto-char (point-min))
14016 (while (re-search-forward "[/:]" nil t)
14017 (replace-match "." t t))
14018 ;; Kludge to get rid of "nntp+" problems.
14019 (goto-char (point-min))
14020 (and (looking-at "nn[a-z]+\\+")
14021 (progn
14022 (search-forward "+")
14023 (forward-char -1)
14024 (insert "\\")))
14025 ;; Translate ".all" to "[./].*";
14026 (while (search-forward ".all" nil t)
14027 (replace-match "[./:].*" t t))
14028 (goto-char (point-min))
14029 ;; Translate "all" to ".*".
14030 (while (search-forward "all" nil t)
14031 (replace-match ".*" t t))
14032 (goto-char (point-min))
14033 ;; Deal with "not."s.
14034 (if (looking-at "not.")
14035 (progn
14036 (setq not-match t)
14037 (setq regexp (buffer-substring 5 (point-max))))
14038 (setq regexp (buffer-substring 1 (point-max)))
14039 (setq not-match nil))
14040 ;; Finally - if this resulting regexp matches the group name,
14041 ;; we add this score file to the list of score files
14042 ;; applicable to this group.
14043 (if (or (and not-match
14044 (not (string-match regexp group)))
14045 (and (not not-match)
14046 (string-match regexp group)))
14047 (setq ofiles (cons (car sfiles) ofiles)))
14048 (setq sfiles (cdr sfiles)))
14049 (kill-buffer (current-buffer))
14050 ;; Slight kludge here - the last score file returned should be
14051 ;; the local score file, whether it exists or not. This is so
14052 ;; that any score commands the user enters will go to the right
14053 ;; file, and not end up in some global score file.
14054 (let ((localscore
14055 (expand-file-name
14056 (if (gnus-use-long-file-name 'not-score)
14057 (concat gnus-kill-files-directory group "."
14058 gnus-score-file-suffix)
14059 (concat gnus-kill-files-directory
14060 (gnus-replace-chars-in-string group ?. ?/ ?: ?/)
14061 "/" gnus-score-file-suffix)))))
14062 ;; The local score file might already be there, but it's
14063 ;; supposed to be the very last file, so we delete it from the
14064 ;; list if it's already there, and add it to the head of the
14065 ;; list.
14066 (setq ofiles (cons localscore (delete localscore ofiles))))
14067 (nreverse ofiles))))
14069 (defun gnus-score-find-single (group)
14070 "Return list containing the score file for GROUP."
14071 (list (gnus-score-file-name group gnus-adaptive-file-suffix)
14072 (gnus-score-file-name group)))
14074 (defun gnus-score-find-hierarchical (group)
14075 "Return list of score files for GROUP.
14076 This includes the score file for the group and all its parents."
14077 (let ((all (copy-sequence '(nil)))
14078 (start 0))
14079 (while (string-match "\\." group (1+ start))
14080 (setq start (match-beginning 0))
14081 (setq all (cons (substring group 0 start) all)))
14082 (setq all (cons group all))
14083 (nconc
14084 (mapcar (lambda (newsgroup)
14085 (gnus-score-file-name newsgroup gnus-adaptive-file-suffix))
14086 (setq all (nreverse all)))
14087 (mapcar 'gnus-score-file-name all))))
14089 (defvar gnus-score-file-alist-cache nil)
14091 (defun gnus-score-find-alist (group)
14092 "Return list of score files for GROUP.
14093 The list is determined from the variable gnus-score-file-alist."
14094 (let ((alist gnus-score-file-multiple-match-alist)
14095 score-files)
14096 ;; if this group has been seen before, return the cached entry
14097 (if (setq score-files (assoc group gnus-score-file-alist-cache))
14098 (cdr score-files) ;ensures caching groups with no matches
14099 ;; handle the multiple match alist
14100 (while alist
14101 (and (string-match (car (car alist)) group)
14102 (setq score-files
14103 (nconc score-files (copy-sequence (cdr (car alist))))))
14104 (setq alist (cdr alist)))
14105 (setq alist gnus-score-file-single-match-alist)
14106 ;; handle the single match alist
14107 (while alist
14108 (and (string-match (car (car alist)) group)
14109 ;; progn used just in case ("regexp") has no files
14110 ;; and score-files is still nil. -sj
14111 ;; this can be construed as a "stop searching here" feature :>
14112 ;; and used to simplify regexps in the single-alist
14113 (progn
14114 (setq score-files
14115 (nconc score-files (copy-sequence (cdr (car alist)))))
14116 (setq alist nil)))
14117 (setq alist (cdr alist)))
14118 ;; cache the score files
14119 (setq gnus-score-file-alist-cache
14120 (cons (cons group score-files) gnus-score-file-alist-cache))
14121 score-files)))
14124 (defun gnus-possibly-score-headers (&optional trace)
14125 (let ((func gnus-score-find-score-files-function)
14126 score-files)
14127 (and func (not (listp func))
14128 (setq func (list func)))
14129 ;; Go through all the functions for finding score files (or actual
14130 ;; scores) and add them to a list.
14131 (setq score-files (gnus-score-find-alist gnus-newsgroup-name))
14132 (while func
14133 (and (symbolp (car func))
14134 (fboundp (car func))
14135 (setq score-files
14136 (nconc score-files (funcall (car func) gnus-newsgroup-name))))
14137 (setq func (cdr func)))
14138 (if score-files (gnus-score-headers score-files trace))))
14140 (defun gnus-score-file-name (newsgroup &optional suffix)
14141 "Return the name of a score file for NEWSGROUP."
14142 (let ((suffix (or suffix gnus-score-file-suffix)))
14143 (cond
14144 ((or (null newsgroup)
14145 (string-equal newsgroup ""))
14146 ;; The global score file is placed at top of the directory.
14147 (expand-file-name
14148 suffix (or gnus-kill-files-directory "~/News")))
14149 ((gnus-use-long-file-name 'not-score)
14150 ;; Append ".SCORE" to newsgroup name.
14151 (expand-file-name (concat (gnus-newsgroup-savable-name newsgroup)
14152 "." suffix)
14153 (or gnus-kill-files-directory "~/News")))
14155 ;; Place "SCORE" under the hierarchical directory.
14156 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
14157 "/" suffix)
14158 (or gnus-kill-files-directory "~/News"))))))
14160 (defun gnus-score-search-global-directories (files)
14161 "Scan all global score directories for score files."
14162 ;; Set the variable `gnus-internal-global-score-files' to all
14163 ;; available global score files.
14164 (interactive (list gnus-global-score-files))
14165 (let (out)
14166 (while files
14167 (if (string-match "/$" (car files))
14168 (setq out (nconc (directory-files
14169 (car files) t
14170 (concat (gnus-score-file-regexp) "$"))))
14171 (setq out (cons (car files) out)))
14172 (setq files (cdr files)))
14173 (setq gnus-internal-global-score-files out)))
14175 ;; Allow redefinition of Gnus functions.
14177 (gnus-ems-redefine)
14179 (provide 'gnus)
14181 ;;; gnus.el ends here